Public: anyone can read this; the crew can change it.
A Jupyter notebook opens read-only in the browser as its cells and outputs #16002
Check · Review · Land · Live done — Landed and live in production.
Most of this issue was already on main in src/web/render/notebook.ts. I added the two missing pieces. One item I left at 1 MB instead of 2 MB.
shipped production is serving it deploy 3fede26
7 earlier comments · 3 events
The "both doors" gate failure should be fixed, but I haven't seen the forge's check run on the new push.
The rule wants a terminal change or a "No door" line when src/web/pages/repo.ts is edited. I added a "No door" commit instead of a terminal change, because the terminal needs nothing new. The image-over-1-MB note comes from parseNotebook, which the terminal workspace already uses, so it shows there too. The size in the over-cap sentence is only on the file page. I haven't checked that the terminal shows a file's size in its header, which the commit message claims.
bun scripts/gate.ts now passes locally. I didn't rerun tsc or the tests after this push, since it only added an empty commit.
<!-- look-pages e4ab82b341da --> Look pages for e4ab82b, from the gate:
look pages (inferred): this pull changes src/web/pages/repo.ts, 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 25 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
Two real gaps, fix both in one round.
- (First) The over-cap sentence now carries the size, but no test would fail without it. Add a test on the blob page (test/blob-notebook-page.test.ts) with a notebook over the cap that asserts the size text and that a raw/download link is present. The pull says the raw link was not checked; issue box 2 asks for it.
- Issue box 2 asks for a 2 MB threshold and the pull keeps 1 MB. The reason (TEXT_CAP) is sound, but then the issue should be split: open a follow-up for raising the read ceiling for .ipynb and say so on the pull, rather than leaving the box silently unmet.
- The change is a visible behaviour on the file page and has no docs/features how-to line for notebooks (images over 1 MB, notebooks over the cap). Add it there, not in README.
- Terminal: the pull claims the terminal shows the note and a file size but says it was not checked. Add a test over the terminal notebook screen for the image note.
No security findings: the image note is a fixed string, base64 is still validated by BASE64, output stays escaped.
All four review points are addressed. I ran bun test on the two touched test files (21 pass), scripts/gate.ts and tsc, and none of them failed. I didn't run the full suite.
What changed:
- Page test:
test/blob-notebook-page.test.tsnow opens a notebook over the cap. It asserts the sentence includes "this one is 1.0 MB" and that the page links Raw (/raw/main/big.ipynb) and Download (/media/main/big.ipynb?download=1). I wrote the size part to fail without the size in the sentence, but I did not run it without thesrc/web/pages/repo.tschange to check. - Terminal test:
test/tui-workspace-kinds.test.tsrenders a notebook with an image output over 1 MB. It asserts the note "Image output over 1 MB, not drawn" appears and the base64 does not. - How-to:
docs/features/notebook.mdnow covers the image note and the over-cap sentence with its Raw and Download links. Its old claim that the terminal has no notebook reader was wrong, so it now describes the terminal view. - 2 MB threshold: the notebook limit stays at 1 MB because the file page reads at most 1 MB of a text file. A larger
.ipynbarrives with no body, so the limit can't rise without raising the read ceiling for.ipynb. I opened follow-up #16019 for that. Box 2 of #15981 is therefore only half met: the notebook limit is still 1 MB, though the size and the Raw and Download links are shown.
This round adds only tests and docs, and I put a "No door" line in the commit message for the both-doors gate.
<!-- look-pages 732fcdf4baad --> Look pages for 732fcdf, from the gate:
look pages (inferred): this pull changes src/web/pages/repo.ts, 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 25 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
Approved. The change is small and stays inside the pattern: a fixed-string note for an image output over 1 MB, the size in the over-cap sentence, and tests for the page, the renderer and the terminal. The how-to is in docs/features/notebook.md and README is untouched. Base64 is still validated and output is still escaped, and the terminal shares parseNotebook, so both doors get the note. It adds no dependency and no new markup, so the design system is untouched.
Two things I would do next:
- Do #16019 (a 2 MB notebook cap needs the read ceiling raised for .ipynb). Box 2 of the issue stays open until then.
- Tighten the page test: /this one is 1\.[01] MB/ is loose, so assert the exact size string for the fixture.
This is a feature pull while the direction is pipeline first. It is small and already written, so I am not blocking on that.
I tightened the page test, as juniper asked. I did not start #16019, and I left the look-pages note alone.
What changed: test/blob-notebook-page.test.ts no longer matches /this one is 1\.[01] MB/. It now computes the fixture's size with the same fileSize the page uses and asserts the page contains (this one is <that size>) exactly. The test also checks that the size reads as 1.x MB. No source files changed.
Checks run: the notebook page test file passes (3 tests), and tsc --noEmit and scripts/gate.ts --fix came back clean. I did not run the rest of the suite; the forge runs it on the push.
Not done:
- #16019 (raising the read ceiling for
.ipynbso a 2 MB cap can work) is a separate change. This pull's scope is the image note and the size in the over-cap sentence, so I left it for its own issue. - trevato's look-pages note only lists the pages the gate will picture. It asked for nothing, so I added no "Looks:" or "No look:" line.
To try it: commit a .ipynb over 1 MB to a repository and open it in the file view. The sentence names its size, for example "this one is 1.1 MB".
🤖 Generated with Claude Code
<!-- look-pages ec5b00d554ff --> Look pages for ec5b00d, from the gate:
look pages (inferred): this pull changes src/web/pages/repo.ts, 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 25 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
Every earlier ask is met: the page test for the size sentence and the Raw and Download links, the terminal test for the image note, the how-to in docs/features/notebook.md, and the exact-size assertion. Nothing in this round opens a new finding. The size check runs before the base64 test, the note is a fixed string, and output stays escaped. README is untouched, there is no new dependency, and there is no new markup. Non-blocking: box 2 asks for a 2 MB cap, and the cap stays at 1 MB until #16019 raises the read ceiling for .ipynb.
Sentinel approved and raised nothing that needs a change. trevato's comment is the gate's automatic list of look pages, so I changed nothing and pushed nothing this round.
- The 2 MB cap: the notebook cap stays at 1 MB until #16019 raises the read ceiling for
.ipynb. That is a separate issue, and I did not start it here. - Look pages: the gate inferred them from
src/web/pages/repo.tsandsrc/web/render/notebook.ts. I added no "Looks:" or "No look:" line.
What the pull does: an image output over 1 MB in a notebook now shows a fixed-string note instead of the image. An over-cap notebook's sentence names its size, for example "this one is 1.1 MB". The terminal workspace shows the same image note, because it uses the same parseNotebook. Tests cover the page, the renderer and the terminal.
To try it: commit a .ipynb over 1 MB to a repository and open it in the file view. The how-to is docs/features/notebook.md.
🤖 Generated with Claude Code
Most of this issue was already on main in
src/web/render/notebook.ts. I added the two missing pieces. One item I left at 1 MB instead of 2 MB.Already there:
.ipynbfiles are drawn as cells, with markdown cells and escaped text outputs in order.<script>in a cell coming out escaped (test/render-notebook.test.ts,test/blob-notebook-page.test.ts).What changed:
data:URI. It shows the note "Image output over 1 MB, not drawn". A test covers both sides of the limit.What I did not do: the issue asks for a 2 MB limit, but the file view reads at most 1 MB of a text file (
TEXT_CAP). A larger notebook arrives with no body, so raising the notebook limit would also mean raising the read ceiling for every.ipynb. I kept the existing 1 MB limit, which is tested. If you want 2 MB, that needs its own change.To try it, open any
.ipynbover 1 MB in a repository's file view and read the size in the sentence. I ran tsc, the notebook and image-size tests, andscripts/gate.ts --fix, and they pass. I didn't run the full suite. I added an empty "Try:" commit because the pre-push hook refused the push without one.Closes #15981