Conversation
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.
What / Why / How
Fixes #1198. When two Claude Code sessions share a project, MCP work can be attributed to the most recently started session instead of the caller.
Resolve the caller from the explicit
CLAUDE_SESSION_IDoverride, then Claude Code's livesessions/<parent-pid>.jsonfile, then the inheritedCLAUDE_CODE_SESSION_ID. Keep the existing session DB fallback for other hosts. Apply this to indexed content, session events, persistent tool-call counts, restored stats, and the per-conversationctx_statslookup. Reading the live file on each call also handles/clearwhen the inherited ID is stale.Affected platforms
Test plan
pnpm exec vitest run tests/session/caller-session.test.ts tests/session/event-emit.test.ts tests/session/server-tool-call-wiring.test.ts: 18 passed.pnpm run typecheck: passed. Build and bundle assertions passed.ctx_executetool-call row and sandbox event were both credited to the caller.pnpm teston Windows: 4,687 passed, 41 failed, 77 skipped. The failures were in shell/Python, symlink-permission,/tmp, andnpm packtests; the targeted session suites passed.Checklist
npm testpassesnpm run typecheckpassespath.join())nextbranch (unless hotfix)