Skip to content

fix(claude): show the conversation on mobile for Claude started with a custom CLAUDE_CONFIG_DIR - #49361

Merged
AmoabaKelvin merged 6 commits into
mainfrom
claude-hooks-custom-config-dir
Nov 26, 2026
Merged

AmoabaKelvin merged 6 commits into
mainfrom
claude-hooks-custom-config-dir

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

If you start Claude in an Orca terminal with your own settings folder, for example CLAUDE_CONFIG_DIR=~/.claude-work claude for a second account, the phone listed the tab but its chat view stayed on "Can't find this conversation yet". Orca's status hooks were only ever installed in ~/.claude and in the account folders Orca makes itself, so that Claude never told Orca which conversation it was running. Now Orca hands its hooks to that Claude at launch, and the phone shows the conversation.

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​38 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​38
Prod 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​174 $\color{#cf222e}{\Huge{\mathbf{−}}}$​32 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​142

What Changed

Before: a Claude whose CLAUDE_CONFIG_DIR points at a folder Orca didn't create loaded none of Orca's hooks. The pane never got a session id, so mobile chat waited forever. Desktop status (working/done) was missing for that pane too.

After: that Claude reports to Orca like any other, with no writes to the user's folder.

How it works:

  • When Orca installs its Claude hooks (ClaudeHookService.install(), default target), it also publishes the same hook entries as a small plugin in its own data folder (<userData>/claude-hook-plugin/orca-status-hooks). The entries are taken from the merged ~/.claude settings, so a user's async choice on an Orca hook carries over. Writes are async, compare-before-write, and coalesced (one running, latest one pending). Turning hooks off deletes the folder.
  • Every local pane gets ORCA_CLAUDE_HOOK_PLUGIN_DIR when status hooks are on and Claude isn't disabled (not WSL). It is stripped with the other hook coordinates, and an inherited copy from a parent Orca is removed from CLAUDE_CODE_PLUGIN_DIRS, the same way the agent-view plugin already does it.
  • The claude shell function (POSIX, fish, PowerShell) already detects a CLAUDE_CONFIG_DIR that Orca didn't inject. For those launches only (an alias like the one above, or the user's own login-shell folder on System default), it adds the plugin to CLAUDE_CODE_PLUGIN_DIRS for that one process. It skips the plugin when it is already listed, or when the folder's settings.json already contains an Orca hook in any form (script path, native .exe, encoded PowerShell). That avoids running Orca's hooks twice, which matters because PreToolUse/PermissionRequest hooks hold the prompt.
  • Plain claude, managed accounts and WSL behave exactly as before.

Why

The running process's CLAUDE_CONFIG_DIR is the only reliable answer to "which folder does this Claude read", and it is only known at launch, in the shell function that already runs before every claude in an Orca pane. #33751 learned folders from hook transcript paths, which can't help a folder that has no hooks.

Alternatives considered:

  • Write Orca's hooks into the user's folder (from a CLI preflight, like orca agent hooks prepare-codex). This edits a file Orca doesn't own. It would need records to clean up on uninstall, and it adds a ~0.3 s CLI start per launch.
  • Read the Claude process's environment from main. This needs native changes on macOS and isn't available on Windows.
  • Always put the plugin in every pane. Default ~/.claude panes would run every hook twice.
  • Add --settings in the wrapper. It conflicts with a user's own --settings and doubles hooks in folders that already have them.

Claude Code loads hooks from CLAUDE_CODE_PLUGIN_DIRS regardless of its config folder, with nothing to enable in that folder (checked on Claude 2.1.332). Orca already uses that variable for its agent-view plugin.

Linked Issue

Fixes #41449

Linear: STA-14983

Visual Proof

Same build, same alias (CLAUDE_CONFIG_DIR=<temp folder> claude), the same prompt answered by a local fake API, opened in the iOS app paired to the desktop.

Before (main's path) After (this PR)
mobile-before-custom-config-dir.png mobile-after-custom-config-dir.png

Testing

  • Live, hidden worktree build (orca serve) + local fake Anthropic API, no real ~/.claude folder used for the Claude runs:

    • A pane running CLAUDE_CONFIG_DIR=/tmp/…/cfg claude got CLAUDE_CODE_PLUGIN_DIRS=<agent-view plugin>:<hook plugin>. Its session.tabs.list entry carried providerSession.id with a transcript under the temp folder, right after SessionStart and before any prompt. nativeChat.readSession (the phone's read) returned the conversation.
    • The same alias with the plugin env unset (main's path) left providerSession empty, which is the bug.
    • The temp folder's settings.json hash was unchanged after the run, and the plugin carried only Orca's 16 entries (the user's own hooks in ~/.claude/settings.json were left out).
    • iOS simulator paired to that build: before/after above.
  • Shell functions run in bash 3.2, zsh (including warn_create_global, nounset, err_return), fish 4.9 and pwsh 7.7. Cases covered: foreign folder, foreign folder with the user's own plugin list, already-listed plugin, folder already holding Orca hooks (.sh / .cmd / .exe / encoded PowerShell), the user's own hooks only, plain claude, managed account, managed + alias, user's own folder on System default, no pointer, plugin env missing. CLAUDE_CODE_PLUGIN_DIRS is restored after the call in every shell.

  • src/main/claude/hooks/claude-hook-plugin.test.ts pins that the shell's duplicate-hook pattern recognizes every hook command form Orca's builders write and leaves user hooks alone. It fails if the encoded-PowerShell part is dropped (checked).

  • Platforms: macOS run live. Windows Git Bash / PowerShell separators and command forms checked by the tests above and by reading the paths, not on a Windows machine.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • Every added test fails without this change and avoids the test anti-patterns

Performance

  • Install: the plugin publish runs only when Orca installs its Claude hooks (startup reconcile, hooks on/repair). It takes Orca's appended entry per planned event (at most 16) and does two async compare reads, with zero writes when nothing changed. Bursts coalesce to one running and one pending write.
  • Panes: each pane spawn adds one string assignment and a split/filter of CLAUDE_CODE_PLUGIN_DIRS, with no file I/O.
  • Launches: in the shell, a launch with no custom folder, with Orca's own folder, or with the plugin already listed does zero file work. Only a launch into a folder Orca didn't set does one file test plus one grep of that folder's settings.json.
  • Idle: no timers, polling, store writes or per-status-event work.

Risk

Level: Medium

The riskiest part is the shell function change, which runs before every claude typed in an Orca pane. Its new branch only acts when CLAUDE_CONFIG_DIR is set to a folder Orca didn't inject, and it only adds one entry to CLAUDE_CODE_PLUGIN_DIRS for that process.

If an organization's managed settings forbid sideloaded plugin folders, that Claude treats this exactly like the agent-view plugin Orca already passes to default-folder panes.

The first claude started in the first moments after the very first startup, before the plugin is published, runs without it; the next launch has it.

WSL panes are unchanged: they get hooks from the guest's own install. SSH hosts run orcad, which builds pane env and installs hooks with this same code, so each host publishes its own plugin.

Back out with a plain revert. It leaves an unused <userData>/claude-hook-plugin folder that nothing reads.

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • No user-owned file is written. The shell only reads the chosen folder's settings.json.
  • No wire, RPC or persisted-state changes. An older daemon's panes keep today's rcfile and behave as before.
  • Follow-up, not in this PR: Codex started with a custom CODEX_HOME likely has the same gap (the ticket mentions it, unverified).

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…m CLAUDE_CONFIG_DIR

A terminal running CLAUDE_CONFIG_DIR=~/.claude-work claude loaded none of
Orca's hooks, because Orca only writes them into ~/.claude and its own
account folders. The pane never got a session id, so the phone's chat view
stayed on "Can't find this conversation yet".

Orca now publishes the same hooks as a plugin in its own data folder, and
the claude shell function adds it to CLAUDE_CODE_PLUGIN_DIRS for a launch
whose config folder Orca did not set and that does not already carry Orca's
hooks. Nothing is written into the user's folder.
Check plugin membership before touching the config folder, recognise every
Orca hook form (including encoded PowerShell) so a hooked folder never gets
the plugin twice, coalesce plugin writes, keep the settings parse before any
script write, and strip an inherited plugin path in nested Orca panes.
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

Claude hook installation now publishes managed hooks to a plugin for default-config installs. PTY environment setup configures the plugin directory for enabled Claude launches outside WSL. POSIX, fish, and PowerShell wrappers conditionally add the plugin directory to Claude's plugin path. Tests cover managed-hook command detection.

Severity of issue fixed: Medium

Merge Risk: Low · up to 6c558

Custom-config Claude sessions now get Orca hooks through a plugin without any change to the user's config folder. In an unusual case, a custom config containing only an Orca statusLine entry skips the plugin and the session stays invisible to mobile chat. This is a narrow gap, so merging is low risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main user-facing fix: Claude sessions started with a custom CLAUDE_CONFIG_DIR now show their conversation on mobile. The changeset adds a plugin publish path, shell-function plugin…
Description check Passed The description follows the template closely. It has ELI5, What Changed, Why, Linked Issue (Fixes #41449), Visual Proof with before/after images, Testing with checkboxes, Performance, Risk with level …
Linked Issues check Passed Linked issue #41449 requires that Claude launched with a user-chosen CLAUDE_CONFIG_DIR (a folder Orca did not create) gets Orca's status hooks, so the pane receives a session id and the mobile chat sh…
Out of Scope Changes check Passed Every changed area supports the #41449 objective or its tests:
- hook-service.ts, claude-hook-plugin.ts: publish and remove the plugin with Orca's hook install lifecycle.
- host-env/assembly.ts, claud…
Full details: Title check

Explanation

The title names the main user-facing fix: Claude sessions started with a custom CLAUDE_CONFIG_DIR now show their conversation on mobile. The changeset adds a plugin publish path, shell-function plugin injection, and env handling that serve that goal. The title is specific and accurate. It uses the conventional 'fix(claude):' prefix. It is longer than ideal, at 95 characters, but it stays readable.

Full details: Description check

Explanation

The description follows the template closely. It has ELI5, What Changed, Why, Linked Issue (Fixes #41449), Visual Proof with before/after images, Testing with checkboxes, Performance, Risk with level Medium and a back-out plan, Agent skill upstream boundary, Notes, and Checklist. The AI Disclosure and Review sections are empty. The template says to leave AI Disclosure blank for StablyAI team members, so that gap may be acceptable. The Review section is empty and has no content. The description is detailed and specific about the mechanism, alternatives, and test coverage.

Resolution

Optional: fill in or remove the empty 'Review' heading, and confirm whether the 'AI Disclosure' section needs content for this contributor.

Full details: Linked Issues check

Explanation

Linked issue #41449 requires that Claude launched with a user-chosen CLAUDE_CONFIG_DIR (a folder Orca did not create) gets Orca's status hooks, so the pane receives a session id and the mobile chat shows the conversation. The PR addresses this with these changes:

  • src/main/claude/hook-service.ts publishes Orca's managed Claude hook entries as a plugin after default-target hook install, and removes it on hook removal.
  • src/main/claude/hooks/claude-hook-plugin.ts writes the plugin manifest and hooks config to <userData>/claude-hook-plugin/orca-status-hooks, with compare-before-write and coalesced writes.
  • src/main/ipc/pty/host-env/assembly.ts sets ORCA_CLAUDE_HOOK_PLUGIN_DIR for local non-WSL panes when status hooks are enabled.
  • src/shared/shell/launch/agents/claude-shell-function.ts adds the plugin to CLAUDE_CODE_PLUGIN_DIRS for the process only when CLAUDE_CONFIG_DIR is a folder Orca did not inject and the folder does not already contain Orca hooks.
    The author reports a live test on macOS. Before the change, providerSession stayed empty. After the change, providerSession.id was set after SessionStart, and nativeChat.readSession returned the conversation. The author also reports before/after mobile screenshots. These results were not re-run in this review. Based on the code evidence, the mechanism covers the reported case. Known limits: the first launch right after first startup may run without the plugin, and Android and Codex are not covered. The issue does not require Android. Codex is an explicit follow-up.
Full details: Out of Scope Changes check

Explanation

Every changed area supports the #41449 objective or its tests:

  • hook-service.ts, claude-hook-plugin.ts: publish and remove the plugin with Orca's hook install lifecycle.
  • host-env/assembly.ts, claude-agent-view.ts, spawn-env-keys.ts: set, strip, and clear the plugin directory variable for panes. The stripping logic extracts the existing agent-view handling into a shared helper.
  • shared/agent-hook-listener/providers/claude/claude-hook-plugin.ts: constants and the managed-hook command pattern used for duplicate-hook detection.
  • claude-shell-function.ts: the POSIX, fish, and PowerShell wrappers that load the plugin for custom config folders.
  • claude-hook-plugin.test.ts: tests for the managed-hook pattern used by the shell function.
    The PR does not change mobile code, Codex handling, or WSL behavior. The Codex gap is documented as a follow-up. No unrelated change was found in the summary.
  • 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

@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.

Minor comments: 1

src/shared/shell/launch/agents/claude-shell-function.ts: 1

25-25: Minor · Functional Correctness · Poor tradeoff

Limit duplicate-hook detection to lifecycle hook entries in all three wrappers.

The POSIX, fish, and PowerShell wrappers match CLAUDE_MANAGED_HOOK_COMMAND_PATTERN against the entire settings.json. The Orca statusLine command uses the same .orca/agent-hooks script path, so a config that contains only that statusLine matches. The wrapper then skips plugin injection. The session starts without the Orca SessionStart hook, so Orca gets no session ID for the pane.

Detection should check only commands under settings.hooks, and it should ignore statusLine. Keep the skip for configs that contain Orca lifecycle hooks. Add a test case in which settings.json contains only an Orca statusLine command, and confirm that plugin injection still occurs.

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: 73e8d1f2-a02f-41f0-b492-669b22abb7fe
Commits

Reviewing files that changed from the base of the PR and between 18bb4d5 and 6c55816.

Files selected for processing: 8

  • src/main/claude/hook-service.ts
  • src/main/claude/hooks/claude-hook-plugin.test.ts
  • src/main/claude/hooks/claude-hook-plugin.ts
  • src/main/ipc/pty/host-env/assembly.ts
  • src/main/ipc/pty/host-env/claude-agent-view.ts
  • src/main/ipc/pty/host-env/spawn-env-keys.ts
  • src/shared/agent-hook-listener/providers/claude/claude-hook-plugin.ts
  • src/shared/shell/launch/agents/claude-shell-function.ts

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

@AmoabaKelvin
AmoabaKelvin merged commit eb1ceb4 into main Nov 26, 2026
56 checks passed
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]: Mobile shows "Can't find this conversation yet" for Claude started with a custom CLAUDE_CONFIG_DIR (Orca hooks are never installed there)

1 participant