Skip to content

fix(claude): stop Orca making a WSL user's ~/.claude.json world-readable - #23973

Merged
brennanb2025 merged 2 commits into
mainfrom
brennanb2025/fix-wsl-claude-trust-mode
Sep 30, 2026
Merged

brennanb2025 merged 2 commits into
mainfrom
brennanb2025/fix-wsl-claude-trust-mode

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​136 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​136
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​81 $\color{#cf222e}{\Huge{\mathbf{−}}}$​36 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​45

ELI5

When Orca starts Claude in a WSL project, it adds one entry to the WSL user's ~/.claude.json so Claude does not stop to ask "Do you trust this folder?". Since #23744, that write also made the file readable by every user on the Linux system (0600 became 0644). The file holds the user's Claude account details. After this change the file keeps exactly the permissions it had.

What Changed

Problem. A WSL user's ~/.claude.json becomes world-readable after Orca starts Claude there. Post-merge QA of #23744 on a Windows machine with an Ubuntu 24.04 WSL distro saw the guest file go from 0600 to 0644 after one Orca-started Claude launch.

Who is affected. Windows users with WSL projects and the "Trust the folder when Orca starts an agent" setting on (the default). This started with #23744, which is not in any release yet. macOS, Linux, SSH hosts, and ordinary Windows (NTFS) files are not affected.

Why it happened. Orca writes the guest file from Windows through \\wsl.localhost\<distro>\...: it writes a temporary file beside it, then renames that over the original. Windows cannot read or set Linux permission bits through that share. Node reports a made-up 0o666 for any writable file there, the writer skipped chmod on Windows, and the guest gives every file created through the share its default 0644. The rename then replaced the 0600 original with that 0644 file.

The fix. Before taking Claude's lock, the writer now creates the empty temporary file first. When the config lives in a WSL guest, it then runs one chmod --reference=<original> -- <temporary file> inside the distro, through Orca's existing runWslProcess (wsl.exe --exec, no shell, never the wsl.exe -- form). After that, as before, it reads, merges and renames synchronously under Claude's lock. It writes into the prepared file without recreating it, so the replacement arrives with the original's exact mode. Native files go through the same create-then-fill order with the same mode handling as before, with one narrow difference: a native config its owner cannot write (0400/0444, or the Windows read-only attribute) is now skipped and Claude asks, where main replaced it.

What stays the same. Claude's lock is still taken and never broken. The file is never created. On macOS, Linux and native Windows, symlinks are kept, because the write goes to the link's target. A symlinked ~/.claude.json inside a WSL guest cannot be read from Windows at all, so Orca skips it and Claude asks, the same as on main. A failure never blocks the launch: if the guest cannot copy the mode, Orca writes nothing, logs [agent-trust] claude trust for <folder> failed; the agent will ask, and Claude shows its trust prompt as it did before #23744. (If the write takes longer than the 1.5 s the launch waits for it, Orca logs only its existing did not settle within 1500ms warning; the outcome is the same.)

Other writers. Claude's is the only trust writer #23744 sends into a WSL guest; Codex, Cursor and the rest skip WSL launches. Orca's Claude login writer only writes the Windows host's own file. Nothing else in Orca writes a guest ~/.claude.json.

Why

Alternatives considered and rejected:

  • Do the whole write inside the guest. That needs a JSON editor in the distro (node, python and jq are not guaranteed), or a shell reimplementation of Claude's lock and the merge. Far more moving parts for the same result.
  • stat the mode before, chmod after the rename. The file is world-readable between the rename and the chmod, and stays that way if the chmod fails, which is this bug again on the failure path.
  • Rewrite the file in place. It keeps the mode, but loses the atomic replace on a file that holds the user's Claude account: a crash mid-write truncates it, and Claude can read a half-written file.

The chosen order fails closed: the mode is set before the file is replaced, and any failure means no write.

Cost: one short wsl.exe --exec chmod per trust write that is actually due, which is the first Orca-started Claude in a new WSL worktree. It runs before Claude's lock is taken, so the lock is still held only for the synchronous read, merge and rename. Measured on the Windows test machine with the distro running: a granted write takes 84 ms on this branch vs 22 ms on main (median of 5), well inside the 1.5 s the launch waits for a trust write. An already-trusted folder starts no wsl.exe. When Claude's lock is held, the chmod still runs (about 60 ms) and nothing is written. chmod --reference is GNU coreutils. On a BusyBox distro such as Alpine it fails, so Orca writes nothing and Claude asks, the same as before #23744.

Linked Issue

None. Found in post-merge QA of #23744 (Windows with WSL Ubuntu 24.04).

Visual Proof

Nothing on screen changes; the fix is a file's permission bits. Live measurement from a pane of this branch's dev build on the Windows test machine (WSL Ubuntu-24.04), scratch config, main's writer vs this branch's writer: main turns the 0600 file into 0644, this branch keeps 0600; an ordinary NTFS config is unchanged on both.

Row 1: main 600 -> 644, this branch 600 -> 600; row 7: NTFS config unchanged on both

End-to-end on Windows + WSL

Owner-approved run on the Windows test machine (WSL Ubuntu-24.04), against the guest user's real ~/.claude.json. The earlier QA of #23744 had left that file at 0644, so it was set back to 0600 first. Orca was built from this PR's head 31811020f3f in a fresh worktree and run in the background with its own profile (trust setting on, no managed Claude account). A throwaway WSL repo got an Orca worktree, and Claude 2.1.285 was started from Orca's new-tab launch.

  • No trust prompt. Claude opened straight to its composer and answered PONG to an inert message.
  • The file stayed 0600 (owner unchanged) and was replaced atomically (new inode). Claude's own later rewrites of the file kept 0600.
  • projects gained the new worktree's key with hasTrustDialogAccepted: true. Claude itself also added its usual entry for the repo's main checkout (hasTrustDialogAccepted: false; Orca only ever writes true, and the same entry appeared in the feat(agents): pre-trust the folder wherever Orca starts an agent #23744 QA). No key was removed: 30 top-level keys before and after, and every earlier projects key is still there.
  • Nothing left beside it: no .orca-trust-*.tmp file and no .claude.json.lock.
  • main, same rig, for comparison: with only claude-folder-trust-file.ts swapped to main's 9be71d0b6df and the rig rebuilt, a Claude start in a fresh worktree turned the same 0600 file into 0644. The file was set back to 0600 afterwards.
  • Other real config files: the guest's ~/.claude/settings.json and ~/.codex/hooks.json stayed byte-identical. The guest's ~/.codex/config.toml kept the same bytes but was rewritten at rig start by Orca's Codex hook-trust grant; every earlier rig on this machine did the same, and it is unrelated to this PR. On the Windows side only the user's ~/.claude.json changed (same size, new content). It was byte-identical right after the first rig start, and 12 other Windows Claude sessions were running on that machine, so the change is not attributed to this run.

Orca built from this PR, WSL worktree: Claude started with no trust prompt and answered PONG

Testing

  • New src/main/claude/claude-folder-trust-file-wsl-guest.test.ts models Windows Node over \\wsl.localhost: a made-up 0o666 mode, a chmod that cannot reach the guest bits, and new files created at the guest's default 0644. It runs grantClaudeFolderTrust on a 0600 guest file. On main it fails with expected 420 to be 384 (0644 instead of 0600); with this change it passes. A second case shows that a failed guest chmod leaves the file, its mode and its folder untouched.

  • Existing writer and trust tests pass: 11 files, 226 tests (claude-folder-trust-file, execution-host-workspace-trust, agent-workspace-trust*, spawn-options-agent-workspace-trust, the relay trust tests, and the structured-session create intent test).

  • pnpm tc:node, oxlint and check:code-quality:changed pass. The SSH relay bundle still builds (the relay shares this file).

  • Live on the Windows high spec machine with WSL Ubuntu-24.04, on scratch files only, never the real ~/.claude.json. This branch's writer and main's were bundled and run from Windows Node the way Orca calls them: resolveLocalClaudeTrustConfig with a WSL auth preparation, then grantClaudeWorkspaceTrust on a \\wsl.localhost path.

    • main: 600 -> 644, trust entry written.
    • this branch: 600 -> 600, trust entry written, no temporary file left behind.
    • an ordinary NTFS file, both builds: attributes, ACL and outcome unchanged and identical.
  • Review QA, same machine, bundles of 31811020f3f vs main 9be71d0b6df, scratch files only:

    • 0600, 0640 and 0644 guest files keep their exact mode on this branch (main: all become 0644); the replacement is a new inode (atomic rename); no temporary file left.
    • Claude's lock held: locked, file and mode unchanged, no temporary file. Already trusted: unchanged, byte-identical, no wsl.exe.
    • A real guest chmod failure: nothing written, no temporary file, and the launch helper logs [agent-trust] claude trust for <folder> failed; the agent will ask.
    • A symlinked guest config: unreadable on both builds (Windows cannot read guest symlinks), so nothing is written and Claude asks.
    • Only Ubuntu-24.04 is installed there, so the BusyBox path was not run live; it is covered by the failed-chmod test.
  • End-to-end through an Orca-started Claude on the real guest file: passed. See "End-to-end on Windows + WSL" above.

  • I manually tested these changes locally

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

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Security: closes a permission widening on a file holding account details. Cross-platform: the new path runs only for a \\wsl.localhost / \\wsl$ config; macOS, Linux and native Windows keep their existing mode handling. SSH: the relay shares the writer but never resolves a WSL guest path. No wire, persisted-data or UI change.

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)
  • 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)

… behind

The replacement file is now created before Claude's lock is taken, so the
locked path must remove it.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: ready for review, with one end-to-end check pending an owner decision

The problem: since #23744 (merged, not yet released), when Orca starts Claude in a WSL project and writes Claude's "trust this folder" entry into the WSL user's ~/.claude.json, the file goes from owner-only (0600) to world-readable (0644). The file holds the user's Claude account details.

What changes for the user: after this PR the file keeps exactly the permissions it had. If Orca cannot copy the permissions, it writes nothing and Claude shows its own trust prompt, as every released build does today.

Code review: two independent review passes. Both came back clean. The first added one test assertion (a skipped write leaves no temporary file behind; commit 31811020f3f). No production code changed during review. The PR body was corrected in four places: native owner-read-only configs are now skipped (Claude asks), symlinked configs inside a WSL guest are never written (unchanged from main), the log line when the write misses the 1.5 s launch wait, and the measured cost.

Live check (Windows test machine, WSL Ubuntu-24.04, scratch config files only): this branch's writer and main's were built and run from Windows Node the way Orca calls them.

  • main turns a 0600 guest file into 0644. This branch keeps 0600, 0640 and 0644 exactly, replaces the file atomically, and leaves no temporary file.
  • If Claude's lock is held, the folder is already trusted, or the guest chmod fails, nothing is written and nothing is left behind. An already-trusted folder starts no wsl.exe.
  • An ordinary Windows (NTFS) config behaves the same on both builds.
  • Cost: a granted write takes 84 ms on this branch vs 22 ms on main (median of 5, distro running), well inside the 1.5 s the launch waits for a trust write.

main 600 -> 644, this branch 600 -> 600; NTFS config unchanged on both

Other checks: tc:node passes. The trust-writer tests pass (9 files / 208 tests, plus 2 files / 18 tests). A pre-release checklist ran at the start and end of review: PASS both times, no blocking findings. CI is green at 31811020f3f. The earlier tests node 24 4/5 failures were an unrelated flaky test (structured-chat-coordinator-mail.test.ts, which also fails 2 of 6 local runs with main's version of this file) and then a crashed test worker. Both passed on rerun.

Pending: the same check through a real Orca-started Claude. For a WSL project without a managed Claude account, that launch writes the test machine's real guest ~/.claude.json, which needs the owner's approval first. The changed code is fully covered by the live scratch-file run above. The launch wiring that calls it is unchanged from #23744.

Accepted trade-offs (each fails safe: Claude asks): a WSL distro whose chmod has no --reference (BusyBox, e.g. Alpine); a native config its owner made read-only; a crash during the guest chmod can leave an empty temporary file beside ~/.claude.json.

@brennanb2025
brennanb2025 marked this pull request as ready for review September 30, 2026 08:12
@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 3/5

[Critical risk] Changes how config file permissions are set on WSL systems.

The PR should not merge until a concurrent permission tightening can no longer be reversed by the trust write.

Findings

  1. P1 Security Stale permissions can be restored ▶
  2. P2 Real WSL path remains untested ▶

Summary

The PR prepares Claude’s replacement config file before taking its lock and uses guest-side chmod --reference to preserve permissions for WSL configs.

  • It adds a mocked WSL permission regression test and a locked-write cleanup assertion.
  • Preparing the mode before the lock leaves a window in which a later permission tightening can be undone.
Diagram
sequenceDiagram
  participant Orca
  participant Claude
  Orca->>Orca: Prepare replacement with current mode
  Claude->>Claude: Tighten config mode
  Orca->>Orca: Acquire lock and re-read config
  Orca->>Orca: Rename replacement with stale mode
Loading

Reviews (1) · Last reviewed commit: "test(claude): assert a skipped trust wri..."

Comment on lines +224 to +226
// Why before the lock: a WSL guest's mode takes a guest process to copy, and Claude's
// lock should stay held only for the synchronous read → rename below.
const replacement = await createReplacementFile(probe.path)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 security Stale permissions can be restored If Claude or another process tightens the config from 0644 to 0600 while this operation waits for the lock, the replacement still has the earlier 0644 mode. The locked re-read checks the path but not the mode, so renaming the replacement makes the account config world-readable again. Copy or validate the mode as part of the protected write. How this was verified: The replacement gets its mode before lock acquisition, and the locked path check does not compare it with the current config’s mode.


beforeEach(() => {
guest.root = realpathSync(mkdtempSync(join(tmpdir(), 'orca-claude-trust-guest-')))
mkdirSync(join(guest.root, 'home/u'), { recursive: true })

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Real WSL path remains untested This regression suite skips Windows and mocks both the UNC filesystem and the WSL process. The Windows WSL E2E job does not check this trust write either, so a failure in the real guest permission-copy path could pass automated tests. Add an automated Windows/WSL grant check that verifies the guest file’s mode afterward.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@coderabbitai

coderabbitai Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: e988a631-218b-4252-aae2-2940a8088b94

📥 Commits

Reviewing files that changed from the base of the PR and between 2aad275 and 3181102.

📒 Files selected for processing (3)
  • src/main/claude/claude-folder-trust-file-wsl-guest.test.ts
  • src/main/claude/claude-folder-trust-file.test.ts
  • src/main/claude/claude-folder-trust-file.ts

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


📝 Walkthrough

Walkthrough

The trust-file rewrite now prepares a replacement file with the target’s permission bits before acquiring the lock. For WSL UNC targets, it copies permissions with guest chmod --reference. Under the lock, the workflow rereads the config and writes the replacement only when the trust entry changes. Tests cover guest mode preservation, command failure cleanup, and cleanup when the config is locked.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 31811

The change stops WSL guest ~/.claude.json files from becoming world-readable and falls back to a Claude trust prompt if the permission copy fails. The supplied evidence shows no remaining merge-blocking risk.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to 31811

The change prevents ordinary WSL trust updates from making private account files readable by other users. However, preparing permissions before taking the update lock can undo a concurrent permission restriction. This requires overlapping file changes and affects the user's Claude configuration rather than a shared service.

Retained concerns

  • Medium · security · inferred: Pre-lock permission capture can reverse concurrent hardening. On local POSIX paths, a pending grant can prepare a 0644 replacement, then wait while another cooperating writer restricts or replaces the same target with mode 0600. The grant subsequently rereads the latest JSON but commits the stale 0644 replacement, restoring group or other readability where directory access permits. The base sampled permissions after acquiring the lock. Path equality and JSON merging do not protect this metadata invariant; the scenario requires a concurrent owner-authorized change, not an established attacker ability to modify the protected file.
Security review details

Security Blast Radius

  • inferred — The identified race affects the resolved Claude config file for a pending trust grant, including account-related content retained in that file. Other local users could read it if stale permissions restore their access and parent directories permit traversal. They do not need write access to read the resulting file, but the race requires a separate owner-authorized permission change. The inspected path does not establish broader service or tenant exposure.

Security Findings and Attack Paths

  • inferred — The active concern is reversal of concurrent permission hardening, not a demonstrated arbitrary-file write or command-injection path. Locked JSON rereading preserves current content but cannot prevent stale permissions from replacing newly restricted metadata at the same pathname.

Trust Boundaries and Controls

  • observed — The production launch resolver derives the WSL config location from authentication preparation and refuses host-file fallback when required guest metadata is missing. Workspace paths supply trust keys. The permission helper derives both distro and guest filename from the resolved UNC target and uses separate chmod arguments, including an option separator, through the shell-free execution path.

Resilience and Maintainability Implications

  • observed — The existing launch deadline stops waiting without cancelling the trust write, so guest preparation may finish after launch proceeds. The eventual write still acquires the config lock and rereads content. Preparation errors prevent rename, while abrupt termination can bypass temporary-file cleanup; the inspected implementation provides no crash-recovery guarantee.

Hardening Proposals

  • proposed — Treat permission freshness as part of the commit invariant: validate the relevant target identity and permissions under the lock, and abort or reprepare if they changed. For WSL, use guest-authoritative metadata rather than synthetic Windows mode bits. A controlled interleaving with a same-path 0644-to-0600 change would validate that the restriction survives.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is detailed and covers the change, rationale, testing, security, and platform impact. However, it explicitly provides no linked issue despite the template requiring one, and the requir… Add a link to the actual issue addressed by this pull request, or attach the pre-existing issue referenced by the change. Confirm that pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass, or state that CI will cover them and update th…
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: preventing Orca from making a WSL user's Claude configuration world-readable.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is detailed and covers the change, rationale, testing, security, and platform impact. However, it explicitly provides no linked issue despite the template requiring one, and the required lint, typecheck, test, and build checklist item remains unchecked.

Resolution

Add a link to the actual issue addressed by this pull request, or attach the pre-existing issue referenced by the change. Confirm that pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass, or state that CI will cover them and update the checklist accordingly.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

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.

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

ℹ️ No critical issues — one minor suggestion inline, plus a nitpick.

Reviewed changes

  • WSL guest permission widening fixed. writeConfigAtomically is split into createReplacementFile (creates an empty temp at the target's mode before the lock) and replaceConfig (fills it with flag: 'r+', then atomic rename). For a \\wsl.localhost config the temp's mode is copied by a guest chmod --reference instead of relying on Windows' synthetic 0o666, so the guest's 0600 survives the replace.
  • Fail-closed failure path. A failed guest chmod throws before any content is written, the temp is removed, and the grant reports a failure so Claude asks — no half-replaced or widened file.
  • Coverage. The new claude-folder-trust-file-wsl-guest.test.ts models Windows Node over \\wsl.localhost (synthetic 0o666, unreachable chmod, new files at 0644) and genuinely fails on main (0644 vs 0600); the native test now asserts no temp file lingers after a lock-skipped write.

One behavior change worth pinning. A native config whose owner cannot write it (0400/0444, or the Windows read-only attribute) now fails the grant where main replaced it, because replaceConfig reopens the temp with r+ and the temp was created at that read-only mode. It fails closed and the PR body calls it out, but nothing tests it — see nitpick below.

ℹ️ Nitpicks

  • The read-only-config behavior change is a real, if narrow, difference from main and has no test; adding one would pin it if it was intentional and catch an accidental widening if it was not.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment on lines +224 to +226
// Why before the lock: a WSL guest's mode takes a guest process to copy, and Claude's
// lock should stay held only for the synchronous read → rename below.
const replacement = await createReplacementFile(probe.path)

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.

The replacement's mode is captured before the lock and never re-validated. createReplacementFile reads the target's mode (native statSync at line 173) or copies it via the guest chmod --reference (lines 163-168) here, before lock() is taken; under the lock only the resolved path is compared to replacement.target (line 249), not the mode or inode. A concurrent narrowing chmod on the target during that window (which spans the guest round trip plus lock retries) means the rename publishes the older, wider mode over a now-narrower file, so the JSDoc's "can never widen them" (line 152) does not hold. main read the mode under the lock inside writeConfigAtomically, so this is a small regression in the exposure ordering on a fix whose whole point is to stop widening.

Technical details
# Mode captured before the lock, not re-checked under it

## Affected sites
- src/main/claude/claude-folder-trust-file.ts:173 — native `statSync(target).mode` read before the lock
- src/main/claude/claude-folder-trust-file.ts:163-168 — guest `chmod --reference` copies the mode before the lock
- src/main/claude/claude-folder-trust-file.ts:226 — `createReplacementFile` call site, ahead of `lock()` at line 230
- src/main/claude/claude-folder-trust-file.ts:249 — under the lock, only `current.path` is compared, not mode/inode

## Required outcome
- The file renamed over the target must never carry a wider mode than the target has at rename time.

## Suggested approach
- Under the lock, re-stat the target's mode (and inode) and, if it changed since the replacement was prepared, abort (return `unreadable`) rather than publishing the stale mode. Aborting on the guest path avoids a second `wsl.exe` round trip inside the lock.

## Open questions for the human
- Is the narrow race worth the extra under-lock stat, or is the current pre-lock capture an accepted tradeoff given it fails closed on every other path?

@brennanb2025
brennanb2025 merged commit 95e8725 into main Sep 30, 2026
113 of 117 checks passed
Jinwoo-H added a commit that referenced this pull request Sep 30, 2026
…nner commit

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Jinwoo-H added a commit that referenced this pull request Oct 1, 2026
…STA-9051) (#24217)

* feat(terminal): warn when a typed Codex joins Codex's shared server

Orca adds --no-daemon to the Codex it launches and to a codex typed in
shells whose wrapper it controls, but a codex typed another way (fish,
cmd.exe, a path-named binary) still joins Codex's shared server, which
mixes up agent status across tabs.

When a local pane's Codex is on that server, show a banner at the top of
the pane with the command that turns auto-start off, a Copy button,
"Don't show again" (a new setting next to the Codex server setting) and
a per-pane dismiss. The banner takes layout space; the terminal refits
below it.

Main answers pty:isCodexOnSharedServer from the pane's outermost Codex
command line (flags and subcommands that keep Codex embedded rule it
out), the CODEX_HOME the pane launched with, and whether that home's
server is live: a socket connect on macOS/Linux, the server's pid record
plus creation time on Windows. The renderer asks only while the pane
already shows Codex, on a short bounded ladder.

Refs STA-9051

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* fix: restore the Claude WSL trust-file fix (#23973) dropped by the banner commit

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* feat(terminal): redesign the Codex shared-server banner and fix dialog

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* feat(terminal): let the Codex shared-server fix run its commands

The fix dialog now runs each step with the shared server's own Codex on the
pane's CODEX_HOME, verifies the result (feature read back, server probed),
and falls back to a copyable command on failure. Stopping asks first.

Also: an apostrophe in a prompt no longer hides an opt-out flag, restored
panes fall back to the saved pty id, and the IPC guards have a table test.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* feat(terminal): give each fix step its own card and label the command it runs

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* refactor(terminal): simplify the Codex shared-server banner after review

- Read a subcommand only from Codex's first positional, so prompt words
  like "a", "update" or "review" no longer hide the banner.
- Probe the server fresh on every ask; drop the probe cache.
- Make the pty preload methods required and stub them on the web client,
  replacing the optional-method and paired-client checks.
- Render the banner from the existing Codex pane portal loop.
- Treat a non-zero or timed-out Codex command as failed; skip the
  read-back when the disable write failed.
- Reserve the banner's space with a CSS :has() selector instead of a
  data attribute.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* fix(terminal): make the Codex shared-server fix persist on Orca's mirror home

- Step 1 now writes daemon_auto_start = false to the user's own Codex home
  when the pane runs on Orca's shared mirror home (as Windows panes do), then
  to the mirror home too; the mirror is rebuilt from the user's home on every
  launch, so a mirror-only write was lost.
- The server probe is three-state (live / absent / unknown); stop reports
  success only once the server is proven gone.
- The banner retires the one-time "runs Codex without its shared server"
  toast it contradicts.
- A command line with no Codex program never counts as joining the server.
- The fallback local PTY provider reports each pane's root pid.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* fix(codex): keep Turn off in Orca's Codex home when ~/.codex has no config

A pane on Orca's mirror home wrote the setting to ~/.codex first. With no
~/.codex the spawn failed on its cwd and Codex rejects a missing CODEX_HOME;
and creating a config holding only this setting would make the next mirror
replace every setting made in Orca's Codex. The mirror skips a missing or
blank ~/.codex/config.toml, so write only the mirror home then.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* feat(codex): promote [features].daemon_auto_start from Orca's Codex home

Promotion now carries one [features] key alongside the [tui] keys, so a
shared-server Turn off written in Orca's mirror home reaches
~/.codex/config.toml instead of being reverted by the next mirror. Table
keys share one <table>.<key> scan for read, removal and upsert. Orca's own
daemon socket override is never read as a user value, and a blank source
config is seeded from the runtime like a missing one.

* refactor(codex): run Turn off once, in the pane's own Codex home

Settings promotion now carries the setting to ~/.codex, so the separate
settings-home resolution and the two-home loop are gone.

* fix(terminal): offer Stop server only after sharing is turned off

Stopping while sharing is still on closes every sharing session, and the
next Codex starts a new shared server.

* fix(terminal): skip legacy mirror panes off Windows and quoted dotted keys

A retained shared-home pane on macOS/Linux points at a mirror that is no
longer promoted, so Turn off there would be reverted; name no home for it.
A quoted top-level key such as "tui.theme" is one key, not [tui].theme.

* fix(terminal): drop the Turn off note that promised the setting reaches Codex outside Orca

Orca's tabs are what this fix is for; carrying the setting to ~/.codex is best-effort.

* fix(terminal): keep the Turn off note that the setting also applies outside Orca

It holds for nearly everyone; the rare Windows upgrade gaps don't justify hiding it.

* fix(codex): promote Turn off to ~/.codex under an older Orca's baseline

A pane on Orca's Windows mirror home writes daemon_auto_start = false into
the mirror. A promotion baseline from an Orca that predates this key has no
entry for it, so the next mirror pass kept the write as a conflict and then
recorded it, and ~/.codex never got the setting.

Turn off on a mirror-home pane now runs the same mirror pass a terminal
launch runs before and after the write: the first records the key in the
baseline, the second promotes the write to ~/.codex. The passes are
synchronous, so they cannot interleave with a launch's pass. A failed pass is
logged and does not fail Turn off, since the write still fixes Orca's tabs.
Real-home panes are unchanged.

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
OmarHung pushed a commit to OmarHung/orca that referenced this pull request Oct 3, 2026
…ble (stablyai#23973)

* fix(claude): keep a WSL guest's ~/.claude.json mode when Orca writes folder trust

* test(claude): assert a skipped trust write leaves no replacement file behind

The replacement file is now created before Claude's lock is taken, so the
locked path must remove it.

(cherry picked from commit 95e8725)
OmarHung pushed a commit to OmarHung/orca that referenced this pull request Oct 3, 2026
…STA-9051) (stablyai#24217)

* feat(terminal): warn when a typed Codex joins Codex's shared server

Orca adds --no-daemon to the Codex it launches and to a codex typed in
shells whose wrapper it controls, but a codex typed another way (fish,
cmd.exe, a path-named binary) still joins Codex's shared server, which
mixes up agent status across tabs.

When a local pane's Codex is on that server, show a banner at the top of
the pane with the command that turns auto-start off, a Copy button,
"Don't show again" (a new setting next to the Codex server setting) and
a per-pane dismiss. The banner takes layout space; the terminal refits
below it.

Main answers pty:isCodexOnSharedServer from the pane's outermost Codex
command line (flags and subcommands that keep Codex embedded rule it
out), the CODEX_HOME the pane launched with, and whether that home's
server is live: a socket connect on macOS/Linux, the server's pid record
plus creation time on Windows. The renderer asks only while the pane
already shows Codex, on a short bounded ladder.

Refs STA-9051

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* fix: restore the Claude WSL trust-file fix (stablyai#23973) dropped by the banner commit

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* feat(terminal): redesign the Codex shared-server banner and fix dialog

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* feat(terminal): let the Codex shared-server fix run its commands

The fix dialog now runs each step with the shared server's own Codex on the
pane's CODEX_HOME, verifies the result (feature read back, server probed),
and falls back to a copyable command on failure. Stopping asks first.

Also: an apostrophe in a prompt no longer hides an opt-out flag, restored
panes fall back to the saved pty id, and the IPC guards have a table test.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* feat(terminal): give each fix step its own card and label the command it runs

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* refactor(terminal): simplify the Codex shared-server banner after review

- Read a subcommand only from Codex's first positional, so prompt words
  like "a", "update" or "review" no longer hide the banner.
- Probe the server fresh on every ask; drop the probe cache.
- Make the pty preload methods required and stub them on the web client,
  replacing the optional-method and paired-client checks.
- Render the banner from the existing Codex pane portal loop.
- Treat a non-zero or timed-out Codex command as failed; skip the
  read-back when the disable write failed.
- Reserve the banner's space with a CSS :has() selector instead of a
  data attribute.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* fix(terminal): make the Codex shared-server fix persist on Orca's mirror home

- Step 1 now writes daemon_auto_start = false to the user's own Codex home
  when the pane runs on Orca's shared mirror home (as Windows panes do), then
  to the mirror home too; the mirror is rebuilt from the user's home on every
  launch, so a mirror-only write was lost.
- The server probe is three-state (live / absent / unknown); stop reports
  success only once the server is proven gone.
- The banner retires the one-time "runs Codex without its shared server"
  toast it contradicts.
- A command line with no Codex program never counts as joining the server.
- The fallback local PTY provider reports each pane's root pid.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* fix(codex): keep Turn off in Orca's Codex home when ~/.codex has no config

A pane on Orca's mirror home wrote the setting to ~/.codex first. With no
~/.codex the spawn failed on its cwd and Codex rejects a missing CODEX_HOME;
and creating a config holding only this setting would make the next mirror
replace every setting made in Orca's Codex. The mirror skips a missing or
blank ~/.codex/config.toml, so write only the mirror home then.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* feat(codex): promote [features].daemon_auto_start from Orca's Codex home

Promotion now carries one [features] key alongside the [tui] keys, so a
shared-server Turn off written in Orca's mirror home reaches
~/.codex/config.toml instead of being reverted by the next mirror. Table
keys share one <table>.<key> scan for read, removal and upsert. Orca's own
daemon socket override is never read as a user value, and a blank source
config is seeded from the runtime like a missing one.

* refactor(codex): run Turn off once, in the pane's own Codex home

Settings promotion now carries the setting to ~/.codex, so the separate
settings-home resolution and the two-home loop are gone.

* fix(terminal): offer Stop server only after sharing is turned off

Stopping while sharing is still on closes every sharing session, and the
next Codex starts a new shared server.

* fix(terminal): skip legacy mirror panes off Windows and quoted dotted keys

A retained shared-home pane on macOS/Linux points at a mirror that is no
longer promoted, so Turn off there would be reverted; name no home for it.
A quoted top-level key such as "tui.theme" is one key, not [tui].theme.

* fix(terminal): drop the Turn off note that promised the setting reaches Codex outside Orca

Orca's tabs are what this fix is for; carrying the setting to ~/.codex is best-effort.

* fix(terminal): keep the Turn off note that the setting also applies outside Orca

It holds for nearly everyone; the rare Windows upgrade gaps don't justify hiding it.

* fix(codex): promote Turn off to ~/.codex under an older Orca's baseline

A pane on Orca's Windows mirror home writes daemon_auto_start = false into
the mirror. A promotion baseline from an Orca that predates this key has no
entry for it, so the next mirror pass kept the write as a conflict and then
recorded it, and ~/.codex never got the setting.

Turn off on a mirror-home pane now runs the same mirror pass a terminal
launch runs before and after the write: the first records the key in the
baseline, the second promotes the write to ~/.codex. The passes are
synchronous, so they cannot interleave with a launch's pass. A failed pass is
logged and does not fail Turn off, since the write still fixes Orca's tabs.
Real-home panes are unchanged.

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
(cherry picked from commit eefc49f)
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.

1 participant