Skip to content

fix(ai-vault): list Claude sessions from a wrapper or launch-setting CLAUDE_CONFIG_DIR - #33751

Merged
nwparker merged 3 commits into
mainfrom
nwparker/agint-23505
Oct 26, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/agint-23505

Conversation

@nwparker

@nwparker nwparker commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​103 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​103
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​103 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​99

ELI5

Some people run Claude through a small wrapper script, like claude-work, that points Claude at a different settings folder (CLAUDE_CONFIG_DIR=~/.claude-work). Others set that folder in Orca's own Claude launch environment setting. Claude saves its chats in that folder, but Agent Session History only looked in ~/.claude and in folders the login shell names. So these chats never showed up. Now Orca remembers any Claude folder it actually sees in use and lists chats from there too.

What was still broken after #33506

#33506 covered a CLAUDE_CONFIG_DIR exported from the shell profile. I reproduced the remaining cases on main with isolated HOME/CLAUDE_CONFIG_DIR and env -i, using the real claude 2.1.310:

Case main
export CLAUDE_CONFIG_DIR in shell rc works (#33506)
wrapper script sets it (the reporter's claude-work) not listed
Orca setting: Claude launch env CLAUDE_CONFIG_DIR not listed
SSH / folder workspaces same as local; the scan runs in the host's orcad

Root cause

  • Claude writes transcripts to $CLAUDE_CONFIG_DIR/projects/<encoded-cwd>/<id>.jsonl, and its hook payloads report that path as transcript_path. Captured from the real CLI: "transcript_path":"/tmp/agint-23505-h1/.claude-work/projects/-private-tmp-agint-23505-h1-proj/5bc3….jsonl".
  • claudeProfileHistoryDirs() only returned the login-shell CLAUDE_CONFIG_DIR and the managed account homes. A wrapper's env var lives only in that one child process. The launch-setting env var was never read.

Change

  • New ClaudeObservedConfigDirs. When a local Claude hook arrives, it takes transcript_path, derives <config> from <config>/projects/<dir>/<file>, and saves it to userData/claude-observed-config-dirs.json. It only does this if the folder exists on this host. The list is capped at 32 entries.
  • The same class also returns agentDefaultEnv.claude.CLAUDE_CONFIG_DIR when it is set to an absolute path.
  • claudeProfileHistoryDirs() includes both lists and removes duplicates. History scan roots, usage discovery, native-chat transcript lookup and worktree-retirement discovery all go through this one function, so they all pick it up.
  • The service is installed by ClaudeRuntimeAuthService, which runs in both desktop main and orcad. Remote/SSH hosts record and scan their own folders. Paths from WSL or remote panes are skipped because the folder doesn't exist on this host.

Not guessed: Orca only adds folders it saw in a hook payload or that come from Orca's own launch setting.

Verification

  • Real hook server + real scanner (temporary test, not checked in). The real claude-work wrapper ran under an isolated HOME. I POSTed the captured hook payload over HTTP to a real AgentHookServer, re-created the service as if Orca had restarted, then ran localAiVaultScanRoots() + scanAiVaultSessions():
    • main: claudeProfileProjectsDirs = [], Claude sessions []
    • this branch: claudeProfileProjectsDirs = [".../.claude-work/projects"], sessions ["5bc3ce6f-…", "91b9ef8e-…"]
  • Resume from History uses the configured Claude command (claude-work '--resume' '<id>'), so a wrapper set as the Claude command resumes under the right folder.
  • Regression tests in claude-profile-router.test.ts: a hook-observed folder survives a restart, and the launch-setting folder is listed. Both fail on main.
  • pnpm tc:node, the claude-accounts / scanner-roots / claude-usage / hook continuation tests, and check:code-quality:changed all pass.

Limits / risk

  • The wrapper case needs Claude hooks to reach Orca. Orca installs its hooks only into ~/.claude/settings.json (and managed account homes). The reporter copied them into ~/.claude-work. With no hooks there, Orca never sees anything from that folder. Installing hooks into user-chosen folders is a separate change.
  • If you launch the wrapper by hand while the Claude command setting is plain claude, Resume still runs plain claude --resume.
  • Low risk: this only adds existing folders to the read-only scan roots, de-duplicated.

Fixes #23505

…CLAUDE_CONFIG_DIR

History, usage and transcript lookup now also scan Claude config folders Orca saw in Claude hook transcript paths (kept across restarts) and the CLAUDE_CONFIG_DIR set in Orca's Claude launch environment.

Fixes #23505
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 8 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5fd24eb3-a297-4096-ad81-c0f4daf60c8b
Commits

Reviewing files that changed from the base of the PR and between 072032f and cd6feab.

Files selected for processing: 8
  • src/main/agent-hooks/server-claude-config-dir-observation.test.ts
  • src/main/agent-hooks/server/server-ingest-normalization.ts
  • src/main/claude-accounts/claude-credential-persistence-ratchet.test.ts
  • src/main/claude-accounts/claude-observed-config-dirs.ts
  • src/main/claude-accounts/claude-profile-installed-router.ts
  • src/main/claude-accounts/claude-profile-router.test.ts
  • src/main/claude-accounts/runtime-auth-service.test.ts
  • src/main/claude-accounts/runtime-auth-service.ts
Walkthrough

The change adds a tracker that records Claude config directories from valid transcript paths and persists them. Claude hook normalization sends transcript paths to the tracker. Claude profile history directory discovery includes tracked directories and the configured Claude launch environment directory, and removes duplicate paths. Tests cover hook filtering, persistence, directory selection, and the tracking limit.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Low · up to 07203

Sessions in a temporarily unavailable config folder may remain absent from History until Orca restarts. This is a bounded issue suitable for owner follow-up.

Pre-merge checks: Passed 3 · Failed 1 · Inconclusive 1

Failed Failed checks: 1 warning · 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 8 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check Inconclusive For [#23505], the PR adds observed Claude config directories from local hook transcript_path values and adds the absolute Claude launch-setting CLAUDE_CONFIG_DIR. It persists observed paths, dedup… Provide reviewable evidence that the Claude subagent transcript allowlist includes the directories returned by claudeProfileHistoryDirs('transcripts'), including observed and launch-setting config directories.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly summarizes the primary change: listing Claude sessions stored under wrapper-provided or launch-setting CLAUDE_CONFIG_DIR paths.
Description check Passed The description is detailed and covers the user impact, root cause, implementation, testing, linked issue, limitations, and risks. It does not use every template heading, and it omits explicit visual-…
Out of Scope Changes check Passed The changed production files implement [#23505] directly. They observe Claude transcript paths, persist config directories, include the launch environment setting, and route the directories through ex…
Full details: Description check

Explanation

The description is detailed and covers the user impact, root cause, implementation, testing, linked issue, limitations, and risks. It does not use every template heading, and it omits explicit visual-proof and checklist entries, but the required information is mostly present.

Full details: Out of Scope Changes check

Explanation

The changed production files implement [#23505] directly. They observe Claude transcript paths, persist config directories, include the launch environment setting, and route the directories through existing history lookups. The added tests cover this behavior. No unrelated change is established.

Full details: Linked Issues check

Explanation

For [#23505], the PR adds observed Claude config directories from local hook transcript_path values and adds the absolute Claude launch-setting CLAUDE_CONFIG_DIR. It persists observed paths, deduplicates them in claudeProfileHistoryDirs, and adds tests for restart persistence and launch-setting discovery. The supplied evidence does not establish whether the Claude subagent transcript allowlist also uses these added roots, as requested by the issue.

Resolution

Provide reviewable evidence that the Claude subagent transcript allowlist includes the directories returned by claudeProfileHistoryDirs('transcripts'), including observed and launch-setting config directories.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

nwparker and others added 2 commits October 25, 2026 20:09
Adds tests that only Claude hooks record a folder (not same-layout CodeBuddy), non-transcript paths are ignored, and the 32-entry cap holds.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 733638e4-2703-475c-aef8-443b32cf8502
Commits

Reviewing files that changed from the base of the PR and between 61cab5e and 072032f.

Files selected for processing: 8
  • src/main/agent-hooks/server-claude-config-dir-observation.test.ts
  • src/main/agent-hooks/server/server-ingest-normalization.ts
  • src/main/claude-accounts/claude-credential-persistence-ratchet.test.ts
  • src/main/claude-accounts/claude-observed-config-dirs.ts
  • src/main/claude-accounts/claude-profile-installed-router.ts
  • src/main/claude-accounts/claude-profile-router.test.ts
  • src/main/claude-accounts/runtime-auth-service.test.ts
  • src/main/claude-accounts/runtime-auth-service.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

if (
basename(projectsDir) !== 'projects' ||
this.observed.includes(configDir) ||
this.missing.has(configDir)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Retry config directories that become available.

If a hook first reports a path while its config directory is unavailable, Line 49 adds the directory to missing. Line 42 then rejects every later hook for that directory without checking it again. If a mount or directory becomes available while Orca remains open, its sessions stay absent from History until restart. Expire cache entries or retry the filesystem check after a bounded interval.

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.

[Bug]: Claude sessions under a custom CLAUDE_CONFIG_DIR never appear in Agent Session History

1 participant