fix(provider): respect CLAUDE_CONFIG_DIR in Claude detection - #134
Open
paoloantinori wants to merge 1 commit into
Open
fix(provider): respect CLAUDE_CONFIG_DIR in Claude detection#134paoloantinori wants to merge 1 commit into
paoloantinori wants to merge 1 commit into
Conversation
detect_provider_from_payload classified a session as Claude only when the transcript path contained /.claude/. When CLAUDE_CONFIG_DIR redirects the config home (a documented Claude Code setting used by multi-account setups, dev containers, and cc-mirror clones), Claude writes transcripts under the redirected dir, so the guard failed and Claude Stop/Notification events were misdetected as codex, dropping the turn's status update. Add _claude_transcript_markers() which returns /.claude/ plus the resolved CLAUDE_CONFIG_DIR path when set (full path, not basename, to avoid false-positives on generic components like /config/).
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.
Fixes #133
Problem
detect_provider_from_payload(src/ccgram/hooks/adapters.py) recognizes a Claude transcript only by the hardcoded substring/.claude/. WhenCLAUDE_CONFIG_DIRredirects the config home (a documented Claude Code setting), Claude writes transcripts under the redirected dir, so the guard fails and themodel/permission_modefields in Claude Stop/Notification payloads trip the codex branch. The session is misdetected as codex, and on Stop the codex short-circuit drops the turn. See #133 for the full reproduction.This extends PR #116, which added the
/.claude/guard for the default home but did not cover redirected config homes.Fix
Add
_claude_transcript_markers(), which returns the transcript-path markers that identify a Claude session:/.claude/projects/for the default home (basename match works across users), and<resolved CLAUDE_CONFIG_DIR>/projects/whenCLAUDE_CONFIG_DIRis set.Each marker is anchored on
projects/(Claude's actual transcript subtree) rather than the bare config dir, which avoids three false-positive cases:CLAUDE_CONFIG_DIR=~would otherwise resolve to the home dir and match almost any path..claude.customwas silently shadowed by the default/.claude/substring.projects/would have matched the bare prefix.config.py:92already resolvesCLAUDE_CONFIG_DIRthe same way; this mirrors that resolution.Tests
Four new tests in
tests/ccgram/test_hook_provider_events.py:/config/pathCLAUDE_CONFIG_DIR=~does not sweep up a codex transcript under the home dir.claude.customredirect is honored as its own config dirFull file: 23 passed.
ruff check,ruff format --check, andpyrightclean.CHANGELOG
Added an
Unreleased>Fixedentry.