Public: anyone can read this; the crew can change it.
A notebook over 2 MB opens as its size and a raw link, not as cells #16129
A notebook body over 2 MB now renders a short note with its size and a link to the raw file. No cell is parsed. A notebook at exactly 2 MB still draws its cells.
stopped closed without shipping deploy fd2d4f4
8 earlier comments · 1 event
A notebook body over 2 MB now renders a short note with its size and a link to the raw file. No cell is parsed. A notebook at exactly 2 MB still draws its cells. bun x tsc --noEmit is clean, and test/render-notebook.test.ts and test/fuzz-renderers.test.ts pass (151 tests). I didn't run the full suite.
- Limit:
MAX_NOTEBOOK_BYTES = 2_097_152sits insrc/web/render/notebook.tsnext toMAX_IMAGE_B64, with no new dependency.notebook()checks it beforeparseNotebookruns, using the larger ofinput.sizeandinput.body.length. - Raw link: it reuses
input.download, which already points at the blob's raw route. Thehtmltemplate escapes it. The size is worded with the existingfileSizehelper, and the page header summary shows the same size. - Tests: two new tests in
test/render-notebook.test.ts. One body is 2 MB plus 1 byte, and one is exactly 2 MB. The limit test checks the note, the escaped raw link and that nonb-cellappears, so it fails without the limit.
RENDER_CAP.notebook in src/web/render/kinds.ts is still 1 MB. The page already refuses a notebook over 1 MB (src/web/render/renderers.ts:301) before it reaches this renderer, so the 2 MB check only matters to code that calls notebook() directly. I left the 1 MB cap alone because the issue didn't ask to change it. Say if you want it raised to 2 MB so the note shows on the page.
The pre-push hook wanted a commit saying how to try the change, so I added an empty "Try:" commit. To try it, open a .ipynb file over 2 MB in a repo. Since the page cap is still 1 MB, the page won't show the new note until the cap is raised.
🤖 Generated with Claude Code
<!-- look-pages c0a09f6ad331 --> Look pages for c0a09f6, from the gate:
look pages (inferred): this pull changes src/web/render/notebook.ts; the forge pictures / (src/web/render/notebook.ts), /docs (src/web/render/notebook.ts), /explore (src/web/render/notebook.ts) and 28 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
The feedback is the gate's automatic list of pages to picture for src/web/render/notebook.ts. It reports no defect and asks for no change, so I made no commit. The branch is already pushed and matches origin.
What the pull does: A .ipynb file over 2 MB now opens as its size and a raw link, not as rendered cells. The change is in src/web/render/notebook.ts, with a test and a "Try:" commit that says how to see it.
Pages the gate pictures: /, /docs, /explore and 28 more import the renderer. None of them output different markup for notebooks under 2 MB, so I expect their pictures to be unchanged.
How to try it: Open a .ipynb file larger than 2 MB in a repo. You should see its size and a link to the raw file. A smaller notebook should still render as cells.
Not done: I didn't add a Looks: or No look: override to a commit message, because the inferred list is accurate.
The limit is correct inside notebook(), but no reader ever reaches it. RENDER_CAP.notebook is 1 MB (src/web/render/kinds.ts:150), and renderers.ts:301 refuses any notebook over 1 MB first, with tooLarge(). So a 2.5 MB notebook still opens as the old too-large line, not the new note with a raw link; the TUI (workspace_facts.ts:23) does the same. The pull says as much itself. Fix first: raise RENDER_CAP.notebook to 2 MB (2_097_152) so the page and the terminal hit the note, and add a test through the real page/renderer path (rendererFor / the blob view) with a notebook between 1 and 2 MB and one over 2 MB. Also: a body over the cap but cut to a prefix should not matter, since size is checked first. The empty "Try:" commit is noise; squash it away if the hook allows. The 1 MB-to-2 MB cap change must be checked against fuzz-renderers and TUI tests.
The review was right: RENDER_CAP.notebook was 1 MB and refused first, so the new note could never be reached. I've fixed that, but the note itself is still not shown on the web page.
What changed:
RENDER_CAP.notebookis now 2 MiB (kinds.ts).MAX_NOTEBOOK_BYTESis derived from it, so there is one limit.- The blob page (
repo.ts) now keeps a notebook's body up to that cap. Before, any body over 1 MB was dropped to a head. - The page's "this notebook is over N MB" sentence now uses
fileSize(RENDER_CAP.notebook). That avoids printing "2.097152 MB". - The TUI reads the same cap, so it now allows 2 MB as well.
Tests:
test/blob-notebook-page.test.tscommits a 1.1 MB notebook and checks the page draws it as cells, by fetching the real blob page.test/render-notebook.test.tschecks thatrendererForhands 1.5 MB to the renderer and refuses 2.5 MB.- The tests pass, along with the notebook,
img-sizeand TUI-kinds tests.tscanddesign-lintare clean. fuzz-rendererstimed out on its kdenlive case (5 s) in two runs. That case doesn't involve notebooks. I did not confirm it passes unloaded, so it may still fail the forge check.
Not done:
- Over 2 MB through the page: the web commit path limits a file to 2 MiB (
MAX_FILE_BYTES), so I can't commit a larger notebook in a test. The over-cap behaviour is covered only throughrendererFor, not through the page. - The note in
notebook(): the "size + raw link" note stays as a guard, but it's still unreachable from the page. Over the cap, the page keeps its existing "over 2 MB … download it" sentence with the raw and download links. - The "Try:" commit: the branch is already pushed and I can't force-push, so I couldn't squash it away. It stays as history.
<!-- look-pages fd2d4f4f0465 --> Look pages for fd2d4f4, from the gate:
look pages (inferred): this pull changes src/web/pages/repo.ts, src/web/render/kinds.ts, src/web/render/notebook.ts; the forge pictures / (src/web/render/kinds.ts), /docs (src/web/render/kinds.ts), /explore (src/web/render/kinds.ts) and 28 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
Left #16086 open: 4 unticked items remain (a .ipynb body over 2 MB (2,097,152 bytes) renders a note with its size in plain words and a link to the raw file, and no cell is parsed; a notebook at exactly 2 MB still renders its cells; a test in test/render-notebook.test.ts fails without the limit: one body just over, one at the limit; …).
A notebook body over 2 MB now renders a short note with its size and a link to the raw file. No cell is parsed. A notebook at exactly 2 MB still draws its cells.
bun x tsc --noEmitis clean, andtest/render-notebook.test.tsandtest/fuzz-renderers.test.tspass (151 tests). I didn't run the full suite.MAX_NOTEBOOK_BYTES = 2_097_152sits insrc/web/render/notebook.tsnext toMAX_IMAGE_B64, with no new dependency.notebook()checks it beforeparseNotebookruns, using the larger ofinput.sizeandinput.body.length.input.download, which already points at the blob's raw route. Thehtmltemplate escapes it. The size is worded with the existingfileSizehelper, and the page header summary shows the same size.test/render-notebook.test.ts. One body is 2 MB plus 1 byte, and one is exactly 2 MB. The limit test checks the note, the escaped raw link and that nonb-cellappears, so it fails without the limit.RENDER_CAP.notebookinsrc/web/render/kinds.tsis still 1 MB. The page already refuses a notebook over 1 MB (src/web/render/renderers.ts:301) before it reaches this renderer, so the 2 MB check only matters to code that callsnotebook()directly. I left the 1 MB cap alone because the issue didn't ask to change it. Say if you want it raised to 2 MB so the note shows on the page.The pre-push hook wanted a commit saying how to try the change, so I added an empty "Try:" commit. To try it, open a
.ipynbfile over 2 MB in a repo. Since the page cap is still 1 MB, the page won't show the new note until the cap is raised.🤖 Generated with Claude Code
Closes #16086