Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions internal/claude/claude.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,9 @@ func applyMeta(src *session.Source, line claudeLine) {
// directory it was started in, and Claude Code stamps every record with
// wherever the agent stands at the time, so a cd into a subdirectory or a
// worktree would otherwise move the whole session out of the listing run
// where the user began it.
if line.Cwd != "" && src.Metadata["cwd"] == "" {
// where the user began it. A sidechain record is a subagent's, not the
// session's, so it never claims the directory.
if line.Cwd != "" && !line.IsSidechain && src.Metadata["cwd"] == "" {
src.Metadata["cwd"] = line.Cwd
}
if line.GitBranch != "" {
Expand Down
4 changes: 3 additions & 1 deletion internal/claude/claude_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ func TestReadThread(t *testing.T) {
// A session that cd's away keeps the directory it was started in: the records
// below walk into a subdirectory, on to a sibling repo, and back, and the
// first cwd is the one a listing must find it under. The empty cwd ahead of
// them stands for a record that carries the field without a value.
// them stands for a record that carries the field without a value, and the
// sidechain record after it for a subagent that started elsewhere.
const wanderer = `{"type":"user","sessionId":"sess-w","cwd":"","timestamp":"2026-06-26T10:00:00Z","message":{"role":"user","content":"start here"}}
{"type":"user","sessionId":"sess-w","cwd":"/home/u/src/catchup/internal","isSidechain":true,"timestamp":"2026-06-26T10:00:02Z","message":{"role":"user","content":"subagent task"}}
{"type":"assistant","sessionId":"sess-w","cwd":"/home/u/src/catchup","timestamp":"2026-06-26T10:00:05Z","message":{"role":"assistant","content":[{"type":"text","text":"ok"}]}}
{"type":"user","sessionId":"sess-w","cwd":"/home/u/src/catchup/internal","timestamp":"2026-06-26T10:01:00Z","message":{"role":"user","content":"now the subdirectory"}}
{"type":"user","sessionId":"sess-w","cwd":"/home/u/src/other","timestamp":"2026-06-26T10:02:00Z","message":{"role":"user","content":"now the sibling"}}
Expand Down
Loading