Repository navigation
fix(ai-vault): list Claude sessions under a CLAUDE_CONFIG_DIR exported only by the login shell - #33506
Merged
Conversation
…d only by the login shell A Dock-launched Orca never inherits CLAUDE_CONFIG_DIR from ~/.zshrc, so session history, usage and transcript lookups only scanned ~/.claude/projects. The Claude account router already resolves the login-shell value; reuse it as a history root. Refs #23505
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.
ELI5
If you tell Claude Code to keep its files somewhere other than
~/.claudeby puttingexport CLAUDE_CONFIG_DIR=...in your shell startup file, Orca opened from the Dock or Finder never sees that line. Agent Session History, the Claude usage scan, and transcript lookups only looked in~/.claude/projects, so those sessions didn't show up. Orca's Claude account router already reads your login shell to find this folder. History now looks there too.Root cause
$CLAUDE_CONFIG_DIR/projects/<encoded-cwd>/<id>.jsonl. You can see this in the installed CLI (2.1.310):function s(){return process.env.CLAUDE_CONFIG_DIR}andx(process.env.CLAUDE_CONFIG_DIR||Y_(), ...). I also confirmed it with a real run (below).claudeProjectsHostDirs()respectCLAUDE_CONFIG_DIR, but it only readsprocess.env. A macOS GUI launch doesn't get variables exported from rc files.ClaudeProfileRouteralready resolves the login-shell env ("Dock launches lack CLAUDE_CONFIG_DIR exported by shell startup files").systemDefaultHome()returned the right folder, butclaudeProfileHistoryDirs()only returned managed account homes.Change
claudeProfileHistoryDirs()now puts the router'suserConfigDir()ahead of the account homes.userConfigDir()is the user's ownCLAUDE_CONFIG_DIR; Orca-injected account pins are already excluded, and it isundefinedwhen not overridden. Every consumer goes through this one function, so all of them pick it up: AI Vault scan roots (passed to scan workers vialocalAiVaultScanRoots), the subagent transcript allowlist, native-chat session file resolution, Claude usage transcript discovery, and worktree-retirement discovery.process.envand the login shell is walked only once.claude-profile-router.test.ts. It fails on main.Verification
HOME=/tmp/agint-…withCLAUDE_CONFIG_DIR=$HOME/.claude-workand the realclaude2.1.310 talking to a local fake Anthropic endpoint. The transcript landed in.claude-work/projects/-private-tmp-…-proj/<id>.jsonl, and$HOME/.claudewas never created.$HOME/.zshrcexportsCLAUDE_CONFIG_DIR,process.envhas none, andSHELL=/bin/zsh. A realClaudeProfileRouterresolved the real login shell, then I ranlocalAiVaultScanRoots()andscanAiVaultSessions().systemDefaultHome = …/.claude-work,claudeProfileProjectsDirs = [], 0 Claude sessions.zsh -ilc 'claude --resume <id> -p again'from the same isolated home picked upCLAUDE_CONFIG_DIRfrom.zshrcand appended to the same transcript. History's plainclaude --resumein an Orca terminal therefore works for this setup.pnpm tc:node, the targeted tests (router, scanner roots, claude-usage, retirement, native-chat), andcheck:code-quality:changedall pass.Scope / not covered
This fixes the "one custom config dir exported by the shell" case, plus Windows user-level env vars set after Orca started, because the router's PowerShell probe reads them. It does not cover the multi-profile setup where each terminal or wrapper (for example
claude-work) sets its ownCLAUDE_CONFIG_DIRand nothing global names those dirs. That needs a product decision: a setting for extra Claude config dirs, or deriving dirs from the configured Claude command. That's why this PR saysRefs, notFixes.Risk
Low. This adds at most one existing directory (the user's own Claude config) to the history roots. Hosts without an override are unchanged, because
userConfigDir()isundefinedthere.Refs #23505