Repository navigation
fix(agents): pre-accept Claude's workspace trust prompt - #18084
himichaelroberts wants to merge 9 commits into
Conversation
Launching Claude in a directory Claude Code has not seen leaves the agent sitting on its "Do you trust the files in this folder?" dialog. Orca already pre-writes trust artifacts for Cursor, Copilot, and Codex via `preflightTrust`, but `claude` and `openclaude` had no preset, so the dialog eats Orca's first keystrokes the same way stablyai#15859 (Devin) and stablyai#11765 (Cursor) describe. It is worse than a stalled paste when the tab opens in the Chat UI. stablyai#16729 removed the terminal-chat toggle and unmounted its Cmd+Shift+J fallback, and Claude's folder-trust dialog produces no `interactivePrompt` — `deriveInteractivePrompt` only emits one for `AskUserQuestion` or a `PermissionRequest` carrying a tool name — so the chat view renders no card and no transcript, with no way back to the terminal to answer. Reported as stablyai#18080. Adds `preflightTrust: 'claude'`, writing `projects["<realpath>"].hasTrustDialogAccepted` in the config the runtime resolver picks (CLAUDE_CONFIG_DIR, else a colocated ~/.claude/.claude.json, else ~/.claude.json), plus the SSH mirror against the remote user's home. Only that one flag is set: the sibling `hasClaudeMdExternalIncludesApproved` is a separate consent about executing external CLAUDE.md includes. The Devin flag pattern does not transfer — `claude --help` documents the workspace trust dialog as skipped only in non-interactive mode, and `--permission-mode` / `--dangerously-skip-permissions` govern tool approvals, not workspace trust. Distinct from stablyai#13086: this writes an artifact for a workspace the user explicitly created, before the agent starts, rather than keystroking through a dialog in a session nobody asked for. Three things fell out of wiring it up: - The IPC handler never awaited the Codex write, so the renderer could launch before trust landed. Both local and remote arms are awaited now. - The local preset dispatch existed twice — once in the IPC handler, once in `markLocalWorktreeTrusted` — and Claude would have silently done nothing on the second. Consolidated into `applyLocalAgentTrustPreset`, with a test that pins an arm for every preset in the union. - The per-file mutation queue was Codex-named but keyed only by path, so it moves to `agent-config-mutation-queue.ts` and Claude's read-modify-write of a config every running Claude rewrites shares the lane. Codex call sites keep their name through a one-line re-export. `AgentTrustPreset` moves to `src/shared/` so the presets, the preload bridge, and `TUI_AGENT_CONFIG.preflightTrust` stop keeping three copies of the union. `openclaude` is deliberately left out: it is a distinct CLI and I have not verified it reads `~/.claude.json`. Also fixes a latent leak in worktree-creation-flow.test.ts, where one test's never-resolving `markTrusted` outlived it and hung every later launch whose agent gained a preset. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…de-preflight-trust
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe change adds Claude as an agent trust preset. Local handling resolves Claude’s active configuration file, preserves valid data, and serializes concurrent writes. Remote handling selects and updates the remote Claude configuration defensively. IPC and worktree startup use centralized preset dispatch. Shared types now include Claude across main, preload, and agent configuration code. Tests cover local, remote, startup, queue, runtime mocks, and renderer behavior. Merge Risk: 🔵 Low · up to The PR pre-accepts Claude workspace trust before launch, but one startup path can still show the trust prompt and configured directories with leading or trailing whitespace can update the wrong file; an unexpected configuration shape may also be replaced. The change is mergeable with explicit owner awareness and follow-up on these bounded cases. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation The changes satisfy the trust-preacceptance objective in Full details: Description checkExplanation The description is complete and relevant. It includes the required ELI5, change summary, rationale, linked issue, visual-proof explanation, testing details, AI disclosure, review considerations, boundary checklist, notes, and completion checklist. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 395bdfd1-299d-43bc-89f8-f306c65176e9
📒 Files selected for processing (16)
config/tsconfig.cli.jsonsrc/main/agent-config-mutation-queue.test.tssrc/main/agent-config-mutation-queue.tssrc/main/agent-trust-presets.test.tssrc/main/agent-trust-presets.tssrc/main/codex/codex-trust-config-mutation-queue.tssrc/main/ipc/agent-trust.tssrc/main/remote-agent-trust-presets.test.tssrc/main/remote-agent-trust-presets.tssrc/main/runtime/runtime-worktree-agent-startup.test.tssrc/main/runtime/runtime-worktree-agent-startup.tssrc/preload/api/agent-status-api.tssrc/preload/api/agent-trust-bridge.tssrc/renderer/src/lib/worktree-creation-flow.test.tssrc/shared/agent-trust-preset.tssrc/shared/tui-agent-config.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
There was a problem hiding this comment.
Important
The SSH arm of the Claude trust preset hardcodes ~/.claude.json and does not mirror the local resolver's colocated ~/.claude/.claude.json fallback, so on remote hosts where Claude reads the colocated config the trust write is a silent no-op.
Reviewed changes
This PR pre-accepts Claude Code's first-launch "do you trust this folder?" dialog by writing projects["<realpath>"].hasTrustDialogAccepted into the config the launched agent reads, and consolidates the trust-preset plumbing.
- Shared
AgentTrustPresetunion —'cursor' | 'copilot' | 'codex' | 'claude'moved tosrc/shared/agent-trust-preset.ts, now referenced by the main presets, the preload bridge, andTUI_AGENT_CONFIG.preflightTrust. markClaudeProjectTrusted/markRemoteClaudeProjectTrusted— local and remote arms set onlyhasTrustDialogAccepted, preserving unrelated keys and refusing to rewrite unparseable config.- Consolidated dispatch (
applyLocalAgentTrustPreset) — replaces the duplicated preset branching inregisterAgentTrustHandlersandmarkLocalWorktreeTrusted. - Generalized mutation queue —
runExclusivelyForCodexTrustConfigbecomesrunExclusivelyForAgentConfigFile, now shared by Claude's.claude.jsonwrites (Codex keeps its name via a re-export). - IPC handler awaits the Codex/Claude writes — the renderer awaits the handler then launches, so an unawaited write can no longer land after the agent reads trust.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
ℹ️ No new issues in this delta.
Reviewed changes
This delta adds a satisfies PreloadApi['agentTrust'] assertion (plus its type-only import) to agent-trust-bridge.ts, pinning the bridge's markTrusted shape to the declared AgentTrustApi contract — consistent with the satisfies PreloadApi[...] pattern used across the other preload bridges.
- Type-level pin on the trust bridge — no behavioral change;
ipcRenderer.invokealready satisfied thePromise<void>return type.
The two findings from the prior review are unchanged by this commit and remain open: the SSH arm's colocated ~/.claude/.claude.json fallback gap, and the hardcoded preset list in the exhaustiveness test. I did not approve because those threads are still unresolved.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Four findings from CodeRabbit and pullfrog, all real: - The remote arm could destroy a live config. `readRemoteTextFile` flattens a transport error, a permission denial, and a binary read all into `''`, which is indistinguishable from an absent file — so an unreadable `.claude.json` looked empty and got replaced, discarding the remote user's Claude credentials, history, and MCP servers. `readRemoteClaudeConfig` now probes existence with `stat` first and refuses to write over anything it cannot parse. - The remote arm had no serialization. The local write takes the per-file lane precisely because `.claude.json` carries counters every running Claude rewrites; the remote one did not, so two workspace creations on one host could write stale snapshots and drop each other's entry — leaving that launch still facing the dialog this preset exists to skip. It now takes the same lane, keyed by host so separate connections don't serialize against each other. - The remote arm hardcoded `~/.claude.json` and ignored the colocated `~/.claude/.claude.json` that `resolveConfigPath` honors. That fallback is a filesystem condition on the host, so on any SSH host whose Claude reads the colocated file the write was a silent no-op. Probed on the remote now. - The exhaustiveness test asserted a guarantee it did not provide: the preset list was hardcoded, so a fifth preset would have left it green with no dispatch arm, and `readdirSync(...).length > 0` passed on any file landing in home. The guard moves into production code as a `satisfies Record<AgentTrustPreset, …>` writer map — a new preset now fails to compile (TS2741). The test derives from the same union and asserts the specific artifact per preset. Worth recording: the first attempt at that guard was a bare `switch` on the strength of `typescript/switch-exhaustiveness-check`. Widening the union to prove it fired showed oxlint is not type-aware across modules and the rule said nothing, so the comment claiming compile-time safety would have been false. `satisfies Record` is verified to fail — the comment says so and names why the switch does not. Also closes a gap neither bot flagged inline but CodeRabbit's merge-risk note did: the local preset resolved the config through this process's `CLAUDE_CONFIG_DIR`, but agents run in a PTY whose profile-loading shell may export a different one — a GUI-launched Electron never sourced those rc files. Trust would land in a file the session never opens and the dialog would still fire, silently. It now resolves through `resolveLoginShellEnvironment`, the same primitive the structured session runtime uses for boot env, falling back to the process-env resolver on any failure. The runtime test harness mocked the three per-preset writers but not the consolidated dispatch, so `markLocalWorktreeTrusted` was calling `undefined` and the swallowing catch hid it. The mock delegates through the dispatch now, preserving the existing artifact and call-order assertions, and registers a Claude writer so a Claude launch is asserted at that layer too. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Pushed CodeRabbit's merge-risk note flagged that "some launch and account paths may still ... write to a different configuration than the launched session reads." That was real and I've fixed it. I checked the account paths too: Orca deliberately does not swap Docstring Coverage (40% vs 80%) — declining. Every exported function and non-obvious branch in this diff carries a JSDoc block explaining why. The shortfall is inline arrow functions in the writer map and per-preset test helpers, where this repo's Still blocked on CI. Local verification on |
There was a problem hiding this comment.
Important
The remote read-modify-write has a data-loss path when stat fails for a non-ENOENT reason.
Reviewed changes
This delta closes the two findings from the prior review and hardens the Claude trust write.
- Local config path now resolved from the login shell's environment —
resolveClaudeLaunchConfigPathconsultsresolveLoginShellEnvironmentforCLAUDE_CONFIG_DIR(the env the launched PTY actually inherits) and falls back toClaudeRuntimePathResolver, so the write lands in the file the launched agent reads. - Compile-time exhaustive local dispatch —
applyLocalAgentTrustPresetroutes throughLOCAL_TRUST_PRESET_WRITERS, declaredsatisfies Record<AgentTrustPreset, …>, so widening the union fails at compile time (a bareswitchwas probed and found not to catch it under oxlint). - Remote arm mirrors the colocated fallback and takes the mutation-queue lane —
resolveRemoteClaudeConfigPathprobes~/.claude/.claude.jsonon the host, and the read-modify-write serializes underrunExclusivelyForAgentConfigFilekeyed${connectionId}\0${configPath}. - Remote read separates "unreadable" from "absent" —
readRemoteClaudeConfigprobes existence before reading so a transport/permission/binary failure is not silently treated as an empty config.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
The existence probe added in 7ba5ace reintroduced the very defect it closed. `stat` rejects on absence *and* on transport resets and permission denials, and a bare `catch` mapped all of them to `exists = false`, which returns `{}` and writes a fresh config over a live remote `~/.claude.json` — discarding the remote user's Claude auth, history, and MCP servers. The function's own comment claimed to prevent exactly that. Both conflation sites now use `isENOENT`, the repo's helper for this, which also matches on message text because an error raised on an SSH host crosses the relay and is rebuilt with the transport's numeric code: - `readRemoteClaudeConfig` returns `{}` only on a confirmed ENOENT and `'unreadable'` otherwise, so the write aborts. - `resolveRemoteClaudeConfigPath` falls back to `~/.claude.json` only on a confirmed ENOENT. A non-ENOENT probe failure returns null and the caller bails, because guessing there could merge trust into a file the session never reads — a silent no-op that leaves the dialog firing. The test helper had the same bug in miniature: `statOnly` threw a bare `Error('missing')` to model absence, which under `isENOENT` is a transport failure, so the existing coverage would have exercised the wrong branch. It throws an ENOENT-coded error now, and two tests pin the new arms — a non-absence failure on the config path, and one on the colocated probe. Reported by pullfrog on stablyai#18084. Its check-run read `conclusion=success` with the summary "The Pullfrog run finished successfully", which means the run completed, not that it found nothing. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/remote-agent-trust-presets.ts (1)
174-174: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy liftProtect the remote Claude config from external writers.
runExclusivelyForAgentConfigFileserializes Orca calls only.markRemoteClaudeProjectTrustedreads the remote config at line 175 and writes the stale snapshot at line 195. A running remote Claude process may update the same file between these operations, so this write can discard its changes. Use a remote conditional update that detects file changes and retries or aborts.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: ad3cf1d1-3870-4528-abc7-80a78cdcde7f
📒 Files selected for processing (2)
src/main/remote-agent-trust-presets.test.tssrc/main/remote-agent-trust-presets.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
|
@coderabbitai on the outside-diff finding at You're right about the mechanism, and you're right that the lane doesn't cover it: Deferring rather than patching, for two reasons. It predates this PR and affects every preset, not just the new arm. I checked all of them:
Fixing only the Claude remote arm would leave four writers exposed and introduce a concurrency mechanism that one of five call sites uses — worse for a reader than the uniform gap. Every remedy is a contract change. I considered shipping the cheap one — re-read immediately before writing and abort on change — and decided against doing it unilaterally: it narrows the window without closing it, and it should be decided for all five writers at once rather than smuggled in on a Claude PR. A properly preconditioned write needs #18092 has the affected-writer table, why the existing guards don't cover it, the impact ranked by file ( Happy to be overruled: if a maintainer would rather have the compare-and-retry applied to all five writers as part of this PR, say so and I'll do it here. |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This delta closes the one open finding from the prior review: the remote Claude trust write now distinguishes a missing config from an unreadable one, so a transient transport or permission failure aborts the write instead of overwriting a live remote ~/.claude.json.
isENOENT-gated config probe —readRemoteClaudeConfigreturns{}only on a confirmed ENOENT and'unreadable'otherwise, andresolveRemoteClaudeConfigPathnow returnsnull(bailing in the caller) when the colocated probe fails for a non-absence reason rather than guessing the home path.- Test helpers model absence faithfully —
makeFsProvider/statOnlynow throw an ENOENT-coded error (matching how the SSH relay rebuilds remote errors), and two new tests pin the non-absence abort arms for both the config path and the colocated probe.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Tip For best results, initiate chat on the files or code changes.
The lost-update risk remains valid, but it affects the listed trust-config writers consistently. A Claude-only mitigation would create inconsistent concurrency behavior. A shared solution should define the required ✏️ Learnings added
You are interacting with an AI system. |
…rimitive The Codex trust path already had the distinction the last commit hand-rolled. `codex-path-observation.ts` returns present/absent/indeterminate, backed by `shared/definitive-filesystem-absence.ts`, whose docstring names this exact caller: "Callers that act on absence -- deleting a mirror, overwriting a config, clearing a credential -- must be able to tell the two apart, and they must all agree on where the line is, so this lives in one place rather than being re-derived per lane." 462c56d re-derived it per lane with `isENOENT`. The local arm now reads through `observe()`, which also collapses the `existsSync` + `readFileSync` pair into one call and closes the TOCTOU window between them. Scope note, stated plainly because the previous commit message would imply more: this is a robustness and reuse change, not a fix for a demonstrated destructive path. `existsSync` uses access(F_OK), so it answers true for a file it cannot read, and the old try/catch already aborted there. Producing data loss locally needs `stat` to fail non-ENOENT while the following write succeeds, and on a local filesystem the same permissions govern both -- no portable repro. It is still the right shape: `observe` also treats EIO and unrecognised errnos as indeterminate, which is reachable on a network home directory, and ENOTDIR as absence, which `isENOENT` misses. The remote arm deliberately keeps `isENOENT` rather than switching to `isDefinitiveAbsence`. An error raised on an SSH host crosses the relay and is rebuilt with the transport's numeric code, so a code-only predicate would read a genuine remote ENOENT as indeterminate and the preset would silently never write on SSH -- failing safe but useless. Comment added at both sites so the asymmetry is not read as drift. A regression test was written for the local path and then removed: it passed with the fix reverted, so it pinned nothing. Better no test than one that reports coverage it does not have. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/agent-trust-presets.ts (1)
151-151: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winDo not trim the configured directory path.
Line 151 changes valid directory names that contain leading or trailing whitespace. Claude still uses the original
CLAUDE_CONFIG_DIRvalue, so Orca writeshasTrustDialogAcceptedto a different file and the trust dialog remains.Proposed fix
- const launchConfigDir = launchEnv.CLAUDE_CONFIG_DIR?.trim() - if (launchConfigDir) { + const launchConfigDir = launchEnv.CLAUDE_CONFIG_DIR + if (launchConfigDir?.trim()) { return join(launchConfigDir, '.claude.json') }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: cb6883ac-bd2c-49fc-9b19-6e4b8c319679
📒 Files selected for processing (2)
src/main/agent-trust-presets.tssrc/main/remote-agent-trust-presets.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/remote-agent-trust-presets.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
A directory name may legally carry leading or trailing spaces, and Claude reads the raw env value, so trimming the value sent the trust write to a file the session never opens — the dialog fires anyway, with no error. Trim only the emptiness test, so a whitespace-only setting still falls through to the resolver while a padded real path is used as given. Reported by CodeRabbit on stablyai#18084 as an outside-diff comment, so it existed only in the review body — the inline listing was empty. Note `ClaudeRuntimePathResolver.getRuntimePaths` trims the value it uses (`runtime-paths.ts:15`), so the two disagree on a padded directory. This commit does not change that: the resolver is on the pre-existing local-launch path and several other callers depend on it. Left as a separate question. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
@coderabbitai on the outside-diff finding at Agreed, and it's worth more than its Minor label: a directory name may legally carry leading or trailing spaces, Claude reads the raw env value, and the failure mode is silent — the write succeeds against a path nothing reads, the dialog fires anyway, and nothing errors. Trimming only the emptiness test keeps a whitespace-only setting falling through to the resolver while a padded real path is used as given. The test uses a Two notes.
Also: this is the second finding of yours that could only be reached through the review body, because the platform would not post it inline. Anyone triaging this PR by listing While I'm correcting the record: I told you earlier that "every remedy is a contract change" for #18092. That was wrong. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '== Candidate files =='
fd -a '^(agent-trust-presets|runtime-paths)\.(ts|test\.ts)$' src || true
fd -a -i 'filesystem.*\.(ts|tsx)$' src || true
echo '== Outlines =='
ast-grep outline src/main/agent-trust-presets.ts --items all --match 'Claude|resolveClaude|markClaude' || true
ast-grep outline src/main/runtime-paths.ts --items all --match 'ClaudeRuntimePathResolver|getRuntimePaths' || true
echo '== CLAUDE_CONFIG_DIR handling =='
rg -n -C 8 'CLAUDE_CONFIG_DIR|resolveClaudeLaunchConfigPath|markClaudeProjectTrusted' \
src/main/agent-trust-presets.ts src/main/runtime-paths.ts
echo '== FileStat declarations and usages =='
rg -n -C 5 '\b(interface|type)\s+FileStat\b|\b(size|mtime|mtimeMs|ino)\b' srcLength of output: 18425 🏁 Script executed: #!/bin/bash
set -u
echo '== Targeted test coverage =='
rg -n -C 10 'trailing space|trailing.*space|CLAUDE_CONFIG_DIR|resolveLoginShellEnvironment' \
src/main/agent-trust-presets.test.ts || true
echo '== Existing runtime resolver =='
ast-grep outline src/main/claude-accounts/runtime-paths.ts --items all --match 'ClaudeRuntimePathResolver|getRuntimePaths' || true
rg -n -C 10 'CLAUDE_CONFIG_DIR|getRuntimePaths|configPath' \
src/main/claude-accounts/runtime-paths.ts || true
echo '== FileStat contract =='
rg -n -C 8 '\b(interface|type)\s+FileStat\b|\bFileStat\b' \
src/main/providers src/shared || true
echo '== FileStat metadata in provider implementations =='
rg -n -C 5 '\b(size|mtime|mtimeMs|ino)\b' \
src/main/providers/ssh-filesystem-provider.ts \
src/main/providers/filesystem-provider-contract.ts \
src/main/local-worktree-filesystem.ts 2>/dev/null || trueLength of output: 24763
Your correction for Thanks for the platform visibility detail. 🐇 ✓ ✏️ Learnings added
🧠 Learnings usedIf you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! You are interacting with an AI system. |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This delta brings the local Claude trust write in line with the already-reviewed remote arm by reading the config through the repo's observe() absence primitive, and adds a clarifying comment to the remote arm.
- Local config read uses
observe()— theexistsSync+readFileSyncpair is replaced so an unreadable config (EACCES/EPERM/EIO) now aborts the write instead of being misread as "no config yet", closing the same data-loss class fixed on the SSH arm in the prior delta. - Remote arm comment — documents why
isENOENT(message-aware) rather thanisDefinitiveAbsence(code-only) is used, since a remote error is rebuilt with the transport's numeric code and a code-only predicate would read a genuine ENOENT as indeterminate.
One informational note, not blocking: the local arm's new indeterminate early-return has no dedicated test, whereas the remote arm's equivalent (readRemoteClaudeConfig → 'unreadable') got two. That's understandable — the local path hits real readFileSync, so simulating EACCES reliably in CI is awkward — but a future refactor could silently re-open the overwrite bug without a test pinning the branch.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This delta fixes resolveClaudeLaunchConfigPath to use CLAUDE_CONFIG_DIR verbatim.
- Trim only for the emptiness check — the raw
CLAUDE_CONFIG_DIRvalue is now joined as-is, so a directory name with legitimate leading/trailing spaces no longer routes the trust write to a different path than the session opens. The.trim()call now gates only the "is it empty" test, and a new test pins the padded-directory case.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
pullfrog noted, non-blocking, that the local arm's `indeterminate` early-return had no test while the remote equivalent had two, so a refactor could silently re-open the overwrite bug. That gap is real and self-inflicted: an earlier version of this test was deleted for claiming to prove the fix when it passed against the pre-`observe()` code too. It is back with the accurate claim. It does not discriminate `observe()` from the previous try/catch — both abort — it pins the branch: deleting the `indeterminate` return makes the run seed an empty config and overwrite the file, and the test fails. Verified by making exactly that mutation. Gated to POSIX non-root, because chmod 000 leaves a file readable for root and on Windows Node's chmod only toggles the read-only flag, so the unreadable state cannot be constructed there. A test that fails on a Docker CI runner is worse than none. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
@pullfrog your non-blocking note on the untested local The gap was self-inflicted and worth naming. An earlier version of that test existed and I deleted it, because it passed with the fix reverted and so pinned nothing. You're right that deleting it left the branch unguarded, which is a different problem from the one I was avoiding. It's back with an accurate claim rather than the one I originally made for it. It does not discriminate On your point that simulating For completeness on the earlier coverage question: this head is the first that both you and CodeRabbit have reviewed clean without me pushing over an in-flight run. I did that twice — killing your |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This delta adds the missing test for the local arm's indeterminate early-return, closing the non-blocking note from the prior review.
- Test pins the unreadable-config branch —
leaves a present-but-unreadable config untouchedchmods a live~/.claude.jsonto000, asserts the trust write leaves it byte-identical, and is gated to POSIX non-root where the unreadable state is actually constructible. TheWhycomment is accurate: the test does not discriminateobserve()from the oldtry/catch, but it pins the branch, and I confirmed the code path (EACCES →indeterminate→ early return; without it, a seed-empty write would overwrite the file and fail the assertion).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This delta adds one test to src/main/agent-trust-presets.test.ts.
- Pinned the local unreadable-config branch —
leaves a present-but-unreadable config untouchedchmods the config to000, callsmarkClaudeProjectTrusted, then asserts the file bytes are unchanged, closing the coverage gap noted in the prior review (the localobserve()-basedindeterminateearly-return had no dedicated test). The test is skipped on Windows (wherechmodonly toggles read-only) and as root (wherechmod 000still reads), and the comment honestly scopes what it pins: the branch against a seed-empty-on-failed-read regression, not theobserve()vstry/catchdistinction.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Conflict in runtime-worktree-agent-startup.test.ts: main added host-resolution and draft-detection suites (stablyai#18294) while this branch rewrote the markLocalWorktreeTrusted describe onto the consolidated dispatch. Took main's file whole and re-applied only the dispatch change — the module mock now provides applyLocalAgentTrustPreset delegating to the per-preset mocks, so main's await and rejection tests keep asserting through markCodexProjectTrusted unchanged, plus the claude and no-preset cases from this branch.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This delta is a merge of origin/main into the branch; no production logic changed since the prior review, and both earlier findings remain resolved.
runtime-worktree-agent-startup.test.tsmock rework — the trust-preset mock now delegatesapplyLocalAgentTrustPresetto the per-preset writers (markClaudeProjectTrusted,markCodexProjectTrusted, etc.), so theclaudeand no-preset cases assert the concrete writer invoked rather than the consolidated dispatch. The addedagent-detectionmock models the module the startup file imports.agent-status-api.tstype reconciliation — a main-sideAgentStatusIpcPayload→AgentStatusCacheIdentityrename merging in; the PR'sAgentTrustPresettyping onAgentTrustApi.markTrustedis unchanged.
I ran the reworked test file directly: 10 tests pass.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
`spawnLocalStartupAndSetupTerminals` in ipc/worktree-remote.ts had its own per-preset chain with cursor/copilot/codex arms and no default, so a preset added later — `claude` — resolved from TUI_AGENT_CONFIG, matched nothing, and silently wrote no trust artifact on that launch path. The `satisfies Record<AgentTrustPreset, …>` guard added earlier cannot catch this: it proves the map is complete, not that no hand-rolled chain exists elsewhere. Found while reading stablyai#15291, which adds a `qoder` arm to this same chain. Also awaits the write. The old chain called `markCodexProjectTrusted` without awaiting inside a sync `if`, so `runtime.createTerminal` immediately below could boot the agent before trust landed — the same race fixed in the IPC handler earlier in this branch. Exhaustively checked for other chains: the six renderer call sites all go through the IPC bridge, `runtime-worktree-agent-startup` has the two already consolidated, and the direct `markCodexProjectTrusted` calls in codex-launch-preparation.ts and codex-session-resume-launch.ts are Codex-specific launch paths that never read `preflightTrust`. This was the last one. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This delta routes the third (and last) hand-rolled trust-preset dispatch — the one in spawnLocalStartupAndSetupTerminals — through the shared applyLocalAgentTrustPreset, closing the silent no-op for Claude on the worktree-create startup path.
- Worktree-create startup trusts via the shared dispatch —
spawnLocalStartupAndSetupTerminalsnow callsapplyLocalAgentTrustPreset(preset, worktree.path)instead of its own cursor/copilot/codexifchain, so theclaudepreset (and any future preset) writes its trust artifact on this launch path rather than silently writing nothing. - Write awaited before the agent boots — the Codex and Claude writes are now awaited before
runtime.createTerminal, closing the race the earlier IPC-handler fix addressed but this local path still had.
I confirmed spawnLocalStartupAndSetupTerminals is reached only from createLocalWorktree (the native, non-SSH path), so the local applyLocalAgentTrustPreset dispatch is correct here — the per-preset local writers it replaces were already local-only.
ℹ️ Nitpicks
applyLocalAgentTrustPreset'ssatisfies Record<AgentTrustPreset, …>guard proves the dispatch map is complete, but it cannot catch a future hand-rolled preset chain like the one this commit replaced (this is the third one found). Nothing to change here — flagging only that the guard does not eliminate this failure class.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

ELI5
Starting Claude in a folder it has never seen makes Claude ask "do you trust the files in this folder?" first. Orca already answers that question ahead of time for Cursor, Copilot, and Codex, but nobody had done it for Claude — so Claude just sat there. This teaches Orca to answer it for Claude too.
What Changed
preflightTrust: 'claude'on theclaudeagent, plus the preset that backs it:markClaudeProjectTrustedwritesprojects["<realpath>"].hasTrustDialogAcceptedinto the config the runtime resolver picks —CLAUDE_CONFIG_DIR, else a colocated~/.claude/.claude.json, else~/.claude.json— so trust lands in the file the launched agent actually reads.markRemoteClaudeProjectTrustedmirrors it against the remote user's home for SSH launches.hasTrustDialogAcceptedis set. The siblinghasClaudeMdExternalIncludesApprovedis a separate consent about executing external CLAUDE.md includes, and granting it here would approve something the user never saw.Three things fell out of wiring it up:
registerAgentTrustHandlers, once inmarkLocalWorktreeTrusted— and a new preset lighting up inTUI_AGENT_CONFIGwould have silently done nothing on the second. Consolidated intoapplyLocalAgentTrustPreset, with a test that pins an arm for every preset in the union.agent-config-mutation-queue.tsso Claude's read-modify-write shares the lane; Codex call sites keep their name through a one-line re-export. This matters more for Claude than for Codex:~/.claude.jsoncarries live per-session counters that every running Claude rewrites, so two concurrent worktree creations must not clobber each other's entry.AgentTrustPresetmoves tosrc/shared/agent-trust-preset.ts. The union had three copies — the main presets, the preload bridge, andTUI_AGENT_CONFIG.preflightTrust— and widening one broke the preload typecheck.Why
Orca's launch flow injects the prompt or draft via bracketed paste once the TUI is foreground. Claude's trust dialog is already up at that point, so the paste becomes menu input. Same failure as #15859 (Devin) and #11765 (Cursor).
It gets worse when the tab opens in the Chat UI. #16729 removed the terminal↔chat toggle and unmounted its ⌘⇧J fallback, and Claude's folder-trust dialog produces no
interactivePrompt—deriveInteractivePromptemits one only forAskUserQuestionor aPermissionRequestcarrying a tool name — so the chat view renders no card and no transcript, with no way back to the terminal to answer. The agent is unreachable. That is #18080; this PR fixes the trust half of it, and the missing toggle is left to that issue.Why the artifact and not a flag. #15860 skips Devin's prompt with
--respect-workspace-trust=false. Claude has no interactive equivalent:claude --helpdocuments the workspace trust dialog as skipped only in non-interactive mode (-p, or non-TTY stdout), and--permission-mode/--dangerously-skip-permissionsgovern tool approvals, not workspace trust. The artifact route is what Cursor, Copilot, and Codex already use.Distinct from #13086. That reports the background
/usagePTY keystroking through the trust dialog in a session the user never initiated. This writes an artifact for a workspace the user explicitly created, before the agent starts — the existingpreflightTrustcontract.openclaudeis deliberately excluded. It is a distinct CLI and I have not verified it reads~/.claude.json. Worth a follow-up.Linked Issue
Fixes #18080
Related: #15859 / #15860 (Devin, same class), #11765 (Cursor), #10666 (Codex trust vs
--inject)Visual Proof
N/A — no UI surface changes. The observable difference is the absence of a TUI dialog at agent startup, which happens inside the agent's own terminal output.
Testing
Ran:
New coverage in
src/main/agent-trust-presets.test.ts:hasTrustDialogAcceptedfor the realpath~/.claude/.claude.jsonwhen that is what Claude readsCLAUDE_CONFIG_DIRover the home fallbackapplyLocalAgentTrustPresethas an arm for every preset in the unionsrc/main/remote-agent-trust-presets.test.tscovers the SSH write, config preservation, the unparseable-config refusal, and the already-trusted skip.runtime-worktree-agent-startup.test.tsis retargeted onto the consolidated dispatch and adds theclaudeand no-preset cases.Platforms actually exercised: macOS (local). Linux/Windows/SSH are covered by unit tests only — the local write goes through
writeFileAtomicallyandnode:path, and the remote write goes through the SSH filesystem provider with a path the provider itself resolved, so neither hardcodes a separator or a host.I did not launch the app to watch the dialog get skipped. Verification is typecheck, lint, and tests.
pnpm buildpasses (exit 0 — full desktop build plus native macOS targets).Note:
pnpmon this machine ships a broken native-binary placeholder, so every script above was invoked throughnode .../pnpm/bin/pnpm.mjsor./node_modules/.bin/*directly rather than thepnpmshim.AI Disclosure
Written with Claude Code (Claude Opus 5).
Review
Agent code review (Claude Opus 5), against the dimensions
CONTRIBUTING.mdnames.Cross-platform. No new path assumptions:
dirname/jointhroughout, and the remote arm uses the path its filesystem provider resolved. One knowingly uneven spot — theleaves a present-but-unreadable config untouchedtest isskipIf-gated to POSIX non-root, becausechmod 000leaves a file readable for root and on Windows Node'schmodonly toggles the read-only flag, so the unreadable state cannot be constructed there. The production code is platform-neutral; the test for that branch does not run on Windows CI or in root containers.SSH / remote / local. Both arms exist and diverge deliberately. The remote arm never consults this process's
CLAUDE_CONFIG_DIR(it belongs to the desktop, not the host), probes the host for the colocated~/.claude/.claude.jsonthatresolveConfigPathhonors, and usesisENOENTrather thanisDefinitiveAbsencebecause an error raised on an SSH host crosses the relay rebuilt with the transport's numeric code — a code-only predicate would read a genuine remote ENOENT as indeterminate and the preset would never write over SSH at all. Both arms refuse to overwrite a config they could not read.Supported agents and integrations. The preset is additive and keyed off
TUI_AGENT_CONFIG.preflightTrust, so no other agent's launch path changes.applyLocalAgentTrustPresetdispatches through a map declaredsatisfies Record<AgentTrustPreset, …>, so a future agent gaining a preset fails to compile rather than silently writing nothing — which is how Claude went unsupported.openclaudeis deliberately excluded: it is a distinct CLI and I did not verify it reads~/.claude.json. No git-provider or integration surface is touched.Performance. One read-modify-write per workspace creation for a supported agent, serialized per config path, skipped entirely when trust is already accepted. The local arm resolves the launch shell environment through
resolveLoginShellEnvironment, which is cached and already warmed by agent detection; on a cold cache it costs one shell spawn on the launch path, and any failure falls back to the process-env resolver.UI quality. Not applicable — no renderer surface. The observable difference is the absence of a TUI dialog inside the agent's own terminal output.
Security. The write grants folder trust for a workspace the user explicitly created, before the agent starts. It does not touch tool-permission or sandbox policy, and it deliberately does not set the sibling
hasClaudeMdExternalIncludesApproved, which is a separate consent about executing external CLAUDE.md includes. A config that fails to parse, reads as binary, or cannot be read is left untouched rather than replaced — that file holds the user's Claude auth and history. Distinct from #13086: this writes an artifact, it does not keystroke through a dialog in a session nobody asked for.Known and accepted: the read-modify-write is not transactional against the agent's own process, so a write landing between this read and this write is lost. That predates this PR and affects all five trust writers; it is tracked in #18092 rather than patched here, because a single-writer fix would be an inconsistent concurrency mechanism. Reviewers who would rather see it fixed in this PR should say so — the compare-and-abort variant applies to all five writers in about 25 lines.
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
hasClaudeMdExternalIncludesApproved. A config that fails to parse is left untouched rather than overwritten, because that file holds the user's Claude auth and history.dirname/jointhroughout, and the remote arm uses the path the SSH provider resolved.CLAUDE_CONFIG_DIRis deliberately not consulted for remote hosts, since it belongs to the desktop process.markTrustedparam widens from three preset values to four, which is additive; an older preload paired with a newer main simply never sends'claude'.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)