neo_o11 (Discord, after v0.1.1809): one conversation still showed as ~9
rows with the same title, and opening one showed "Session start" and a
single turn.
Cause, reproduced with real Claude Code 2.1.312 in a sandbox
CLAUDE_CONFIG_DIR: the reporter's session was compacted, then forked
several times (headless --fork-session per task, or /branch). Each fork
starts at the compact boundary and summary, and copies the session's
last reply under the same uuid. So every fork holds the original's
Leaf, and ccCopies hid the original as a fork's copy, though it alone
holds the conversation before the compaction. Each fork had a Leaf of
its own and stayed a row, with the copied title. Opening a fork read
its own file: the summary and one turn.
Fix:
- cc_copies.go: ccFamily returns copies and branches. A file is a
copy of another only when that one holds its Leaf and its Root too,
so a file with what came before the other's start is never hidden.
The members of a family left visible pick a head (holds the other's
Root, then named in the other's forkedFrom, then the earlier start,
then the lower key); the rest are branches of it.
- sessions.go, manage.go: a branch has role "branch" and
parent_session = its head, in List, Find/get and ListAgent.
- transcript.go: a branch's transcript is its head up to the fork
point (the last line of the head holding one of the branch's
uuids), then the branch's own lines. Search still reads its file.
- stats.go: a branch counts only its own lines, so tokens are not
counted twice.
- GUI sessions plugin: the fold under a session names branches apart
("2 branches · 1 subagent"), in en/zh/zh-TW/ja/de.
- Fixtures in testdata/claude-forks/tasks*.jsonl are trimmed from real
2.1.312 output: a session compacted once, two --fork-session task
forks and a /branch copy with forkedFrom.
- docs/subsystems/gateway-sessions.md: copies and branches.
Run:
- go test ./internal/sessions -run 'TestClaude|TestQoder|TestMergeExternal'
on mote, at e15b2277c before the rebase: ok. Red on the old code (cc_copies/sessions/transcript/stats
restored from HEAD~): 5 tests failed (the original hidden, only forks
as rows; a branch's prompts starting at the summary).
- Broken by hand, each red: dropping the Root rule (3 compacted-fork
tests), ignoring forkedFrom (TestClaudeBranchNamesItsSession),
turning branchTranscript off (3 tests), counting a branch whole in
stats (90 tokens, not 80).
- GOOS=linux (-tags nogui), windows and darwin go vet, at e15b2277c: ok.
- Full go test ./... -timeout 45m at this head (71124a2d7 on c1660481c),
on the Linux box (mote was at load 300 with six suites): every
package ok, sessions 144s, gateway 987s, except: ., internal/cli and
internal/gui didn't build (no gtk4 there), ok again with -tags nogui;
internal/agent's TestInstalledVersion, TestGrokInstalled,
TestOmpDetectedWithPiDir and TestCursorFolderFromTheEditorIsNotTheCLI,
the first three red the same at origin/main c1660481c there, all four
in #4033 (#3548, #3141). Nothing here touches internal/agent.
- GUI on the Windows box, both engines, every language:
sessions-subagents + i18n-keys 40/44, the 4 reds 5s nav-click and
goto timeouts in WebKit; WebKit alone again 20/20. Every
session*.test.cjs file (32): 381/399. Its six red files run again at
origin/main c1660481c and here, one at a time: calendar-fill zh red
on both (#1314), sessions-today WebKit zh red here only, the
reads.n race of #1315; the rest green on both.
Not tried: get()'s path for a session beyond the listing's 200 has no
test of its own; the TUI and CLI lists show a branch as a row of its
own, not nested; an uncompacted fork that went on has no real
forkedFrom fixture (TestClaudeBranchNamesItsSession injects one).