Skip to content

feat(native-chat): Claude permission mode picker in the composer, and fix fast mode - #14745

Closed
Lunivo wants to merge 8 commits into
stablyai:mainfrom
Lunivo:Lunivo/improve-chat-ui-for-agent
Closed

Lunivo wants to merge 8 commits into
stablyai:mainfrom
Lunivo:Lunivo/improve-chat-ui-for-agent

Conversation

@Lunivo

@Lunivo Lunivo commented Aug 15, 2026 •

Copy link
Copy Markdown

ELI5

Claude Code lets you change how much it's allowed to do on its own — ask me every time, auto-accept edits, plan without touching anything, and so on. In the terminal you switch that with Shift+Tab. In Orca's Chat UI there was no way to see or change it, so a chat session was stuck on whatever it launched with.

This adds a Mode button next to the composer that shows the current mode and lets you change it, and fixes Claude's fast mode toggle, which broke when the CLI started asking for confirmation.

What Changed

Mode button in the composer (Claude sessions), left of the options and model pills. Shows the live mode — Manual / Accept edits / Plan / Auto / Bypass permissions — and switches it mid-session.

Under the hood:

Piece What it does
sessionOptions on AgentSessionOptionCatalog New extension point — every option was per-model before, and permission mode is per-session
sessionValues on the option record Values with no model to file under; survive a model switch
claude-terminal-session-options.ts Reads all five modes, and fast mode, off Claude's status line
native-chat-live-screen.ts Parse-driven screen source: alt-screen frame → normal buffer → mounted xterm
claude-permission-mode-cycle.ts Press-and-observe cycling with a diagnosable outcome
NativeChatSessionOptionPickers.tsx The Mode button, plus per-choice disabling (new capability)

Fast mode fix (#14752). A bare /fast no longer toggles — it opens a confirmation panel (Tab to toggle · Enter to confirm) that a dispatch leaves hanging and unapplied. The CLI still accepts /fast on|off, which sets the value outright.

That makes fast mode an absolute setter, so the flip-only machinery it was the last user of is removed (isFlipOnlyMidSession, the toggle-command kind, the Toggle action row, flip dedup — across shared, renderer and mobile). The flip's fallback for an unknown baseline was a bare /fast, which is exactly the command that now opens the panel. State comes from Claude's ↯ glyph instead, so no baseline is needed.

Also fixes a latent bug found on the way: a picker command cleared the tracked model for whichever option was being matched, so a typed bare /fast would have blanked every model-scoped row.

Why

Three facts about Claude's CLI shaped the implementation. All were verified against a live session — the first two contradict what the shipped binary's own strings suggest, and cost me a rewrite each:

  1. There is no slash command for permission mode, and Shift+Tab cycles — it does not open a menu. The numbered menu is the Claude Code desktop app; Orca drives the CLI. So an apply presses, re-reads the status line, and repeats until the target appears — bounded by a completed lap or a press cap.

  2. Every mode names itself in the status line, manual included (⏸ manual mode on). Reading it needs no banner, which matters because Claude's banner scrolls out of the viewport after the first screenful — a banner-gated read reports nothing for the rest of the session.

  3. Bypass is launch-granted only. Claude refuses it otherwise:

    Refusing restored mode 'bypassPermissions' (disabled by settings/policy or session not launched with --dangerously-skip-permissions); falling back to 'default'

    So that row deep-links to Settings → Agents → Agent Permissions rather than driving Claude's danger warning. Orca never auto-consents to a permission bypass on the user's behalf — that decision stays with the existing setting.

Safety property: the cycle drains the PTY send queue before its first keystroke. A chat send holds a delayed Enter for ~500 ms, and one landing mid-cycle would select a mode the user never chose. Pinned by an order-asserting test, not just a "was called" check.

Linked Issue

Fixes #11548
Fixes #14752 (Chat UI fast mode toggle no longer applies — bare /fast opens a confirmation panel)

Substantially addresses #12576 (Per-session permission mode selector in the Chat UI composer), which specifies this feature in detail. Deliberately not covered, so review can judge scope rather than discover gaps:

  • No cycle keybinding in the composer (that issue asks for a Shift+Tab mirror). Dropdown only.
  • Not surfaced in orca terminal show / worktree JSON.
  • "Mixed" launch args aren't labelled as such. Bypass availability is a containment check, so the flag plus extra args works correctly, but the picker doesn't say "mixed".
  • Claude only. Codex /approvals and other harnesses are untouched — the catalog now has the extension point for them.

Relationship to open work

# Relationship
#13348 Auto permission mode across harnesses Complementary, will conflict textually. That PR changes the launch-time preset (Manual/Auto/Yolo); this adds the per-session control. Both touch tui-agent-permissions.ts, AgentsPane.tsx, en.json — whichever lands second rebases. They compose correctly: an Auto-preset session reports bypass as unavailable here, which is right.
#10111 Codex Fast mode Overlaps 4 files, including agent-session-option-catalog-claude-codex.ts and the labels/pickers. It adds Codex fast mode while this changes Claude's. Worth coordinating on ordering.
#13081 Intermediate permission modes Claude's Auto is now selectable per-session here; #13348 covers the launch-time half.
#10886 Stale YOLO args after restart Same root area. This reads launch args from the pane's status entry, never settings.agentDefaultArgs (the default for new sessions).

No open PR implements the chat-UI permission mode picker — this is not a duplicate.

Visual Proof

1 — Composer, Mode button (after). The new control, showing the live mode (Auto). Before this PR the composer had only the options and model pills, with no way to see or change permission mode.

2 — The same session's terminal. ▶▶ auto mode on (shift+tab to cycle) — the pill reflects what the TUI actually reports, and changing it in the TUI propagates back to the pill.

3 — After setting fast mode from the picker. Pills read Accept edits and High · Fast; the transcript shows Ran /fast on.

4 — The same, in the terminal. /fast on → ↯ Fast mode ON · $10/$50 per Mtok, with no confirmation panel left hanging. Status line reads accept edits on.

5 — Effort dropdown, Fast mode section. Fast mode now shows real On / Off state read from Claude's ↯ glyph. Before, an unknown baseline could only offer a blind "Toggle fast mode" action.

6 — Mode dropdown. Manual / Accept edits / Plan / Auto, plus Bypass permissions carrying an Enable affordance because this session wasn't launched with --dangerously-skip-permissions. That row deep-links to Settings → Agents → Agent Permissions rather than driving Claude's danger warning.

Testing

  • pnpm run lint, pnpm typecheck, pnpm test, pnpm build all pass locally.
  • Pre-existing unrelated failure: 4 tests in src/main/rate-limits/codex-fetcher-pty-settle.test.ts fail identically on clean origin/main (verified in a separate worktree at b849099045). Not from this change.
  • Manually tested on macOS against a live Claude session: all five modes switch both ways, changes made in the TUI propagate back to the pill, and fast mode toggles without the confirmation panel.

Regression tests pin the specific things that broke during development, all of which shipped-and-were-caught by real use:

  • Prose reading how do I turn plan mode on must not be read as live status.
  • plan 2 things above the menu must not yield a wrong digit.
  • A stale main-buffer snapshot that reads fine but doesn't parse must fall through to the mounted xterm.
  • Every menu row is covered as the active one (the active row swaps its digit for ✓, so a fixed label→digit table is wrong).

Failure paths are diagnosable rather than silent — a failed change names the step that gave up and the modes it saw (Gave up after 6 presses; saw auto → plan → …).

  • I manually tested these changes locally
  • Automated tests added/updated

AI Disclosure

Written with Claude Code (Opus 5, 1M context) driving implementation, review and this description, with the author testing against live sessions and directing the design.

Review

Cross-platform (macOS / Linux / Windows). No platform-specific code paths, no metaKey hardcoding, no path construction. The change is terminal-text parsing plus a dropdown. Verified on macOS; the parsing is platform-neutral (it reads PTY output, not OS APIs).

Remote SSH / local. The screen reader tries the main-buffer snapshot API first and falls back to the mounted xterm, which is the only source for remote/SSH ptys the API doesn't cover — the same layering the existing model/effort read uses. Keystrokes go through sendRuntimePtyInput, which already branches local vs. remote. Not yet tested over a real SSH session: settleMs (250 ms between cycle presses) is a reasoned default, and a slow round-trip could make it read a stale mode. That self-corrects (one extra press, re-settle) but is the one number to tune if it misbehaves.

Mobile. Touched only by the flip-only removal (use-mobile-native-chat-session-options.ts, MobileNativeChatSessionOptionRows.tsx). Mobile has no permission-mode picker; its option surface is unchanged otherwise, and its tests pass.

Agent / integration compatibility. Codex, Gemini, Cursor and Grok catalogs declare no sessionOptions, so no new descriptor appears for them and their reporting path is unchanged. Mode labels are scoped by option id — Cursor ships a model literally named auto, and an unscoped label switch would have relabelled it in every non-English locale (there's a test for exactly that).

Backwards compatibility. sessionValues is guarded for records rehydrated from a cache written before the field existed. The removed toggle-command kind had no remaining catalog user in any agent.

Performance. The screen read runs once on mount and once per mode change, not in a hot path. The cycle is bounded by a press cap and a completed-lap check, so it cannot spin. No new subscriptions or timers outside the bounded cycle.

Security. The one security-relevant decision is deliberate: Orca never auto-confirms Claude's dangerous-permissions prompt. Selecting Bypass when it isn't launch-granted routes the user to Orca's own Agent Permissions setting instead of pressing through the warning — consent stays an explicit, existing control. Launch args are read from the live pane's status entry, never from the global default, so a stale global can't imply a permission the session doesn't have.

Known limitation worth its own issue. getLaunchConfigForEntry (agent-status.ts:948) passes launchToken: undefined, while registerAgentLaunchConfig stores entries with a token and the matcher rejects on mismatch — so launch args resolve empty for essentially every Orca-launched session, not an edge case. This PR works around it (an observed bypass permissions on is itself proof of the grant); the residual gap is a bypass-launched session never scraped even once. A real fix needs launchToken on AgentStatusEntry and every setAgentStatus site, which is out of scope here.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes — captions in place, images being dropped in
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (one pre-existing unrelated test failure, noted above)

Author

  • X / Twitter: @your_handle

Options hung off CatalogModel.options, which is per-model; permission mode
is per-session and orthogonal to the model, so the catalog gains a
sessionOptions array and a cycle-key mid-session kind.

hasYoloTuiAgentLaunch asks 'is bypass granted?' by containment, unlike
resolveTuiAgentPermissionMode which asks 'are these exactly the yolo
preset?' and reports mixed once any extra arg is present.
A session option has no model to file under, so the record gains a
sessionValues bucket beside valuesByModel. Reported values route there by
catalog id, survive a model switch, and stay truthful when the model
itself is unreadable.
Every mode names itself in the status line, manual included — observed
live, not derivable from the binary's label table. Reading it needs no
banner, which matters because the banner scrolls out of the viewport
after the first screenful and would otherwise strand the read.

The live-screen reader is parse-driven across three sources: the
snapshot's current frame (the alternate screen itself while a TUI owns
it), its normal buffer, then the mounted xterm. Falling back only on an
empty READ stranded us on a stale buffer that parsed to nothing.
…pped

Shift+Tab advances one mode per press — there is no menu to answer, and
which modes exist varies per session. So press-and-observe rather than
computing a step count, bounded by a completed lap or a press cap.

The send queue is drained first: a chat send holds a delayed Enter for
~500ms, and one landing mid-cycle would pick a mode the user never chose.

Bypass is gated on the launch flag, read from the pane's own status entry
rather than settings.agentDefaultArgs (the default for new sessions, not
what this one launched with — see stablyai#10886). An observed bypass mode is
itself proof of the grant, which backstops a launch-args lookup miss.

Every failure here is invisible from the chat pane, so the outcome names
the step that gave up and the modes it saw.
…lyai#11548)

Mode sits left of the options and model pills and shows the current
selection — including Manual, since the button's whole job is naming what
is selected. It is deliberately out of the effort menu.

Bypass renders an Enable affordance that deep-links to Settings → Agents →
Agent Permissions rather than driving Claude's danger warning, so Orca
never auto-consents to a permission bypass on the user's behalf. That
needed per-choice disabling, which the picker could not express before.

Mode labels are scoped to their own option: Cursor ships a model named
'auto', and a shared switch would relabel it in every non-English locale.

The composer's send-path choice moves to its own module to stay under the
file's max-lines budget.
…status line

A bare `/fast` no longer toggles — it opens a confirmation panel (Tab to
toggle · Enter to confirm) that a dispatch leaves hanging and unapplied.
The CLI still accepts `/fast on|off`, which sets the value directly.

That makes fast mode an absolute setter, so the flip-only machinery it was
the last user of is gone: the blind-flip fallback for an unknown baseline
was a bare `/fast`, which is exactly the command that now opens the panel.
Its state instead comes from Claude's own ↯ glyph, so the picker no longer
needs a baseline to reason from — absence is only read as off on a screen
the banner proves is Claude's.

Also fixes a latent bug in command recording: a picker command cleared the
tracked model for whichever option was being matched, so a typed bare
`/fast` would have blanked every model-scoped row.
@Lunivo
Lunivo marked this pull request as ready for review August 15, 2026 08:54
@Lunivo
Lunivo requested a review from brennanb2025 as a code owner August 15, 2026 08:54
@coderabbitai

coderabbitai Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d4369934-c500-4ae4-a386-6919aea9688c

📥 Commits

Reviewing files that changed from the base of the PR and between 0e4ebbe and e9983f9.

📒 Files selected for processing (5)
  • src/renderer/src/components/native-chat/claude-permission-mode-cycle.ts
  • src/renderer/src/components/native-chat/claude-terminal-session-options.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-labels.ts
  • src/shared/native-chat-session-option-snapshot.ts
  • src/shared/native-chat-session-option-state.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/renderer/src/components/native-chat/claude-terminal-session-options.ts
  • src/shared/native-chat-session-option-snapshot.ts
  • src/renderer/src/components/native-chat/claude-permission-mode-cycle.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-labels.ts
  • src/shared/native-chat-session-option-state.ts

📝 Walkthrough

Walkthrough

The change adds Claude session-scoped permission modes with launch-argument gating and Shift+Tab cycling. Terminal readers detect permission and fast modes from live screens. Session state separates session values from model values. Native chat pickers render permission modes separately and expose settings actions for unavailable choices. Fast mode uses explicit on/off commands. Composer sending uses a unified dispatcher, and mobile toggle-only handling is removed.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The fast-mode rewrite and related flip-only removal address #14752, not the linked Plan mode issue #11548, so part of the changeset is outside linked scope. Split the fast-mode work into a separate PR or link #14752 as an additional issue for this changeset.
Docstring Coverage ⚠️ Warning Docstring coverage is 24.53% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR adds a Claude composer control that includes Plan mode and supports changing it during a chat session, satisfying issue #11548.
Title check ✅ Passed The title clearly identifies the Claude permission-mode picker and fast-mode fix, which are the pull request’s primary changes.
Description check ✅ Passed The description is comprehensive and covers the change, rationale, linked issues, testing, limitations, and review considerations; visual attachments remain pending.

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.

@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: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
mobile/src/session/use-mobile-native-chat-session-options.ts (1)

163-171: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Wire session-scoped options through the mobile controller.

The shared snapshot publishes permissionMode as settable. setOption() only resolves model-scoped options, so setOption('permissionMode', 'plan') returns false before it can dispatch the mode change.

Resolve catalog.sessionOptions before model options. Thread the live agentArgs and agentEnv into the snapshot call so a mobile session launched with bypass permissions does not render Bypass as unavailable.

Also applies to: 217-225


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bc032dae-3acd-444e-b998-289c47296a15

📥 Commits

Reviewing files that changed from the base of the PR and between 2eb3e11 and 0e4ebbe.

📒 Files selected for processing (43)
  • mobile/src/session/MobileNativeChatSessionOptionRows.tsx
  • mobile/src/session/use-mobile-native-chat-session-options.ts
  • src/renderer/src/components/native-chat/NativeChatComposer.tsx
  • src/renderer/src/components/native-chat/NativeChatSessionOptionPickers.test.tsx
  • src/renderer/src/components/native-chat/NativeChatSessionOptionPickers.tsx
  • src/renderer/src/components/native-chat/claude-permission-mode-cycle.test.ts
  • src/renderer/src/components/native-chat/claude-permission-mode-cycle.ts
  • src/renderer/src/components/native-chat/claude-terminal-session-options.mode.test.ts
  • src/renderer/src/components/native-chat/claude-terminal-session-options.test.ts
  • src/renderer/src/components/native-chat/claude-terminal-session-options.ts
  • src/renderer/src/components/native-chat/native-chat-composer-send-dispatch.ts
  • src/renderer/src/components/native-chat/native-chat-live-screen.test.ts
  • src/renderer/src/components/native-chat/native-chat-live-screen.ts
  • src/renderer/src/components/native-chat/native-chat-live-session-launch-args.test.ts
  • src/renderer/src/components/native-chat/native-chat-live-session-launch-args.ts
  • src/renderer/src/components/native-chat/native-chat-pty-session-options.mode.test.ts
  • src/renderer/src/components/native-chat/native-chat-pty-session-options.test.ts
  • src/renderer/src/components/native-chat/native-chat-pty-session-options.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-apply.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-command-dispatch.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-labels.test.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-labels.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-snapshot.mode.test.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-snapshot.ts
  • src/renderer/src/components/native-chat/use-native-chat-session-option-command.mode-cycle.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-session-option-command.ts
  • src/renderer/src/components/native-chat/use-native-chat-session-options.ts
  • src/renderer/src/components/settings/AgentsPane.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/shared/agent-session-option-catalog-claude-codex.ts
  • src/shared/agent-session-option-catalog-types.ts
  • src/shared/agent-session-option-catalog.test.ts
  • src/shared/agent-session-option-catalog.ts
  • src/shared/native-chat-session-option-commands.test.ts
  • src/shared/native-chat-session-option-commands.ts
  • src/shared/native-chat-session-option-record.test.ts
  • src/shared/native-chat-session-option-reporting.test.ts
  • src/shared/native-chat-session-option-snapshot.test.ts
  • src/shared/native-chat-session-option-snapshot.ts
  • src/shared/native-chat-session-option-state.ts
  • src/shared/native-chat-session-options.ts
  • src/shared/tui-agent-permissions.test.ts
  • src/shared/tui-agent-permissions.ts
💤 Files with no reviewable changes (1)
  • mobile/src/session/MobileNativeChatSessionOptionRows.tsx

Comment on lines +69 to +74
// A repeat means a full lap completed without ever showing the target —
// it isn't in this session's cycle (e.g. bypass without the launch flag).
if (seen.has(mode)) {
return result('unavailable', 'not-in-cycle')
}
seen.add(mode)

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

A stale screen read can be misreported as not-in-cycle.

The lap check treats any repeated mode as proof that the target is absent from the cycle. A slow repaint after a press returns the previous mode within settleMs, so the cycler reports unavailable and the user sees "is not in this session's cycle" even though the mode is available. Remote (SSH) hosts repaint more slowly than the fixed 250 ms settle.

Re-read once before you conclude a lap completed.

🛠️ Proposed re-read before declaring a lap
     // A repeat means a full lap completed without ever showing the target —
     // it isn't in this session's cycle (e.g. bypass without the launch flag).
     if (seen.has(mode)) {
-      return result('unavailable', 'not-in-cycle')
+      // Why: an unrepainted screen repeats the previous mode, which is not a lap.
+      await delay(settleMs)
+      const recheck = await args.readMode()
+      if (recheck === args.target) {
+        observed.push(recheck)
+        return result('applied', 'reached')
+      }
+      if (recheck === null || seen.has(recheck)) {
+        return result('unavailable', 'not-in-cycle')
+      }
+      observed.push(recheck)
+      seen.add(recheck)
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// A repeat means a full lap completed without ever showing the target —
// it isn't in this session's cycle (e.g. bypass without the launch flag).
if (seen.has(mode)) {
return result('unavailable', 'not-in-cycle')
}
seen.add(mode)
// A repeat means a full lap completed without ever showing the target —
// it isn't in this session's cycle (e.g. bypass without the launch flag).
if (seen.has(mode)) {
// Why: an unrepainted screen repeats the previous mode, which is not a lap.
await delay(settleMs)
const recheck = await args.readMode()
if (recheck === args.target) {
observed.push(recheck)
return result('applied', 'reached')
}
if (recheck === null || seen.has(recheck)) {
return result('unavailable', 'not-in-cycle')
}
observed.push(recheck)
seen.add(recheck)
}

Comment on lines +239 to +243
function matchFastModeGlyph(lines: readonly string[]): boolean {
return lines.some(
(line) => line.includes(FAST_MODE_GLYPH) && !line.toLowerCase().includes(FAST_MODE_PANEL_TITLE)
)
}

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Restrict the fast-mode glyph match to the indicator window.

matchPermissionModeIndicator scans only the last INDICATOR_WINDOW_SIZE nonblank rows, but matchFastModeGlyph scans the whole screen. Any scrolled-past conversation row that contains ↯ reports fast mode as on. Both readClaudeFastModeFromTerminalScreen and readClaudeSessionOptionsFromTerminalScreen inherit that false positive.

Apply the same window to the glyph.

🛠️ Proposed windowed glyph match
 function matchFastModeGlyph(lines: readonly string[]): boolean {
-  return lines.some(
+  // Why: same staleness reason as the mode indicator — older rows may quote the glyph.
+  return withoutTrailingBlankRows(lines)
+    .slice(-INDICATOR_WINDOW_SIZE)
+    .some(
     (line) => line.includes(FAST_MODE_GLYPH) && !line.toLowerCase().includes(FAST_MODE_PANEL_TITLE)
-  )
+    )
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function matchFastModeGlyph(lines: readonly string[]): boolean {
return lines.some(
(line) => line.includes(FAST_MODE_GLYPH) && !line.toLowerCase().includes(FAST_MODE_PANEL_TITLE)
)
}
function matchFastModeGlyph(lines: readonly string[]): boolean {
// Why: same staleness reason as the mode indicator — older rows may quote the glyph.
return withoutTrailingBlankRows(lines)
.slice(-INDICATOR_WINDOW_SIZE)
.some(
(line) => line.includes(FAST_MODE_GLYPH) && !line.toLowerCase().includes(FAST_MODE_PANEL_TITLE)
)
}

const screens: (string | null)[] = []
if (args.ptyId && window.api?.pty?.getMainBufferSnapshot) {
try {
const snapshot = await window.api.pty.getMainBufferSnapshot(args.ptyId, { scrollbackRows: 0 })

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.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Add a timeout before the xterm fallback.

getMainBufferSnapshot has no deadline. If the IPC promise remains pending, this function never reads scrollbackAnsi or the mounted xterm. This can leave permission-mode changes waiting indefinitely. Bound the IPC read and continue with fallback sources when it times out. Add a pending-promise test.

Comment on lines +36 to +38
const parsed = args.parse(screen)
if (parsed) {
return parsed

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Accept valid falsy parser results.

parse permits any T | null. A parser that returns false is valid, but this truthiness check discards it and can return a later result or null. Compare against null explicitly. Add a test with a false result.

Proposed fix
-    if (parsed) {
+    if (parsed !== null) {
       return parsed
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const parsed = args.parse(screen)
if (parsed) {
return parsed
const parsed = args.parse(screen)
if (parsed !== null) {
return parsed

Comment on lines +146 to +149
const target = resolveTarget()
if (!target || disabled) {
return { outcome: 'unknown', reason: 'unreadable', presses: 0, observed: [] }
}

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

The no-target path reports a misleading reason.

reason: 'unreadable' makes describeClaudePermissionModeCycle render "Could not read the current mode from the terminal." The actual cause is a missing PTY target or a disabled composer. Add a distinct reason so the toast states the real cause.

🛠️ Proposed distinct reason

src/renderer/src/components/native-chat/claude-permission-mode-cycle.ts:

 export type ClaudePermissionModeCycleReason =
   | 'reached'
   | 'unreadable'
+  | 'no-terminal'
   | 'undelivered'
     case 'unreadable':
       return 'Could not read the current mode from the terminal.'
+    case 'no-terminal':
+      return 'No live terminal is available.'

Then in this file:

-        return { outcome: 'unknown', reason: 'unreadable', presses: 0, observed: [] }
+        return { outcome: 'unknown', reason: 'no-terminal', presses: 0, observed: [] }

const discoveredModels = discoveryContext
? readNativeChatEnrichedModels(agent, discoveryContext.hostKey)
: null
const { agentArgs, agentEnv } = resolveNativeChatLiveSessionLaunchArgs(paneKey)

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Inspect the launch-arg resolver, the store slice it reads, and pane-key construction.
fd -a 'native-chat-live-session-launch-args.ts' -X cat -n
rg -nP -C4 'agentStatusByPaneKey|getAgentLaunchConfigForStatusEntry' --type=ts --type=tsx -g '!**/*.test.*'
rg -nP -C4 '\bpaneKey\s*[=:]' --type=tsx -g '**/native-chat/**'

Repository: stablyai/orca

Length of output: 1110


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- target file ---'
cat -n src/renderer/src/components/native-chat/use-native-chat-session-options.ts | sed -n '1,220p'
printf '%s\n' '--- resolver and store definitions/usages ---'
rg -n -C5 'agentStatusByPaneKey|getAgentLaunchConfigForStatusEntry|resolveNativeChatLiveSessionLaunchArgs' src/renderer/src --glob '*.ts' --glob '*.tsx'
printf '%s\n' '--- native-chat pane key references ---'
rg -n -C4 'paneKey' src/renderer/src/components/native-chat --glob '*.ts' --glob '*.tsx'

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- session options hook ---'
cat -n src/renderer/src/components/native-chat/use-native-chat-session-options.ts | sed -n '1,210p'
printf '%s\n' '--- launch-arg resolver location ---'
fd -a -t f 'native-chat-live-session-launch-args.ts'
printf '%s\n' '--- resolver usages and status-store writes (excluding tests) ---'
rg -n -C3 'resolveNativeChatLiveSessionLaunchArgs|agentStatusByPaneKey' src/renderer/src/components/native-chat src/renderer/src/store --glob '*.ts' --glob '*.tsx' --glob '!*.test.*' | head -n 400
printf '%s\n' '--- status entry type and launch-config selector ---'
rg -n -C6 'getAgentLaunchConfigForStatusEntry|type AgentStatusEntry|interface AgentStatusEntry' src --glob '*.ts' --glob '*.tsx' --glob '!*.test.*' | head -n 300

Repository: stablyai/orca

Length of output: 50369


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- remaining hook logic ---'
cat -n src/renderer/src/components/native-chat/use-native-chat-session-options.ts | sed -n '180,380p'
printf '%s\n' '--- pty surface implementation ---'
cat -n src/renderer/src/components/native-chat/native-chat-pty-session-options.ts | sed -n '1,340p'
printf '%s\n' '--- launch config API ---'
rg -n -C10 --glob '*.ts' --glob '*.tsx' --glob '!*.test.*' 'getAgentLaunchConfigForStatusEntry'
printf '%s\n' '--- launch config state updates ---'
rg -n -C8 --glob '*.ts' --glob '*.tsx' --glob '!*.test.*' 'agentLaunchConfigByPaneKey|setAgentLaunchConfig'

Repository: stablyai/orca

Length of output: 14991


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- all launch-config references ---'
rg -n -C5 'getAgentLaunchConfig|agentLaunchConfigByPaneKey' . --glob '!node_modules/**' --glob '!dist/**' --glob '!build/**' | head -n 500
printf '%s\n' '--- option applier async/state behavior ---'
cat -n src/renderer/src/components/native-chat/native-chat-session-option-apply.ts 2>/dev/null | sed -n '1,320p' || true
fd -a -t f '*session-option*' src/renderer/src/components/native-chat
printf '%s\n' '--- relevant cache implementation ---'
cat -n src/renderer/src/components/native-chat/native-chat-session-option-cache.ts | sed -n '1,240p'

Repository: stablyai/orca

Length of output: 50369


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- launch-config matching ---'
cat -n src/renderer/src/store/slices/agent-status.ts | sed -n '1025,1175p'
printf '%s\n' '--- launch-config registration ---'
cat -n src/renderer/src/store/slices/agent-status.ts | sed -n '1675,1778p'
printf '%s\n' '--- cache implementation ---'
cat -n src/renderer/src/components/native-chat/native-chat-session-option-cache.ts | sed -n '1,260p'
printf '%s\n' '--- applier set/dispatch paths ---'
cat -n src/renderer/src/components/native-chat/native-chat-session-option-apply.ts | sed -n '120,340p'

Repository: stablyai/orca

Length of output: 20393


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- registration call sites ---'
rg -n -C8 'registerAgentLaunchConfig\(' src --glob '*.ts' --glob '*.tsx' --glob '!*.test.*' | head -n 300
printf '%s\n' '--- hook call sites and prop flow ---'
rg -n -C12 'useNativeChatSessionOptions\(' src/renderer/src --glob '*.ts' --glob '*.tsx' --glob '!*.test.*'
printf '%s\n' '--- pane key construction and status event keys ---'
rg -n -C5 'setAgentStatus\(|paneKey.*:.*leafId|\\$\\{.*\\}:\\$\\{.*\\}' src/renderer/src --glob '*.ts' --glob '*.tsx' --glob '!*.test.*' | head -n 500

Repository: stablyai/orca

Length of output: 15534


🏁 Script executed:

#!/bin/bash
set -eu
python3 - <<'PY'
from pathlib import Path

hook = Path("src/renderer/src/components/native-chat/use-native-chat-session-options.ts").read_text()
store = Path("src/renderer/src/store/slices/agent-status.ts").read_text()
cache = Path("src/renderer/src/components/native-chat/native-chat-session-option-cache.ts").read_text()
apply = Path("src/renderer/src/components/native-chat/native-chat-session-option-apply.ts").read_text()

# Read-only structural checks for the state-shape and lifecycle claim.
assert "const state = useAppStore.getState()" in Path(
    "src/renderer/src/components/native-chat/native-chat-live-session-launch-args.ts"
).read_text()
memo_deps = hook[hook.index("  }, [", hook.index("const surface")):hook.index("  ])", hook.index("const surface"))]
assert "agentStatusByPaneKey" not in memo_deps
assert "agentLaunchConfigByPaneKey" not in memo_deps

register = store[store.index("registerAgentLaunchConfig:"):store.index("getAgentLaunchConfigForStatusEntry:")]
assert "agentLaunchConfigByPaneKey:" in register
assert "agentStatusByPaneKey:" not in register

# Minimal state transition model: registering launch metadata changes the
# registry object but leaves the status-entry object reference unchanged.
status_entry = {"paneKey": "tab-1:leaf-1", "agentType": "claude"}
state_before = {
    "agentStatusByPaneKey": {"tab-1:leaf-1": status_entry},
    "agentLaunchConfigByPaneKey": {},
}
state_after = {
    "agentStatusByPaneKey": state_before["agentStatusByPaneKey"],
    "agentLaunchConfigByPaneKey": {
        "tab-1:leaf-1": {"launchConfig": {"agentArgs": "--dangerously-skip-permissions"}}
    },
}
assert state_after["agentStatusByPaneKey"]["tab-1:leaf-1"] is status_entry
assert state_after["agentLaunchConfigByPaneKey"] is not state_before["agentLaunchConfigByPaneKey"]

# The cache is cloned on read/write, so replacing the surface creates a new
# record. The async applier writes only after its dispatch finishes.
assert "cloneNativeChatSessionOptionRecord(record)" in cache
assert "await dispatchLiveCommand" in apply
assert "ctx.publish()" in apply

print("status-entry selector would not observe a launch-config-only update")
print("launch config is keyed independently by the same pane key")
print("surface replacement creates an independent cached record while live dispatch is async")
PY

Repository: stablyai/orca

Length of output: 240


🏁 Script executed:

#!/bin/bash
set -eu
python3 - <<'PY'
from pathlib import Path

files = {
    "hook": Path("src/renderer/src/components/native-chat/use-native-chat-session-options.ts").read_text(),
    "resolver": Path("src/renderer/src/components/native-chat/native-chat-live-session-launch-args.ts").read_text(),
    "store": Path("src/renderer/src/store/slices/agent-status.ts").read_text(),
    "cache": Path("src/renderer/src/components/native-chat/native-chat-session-option-cache.ts").read_text(),
    "apply": Path("src/renderer/src/components/native-chat/native-chat-session-option-apply.ts").read_text(),
}
checks = [
    ("resolver uses getState", "const state = useAppStore.getState()" in files["resolver"]),
    ("memo has no status selector", "agentStatusByPaneKey" not in files["hook"][files["hook"].index("  }, [", files["hook"].index("const surface")):files["hook"].index("  ])", files["hook"].index("const surface")]),
    ("memo has no launch selector", "agentLaunchConfigByPaneKey" not in files["hook"]),
    ("registration updates launch registry", "agentLaunchConfigByPaneKey:" in files["store"][files["store"].index("registerAgentLaunchConfig:"):files["store"].index("getAgentLaunchConfigForStatusEntry:")]),
    ("registration does not update status map", "agentStatusByPaneKey:" not in files["store"][files["store"].index("registerAgentLaunchConfig:"):files["store"].index("getAgentLaunchConfigForStatusEntry:")]),
    ("cache clones records", "cloneNativeChatSessionOptionRecord(record)" in files["cache"]),
    ("apply awaits dispatch", "await dispatchLiveCommand" in files["apply"]),
    ("apply publishes", "ctx.publish()" in files["apply"]),
]
for name, value in checks:
    print(f"{name}: {value}")
PY

Repository: stablyai/orca

Length of output: 683


🏁 Script executed:

#!/bin/bash
set -eu
python3 - <<'PY'
from pathlib import Path

hook = Path("src/renderer/src/components/native-chat/use-native-chat-session-options.ts").read_text()
resolver = Path("src/renderer/src/components/native-chat/native-chat-live-session-launch-args.ts").read_text()
store = Path("src/renderer/src/store/slices/agent-status.ts").read_text()
cache = Path("src/renderer/src/components/native-chat/native-chat-session-option-cache.ts").read_text()
apply = Path("src/renderer/src/components/native-chat/native-chat-session-option-apply.ts").read_text()

surface_start = hook.index("  const surface = useMemo")
deps_start = hook.index("  }, [", surface_start)
deps_end = hook.index("  ])", deps_start)
deps = hook[deps_start:deps_end]

checks = [
    ("resolver uses getState", "const state = useAppStore.getState()" in resolver),
    ("memo has no status selector", "agentStatusByPaneKey" not in deps),
    ("memo has no launch selector", "agentLaunchConfigByPaneKey" not in deps),
    ("registration updates launch registry", "agentLaunchConfigByPaneKey:" in store[store.index("registerAgentLaunchConfig:"):store.index("getAgentLaunchConfigForStatusEntry:")]),
    ("registration does not update status map", "agentStatusByPaneKey:" not in store[store.index("registerAgentLaunchConfig:"):store.index("getAgentLaunchConfigForStatusEntry:")]),
    ("cache clones records", "cloneNativeChatSessionOptionRecord(record)" in cache),
    ("apply awaits dispatch", "await dispatchLiveCommand" in apply),
    ("apply publishes", "ctx.publish()" in apply),
]
for name, value in checks:
    print(f"{name}: {value}")
PY

Repository: stablyai/orca

Length of output: 415


🏁 Script executed:

#!/bin/bash
set -eu
python3 - <<'PY'
from pathlib import Path

store = Path("src/renderer/src/store/slices/agent-status.ts").read_text()
start = store.index("    registerAgentLaunchConfig:")
end = store.index("    getAgentLaunchConfigForStatusEntry:", start)
register = store[start:end]
print("registration range:", start, end)
print("updates launch registry:", "agentLaunchConfigByPaneKey:" in register)
print("updates status map:", "agentStatusByPaneKey:" in register)
print("relevant lines:")
for number, line in enumerate(register.splitlines(), start=1695):
    if "agentLaunchConfigByPaneKey" in line or "agentStatusByPaneKey" in line:
        print(f"{number}: {line.strip()}")
PY

Repository: stablyai/orca

Length of output: 464


Make launch-argument availability reactive to the launch-config registry.

agentLaunchConfigByPaneKey is separate from agentStatusByPaneKey, and registerAgentLaunchConfig updates only the registry. Subscribe to the pane's launch-config and status entries, then update the existing surface without replacing it during an in-flight option command.

@Lunivo

Lunivo commented Aug 15, 2026

Copy link
Copy Markdown
Author

Addressing both warnings.

Out of Scope Changes ✅

Fair catch — #11548 only asks for Plan mode. Filed #14752 for the fast-mode bug and linked it, so that scope is now covered by an issue of its own rather than riding on #11548.

On why it isn't split into a separate PR: the two changes are entangled in the same files (agent-session-option-catalog-claude-codex.ts, native-chat-session-option-labels.ts, NativeChatSessionOptionPickers.tsx, native-chat-pty-session-options.test.ts), so splitting produces two PRs that conflict with each other rather than two independent ones. Happy to split if a maintainer prefers it — say the word and I'll stack them.

The fast-mode change is isolated to its own commit (5811448) if you'd rather review it separately.

Docstring Coverage ⚠️ partially addressed

Added JSDoc to the functions this PR introduces that lacked it — the screen readers, the cycle helpers, the mode-label and gating helpers (e9983f9).

I did not blanket-document to reach 80%, and want to flag why rather than silently ignore it. The measured 24.53% is dominated by pre-existing upstream functions in files this PR merely touches — AgentsPane.tsx (12 undocumented), tui-agent-permissions.ts (9), native-chat-session-option-state.ts (10), agent-session-option-catalog.ts (5), and others. Documenting ~100 functions I didn't write would be considerably worse scope creep than the thing the first check just flagged, and it collides with this repo's own style rule in AGENTS.md:

Concise/Brief Non-obvious comments ONLY

  • DO NOT: be verbose, explain the obvious, walk through the code ("WHY not HOW")

So the functions this PR adds are documented, and the rationale that matters — why the cycle presses rather than commands, why the screen read is parse-driven across three sources, why bypass deep-links instead of auto-confirming — is in JSDoc at the point of use.

Happy to go further if you'd like, but it'd be worth deciding whether the threshold should apply to changed files or only to added functions, since on a PR touching this much shared surface the two give very different answers.

@nwparker

nwparker commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Related active PRs for cross-review: #30677 (agent settings and terminal Auto), #30853 (native-chat defaults, stacked on #30677), and #19244. Refs #13081 and #25559.

#30853 configures per-agent defaults for newly created structured native chats. This PR adds live permission-mode controls for terminal-backed native chat. Cross-review launch-default seeding alongside live mode persistence, preserving existing chat choices when defaults change, and CLI/model support checks for Auto.

#19244 and #30677 overlap settings controls and permission mappings. #30853 uses explicit native-sync opt-in and a separate host capability to preserve behavior in both directions of mixed-version pairing.

@nwparker

Copy link
Copy Markdown
Contributor

Thank you for this PR. Both halves have now landed on main in other forms: the composer has a permission mode picker with per-agent defaults (#30853, #31315), and Fast mode is owned by the chat (#30561). Since this branch is stale and conflicting, we are closing it as superseded. We appreciate you taking the time to build it. Please open an issue if either is still off on the latest build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Chat UI fast mode toggle no longer applies — bare /fast opens a confirmation panel [Feature] Plan mode in chat UI

5 participants