A big JSON file opens as its first level
A .json file over the page's 1 MB read ceiling is not parsed and not turned
into a form. The repository page and the terminal open it as an outline of its
first level: each key (or, for an array, each item) with its type and how many
children it has.
- The 4 MB read. Only the first 4 MB of the file is read
(
JSON_PREFIX_BYTES), however big the file is. The outline is scanned from that prefix; nothing is parsed whole. The line under the outline says how much was read of how much. - The 500-member limit. At most 500 keys or items are listed
(
outlineJson'slimit). When the list stops there, the line says the rest are not listed. - "At least". A value the 4 MB read cut short has a count of the children seen so far, marked "at least": the real count is that or more. A cut value is the last row, because nothing after it was read.
- When there is no outline. A file whose first byte is not
{or[, or that holds a NUL byte, says so and offers the download. - The terminal. The workspace screen draws the same rows as aligned text,
read-only, with where the whole file is (
jsonOutlineText).
A key opens on its own too: see "One key on its own" below.
Code: src/web/render/json-big.ts (facts, table, text), json-doc.ts
(outlineJson), kinds.ts (JSON_PREFIX_BYTES), src/view/local.ts (the
prefix read). Tests: test/render-json-big.test.ts, test/json-big-page.test.ts,
test/tui-workspace-formats.test.ts.
One key on its own
Each key (an object) or item (an array) in the outline links to ?key=<name> or ?index=<n>. The outline scan keeps every member's character span; the member's byte offset and length come from it, and only that range is read (RepoSource.range, blobRange in src/git/read.ts). Git cannot seek inside a blob, so bytes before the member are streamed past and dropped, never held; the read stops at the member's end. A member up to 1 MB (JSON_VALUE_CAP) is shown pretty-printed; a bigger one, or one the 4 MB prefix ended inside, shows its own first level with the note on what was not shown. A key or index the outline does not list (including members past the prefix) is a 404 with a plain message.
What "not read" means. The member is never held whole in memory or parsed beyond its own bytes, and only the 4 MB prefix is scanned. The I/O is another matter: blobRange streams every byte before the member through the git cat-file pipe and drops it, because git cannot seek inside a blob. So "the whole file is never read" holds for memory and parsing, not for I/O; a member late in a 20 MB file costs a pass over the bytes before it (test/json-big-page.test.ts commits a ~20 MB blob and reads a late member through localSource.range in under 500 ms).
The terminal. On a big JSON file the workspace screen binds m (openKey in src/tui/screens/workspace.ts): it asks for a key (an item's number for an array) and opens that member through openMember, the page's own code, so the view and the words are the same. A key the outline does not list keeps the prompt open with the page's message ("This file has no such key or item in its first level."). r returns to the outline. Test: test/tui-workspace-formats.test.ts.
The page. The member sits in a focusable, horizontally scrolling region (table-scroll, tabindex=0, labelled by its key), so a long line never widens a phone's page. The path is the design system's .crumbs (file / key), the key is the page's heading. A member cut at JSON_VALUE_CAP is trimmed to its last whole UTF-8 sequence (wholeUtf8). A member's page at a commit id carries the same immutable cache headers as the file's own page (immutableWhenAddressed); at a branch name it does not.