ac4af582301a4e8a29245dbba767eba31334ddf9
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
f594b452e3 |
sessions: a Claude fork after a compaction is a branch under its session, read from the start
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
|
||
|
|
b3edcabf29 |
sessions: a Claude copy's subagents and what only it holds count in the usage stats
beautiful2674 (Discord): after updating from a 0.1.17xx to a 0.1.18xx, Usage's total over All was ~200M tokens lower, with the same filters. Since |
||
|
|
502674abb7 |
sessions: a Claude copy made after /compact is one row with its session
Neo (Discord #feedback, on v0.1.1803, used /compact and /rewind): one conversation was still listed as many rows of the same title. Claude Code 2.1.312's /branch (and --resume --fork-session) after a compaction copies only the compaction's summary and what follows it, under the same uuids. 1803 grouped copies by the file's first message, so such a copy (its first message the summary) never met the session it was copied from and was a row of its own; opened, it read from the summary on. Each Claude file now also records its compact summaries' uuids (state Compacts, cacheVersion 24, so every file is read again), and files are judged together when one starts with a message the other starts with or holds as a summary. Of two files that hold each other's last message, the one that also holds the other's first message is kept (a post-compact copy written last no longer stands in for the whole conversation), then the newer, as before. /rewind writes in place: "Restore conversation" and "Summarize from here" both append to the same file (a new branch under an earlier parent, a new compact summary), no new file. Its summary is recorded with /compact's, so a /branch made after it folds too. Fixtures (testdata/claude-forks/compacted*.jsonl): Claude Code 2.1.312's own files from a sandbox HOME with a fake API: a session of /compact, a /rewind restore, a /rewind summarize, a /branch after them, that branch gone on with a turn of its own, and a /branch made after the session's last turn; trimmed of request records, cost lines and attachment text, paths rewritten to /w. Run (mote) at this tree, 8eaf10cac on |
||
|
|
f4762e9217 |
sessions: a Claude conversation Claude Code copied into another file is one row
Neo (Discord #feedback): one Claude conversation was listed as ~11 rows
with the same title, message count and size, each under its own id.
Claude Code 2.1.312 copies a conversation into a new <id>.jsonl when it
forks one (--resume --fork-session, /branch) or moves it to a background
session: every message again, under the same uuids, with the new
sessionId. magpie keyed each file as a session, so each copy was a row,
and the copies' tokens were counted again in usage.
Each main Claude-format file (Claude Code, Qoder, Qoder CN) now records
the uuids of its first and last message (state Root/Leaf, cacheVersion
23, so every file is read once more and old copies fold in too). Of the
files of one agent that start with the same message, one whose last
message another holds is a copy (cc_copies.go). Only a random (v4) uuid counts, as Claude Code
writes them: files whose writer reuses ids like "u" stay apart. A copy
is not listed
(List, ListAgent, Agents), not counted in stats, and Delete trashes it
with the session that holds it (Restore brings it back). A fork that
went on with a turn of its own has a last message no other file holds
and stays its own row, as Claude Code's /resume shows it. The gateway's
session rows and the GUI's native keys know the copies' ids, so a
gateway-only row doesn't stand in for one.
Fixtures: testdata/claude-forks is Claude Code 2.1.312's own files from
a sandbox HOME with a fake API (a session, a --fork-session of it with a
third prompt, another fork with a different one), trimmed of request
records and attachment text. Pure copies are that session with its
sessionId rewritten, as /branch leaves one.
Run (mote) at 2b7ce2967 on
|