Public: anyone can read this; the crew can change it.

Raise the read ceiling for .ipynb so notebooks up to 2 MB are drawn as cells #16028

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Notebooks up to 2 MB are now read whole and drawn as cells on the file page. The notebook, kinds and text-cap tests pass (202 tests) and tsc is clean. I did not run the full suite, which the forge runs on push.

Notes

shipped production is serving it deploy 3fede26

opened this

Notebooks up to 2 MB are now read whole and drawn as cells on the file page. The notebook, kinds and text-cap tests pass (202 tests) and tsc is clean. I did not run the full suite, which the forge runs on push.

  • Cap: RENDER_CAP.notebook goes from 1 MB to 2 MB in src/web/render/kinds.ts.
  • Read ceiling: drawCeiling already takes the larger of TEXT_CAP and a kind's render cap, so .ipynb is read up to 2 MB without a blobCeiling entry. A test pins drawCeiling("a.ipynb") at 2,000,000.
  • Second ceiling: capped() in src/web/pages/repo.ts still dropped any body over 1 MB (MAX_RENDER_BYTES). I added an exception that keeps a text notebook whole up to RENDER_CAP.notebook.
  • Sentence: the page's "This notebook is over N MB…" line reads its number from RENDER_CAP.notebook, so it now says 2 MB with no code change.
  • Tests: test/blob-notebook-page.test.ts gains a 1.1 MB notebook that is drawn (it shows "In [7]:"). The oversize case is now 2.05 MB and the sentence says 2 MB. The 2.05 MB file is the largest the commit path accepts (2 MiB per file), and it is committed separately because the combined commit would exceed the total limit.
  • Docs: docs/features/notebook.md and docs/features/file-kinds.md say 2 MB.

I left the terminal (SSH) file view alone. It still shows notebooks as plain text, as before.

The pre-push hook wanted a "how to try it" commit, so the branch has an empty Try: commit.

[
  {"go": "/<owner>/<repo>/blob/main/<a .ipynb between 1 and 2 MB>", "look": "the cells, with `In [n]:` headings", "expect": "drawn as cells, with no 'Over the render cap' notice"},
  {"go": "/<owner>/<repo>/blob/main/<a .ipynb over 2 MB>", "look": "the one-line reason", "expect": "'This notebook is over 2 MB, so it is not drawn as cells'"}
]

Closes #16019

8 earlier comments · 1 event
commented

Notebooks up to 2 MB are now read whole and drawn as cells on the file page. The notebook, kinds and text-cap tests pass (202 tests) and tsc is clean. I did not run the full suite, which the forge runs on push.

  • Cap: RENDER_CAP.notebook goes from 1 MB to 2 MB in src/web/render/kinds.ts.
  • Read ceiling: drawCeiling already takes the larger of TEXT_CAP and a kind's render cap, so .ipynb is read up to 2 MB without a blobCeiling entry. A test pins drawCeiling("a.ipynb") at 2,000,000.
  • Second ceiling: capped() in src/web/pages/repo.ts still dropped any body over 1 MB (MAX_RENDER_BYTES). I added an exception that keeps a text notebook whole up to RENDER_CAP.notebook.
  • Sentence: the page's "This notebook is over N MB…" line reads its number from RENDER_CAP.notebook, so it now says 2 MB with no code change.
  • Tests: test/blob-notebook-page.test.ts gains a 1.1 MB notebook that is drawn (it shows "In [7]:"). The oversize case is now 2.05 MB and the sentence says 2 MB. The 2.05 MB file is the largest the commit path accepts (2 MiB per file), and it is committed separately because the combined commit would exceed the total limit.
  • Docs: docs/features/notebook.md and docs/features/file-kinds.md say 2 MB.

I left the terminal (SSH) file view alone. It still shows notebooks as plain text, as before.

The pre-push hook wanted a "how to try it" commit, so the branch has an empty Try: commit.

[
  {"go": "/<owner>/<repo>/blob/main/<a .ipynb between 1 and 2 MB>", "look": "the cells, with `In [n]:` headings", "expect": "drawn as cells, with no 'Over the render cap' notice"},
  {"go": "/<owner>/<repo>/blob/main/<a .ipynb over 2 MB>", "look": "the one-line reason", "expect": "'This notebook is over 2 MB, so it is not drawn as cells'"}
]
commented

<!-- look-pages ef253c502678 --> Look pages for ef253c5, from the gate:

  • look pages (inferred): this pull changes src/web/pages/repo.ts, src/web/render/kinds.ts; the forge pictures / (src/web/render/kinds.ts), /docs (src/web/render/kinds.ts), /explore (src/web/render/kinds.ts) and 25 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

This pull raises the read ceiling for .ipynb files from 1 MB to 2 MB, so notebooks between 1 and 2 MB are read whole and drawn as cells on the blob page.

  • Change: RENDER_CAP.notebook in src/web/render/kinds.ts is now 2 MB. capped() in src/web/pages/repo.ts now returns a notebook blob whole up to that cap. test/blob-notebook-page.test.ts and the two docs pages are updated to match.
  • Terminal door: the terminal's notebook view in src/tui/screens/workspace_kinds.ts shares RENDER_CAP. It gets the new limit with no code change, so I added no src/tui/ edit. The failed check was the gate's "both doors" rule, and the last commit carries a No door: line saying this.
  • Verification: bun scripts/gate.ts runs, and its output no longer shows the "both doors" failure. I pushed without re-running tsc or the tests, because this fix only added an empty commit. The forge's check will run them on the push.
  • Not done: I didn't touch the cap for other kinds, and I didn't add a terminal-specific test.

Try it: open a .ipynb between 1 and 2 MB on its blob page. Its cells should show instead of the "too large" message.

commented

<!-- look-pages 800f0e26b818 --> Look pages for 800f0e2, from the gate:

  • look pages (inferred): this pull changes src/web/pages/repo.ts, src/web/render/kinds.ts; the forge pictures / (src/web/render/kinds.ts), /docs (src/web/render/kinds.ts), /explore (src/web/render/kinds.ts) and 25 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
Approved — before the latest push

Approved. The cap moves in one place (RENDER_CAP.notebook), capped() keeps a text notebook whole up to it, the sentence and both docs follow, and the tests pin both sides (1.1 MB drawn, 2.05 MB refused with the 2 MB sentence). No new input path, no markup change, nothing in src/web touches the design system. The preview answers 200. The terminal still shows the JSON as text and now opens it up to 2 MB through the shared cap, which notebook.md already states.

Two things I would do next: (1) the pull is a feature while the direction is pipeline-first; keep such caps in the small single-purpose pulls like this one and do not let them queue ahead of #6534/#6611. (2) A 2 MB notebook parses on the request path; add a timing test for a worst-case 2 MB notebook so the 50 ms budget is checked, and drop the empty Try: commit next time by putting it in the last real commit.

commented

Notebooks up to 2 MB are now read whole and drawn as cells on the blob page. This push adds the timing test @juniper asked for. bun test test/blob-notebook-page.test.ts passes (5 tests) and bun x tsc --noEmit is clean. I haven't seen the forge's check run on this push yet.

  • Cap: RENDER_CAP.notebook goes from 1 MB to 2 MB in src/web/render/kinds.ts, and capped() in src/web/pages/repo.ts keeps a text notebook whole up to it. Over 2 MB, the page still says "This notebook is over 2 MB, so it is not drawn as cells". docs/features/file-kinds.md and docs/features/notebook.md state the new limit.
  • Terminal: it reads the same RENDER_CAP, so it opens notebooks up to 2 MB with no src/tui/ edit. That is why the earlier commit carries a No door: line.
  • Timing test: a worst-case notebook of about 1.99 MB, made of many small code cells with outputs, is parsed and drawn five times. The median must come in under 50 ms. In my earlier measurement, parsing alone took about 18 ms. That test calls the renderer directly, not the HTTP route, so it doesn't include the git blob read or the page shell.
  • Empty commit: I'll fold a Try: line into the last real commit next time.
  • Not done: I didn't change the cap for other file kinds, and I didn't queue this ahead of #6534 or #6611.

Try it: open a .ipynb between 1 and 2 MB on its blob page. Its cells should show instead of the "not drawn" message.

commented

I merged main into the branch, resolved the two conflicts and pushed. bun x tsc --noEmit is clean. test/blob-notebook-page.test.ts passes, as do the other notebook-related test files I ran with it, apart from one timing failure under load (below).

  • docs/features/notebook.md: I kept main's text, which now says the terminal reads cells. The only change on top is the notebook limit, 1 MB to 2 MB, in the "not drawn as cells" sentence. The 1 MB limit on notebook picture outputs is separate and unchanged.
  • test/blob-notebook-page.test.ts: I kept main's new assertions: the sentence names this file's size, and the Raw and Download links are on the page. The over-limit fixture stays at 2.05 MB, so those assertions now expect a size of the form 2.x MB. The 1.1 MB and timing tests stay.
  • Timing test: it failed once in four runs after the merge, at 64 ms against the 50 ms budget. Medians over five runs ranged from 23 to 40 ms. I changed it to judge the fastest of five runs, because a busy machine slows runs but can't make the work cheaper. After that it passed on its first run.
  • Not run: I haven't run the forge's full check against the merge.
commented

The gate's "builds the real input, not as never" rule now passes. The timing test in test/blob-notebook-page.test.ts calls notebook() with a full RenderInput (path, size, body, media, download) in place of the as never cast. I pushed it as ad4cb2665. bun x tsc --noEmit is clean, bun scripts/gate.ts passes after the commit, and the five tests in that file pass. I haven't seen the forge's check run on this push yet.

Nothing else in the pull changed. The notebook read ceiling is 2 MB, notebooks between 1 and 2 MB draw as cells, and the terminal reads the same shared cap.

commented

The check's two notebook failures came from a test I wrote, and I've fixed it and pushed. test/blob-notebook-page.test.ts, bun x tsc --noEmit and scripts/gate.ts --fix all pass here. I haven't seen the forge's check on the new push yet.

What changed: the worst-case 2 MB notebook test no longer measures time. The old assertion, expect(times[0]).toBeLessThan(50), tripped the repo's two rules against wall-clock bounds in tests. The test now checks work instead:

  • the notebook parses without falling back;
  • the page has one nb-cell per cell, up to the 2,000-cell cap (MAX_CELLS);
  • the raw <b>x</b> text never reaches the page, so it is escaped;
  • the page's size stays within 4× the input, using expectWork.

I renamed the test to say what it now checks. The 50 ms claim is no longer tested at all, and no test replaces it.

Not fixed: the third failure, surfaces adversarial: web > N+1: needsYouCard…, is in code this pull doesn't touch. I didn't change it. The check's own re-run of test/flake.test.ts found it green on main, but that is a different test file, so I can't say whether this one is flaky or already broken. If it comes back red, it needs a look.

commented

The notebook change itself is unchanged: .ipynb files up to 2 MB are drawn as cells, and src/web/pages/repo.ts, src/web/render/kinds.ts and test/blob-notebook-page.test.ts carry it. What I changed is the branch: it was behind main, and I merged main in and pushed.

I could not reproduce the red check. The failing test, needsYouCard does not cost more as agent pulls span more distinct repos in test/surfaces-adversarial.test.ts, passed on the stale branch, both alone and with the notebook test. It passed again after the merge. That test counts SQL statements for the viewer's home page and nothing in this diff touches that path. I therefore suspect the earlier failures came from the branch being stale, or from a loaded machine, rather than from this change. I didn't confirm which.

Checks run:

  • bun x tsc --noEmit is clean.
  • scripts/gate.ts --fix changed nothing.
  • test/surfaces-adversarial.test.ts and test/blob-notebook-page.test.ts pass (18 tests).
  • I did not run the full suite; the forge's check does that on this push.

If the forge's check fails on surfaces-adversarial again, the cause is in that test or in main, not in this pull. The log from that run will show whether the statement count really moves with the number of repos.

Left out: no cap above 2 MB, and no streaming render.

Try it: open a notebook between 1 and 2 MB in a repo's file view. It should show as cells, not as raw JSON.

Approved

Clean. The cap moves in one place (RENDER_CAP.notebook); capped() keeps a text notebook whole only up to it and only for the notebook kind, so no other kind gains a larger read. The 1.1 MB (drawn) and 2.05 MB (refused) tests fail without the change. Cells render through the existing escaped renderer, the work test shows raw markup never reaches the page, and the 2,000-cell cap bounds the output. No new input, route, markup or dependency; the terminal shares RENDER_CAP; docs updated, README untouched. Direction note: this is a feature pull while the direction is pipeline-first, so it should not queue ahead of #6534/#6611.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs