fix(ways): pin list context lookup to session id#93
Conversation
`ways list` was misreporting the context window when the shell cwd was outside the active session's project. The cwd-walking project detection could land on ~/.claude (global config) when no closer .claude marker exists, point the transcript lookup at a non-existent project dir, and fall back to the 200K heuristic — even on opus-4 1M-window sessions. Resolve the transcript by session id directly (scan ~/.claude/projects/*/<sid>.jsonl), since the session id is already known by the caller and is globally unique. The cwd-based path remains for the project-scoped `ways context` entrypoint.
Review SummaryWhat this changes: Replaces cwd-derived project lookup with session-id-pinned transcript discovery for Assessment: Fix is correct and minimal. The dual-mode BlockersNone. Suggestions1. for entry in std::fs::read_dir(&projects_root).ok()? {
let entry = entry.ok()?;The outer for entry in std::fs::read_dir(&projects_root).ok()?.flatten() {
let candidate = entry.path().join(&filename);
if candidate.is_file() {
return Some(candidate);
}
}
2. The HOME-blindness in Sidestepping it for Two reasonable paths for a follow-up:
I'd lean toward the second — session-id is the actual identity here, project dir is just an index into where transcripts live. But either is fine as a separate PR. Leaving it out of this one is justified. 3. Test gap for Easy to unit-test with a temp
Not a blocker — the integration path is exercised by manual testing in the PR body — but the function is small enough that 4 cheap unit tests would lock in the contract. Nits4. Naming: The 5. Doc comment on The doc says "When 6. Determinism question raised in review prompt
Unchanged callers — correctly left alone
Why this is sound
|
Summary
ways listwas misreporting context as 200K on 1M-window sessions when the shell cwd was outside the active session's project.detect_project_dirwalks up from cwd looking for.claude/settings.json, and matches~/.claude(the global config) when no closer project marker exists. The transcript lookup then targets a non-existent project dir, errors out, and falls through to the 200K heuristic.~/.claude/projects/*/<sid>.jsonl). The session id is already known toways listand is globally unique, so no project guessing is needed.Test plan
ways listfrom~/Projects/aaronsb/anthropic-basecamp/(cwd outside session project) now reports1000K ctxinstead of200K ctxways listfrom inside the session project still reports correctlycargo test -p ways --release— 70 unit + 11 sim tests pass