Files
yetone 3eba174fd9 sessions: a restart no longer opens each Claude Code subagent's file again (shangyuan0818 on X)
Every list built each session's subagents, and ccTask and ccMeta keep what
they read in memory only. After a start, each of a few thousand subagent
files was opened for its first user line (or its meta file), under
Defender's per-open scan. The parse already read that file; its task and
meta now stay in its state (StateMore Task, TaskRead, SubMeta) and the
list uses them, falling back to ccTask/ccMeta when a parse has none. A
subagent's parse made before this (no TaskRead) is read again once
(ccStale), then not.

Windows (xiaomi-gpu, Defender on, sandbox HOME, Claude-only reads), fixture
of 12k files / 9.3 GB with 9k subagent files, three requests together:
- warm restart: 2.2 s -> 1.0 s
- restart after one session grew: 2.4 s -> 1.1 s
- restart after one new session: 2.3 s -> 1.1 s
- grow or new session while running: 0.55 s -> 0.4 s on the next list
- cold, no cache: 21 s -> 15.8 s (the subagent read is no longer done twice)
The plain 100-session fixture (6.6 GB) was 0.3 to 0.8 s warm before and
stays there: it has no subagent files to open, and I did not reproduce
"15 s after an agent used". The 5 s cold figure the reporter gives matches.

Run: go test ./internal/sessions at this head (mote), gofmt, go vet for
linux, windows and darwin. TestSubagentTaskAndMetaComeBackFromTheSavedParse
is red on the old code (the list read the subagent's file once with its meta
gone); TestSubagentParseWithoutItsTaskIsReadOnce guards the one-time reread.
Not tried: a real Claude Code subagent's meta.json on Windows (the fixture
has none, the meta path is covered by the test); the full suite and the GUI
files are run after the push. A task past a subagent's 16th line is now
found where ccTask gave none.
2026-11-20 03:53:58 +08:00
..
2026-10-02 08:20:33 +08:00