fix: default to the current session via CLAUDE_CODE_SESSION_ID#8
Open
wan-huiyan wants to merge 1 commit into
Open
fix: default to the current session via CLAUDE_CODE_SESSION_ID#8wan-huiyan wants to merge 1 commit into
wan-huiyan wants to merge 1 commit into
Conversation
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.
This was referenced May 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No-arg
cctimepicked the most-recently-modified file, which loses to a concurrently-active session. Now resolvesCLAUDE_CODE_SESSION_ID(exported to subprocesses) viagetSessionByIdso it reports the session you're in; by-id also skips themessageCount>2filter 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