Skip to content

Make the Agent Permissions toggle apply to Codex chat - #20977

Merged
brennanb2025 merged 3 commits into
mainfrom
brennanb2025/native-chat-args-review-fixes
Sep 17, 2026
Merged

brennanb2025 merged 3 commits into
mainfrom
brennanb2025/native-chat-args-review-fixes

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​256 $\color{#cf222e}{\Huge{\mathbf{−}}}$​78 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​178
Prod 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​131 $\color{#cf222e}{\Huge{\mathbf{−}}}$​54 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​77

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-server as a command-line flag. But app-server does 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-server fell back to your own ~/.codex/config.toml. If that file says approval_policy = "never", then Manual meant nothing and you were bypassed.

Two changes fix it:

  1. Send the posture where app-server actually reads it — the typed fields on thread/start and thread/resume, instead of a flag it ignores.
  2. Make Manual say something instead of nothing. Sending no policy is what let the config file decide. Manual now explicitly asks for approvals.

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.

Situation Before After
Manual, on a machine whose ~/.codex/config.toml sets approval_policy = "never" A brand-new Codex chat came up fully bypassed and never asked for approval, while Settings said Manual Manual asks before acting outside the workspace
Manual, where your config sets sandbox_mode = "workspace-write" Manual sent nothing, so your config decided everything Your choice is kept — edits inside the workspace don't prompt, leaving it does
Yolo in Codex structured chat Orca sent the bypass flag as a command-line argument to app-server, which takes its policy from typed request fields The toggle sets it directly, through typed thread/start params
--profile, --add-dir or -c in your Codex Arguments Reached app-server through a filter No longer reach structured chat. Terminal launches still get them in full

The 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' on thread/start and thread/resume. The --dangerously-bypass-approvals-and-sandbox flag no longer rides in front of the app-server subcommand.

Manual now states a posture instead of omitting one. This is the part with real teeth. app-server resolves an omitted approvalPolicy / sandbox through the config.toml of the home it was started with, and Orca mirrors your ~/.codex/config.toml into the managed home it hands that process. Manual was never a posture — it was "inherit whatever the config says". It now sends approvalPolicy: 'on-request' / sandbox: 'workspace-write' explicitly.

workspace-write rather than codex's built-in read-only, so a deliberate sandbox_mode = "workspace-write" is not overridden into needing an approval for every file write. It still resets Yolo's danger-full-access.

Claude keeps its owned CLI flag. --dangerously-skip-permissions goes through SDK extraArgs rather 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.

Situation Before After
Manual, on a machine whose ~/.codex/config.toml sets approval_policy = "never" A brand-new Codex chat came up fully bypassed and never asked for approval, while Settings said Manual Manual asks before acting outside the workspace
Manual, where your config sets sandbox_mode = "workspace-write" Manual sent nothing, so your config decided everything Your choice is kept — edits inside the workspace don't prompt, leaving it does
Yolo in Codex structured chat Orca sent the bypass flag as a command-line argument to app-server, which takes its policy from typed request fields; the posture you actually got came from your config.toml The toggle sets it directly, through typed thread/start params
--profile, --add-dir or -c in your Codex Arguments Reached app-server through a filter No longer reach structured chat. Terminal launches still get them in full

The 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-server have 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-server grows 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.ts asserts the generated child argv, and codex-structured-thread-open.test.ts asserts the exact thread/start and thread/resume params.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated

  • pnpm tc

  • pnpm run check:code-quality:changed: 0 findings across all six scans, 12 changed files

  • Focused provider and runtime contracts: 5 files, 56 tests passed

  • Full unfiltered pnpm test (covers src/, config/scripts/, and tests/)

Measured against codex 0.153.4: both Manual values are accepted on thread/start and thread/resume, and the reply echoes them back as the effective policy even when the home's config.toml asks for never / 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.toml anywhere.

This change adds no polling, timers, subprocess fanout, render churn, or retained resources.

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

No schema, migration, dependency, wire, mobile, or user-owned data format changed. permissionPolicy is an in-process launch field consumed by the local app-server request, 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

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

@brennanb2025
brennanb2025 force-pushed the brennanb2025/native-chat-args-review-fixes branch from 4fdb2c3 to 7819605 Compare September 16, 2026 06:47
@coderabbitai

coderabbitai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

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: bb26e705-b2b4-493b-9e29-9f4c1b836083

📥 Commits

Reviewing files that changed from the base of the PR and between 23a8b5b and 770487b.

📒 Files selected for processing (8)
  • src/main/claude/claude-structured-permission-mode.ts
  • src/main/codex/codex-structured-permission-policy.test.ts
  • src/main/codex/codex-structured-permission-policy.ts
  • src/main/codex/codex-structured-session-adapter.test.ts
  • src/main/codex/codex-structured-session-options.test.ts
  • src/main/codex/codex-structured-turn-start.ts
  • src/shared/tui-agent-launch-defaults.test.ts
  • src/shared/tui-agent-launch-defaults.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

Claude structured launches now pass bypass permissions through extraArgs using the owned CLI flag. Codex structured launches now derive explicit manual or bypass policies from settings, attach them to launch state, and forward them on thread start and resume. The previous Codex permission-argument helper and its tests were removed. Tests were updated for both provider-specific permission representations.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 77048

No concrete merge-blocking risk remains from the reviewed changes.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 47.37% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 32 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: applying the Agent Permissions toggle to Codex chat.
Description check ✅ Passed The description is detailed, focused, and covers the user impact, implementation, rationale, testing, compatibility, and checklist requirements. It references related issues and visual evidence, altho…
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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 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/requiresTuiLaunchCommand became tui_launch_customization/requiresTuiLaunchCustomization through main, renderer, shared, and e2e; no consumer still reads the old string.
  • Per-launch args demote structured chat — AgentLaunchRouteArgs.tuiCustomization gains agentArgs, wired from launch-agent-in-new-tab.ts (raw override, not the resolved default) and launch-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 typed permissionMode/allowDangerouslySkipPermissions pair, preserving the user-installed-binary contract; Manual passes neither.
  • Codex permission encoding — new codex-structured-permission-policy.ts emits { approvalPolicy: 'never', sandbox: 'danger-full-access' } on thread/start and thread/resume instead of app-server argv; the posture is re-derived per acquisition.
  • Shell-aware bypass parsing — resolvedTuiAgentArgsBypassPermissions tokenizes 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?

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

@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 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.ts changes the partial AppState mock cast from as AppState to as unknown as AppState, keeping the existing line-scoped SAFETY: 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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Final review status: clean

Three adversarial review rounds completed. The third round found no remaining in-scope correctness, architecture, regression, or performance issue.

Issues fixed during review

  • Explicit recipe/launch arguments now force the terminal path, including an override equal to Orca's default bypass flag; global Agent Settings arguments and environment remain nonblocking for structured chat.
  • Permission-bypass detection uses the existing POSIX, PowerShell, or cmd startup tokenizer and ignores quoted text and operands after --.
  • Claude uses the established --dangerously-skip-permissions flag through SDK extraArgs, avoiding a compatibility dependency on the newer allow flag.
  • Codex supplies approvalPolicy: 'never' and sandbox: 'danger-full-access' through both thread/start and thread/resume, with no permission argv on app-server.
  • The shared route concept accurately covers command, per-launch argument, and cwd customization.

Verification

  • Focused provider, runtime, routing, and launch contracts: 18 files, 283 tests passed.
  • Final route-preparation/direct-launch extraction: 2 files, 16 tests passed.
  • pnpm tc passed locally and in CI.
  • Changed-code quality passed with zero findings across all six scans; pre-commit oxlint, React Doctor lint, formatting, and git diff --check passed.
  • CI is green: static analysis, Linux packaging, Windows packaging, and all eight test shards.
  • One shard initially completed all assertions but reported an unrelated AiVaultSessionSubagents.test.tsx teardown timer after window disposal; its isolated retry passed.
  • Opening readiness found one P2 around launch-scoped recipe arguments, fixed here. Final readiness found zero P0, P1, or P2 findings.
  • Performance review is clean: bounded acquisition-time tokenization and constant-sized route checks only; no polling, timers, subprocess fanout, render churn, or retained resources were added.

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.

@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 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 — codexStructuredPermissionPolicyForSettings returns { approvalPolicy: 'on-request', sandbox: 'workspace-write' } instead of undefined, and openCodexThread spreads it into both thread/start and thread/resume. Verified against openai/codex v0.153.4: both are the exact kebab-case wire values, both params are accepted on each request, and a resume applies them (a request sandbox override makes codex skip the persisted Yolo profile).
  • Empty and null per-launch overrides route to the terminal — requiresTuiLaunchCustomization switched from truthiness to presence (!== undefined), so agentArgs: '' no longer falls through to structured chat.
  • Tokenizer blind spot documented and pinned — a KNOWN LIMIT note on tuiAgentArgsBypassPermissions plus a measured-against-Claude-2.1.270 vector table that pins the one remaining arity case the reader still gets wrong.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

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.ts
  • src/main/codex/codex-structured-launch-resolution.ts
  • src/main/codex/codex-structured-permission-policy.test.ts
  • src/main/codex/codex-structured-permission-policy.ts
  • src/main/codex/codex-structured-thread-open.test.ts
  • src/main/runtime/structured-agent-session-runtime.ts
  • src/renderer/src/lib/agent-launch-route-input.test.ts
  • src/renderer/src/lib/agent-launch-route-input.ts
  • src/renderer/src/lib/launch-agent-structured-chat-guard.test.ts
  • src/shared/tui-agent-launch-defaults.test.ts
  • src/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

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.

🔒 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' \
  src

Repository: 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.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/native-chat-args-review-fixes branch from 3302736 to 23a8b5b Compare September 16, 2026 22:50
@brennanb2025 brennanb2025 changed the title Fix structured chat launch and permission semantics Deliver the Agent Permissions posture through each structured transport's own contract Sep 16, 2026

@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 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/codexStructuredPermissionArgsForSettings is replaced by codexStructuredPermissionPolicyForSettings, whose { approvalPolicy, sandbox } is spread into both thread/start and thread/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.toml or inherited from a prior Yolo resume.
  • Kept Claude's owned bypass flag — Yolo now sends extraArgs: { 'dangerously-skip-permissions': null } merged over CLAUDE_STRUCTURED_BASE_OPTIONS.extraArgs, and no longer sets the SDK's typed permissionMode / allowDangerouslySkipPermissions.
  • Dropped the earlier routing and tokenizer work — the tui_launch_customization rename, per-launch agentArgs routing, 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).

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

Comment on lines +23 to +25
* 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`.

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.

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?

@brennanb2025 brennanb2025 changed the title Deliver the Agent Permissions posture through each structured transport's own contract Make the Agent Permissions toggle apply to Codex chat Sep 16, 2026

@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 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 — tuiAgentArgsBypassPermissions tokenizes 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 — resolvedTuiAgentArgsBypassPermissions now takes full settings plus the platform and derives the local Windows shell family via resolveLocalWindowsAgentStartupShell; both claudeStructuredPermissionModeForSettings and codexStructuredPermissionPolicyForSettings pass process.platform.
  • Codex per-turn approvalPolicy removed from the allow-list — CODEX_TURN_OPTION_KEYS no longer lists it, so the adapter rejects setOption for it and restoredCodexSessionOptions filters 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.

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

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron QA: Agent Permissions × Codex structured chat

Exact commit: 770487b1975b43281ae1cea65b64471a89b164bd. Isolated hidden launch (ORCA_BACKGROUND_LAUNCH=1); window.api.app.getIdentity() was Orca: review/pr20977-current / worktree native-chat-args-terminal-only. Host ~/.codex/config.toml still has approval_policy = "never" / sandbox_mode = "danger-full-access" — the setup where Manual previously inherited bypass.

Scenario

Settings → 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; /tmp is inside Codex workspace-write).

Visible evidence

Manual showed the live approval card (Run a command? / Allow / Stop). Sidebar was Needs permission / Blocked. Stop was clicked; the home file was not created.

05-codex-manual-approval-card.png

02-agent-permissions-manual.png

Yolo ran the analogous home-path write and completed with no approval card. Composer returned to idle Send.

08-codex-yolo-completed.png

06-agent-permissions-yolo.png

Backing evidence

  • Manual thread rollout turn_context: approval_policy = on-request, sandbox_policy.type = workspace-write. Journal recorded item/commandExecution/requestApproval.
  • Yolo thread rollout turn_context: approval_policy = never, sandbox_policy.type = danger-full-access. Journal had a completed shell tool-call and no approval item.
  • Isolated codex app-server argv had no --dangerously-bypass-approvals-and-sandbox. Posture came from typed thread/start fields, not a CLI flag.

Remaining gap

A first Manual prompt that wrote under /tmp did not prompt, because Codex workspace-write treats slash_tmp as writable. The home-path write is the one that leaves that sandbox. Resume of a Yolo thread after switching to Manual was not staged. Folder / WSL / SSH / remote hosts were not exercised.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Final review status: ready to merge

Reviewed the rewritten PR through exact head 770487b1975b43281ae1cea65b64471a89b164bd, including the changes made after the earlier review comment.

Two meaningful issues were found, fixed, and pushed:

  • 2dae3578 parses permission arguments with the platform-aware shell tokenizer. Quoted mentions and operands after -- can no longer enable bypass mode, and malformed input fails closed.
  • 770487b1 removes approvalPolicy from restored/per-turn Codex options, so stale session state cannot override the current Agent Permissions setting on later turns.

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 on-request + workspace-write; Yolo is never + danger-full-access. No polling, retry loop, retained state, render work, or material performance cost was added.

Validation completed:

  • 139 focused tests, pnpm tc, and changed-file code-quality checks passed locally.
  • Full PR CI is green, including static analysis, typecheck, all eight test shards, macOS packaging, and Windows packaging.
  • Hidden Electron QA with screenshots verified a fresh Manual Codex chat showed a live approval card for an outside-workspace write, while a fresh Yolo chat completed the analogous write without approval. The recorded policies matched the expected typed request fields.
  • The live run covered fresh Manual and Yolo sessions. The Yolo-to-Manual resume transition is covered by focused RPC assertions rather than a second live resume flow. Structured chat remains local-only, so this PR does not change mobile, SSH, WSL, relay, or remote-wire behavior.

This head is clean and ready to merge.

@brennanb2025
brennanb2025 merged commit 7f5141a into main Sep 17, 2026
28 checks passed
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
* 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
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