Repository navigation
Make the Agent Permissions toggle apply to Codex chat - #20977
Conversation
4fdb2c3 to
7819605
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (8)
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughClaude structured launches now pass bypass permissions through Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to No concrete merge-blocking risk remains from the reviewed changes. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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.
ℹ️ No critical issues — one defer-able design note on where per-launch customization lives.
Reviewed changes — full read of the 30-file delta; both external provider contracts were independently verified and the route-planning surfaces were traced to confirm no per-launch-arg path was missed.
- Terminal-only customization signal renamed —
tui_launch_command/requiresTuiLaunchCommandbecametui_launch_customization/requiresTuiLaunchCustomizationthrough main, renderer, shared, and e2e; no consumer still reads the old string. - Per-launch args demote structured chat —
AgentLaunchRouteArgs.tuiCustomizationgainsagentArgs, wired fromlaunch-agent-in-new-tab.ts(raw override, not the resolved default) andlaunch-work-item-direct-route-preparation.ts; global settings args no longer demote. - Claude permission encoding — Yolo now rides
extraArgs: { 'dangerously-skip-permissions': null }rather than the SDK's typedpermissionMode/allowDangerouslySkipPermissionspair, preserving the user-installed-binary contract; Manual passes neither. - Codex permission encoding — new
codex-structured-permission-policy.tsemits{ approvalPolicy: 'never', sandbox: 'danger-full-access' }onthread/startandthread/resumeinstead of app-server argv; the posture is re-derived per acquisition. - Shell-aware bypass parsing —
resolvedTuiAgentArgsBypassPermissionstokenizes through the resolved local Windows startup shell, stops at a standalone--, and fails closed on unparseable input.
Verified beyond the diff: --dangerously-skip-permissions takes precedence over the SDK-always-emitted --permission-mode default in the Claude CLI resolver (first non-policy-disabled entry wins; stable 1.0.100→2.1.100), and approvalPolicy: "never" / sandbox: "danger-full-access" are the correct top-level thread/start/thread/resume params in the Codex v2 protocol.
ℹ️ Per-launch customization has two definitions; the shared intent's is unwired
This PR fixes per-launch-argument routing by extending the renderer-local AgentLaunchRouteArgs.tuiCustomization with agentArgs. The shared AgentLaunchIntent already declares and documents AgentLaunchCustomization (agentArgs/cwd) as the routing input for exactly this, yet nothing populates it and the host-side decision never reads it. No caller passes customization today, so there is no live bug — but the two representations will drift as surfaces migrate onto agent.launch, and the silent arg-drop this PR fixes can reappear through the host path.
Technical details
# Per-launch customization is defined twice, and the shared copy is dead
## Affected sites
- `src/shared/agent-launch-intent.ts:56-71` — `AgentLaunchCustomization` + `AgentLaunchIntent.customization`, documented as "a caller states that it is passing custom agent arguments, and the host concludes that a terminal is required."
- `src/main/runtime/rpc/methods/agent-launch.ts:57-68` — `agentLaunchIntent()` never populates `customization`; `AgentLaunch` (`agent-launch-schemas.ts`) has no such field.
- `src/main/agent-launch/agent-launch-mode.ts:79-85,153` — `AgentLaunchModePlacement` has no customization/args, and `decideAgentLaunchMode` passes only `hasExplicitTuiLaunchCommand(settings, agent)`.
- `src/main/agent-launch/agent-launch-executor.ts:102-109` — `executeAgentLaunch` calls `decideAgentLaunchMode` with `{ agent, terminal }` only.
- `src/renderer/src/lib/agent-launch-route-input.ts:55-56,132-135` — the renderer-local `tuiCustomization.agentArgs` this PR extended.
## Required outcome
One definition of "per-launch launch customization" that a host-side `agent.launch` decision can read, so a structured session is never chosen for a launch that supplied per-launch args. This PR is not required to do that migration; the note is that the shared field exists and is currently inert.
## Suggested approach (optional)
Either wire `customization` from `AgentLaunch` params through `agentLaunchIntent()` into `decideAgentLaunchMode` (mirroring `requiresTuiLaunchCustomization` in `resolveStructuredNativeChatSupport`), or drop the unused field so the renderer-local type is the single source until migration.
## Open questions for the human (optional)
Is `AgentLaunchIntent.customization` intended to become the canonical routing input as surfaces move onto `agent.launch`, or is the renderer-local `tuiCustomization` the long-term shape?DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — incremental delta since the prior pullfrog review (commit 4fdb2c3f7e → 7819605f71).
- Test-only type fix —
launch-work-item-direct-route-preparation.test.tschanges the partialAppStatemock cast fromas AppStatetoas unknown as AppState, keeping the existing line-scopedSAFETY:justification. No production code, behavior, or routing changes.
The full-PR findings from the prior review (one defer-able ℹ️ note on the shared AgentLaunchIntent.customization being unwired) are unaffected by this delta.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Final review status: cleanThree adversarial review rounds completed. The third round found no remaining in-scope correctness, architecture, regression, or performance issue. Issues fixed during review
Verification
Electron routing and permission evidence covers structured routing with extra arguments, Yolo without an approval card, Manual with an approval card, and command-override terminal fallback. Remaining validation gaps: no live older-Claude binary or Windows cmd/PowerShell run was available. Final Claude argv, Codex request payloads, and shell-tokenizer behavior are pinned by regression tests. |
There was a problem hiding this comment.
ℹ️ No critical issues — one behavior question on the new empty-override routing.
Reviewed changes — incremental delta since the prior pullfrog review (commit 7819605f71 → 3302736418).
- Codex Manual now states an explicit thread policy —
codexStructuredPermissionPolicyForSettingsreturns{ approvalPolicy: 'on-request', sandbox: 'workspace-write' }instead ofundefined, andopenCodexThreadspreads it into boththread/startandthread/resume. Verified againstopenai/codexv0.153.4: both are the exact kebab-case wire values, both params are accepted on each request, and a resume applies them (a requestsandboxoverride makes codex skip the persisted Yolo profile). - Empty and null per-launch overrides route to the terminal —
requiresTuiLaunchCustomizationswitched from truthiness to presence (!== undefined), soagentArgs: ''no longer falls through to structured chat. - Tokenizer blind spot documented and pinned — a
KNOWN LIMITnote ontuiAgentArgsBypassPermissionsplus a measured-against-Claude-2.1.270 vector table that pins the one remaining arity case the reader still gets wrong.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 45196825-c9bd-4249-af22-b9c777ca38e2
📥 Commits
Reviewing files that changed from the base of the PR and between 7819605 and 3302736418a078443561d85f86414ca9c079254f.
📒 Files selected for processing (11)
src/main/codex/codex-structured-launch-resolution.test.tssrc/main/codex/codex-structured-launch-resolution.tssrc/main/codex/codex-structured-permission-policy.test.tssrc/main/codex/codex-structured-permission-policy.tssrc/main/codex/codex-structured-thread-open.test.tssrc/main/runtime/structured-agent-session-runtime.tssrc/renderer/src/lib/agent-launch-route-input.test.tssrc/renderer/src/lib/agent-launch-route-input.tssrc/renderer/src/lib/launch-agent-structured-chat-guard.test.tssrc/shared/tui-agent-launch-defaults.test.tssrc/shared/tui-agent-launch-defaults.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/shared/tui-agent-launch-defaults.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.
| /** The same setting for Codex, as app-server argv; absent means its approval prompts stay on. */ | ||
| resolveCodexPermissionArgs?: () => string[] | ||
| /** The same setting for Codex, as app-server thread policy. */ | ||
| resolveCodexPermissionPolicy?: () => CodexStructuredPermissionPolicy |
There was a problem hiding this comment.
🔒 Security & Privacy | 🛡️ Analyzed with Security Review | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Map the changed runtime before inspecting its policy wiring.
ast-grep outline src/main/runtime/structured-agent-session-runtime.ts --items all
# Inspect runtime builders and the downstream resolver contract.
rg -n -C 6 --type ts \
'StructuredAgentSessionRuntimeDeps|resolveCodexPermissionPolicy|createCodexStructuredLaunchResolver|resolvePermissionPolicy|permissionPolicy' \
srcRepository: stablyai/orca
Length of output: 36329
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C 8 --type ts \
'ensureStructuredAgentSessionHost|StructuredAgentSessionRuntimeDeps|resolveCodexPermissionPolicy' \
src/main src/shared \
-g '!*.test.ts' -g '!*.spec.ts'Repository: stablyai/orca
Length of output: 35855
Security Misconfiguration
Reachability: Internal
Exploitability: Difficult
CWE: CWE-276 — Incorrect Default Permissions
Require the Codex permission-policy resolver. The current production caller supplies this resolver, but the optional contract permits future callers to omit it. The launch path then sends no policy and can inherit configuration or prior thread state. Require the resolver and fail installation when it is absent, matching resolveClaudeAuthPolicy.
…nsport's own contract Codex posture moves off app-server argv onto typed `thread/start` and `thread/resume` params. Manual states `on-request` / `workspace-write` explicitly instead of omitting the fields, which app-server resolved through the mirrored config.toml — a Manual thread on a home carrying `approval_policy = "never"` never prompted. Claude keeps its owned `--dangerously-skip-permissions` flag through SDK `extraArgs`; the SDK's typed bypass option emits a newer allow flag that older user-installed binaries reject. Posture is re-derived from current settings on every session acquisition.
3302736 to
23a8b5b
Compare
There was a problem hiding this comment.
ℹ️ No critical issues — one design question on Manual's sandbox override.
Reviewed changes — incremental delta since the prior pullfrog review (3302736418 → 23a8b5bf3b), which rewrote the branch into a 14-file provider/transport diff.
- Moved the Codex permission posture off app-server argv and onto typed thread policy — the deleted
codex-structured-permission-mode.ts/codexStructuredPermissionArgsForSettingsis replaced bycodexStructuredPermissionPolicyForSettings, whose{ approvalPolicy, sandbox }is spread into boththread/startandthread/resume. - Stated Manual's posture explicitly (
on-request/workspace-write) instead of omitting it — an absent field could otherwise be resolved through the mirrored~/.codex/config.tomlor inherited from a prior Yolo resume. - Kept Claude's owned bypass flag — Yolo now sends
extraArgs: { 'dangerously-skip-permissions': null }merged overCLAUDE_STRUCTURED_BASE_OPTIONS.extraArgs, and no longer sets the SDK's typedpermissionMode/allowDangerouslySkipPermissions. - Dropped the earlier routing and tokenizer work — the
tui_launch_customizationrename, per-launchagentArgsrouting, and shell-aware bypass parsing are no longer part of this PR.
Reviewed files: 14. Focused tests for the four changed provider/runtime test files pass (45 tests).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| * Why `workspace-write` and not codex's built-in `read-only`: read-only would override a | ||
| * deliberate `sandbox_mode = "workspace-write"` and make every file write in a Manual session | ||
| * need an approval it did not need before. This still resets Yolo's `danger-full-access`. |
There was a problem hiding this comment.
A request-level sandbox is authoritative over the home's config.toml, so Manual now forces workspace-write even when the user deliberately set sandbox_mode = "read-only" — the more cautious toggle loosens the more cautious config. The rationale above covers only the converse (choosing read-only would override a deliberate workspace-write). Is that intended, or should Manual preserve whichever sandbox is stricter?
Technical details
# Manual's `workspace-write` overrides a stricter `read-only` config
## Affected sites
- `src/main/codex/codex-structured-permission-policy.ts:27` — `MANUAL_POLICY.sandbox = 'workspace-write'`.
- `src/main/codex/codex-structured-thread-open.ts:80,88` — the policy is spread onto `thread/start` and `thread/resume` unconditionally.
- `src/main/codex-accounts/*` — Orca mirrors the user's `~/.codex/config.toml` into the managed home the app-server is started with.
## Evidence
- codex-rs `build_thread_config_overrides` maps the request `sandbox` into `ConfigOverrides.sandbox_mode`, and `ConfigToml::derive_permission_profile` does `sandbox_mode_override.or(self.sandbox_mode)` — the request wins over `config.toml`.
- `thread_resume` prefers the request value over the persisted thread policy, so the same override applies on resume.
## Required outcome
Decide whether Manual means a fixed `workspace-write` posture regardless of config, or the stricter of the two. If fixed, the trade-off for `read-only` users is worth stating where the current rationale only discusses the workspace-write case.
## Open questions for the human
Is a `sandbox_mode = "read-only"` user expected to lose read-only when they switch Agent Permissions to Manual?There was a problem hiding this comment.
ℹ️ No new issues on the incremental delta — the two new commits harden permission-flag detection and remove the last client-settable Codex posture key. No inline comments.
Reviewed changes — incremental delta since the prior pullfrog review (23a8b5bf3b → 770487b197), two commits.
- Permission-flag detection now reads argv, not a regex —
tuiAgentArgsBypassPermissionstokenizes the configured arguments through the resolved startup shell, drops everything after a standalone--, and fails closed on unparseable input, so quoted prompt text and operands after--can no longer authorize a structured session. - Shell and platform threaded through the resolver —
resolvedTuiAgentArgsBypassPermissionsnow takes full settings plus the platform and derives the local Windows shell family viaresolveLocalWindowsAgentStartupShell; bothclaudeStructuredPermissionModeForSettingsandcodexStructuredPermissionPolicyForSettingspassprocess.platform. - Codex per-turn
approvalPolicyremoved from the allow-list —CODEX_TURN_OPTION_KEYSno longer lists it, so the adapter rejectssetOptionfor it andrestoredCodexSessionOptionsfilters a persisted value out; posture stays owned by thread open/resume. No consumer ever set it, so this drops dead client-controllable posture rather than a live path.
Verified locally: the nine focused suites covering the changed files pass (133 tests), including the new tokenizer, Windows-shell, fail-closed, and turn-option rejection cases.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Electron QA: Agent Permissions × Codex structured chatExact commit: ScenarioSettings → Experimental: Chat UI on, default view Chat UI, updated structured native chat on. Settings → Agents: Manual, then a fresh New tab → Codex structured chat. After that, Agents → Yolo and a second fresh Codex chat. Both chats used a harmless shell write outside the workspace (a home-directory path; Visible evidenceManual showed the live approval card (Run a command? / Allow / Stop). Sidebar was Needs permission / Blocked. Stop was clicked; the home file was not created. Yolo ran the analogous home-path write and completed with no approval card. Composer returned to idle Send. Backing evidence
Remaining gapA first Manual prompt that wrote under |
Final review status: ready to mergeReviewed the rewritten PR through exact head Two meaningful issues were found, fixed, and pushed:
The final independent readiness review found zero remaining P0/P1/P2 candidates. The architecture now keeps the global setting authoritative: Orca re-derives the policy at structured-session acquisition and translates it at the provider boundary for start/resume. Manual is Validation completed:
This head is clean and ready to merge. |
* fix(structured-chat): deliver the permission posture through each transport's own contract Codex posture moves off app-server argv onto typed `thread/start` and `thread/resume` params. Manual states `on-request` / `workspace-write` explicitly instead of omitting the fields, which app-server resolved through the mirrored config.toml — a Manual thread on a home carrying `approval_policy = "never"` never prompted. Claude keeps its owned `--dangerously-skip-permissions` flag through SDK `extraArgs`; the SDK's typed bypass option emits a newer allow flag that older user-installed binaries reject. Posture is re-derived from current settings on every session acquisition. * fix(structured-chat): parse permission arguments as argv * fix(structured-chat): keep permission policy authoritative





ELI5
Yes — this makes the Agent Permissions toggle actually control Codex chat. It did not before.
If you set Manual, a new Codex chat could still come up with every permission bypassed and never ask you about anything.
Here is why. Orca sent your choice to
codex app-serveras a command-line flag. Butapp-serverdoes not take its permission policy from command-line flags — it takes it from typed fields on the request that starts a thread. So the flag went nowhere. With nothing telling it otherwise,app-serverfell back to your own~/.codex/config.toml. If that file saysapproval_policy = "never", then Manual meant nothing and you were bypassed.Two changes fix it:
app-serveractually reads it — the typed fields onthread/startandthread/resume, instead of a flag it ignores.Claude was never affected by this: its transport does read the flag Orca was already sending, so that path keeps working as it did.
What you'll notice
Only Codex structured chat changes behaviour. Terminal launches are untouched — they still receive your complete configured argument string, verbatim.
~/.codex/config.tomlsetsapproval_policy = "never"sandbox_mode = "workspace-write"app-server, which takes its policy from typed request fieldsthread/startparams--profile,--add-diror-cin your Codex Argumentsapp-serverthrough a filterThe first row is measured against codex 0.153.4. The Yolo row describes the delivery mechanism that changed; the failure it could produce was not separately staged.
What Changed
Codex posture moves from argv onto typed thread params. Yolo sends
approvalPolicy: 'never'/sandbox: 'danger-full-access'onthread/startandthread/resume. The--dangerously-bypass-approvals-and-sandboxflag no longer rides in front of theapp-serversubcommand.Manual now states a posture instead of omitting one. This is the part with real teeth.
app-serverresolves an omittedapprovalPolicy/sandboxthrough theconfig.tomlof the home it was started with, and Orca mirrors your~/.codex/config.tomlinto the managed home it hands that process. Manual was never a posture — it was "inherit whatever the config says". It now sendsapprovalPolicy: 'on-request'/sandbox: 'workspace-write'explicitly.workspace-writerather than codex's built-inread-only, so a deliberatesandbox_mode = "workspace-write"is not overridden into needing an approval for every file write. It still resets Yolo'sdanger-full-access.Claude keeps its owned CLI flag.
--dangerously-skip-permissionsgoes through SDKextraArgsrather than the SDK's typed bypass option, which emits a newer allow flag that older user-installed Claude binaries reject before a structured session can start.Posture is re-derived from current settings on every structured-session acquisition, never latched into the session record, so a failed restore cannot silently downgrade a session and nothing can disagree with the setting.
~/.codex/config.tomlsetsapproval_policy = "never"sandbox_mode = "workspace-write"app-server, which takes its policy from typed request fields; the posture you actually got came from yourconfig.tomlthread/startparams--profile,--add-diror-cin your Codex Argumentsapp-serverthrough a filterThe first row is measured against codex 0.153.4. The Yolo row describes the delivery mechanism that changed; the failure it could produce was not separately staged.
Terminal launches are untouched — they still receive your complete configured argument string, verbatim.
Why
The interactive CLIs, the Claude SDK, and the Codex
app-serverhave different option contracts. Passing one free-text field through all three silently changes behavior and can break older installed binaries. Each structured provider boundary should translate the one shared permission choice into the form that boundary actually reads.The alternative — keep sending argv and hope
app-servergrows support for it — is what produced the bug: an option the receiver ignores looks exactly like an option that worked. Stating both postures outright is what makes the toggle mean something, because the field left unsaid is the one a resume silently inherits from the other.Linked Issue
No separate issue. Split out of #20977; follow-up to the user-reported bug fixed by #20944.
Visual Proof
Electron permission evidence on #20944: Yolo runs without an approval card, Manual shows the approval card.
The provider encoding changed after those screenshots; its final Claude argv and Codex thread-policy boundaries are pinned by automated tests —
claude-agent-sdk-contract-pins.test.tsasserts the generated child argv, andcodex-structured-thread-open.test.tsasserts the exactthread/startandthread/resumeparams.Testing
I manually tested these changes locally
Automated tests added/updated
pnpm tcpnpm run check:code-quality:changed: 0 findings across all six scans, 12 changed filesFocused provider and runtime contracts: 5 files, 56 tests passed
Full unfiltered
pnpm test(coverssrc/,config/scripts/, andtests/)Measured against codex 0.153.4: both Manual values are accepted on
thread/startandthread/resume, and the reply echoes them back as the effective policy even when the home'sconfig.tomlasks fornever/danger-full-access.Residual validation gaps: no live older-Claude binary run was available; the generated Claude argv is covered by the contract-pin regression test. The resume half of the reported bug is stated as reported, not as measured — staging a real Yolo thread needs a live turn before codex writes the rollout.
AI Disclosure
Review
Split out of #20977 as one concern. The reviewable question here is whether each transport is told the posture in the form it actually reads, and whether Manual can still fall through to
config.tomlanywhere.This change adds no polling, timers, subprocess fanout, render churn, or retained resources.
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
No schema, migration, dependency, wire, mobile, or user-owned data format changed.
permissionPolicyis an in-process launch field consumed by the localapp-serverrequest, not a client/host wire field. Structured execution remains local-only; existing WSL, SSH, relay, and remote-host blockers are unchanged.The Settings Arguments UI and its mixed custom-arguments Yolo/Manual display remain unchanged.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)