Skip to content

fix: default to the current session via CLAUDE_CODE_SESSION_ID#8

Open
wan-huiyan wants to merge 1 commit into
dioptx:mainfrom
wan-huiyan:upstream/current-session
Open

fix: default to the current session via CLAUDE_CODE_SESSION_ID#8
wan-huiyan wants to merge 1 commit into
dioptx:mainfrom
wan-huiyan:upstream/current-session

Conversation

@wan-huiyan
Copy link
Copy Markdown

No-arg cctime picked the most-recently-modified file, which loses to a concurrently-active session. Now resolves CLAUDE_CODE_SESSION_ID (exported to subprocesses) via getSessionById so it reports the session you're in; by-id also skips the messageCount>2 filter that can drop an active session with a stale cached count. +2 tests; verified live; tsc clean.

Supersedes #4 (dedicated branch). 🤖 Generated with Claude Code

Run with no args, cctime picked the most-recently-*modified* session file —
which loses to any concurrently-active Claude session, so it could silently
report a different session's stats than the one you're in (hit in practice:
a 16h background session shadowed the 1h session being asked about).

Claude Code exports CLAUDE_CODE_SESSION_ID to subprocesses. Resolve it via
getSessionById (the same authoritative lookup --session uses) so the default
is the actual current session. getSessionById matches by id and skips the
messageCount>2 "main session" filter — important because an active session's
cached index count can be stale/low and would otherwise exclude it from
getAllSessions. When not inside Claude Code and ≥2 sessions were active in the
last 5 min, print the chosen id + a --session hint instead of choosing silently.

Adds getCurrentSessionId() + getAllSessions() to finder + 2 tests. 89 pass.
Verified live: no-arg run now reports the current session, not a 16h sibling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant