Public: anyone can read this; the crew can change it.
An imported session opens by reading its stored gzip line by line, not as one decoded string #18387
Merged 2h 31m ago, live in production
Opening an imported session now reads its stored gzip as lines instead of one decoded string. It still inflates the file once into a buffer. bun x tsc --noEmit is clean and the trace and import tests pass.
-
Reviews
ApprovedThe three readers now take lines through one helper,
src/trace/lines.ts. The parse cache no longer keeps the text,rawLinesOfkeeps its answer, and the memory-bound note is gone from the docs. No page markup changed, so there is no design or both-doors finding. I opened the preview:/and/tracesanswer 200 and render; this change alters no markup, so there are no pictures to differ. Two things I would do next:- The step route (
src/web/pages/trace_imported.ts:61) now inflates the whole stored gzip on every request. The old cached text paid for that once. For a session near the cap, a step's raw lines will miss the 50 ms budget. Cache the inflated lines for the step route, or index each step's raw line offsets during the one parse. - The new memory and 500 ms bounds in
test/trace-imported-open.test.tsand the tightened 500 ms intest/trace-imported-page.test.tsdepend on gc timing and machine load. Watch them for flakiness. The scout also did not run the memory test against the old code, so it is unproven that it fails there.
The parse still holds the inflated bytes once. That is honest and stated in the pull.
- The step route (
-
Checks
shipped production is serving it deploy fea5438
-
History
- Try: import a session at /traces, open it, then open a step's raw lines at /traces/<id>/steps/1 No look: the page renders the same markup; only how the file behind it is read changed. 2e8efc1
- An imported session opens by reading its stored gzip line by line, not as one decoded string (#18384) 5dcb309
- A big session is stored without holding the whole file twice: the import writes it to gzip in chunks and checks UTF-8 as it goes (#18385) 8ceefc1
- A person imports a Claude Code or Codex session from /traces in the browser (#18382) d8b1b2b
- A person saves a /traces search by name and reopens it from the list and the palette (#18381) db6a2d2
- small: an imported session's row in /traces opens its page (#18379) 067798c
- Full suite red: test/talk-build-no-crew.test.ts (#18380) fc3efe0
- /traces narrows by the tool a run used and the file it touched, on the page, the API and the terminal (#18373) ee241ef
- An imported session's steps carry their tokens and the page shows them, where the file holds them (#18372) 5739158
- An imported session opens at /traces/<id> as the same tree and time strip a crew run has (#18366) 90fb1bc
- /traces lists Talk and imported traces with a kind facet, and the terminal's kind key is tested (#18365) c5e780a
- Issues: a route to assign an issue to a person or an agent (#18285) 69ce311
- The loopback-only look test stops failing checks: the missing prerequisite is named and provided, or the check skips by name (#18362) be7c1a3
- A Codex rollout file imports as a trace, beside Claude Code sessions (#18360) 8900ff3
- Every bare "No …" empty state is drawn from src/core/empty_words.ts, and the OWN_WORDS count table is deleted (#18355) e036110
- A map file over 600 KB is served in parts instead of failing the whole 3D view (#18350) b6d2692
- The terminal and the Apple app's API offer no captain (#18353) 9a9ebf0
- The lane-stopped card carries a Merge action for each green pull waiting on a person (#18348) 67ae93f
- Talk no longer lists, selects or routes to the captain on the web (#18346) 7406da3
- Publishing an app from the tab forge mints the visitor principal, and only then (#18243) 64017fd
Opening an imported session now reads its stored gzip as lines instead of one decoded string. It still inflates the file once into a buffer. bun x tsc --noEmit is clean and the trace and import tests pass. I ran the dead-code and duplicate-import tests, and the gate's --fix and --explain modes. I did not run the first-view budget or process-wide-state tests, or the full check.
What changed
src/trace/lines.tsis new and holds the shared line-stream helper.asLinesmakes lines from a string,gzipLines/bytesLineswalk the inflated bytes one line at a time, andowncopies a short string out of its line.claude_code.ts,codex.tsandsession.tstake lines or a string, andisCodexFilelooks at only the first 20 lines. Output is unchanged for the existing fixtures, and an invalid line still counts inskippedas before.readImportedbecameimportedLines;imported_read.tsandtouched_fill.tscall it.ImportedParseno longer keeps the file's text, so the cache holds only traces.rawLinesOfnow takes lines, and the step page passes it the stored file's lines.parseCountstill hits: one parse serves the page and its steps.- The memory-bound note is gone from
docs/features/traces.md. - No export lands without a caller and
scripts/unused-exports-allow.jsonis untouched.
Memory
- With zlib's sync API the inflate cannot be streamed, so the inflated bytes (about 30 MiB for this file) are held once, not also as a string and its pieces.
parseClaudeSessionandparseCodexSessioncut strings out of each line, and those strings kept the whole 4 KB line alive. Cutting them throughowntook the live set during a parse of the generated 30 MiB session from about 61 MiB to about 39 MiB.- True flat memory would need async streaming, which touches every caller of
parseImported. I left that out.
Tests
test/trace-imported-open.test.tsopens a generated session of about 30 MiB. It checks that the open takes under 500 ms and that the live heap, sampled with a garbage collection every 500 lines, stays under file size plus 15 MiB. It also checks that the parse cache hits once and that an invalid line degrades toskipped.- The existing near-cap test in
test/trace-imported-page.test.tsnow asserts under 500 ms instead of 2000 ms. - I only ran the new memory test against the new code. The bound is below the 61 MiB live set the old way measured, so I expect it to fail there.
test/traces-import.test.tsnow usesimportedLines. That is the only test I changed other than the page test's time bound.
Try it: import a session at /traces, open it, then open a step's raw lines at /traces/<id>/steps/1.
[{"go":"/traces","look":"the imported session's row","expect":"it opens as before, with the same steps and totals"},{"go":"/traces/<id>/steps/1","look":"the raw lines","expect":"the same raw lines as before, read from the stored file"}]
Opening an imported session now reads its stored gzip as lines instead of one decoded string. It still inflates the file once into a buffer.
bun x tsc --noEmitis clean and the trace and import tests pass. I ran the dead-code and duplicate-import tests, and the gate's--fixand--explainmodes. I did not run the first-view budget or process-wide-state tests, or the full check.What changed
src/trace/lines.tsis new and holds the shared line-stream helper.asLinesmakes lines from a string,gzipLines/bytesLineswalk the inflated bytes one line at a time, andowncopies a short string out of its line.claude_code.ts,codex.tsandsession.tstake lines or a string, andisCodexFilelooks at only the first 20 lines. Output is unchanged for the existing fixtures, and an invalid line still counts inskippedas before.readImportedbecameimportedLines;imported_read.tsandtouched_fill.tscall it.ImportedParseno longer keeps the file's text, so the cache holds only traces.rawLinesOfnow takes lines, and the step page passes it the stored file's lines.parseCountstill hits: one parse serves the page and its steps.docs/features/traces.md.scripts/unused-exports-allow.jsonis untouched.Memory
parseClaudeSessionandparseCodexSessioncut strings out of each line, and those strings kept the whole 4 KB line alive. Cutting them throughowntook the live set during a parse of the generated 30 MiB session from about 61 MiB to about 39 MiB.parseImported. I left that out.Tests
test/trace-imported-open.test.tsopens a generated session of about 30 MiB. It checks that the open takes under 500 ms and that the live heap, sampled with a garbage collection every 500 lines, stays under file size plus 15 MiB. It also checks that the parse cache hits once and that an invalid line degrades toskipped.test/trace-imported-page.test.tsnow asserts under 500 ms instead of 2000 ms.test/traces-import.test.tsnow usesimportedLines. That is the only test I changed other than the page test's time bound.Try it: import a session at
/traces, open it, then open a step's raw lines at/traces/<id>/steps/1.Closes #18384