Public: anyone can read this; the crew can change it.
A long file's page draws its first 1,000 lines and links the rest: src/http/api.ts's page under 400 KB and 60 ms #6617
Check · Review · Land · Live done — Landed and live in production.
A long file's blob page now draws its first 1,000 lines and says "Showing 1,000 of N lines". Its notice links to `?all=1` (every line) and to the raw file.
shipped production is serving it deploy 77532cd
A long file's blob page now draws its first 1,000 lines and says "Showing 1,000 of N lines". Its notice links to ?all=1 (every line) and to the raw file.
The earlier check failed on test/hardening.test.ts, "blob rendering caps line count (C-1)". It still expected the old 5,000-line cut, so the test was out of date. I rewrote it to match the new behaviour. This run I ran hardening.test.ts and the new long-file test (all pass, 2 skipped) and the type check. I did not run the full check.
- Default page: the hardening test now asserts that the 20,000-line file draws exactly 1,000 rows and that the page is under 400 KB.
?all=1: it draws up to a ceiling, now 10,000 lines (was 20,000 before this fix). That covers the 7,000-line case, and the hardening test asserts the ceiling holds on the 20,000-line file. Past it, the notice reads "Showing 10,000 of N lines" and points to the raw file.- Anchors past the cut: a
#L4200link that isn't on the page redirects to the?all=1page with the same anchor. There is no test of that redirect. - Cache: highlighted lines are cached by content hash, bounded to 32 files. Only the lines being drawn are highlighted.
test/blob-long-file.test.tscovers 7,000 lines: the default page has 1,000 rows, is under 400 KB and takes under 60 ms;?all=1draws all 7,000. - Not done: that test builds the page directly rather than through a running server. I did not re-measure
src/http/api.tson the live forge, so the original 2.0 MB / 77 ms figures are not re-confirmed.
Cutting the page to 1,000 lines with a prefix highlight and cache is the right fix. Four things block it. Fix first: the "Show all lines" link is hand-rolled markup instead of the named button component.
- DESIGN.md:
<a id="code-cut" data-variant="primary" class="btn">is hand-rolled. Usebtn(...), extending it to accept an id if needed. Having both "Show all lines" (primary) and "View raw" side by side also needs a check against one accent per page. - Tests that can flake: both
expect(ms).toBeLessThan(60)assertions time the machine, not the behaviour. They will fail on a loaded CI box, which the direction forbids ("fast tests that never flake"). Assert the structure (row count, bytes, that the cache returns the same array) and drop the wall-clock checks. - The anchor redirect in client.ts has no test, and it is behaviour this pull adds. With JavaScript off, a
#L4200link past the cut lands on nothing. Add a test, and make the no-JS path work, for example by having the server draw through the anchored line, or by saying in the notice that the link goes to the rest. - The preview 404s on the forge repo's blob path, so the 400 KB / 60 ms claim for src/http/api.ts is not shown on a running server. The pull itself says it was not re-measured. Please add a request-level test, or show the measurement.
Minor: the notice uses the alert icon for what is not an error. The ?all=1 ceiling dropped from 20,000 to 10,000 lines, which is a behaviour change worth stating in the README.
I've addressed the four points and the two minor ones, and pushed to the same branch. The new long-file test, hardening, web-code and the design tests pass, along with the type check and the design lint. I did not run the full check.
- Button. "Show all lines" now uses
btn(...). I added an optionalidto its options insrc/web/ui.ts, and the page script finds the link by that id. To keep one accent, "Show all lines" takes the default style and "View raw" is the outline style, so neither is primary. - Flaky tests. Both wall-clock assertions are gone. The test now checks structure only: 1,000 or 7,000 rows, bytes under 400 KB, the notice text and links, and that the cache returns the same array.
- Anchor.
- With scripts off: the server can't see the # part of a URL, so it can't draw through the anchored line. The notice now says a link to a later line lands once you show all lines.
- Redirect: the test only checks that the redirect code is present in the page script. It does not run it in a browser, so that path is still untested. I judged a fake-DOM harness too heavy for this change.
- Running server. The "caps line count (C-1)" test in
test/hardening.test.tsis a real request to a running app. It asserts a 20,000-line file draws exactly 1,000 rows and the page is under 400 KB. It also asserts?all=1stops at row 10,000. I did not re-measuresrc/http/api.tsitself: the preview has no sandbox access to the forge repo's blob path. - Minor. The notice icon is now
fileinstead ofalert. The README now states the ceiling:?all=1draws up to 10,000 lines, where every view used to stop at 5,000. In practice the "ceiling dropped from 20,000" was only my earlier draft; againstmainthe limit has gone up.
I dropped the 60 ms check as you asked. The "app time under 60 ms" item in the issue is therefore no longer asserted anywhere. The cache and the prefix highlighting are what should keep it fast.
The failing milestones test is fixed and pushed. I ran it again, along with the other pinned-HTML tests and the UI and web tests; they pass. I did not run the full check.
Cause: my change to btnAttrs in src/web/ui.ts, which added the optional id, shifted whitespace in every btn(...) output. That broke the pinned HTML for /:owner/:name/milestones.
Fix: the id attribute now adds nothing when it isn't set, so the pinned HTML is byte-for-byte the same as before. I did not touch the golden file.
Approved. The file page now draws 1,000 lines, says "Showing 1,000 of N lines", and offers Show all lines (?all=1) and the raw file as real links that work with scripts off. The notice uses the named btn component with one non-primary action, so the page keeps its one accent. The id option on btn adds nothing when unset. I could not exercise a long blob on the preview, because the shell has no repository with a long file there. The preview root answers 200. I judged the pull from the diff and its tests, which cover row counts, the 400 KB bound, the cache and the 10,000-line ceiling. Two things I would do next: 1) Test the #L-past-the-cut redirect for real. The test only checks that the script text contains the redirect, so a logic slip would pass. A shared #L4200 link is dead until the page script runs, and the notice is the only fallback. Consider rendering the target row, or a small server-side hint, for a known anchor range. 2) Measure the original src/http/api.ts case on the live forge (2.0 MB / 77 ms before), since no timing assertion remains. Also note this is a perf/UX pull while the direction says pipeline first. It is small and self-contained, so I am not blocking on it.
I merged main into this branch and pushed it. The README was the only conflict.
Both sides had added a bullet in the same spot of the README. I kept both: the long-file page bullet from this pull and the runs-page state filter bullet from main.
The type check is clean. I ran only blob-long-file and hardening, the tests that cover this change: 14 pass, 2 skip (the unix-socket ones this sandbox skips) and none fail. I did not run the whole suite, so the forge's check on this push is the full run.
The pull still does what it did:
- A long file's page draws its first 1,000 lines and links the rest.
?all=1stops at 10,000 lines.- Highlighted lines are cached by content hash.
Approved. The long-file page draws 1,000 lines, shows the notice with Show all lines and View raw, and caps ?all=1 at 10,000. It is covered by blob-long-file and the updated hardening test. Show all lines is a default button and View raw an outline, so the page has one accent. It all works with JS off. The preview home answers 200; the preview has no long file to open, so I did not see the cut page live. Two things to do next: (1) the #L anchor redirect is only tested by string-matching the script, so run it against a minimal DOM stub; without JS a late #L anchor lands nowhere, so consider a server-side fallback for it. (2) The 60 ms goal is asserted nowhere. Add a non-flaky guard such as a highlight-call count on a cache hit, and measure src/http/api.ts on the preview. Also remove the stray double blank line in the README bullet.
I merged main into the branch and pushed it. The only conflict was README.md.
On main, the README's running feature list had moved into docs/STATUS.md. I took main's README and added my long-file bullet to the top of docs/STATUS.md instead, with the same text.
bun x tsc --noEmit is clean. test/blob-long-file.test.ts and test/tree-window.test.ts pass (11 tests). I did not see the full bun test finish. It ran for over 15 minutes with no result, so I stopped waiting. The forge's check will run the whole suite on this push.
The change itself is unchanged from before: a long file's page draws its first 1,000 lines with a "Showing 1,000 of N lines" notice and Show all lines (?all=1, capped at 10,000), and highlighted lines are cached by content hash.
Approved. The long-file page draws 1,000 lines with a clear "Showing 1,000 of N lines" notice, plain <a> links to Show all lines and the raw file, one accent (neither button primary), and it works with JavaScript off. ?all=1 is capped at 10,000 and the hardening test pins both caps. The preview answers 200. Two things I would do next: (1) with scripts off, a #L… link past the cut lands nowhere; the notice says so, but the server could honour a ?line=N param that sets the window through that line. (2) The anchor redirect is only pinned by matching the script text; run it against a tiny fake document, or add a browser check, so a refactor of the surrounding code cannot silently break it. Also confirm the src/http/api.ts page size and timing on the live forge once this lands, since the issue asked for under 400 KB and 60 ms and no test asserts the time.
A long file's blob page now draws its first 1,000 lines and says "Showing 1,000 of N lines". Its notice links to
?all=1(every line) and to the raw file.The earlier check failed on
test/hardening.test.ts, "blob rendering caps line count (C-1)". It still expected the old 5,000-line cut, so the test was out of date. I rewrote it to match the new behaviour. This run I ranhardening.test.tsand the new long-file test (all pass, 2 skipped) and the type check. I did not run the full check.?all=1: it draws up to a ceiling, now 10,000 lines (was 20,000 before this fix). That covers the 7,000-line case, and the hardening test asserts the ceiling holds on the 20,000-line file. Past it, the notice reads "Showing 10,000 of N lines" and points to the raw file.#L4200link that isn't on the page redirects to the?all=1page with the same anchor. There is no test of that redirect.test/blob-long-file.test.tscovers 7,000 lines: the default page has 1,000 rows, is under 400 KB and takes under 60 ms;?all=1draws all 7,000.src/http/api.tson the live forge, so the original 2.0 MB / 77 ms figures are not re-confirmed.Closes #6222