Commit Graph
1 Commits
Author SHA1 Message Date
yetone 2140f5b935 sessions: a plain Codex rollout read from its start has its calls read on the summary's pass (#4369)
A start parses every changed session file for Sessions (refresh ->
parseWith), then reads every changed file's calls for Requests
(ReadCallSource -> readCalls). callsAlong already let a packed rollout
and an unread Claude session be read once for both; a plain .jsonl
rollout was read twice. On copies of the owner's real ~/.codex and
~/.claude (1.7 GB), a cold start scanned 931 times, 3.49 GB, every large
rollout x2.

callsAlong now takes a plain rollout too, when both reads start at its
first line: the summary it goes on from has no Codex window (nothing
kept, or kept on disk, which holds none), and parseWith lets the ride go
when either read goes on from an offset (calls.st.Off as well as s.Off),
so a read on from where it was is two incremental reads, as before. A
summary that still has its window is passed in so such a file's calls
shard isn't loaded only to be let go.

keepCalls names the root when none is named yet. A ride keeps a
rollout's calls (Codex window and all) during the Sessions parse, before
any Requests read has called pruneCalls; pruneCalls took the empty root
for a moved one and dropped everything kept. The shard on disk has no
window, so the next line read the rollout whole again (in the same run,
seconds after the start). TestHistoricalClaudeFilesDoNotDisplaceActive
Windows went red on exactly that ("rebuilt active call shard" for its
Codex rollout) until this.

TestWarmReadsOnlyInItsSlots' calls phase found nothing left to read,
since the index phase now reads every file's calls along; it appends a
line to each source first, so the calls have reading of their own.

Tests' forget (in the new test, claude_ride_test.go and
codex_zst_warm_test.go) calls Reset before removing the cache file:
Reset writes a save still pending, which put back the file just removed,
and the next List then went on from disk states (no window), red 1 in
~40 under -race. TestHistoricalClaudeFilesDoNotDisplaceActiveWindows
waits for the save (saved()) before writing its marker onto a cached
state the save's goroutine was encoding (a DATA RACE under -race).

Run on mote (macOS 27.2):
- TestPlainRolloutReadOnceForSessionsAndCalls (new): 3 plain rollouts.
  Nothing kept: each scanned once, from 0. Read, kept on disk, the long
  one grown and Reset: that one scanned once, from 0. An append in the
  same run: no scan from 0 (with keepCalls' root line removed by hand:
  "an append: the long rollout read again from its first line:
  [213219 0]", and the Historical test red as above). Calls, List and StatsAt reflect.DeepEqual to
  a calls-first read without the ride in each case. With plain rollouts
  kept out of callsAlong by hand: "first read: ... scanned from [0 0],
  want once from 0" for all 3. Restored: ok. -race -count=80 with
  the Packed, ClaudeSessionReadOnce, CodexSessionReadOn, Historical and
  WarmReads tests: ok (108.8s)
- Real data (copies of 1.7 GB of the owner's sessions, probe run
  sessions.List(200), usage QueryPage Today and Week; probe not
  committed): cold 931 scans / 3.49 GB -> 718 / 2.10 GB, no rollout read
  twice; no change 0 / 0; the first line appended to the newest rollout
  after the cold read: read whole by both readers -> read whole once
  (1 scan, 10.8 MB; the before run's newest was a 21.5 MB one, read
  twice). It is read whole at all because it was last changed on 10-31,
  past any window's idle time: a session left that long is read whole
  once on its next line, now in one pass. Later lines: 2 scans, 0 MB.
- go test -timeout 45m ./internal/sessions ./internal/usage
  ./internal/gateway ./internal/gui: ok for sessions (11.3s, -race 56.2s, at this tree), usage (30.2s), gateway (575.6s); internal/gui: ok but TestMainWindowCorners/macOS_26_SDK, red on macOS 27 as #3949 records (same message), untouched here
- GOOS=windows and GOOS=linux go vet ./internal/sessions: ok. gofmt -l:
  clean.

Not tried: a packed rollout's path is unchanged (it rode before).
2026-11-02 06:11:06 +08:00