fix(T-1032): Claude session resolver fails when listing all projects#157
Conversation
Code ReviewOverviewThis PR fixes T-1032 by refactoring What's good
Issues / suggestions1. entries, err := os.ReadDir(projectsRoot)
if err != nil {
return "", fmt.Errorf("session not found: %s", sessionID)
}If if err != nil {
return "", fmt.Errorf("session not found: %s (could not read projects directory: %w)", sessionID, err)
}Or at minimum keep the underlying error in a 2. No test for the input-validation guard (minor) The for _, bad := range []string{"../other", "sub/session", "foo\\bar", "a..b"} {
_, err := resolver.Resolve(SourceClaude, bad)
assert.Error(t, err, "expected error for session ID: %s", bad)
}Note: the 3. No test for missing projects root (minor)
4. First-match semantics are undocumented (informational) If the same session ID somehow appears in two project directories, the function returns the first one found by SummaryThe fix is correct, the refactor is clean, and the tests cover the primary happy-path and not-found cases. The main action items are:
Happy to approve once those are addressed (or if you're comfortable accepting the minor gaps as-is). |
7a18e72 to
ec6cb9e
Compare
Code Review: fix(T-1032) — Claude session resolver fails when listing all projectsOverviewThis PR fixes a bug where What Works Well
Issues and SuggestionsMinor: strings.Contains(sessionID, "..")This rejects session IDs that contain Minor: redundant if r.projectPath != "" {
...
if !web.IsPathWithinDir(sessionFile, baseDir) { // <-- redundant after the up-front ID check
return "", fmt.Errorf("session not found: %s", sessionID)
}After the up-front Observation: first-match wins when session ID collides across projects If the same session ID exists in two different project directories (unlikely but possible), the search returns whichever subdirectory Style note (CLAUDE.md): multi-line comment block The function comment on // findClaudeSessionPath locates sessionID under ~/.claude/projects/, searching all subdirs when projectPath is empty.Similarly, the test functions have multi-paragraph docstrings explaining expected behavior — per CLAUDE.md these should be trimmed or removed. SummaryThe fix is correct and the approach is sound. The main actionable suggestions are:
None of these are blockers — the bug fix is solid and the tests verify the new behavior properly. |
Fixes Transit ticket T-1032: Claude session resolver fails when listing all projects