Drop sessions that hold no conversation - #47
Conversation
| continue | ||
| } | ||
| kept = append(kept, p.Session) | ||
| kept = append(kept, s) |
There was a problem hiding this comment.
[P2] Retain Codex sessions that contain a prompt
A Codex transcript can contain a user_message but no task_started event—for example, if it is interrupted before execution begins. Once it is no longer live, it has nil status, zero turns/tool uses, and no tokens, so this condition drops it even though it is not session-meta-only and contains recoverable user work. Include parsed prompt/activity state in the emptiness test.
There was a problem hiding this comment.
Correct, and fixed in c3c1457.
The cause is a difference between the two parsers. Codex increments turns on task_started only (codex/parse.go:194), and its unifiedSession sets Turns: analysis.turns. Claude falls back to the prompt count in the same position (claude/parse.go:367). A recorded prompt therefore leaves Turns at 0 on Codex, and on Codex only.
I did not find such a rollout on disk. In all 82 local rollouts, task_started comes before user_message. Codex writes task_started at line 2 and the prompt event at line 11, so the prompt event belongs to a turn that already started. My data is one machine, and it does not prove that the file cannot exist. I built the file from a real rollout instead, and it parses like this:
Turns=0 ToolUses=0 tokens=0 digest=1
FirstPrompt="make release\nnpm --prefix ../frontend ci\nnpm warn EBADENGINE"
DROPPED BY servableRoots FILTER: true
The fix
The old condition tested whether work happened. The correct test is whether the session holds anything to show, and a prompt is something to show:
if s.Status == nil && s.FirstPrompt == nil &&
s.Turns == 0 && s.ToolUses == 0 && len(s.Tokens) == 0 {
continue
}FirstPrompt states the condition exactly. Both parsers set the field only for a prompt that is not empty (claude/parse.go:386, codex/parse.go:327).
Test
The constructed rollout now survives the filter. The two /clear stubs still drop, because emitPrompt never fires for them and their FirstPrompt stays nil. List(0) returns 187 sessions, the same count as before this change.
go vet ./... and go test ./... pass. collector_test.go gains the interrupted rollout as a case.
|
[P2] Exclude amended commits before parsing their message Affected file: For I could not attach this inline because this file is not changed in the current PR diff. |
Context
Some sessions appeared in the UI with no data: unknown model,
≈$0.00, and<1m · 0 turns · 0 tools · 0 errors. These transcripts hold no conversation. Claude Code writes one for each/clear, and Codex writes one when a rollout ends before its first turn.Changes
/clearstub and asession_meta-only Codex rollout are the same case.servableRootsruns afterresolveStatus, so a non-nilStatusmarks the session as live and exempts it.excludeSynthesisRunsbecomesservableRoots. The function already dropped the synthesis CLI sessions, so the new rule reuses that pass instead of adding another one.Test
go vet ./...— passedgo test ./...— passedList(0)over the local transcripts. The two/clearstubs are gone. 187 of 189 roots remain, and every session with content is still listed.Screenshots
before


after