Skip to content

fix(runtime): apply the structured-chat setting to every RPC caller - #18700

Merged
brennanb2025 merged 11 commits into
mainfrom
brennanb2025/bug4-policy-all-clients
Sep 7, 2026
Merged

brennanb2025 merged 11 commits into
mainfrom
brennanb2025/bug4-policy-all-clients

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​436 $\color{#cf222e}{\Huge{\mathbf{−}}}$​334 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​102
Prod 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​450 $\color{#cf222e}{\Huge{\mathbf{−}}}$​38 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​412

ELI5

Orca has a setting that turns structured Codex chat on or off. The host only actually checked that setting when a phone asked. When the desktop asked, it skipped the check.

So the same setting meant different things depending on which device was asking. This makes it one rule for everyone.

What this actually fixes — and what it does not

It would be easy to read this as "stop showing structured tabs when the feature is off." That is not the bug, because the desktop renderer already gates itself:

if (!enabled) { clearLocalStructuredSessionTabs(); return }

So even when the host admitted structured tabs with the setting off, the renderer cleared them and never subscribed. Users were not seeing stray tabs.

The real problem is host-side work. session.tabs.list / session.tabs.listAll call restoreStructuredTabsIfSupported unconditionally, and the desktop renderer calls those routinely. With the setting off, that still ran restoreStructuredAgentSessionTabsOnce — startup restoration, restoreReadableSessions(...) over persisted session ids, and headless session-tab hydration — for a feature that is switched off, and the renderer then threw the results away.

Before / after

Caller, setting off Before After
Phone asks Refused Refused (unchanged)
Desktop asks Host ran structured session restoration; renderer discarded the result Host doesn't run it
Anything asks, setting on Works Works (unchanged)
Launching a chat — Unchanged, asserted in tests

The behaviour change, stated plainly

With the setting off, host-side structured-tab restoration now follows the flag for every caller, not just mobile. Because the renderer already discarded those tabs, this is not expected to be visible in normal use — the difference only surfaces if something bypasses the renderer's own gate. (The runtime proof below had to call the production function directly for exactly that reason.)

Why not a narrower fix? Exempting restoration would have added a second, restoration-only predicate — re-creating the "the policy depends on which door you knocked on" shape this PR exists to remove.

Scope

Capability logic untouched: it is asked only of remote clients, so capability-less in-process callers are still admitted. Desktop is clientKind: 'runtime' with the capability hardcoded, so only the settings term was unified. Making the projection argument required surfaced 8 non-mobile call sites passing undefined; those now read the host setting.

Evidence

  • Runtime differential (Electron, isolated instance): with the setting off, the host admitted the structured tab before the fix and refuses it after; with the setting on, structured launch and post-restart restoration still work. Disclosed method: because the renderer self-gates on the same setting, each frame invoked the real production refreshLocalStructuredSessionTabs() over the real wire rather than relying on the automatic startup path.
  • Mobile regression QA: 6/6 pass, 11 screenshots. The rewritten gate exercised both directions — with the setting off the structured tab projects out into a graceful empty state (no redbox) and a new Codex tab arrives as a working terminal with the host record count staying at 1; restoring the setting brings the tab back with its transcript intact.
  • Review loop: zero P0/P1/P2 across 151 focused tests plus typecheck, changed-code quality, cross-version wire, and packaging.

Merge order

Its prerequisite (#18697, the pre-commit refusal envelope) has merged, so the original ordering constraint is satisfied. Still draft pending a decision on the restoration change above.

supportsStructuredAgentSessions only consulted experimentalStructuredNativeChat
when clientKind === 'mobile', so identical host settings admitted desktop and
in-process callers while refusing a phone. The server branched on client surface.

The setting is now one rule for every caller. The negotiated capability stays a
wire term asked of remote clients only, so a capability-less in-process caller is
still admitted on the setting alone.

Making the projection's structuredNativeChatEnabled argument required surfaced
eight call sites that passed `undefined` for non-mobile clients; they now read the
host setting, so tab projection follows the same single rule.

Announced behaviour change: with the flag off, session.tabs.list/listAll no longer
restore structured tabs for desktop. The desktop renderer already discards them in
that state, and startup record/lease reconciliation is unaffected.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Visual proof — runtime differential on a real Electron instance

Tested at 32375946a5db46e5a1350723ff9206f02f4e05a3 in an isolated dev instance (own .app, own user-data dir, own renderer + CDP ports; CDP port owner pid verified against this worktree's build before the first command).

Unit tests pass, but they are not the evidence here — this is the rendered behaviour.

How the frames were driven. The renderer also self-gates on experimentalStructuredNativeChat (useLocalStructuredSessionTabsSync, use-app-startup-hydration.ts), so the host-side admission change is invisible through the renderer's automatic startup path. Each frame therefore invokes the real production refresh — refreshLocalStructuredSessionTabs(), which calls session.tabs.listAll over the real desktop IPC and applies the result to the store — from the console. Nothing is stubbed; only the trigger is manual, and that is disclosed because the automatic trigger is itself setting-gated. The structured session is real (created through the UI: new tab → Codex), and each arm was captured after a full app restart at steady state. The experimentalStructuredNativeChat toggle has no Settings UI, so each frame carries a banner written into the real terminal pty.


BEFORE — fix ablated to the pre-PR predicate, experimentalStructuredNativeChat = OFF

The desktop caller (clientKind: 'runtime' + structured capability) is admitted regardless of the host setting, so the host returns the structured agent-session tab and "Codex Chat" appears in the tab strip with the setting off.

{"setting": false, "hostAgentTabs": ["Codex Chat"],
 "rendererTabs": ["bc73e3ec-…", "structured-agent-session-codex_fefada2b_…"]}

BEFORE — fix ablated, setting OFF, Codex Chat tab wrongly present


AFTER — fix applied (this PR), same flow, experimentalStructuredNativeChat = OFF

One rule for every caller: the host refuses the agent-session tab, and the structured tab the renderer had persisted from the ablated run is removed by the host's answer. Tab strip shows Terminal 1 only.

{"setting": false, "hostAgentTabs": [],
 "tabsAtStartup": ["bc73e3ec-…", "structured-agent-session-codex_fefada2b_…"],
 "tabsAfterRefresh": ["bc73e3ec-…"]}

AFTER — fix applied, setting OFF, no Codex Chat tab


No regression — fix applied, experimentalStructuredNativeChat = ON

Structured launch still routes to the chat surface, and the tab still survives a full app restart (hostAgentTabs: [{title: "Codex Chat", agent: "codex", isActive: true}]).

Setting ON — Codex structured chat launches normally

Setting ON — Codex Chat tab restored after a full app restart


Renderer console: 0 errors in both arms; 2 benign warnings in each (React Grab version notice, xterm task-queue deadline) — identical before and after, so no new console noise.

Ablation hygiene: one file touched (structured-agent-session-policy.ts), reverted with git checkout --. Post-restore HEAD is still 32375946a5db46e5a1350723ff9206f02f4e05a3, the working tree is clean, and the pre-PR clientKind !== 'mobile' branch is gone (grep count 0).

Not covered: live mobile or remote/relay callers (no paired client in this rig), and the agentSession.* method surface gated by the same predicate was not separately driven at runtime — the differential shown is on session.tabs.list* admission and restoration.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron QA — structured-chat setting at 0450cc27f10

Tested 0450cc27f10 (fix(runtime): keep structured session cleanup available) in an isolated electron-vite instance: unique CDP 9335, renderer 5175, dedicated ORCA_DEV_USER_DATA_PATH. window.api.app.getIdentity():

{"name":"Orca: brennanb2025/pr18700-merge-final","isDev":true,"devLabel":"pr18700-codex-loop @ brennanb2025/pr18700-merge-final","devBranch":"brennanb2025/pr18700-merge-final","devWorktreeName":"pr18700-codex-loop","devRepoRoot":"/Users/brennanbenson/orca/workspaces/orca/pr18700-codex-loop"}

No code was modified. Images were uploaded with gh image and are not in the diff.

Setting on permits structured chat

Experimental → Chat UI on, default view Chat UI, Use updated structured native chat on. New tab → Codex opened a host-owned Codex Chat tab with the structured composer (unified contentType: agent-session, session.tabs.listAll returned that agent-session tab).

Setting on in Experimental

Codex Chat mounted with setting on

Toggling off while mounted does not leave cleanup broken

Opening Settings unmounts the pane first, so the live-mounted off-toggle used the same updateSettings({ experimentalStructuredNativeChat: false }) path as the Experimental switch while Codex Chat was still on screen. Visible result: the structured tab disappeared and Terminal 1 remained. The Settings switch then showed off.

{"settingAfter":false,"unifiedAfter":[{"contentType":"terminal"}],"inventoryTabs":[{"type":"terminal","title":"Terminal 1"}],"release":{"ok":true,"result":{"released":true}},"unsubscribe":{"ok":true,"result":{"unsubscribed":true}},"hold":{"ok":false,"error":{"message":"structured_agent_session_unsupported"}}}

After toggle off — Codex Chat gone

Settings switch off after the toggle

Setting off refuses structured restoration / launch

With the setting off, session.tabs.listAll returned only the terminal tab (no agent-session). A second New tab → Codex launch created a terminal tab with the existing Chat UI overlay, not a structured Codex Chat tab.

Codex launch with setting off uses terminal-backed chat

Logs

Renderer: 0 errors from the setting toggle or structured unmount. One 404 is from this QA probe dynamically importing local-structured-session-tabs-sync.ts (not an app path). Remaining warnings are the usual React Grab / tooltip / xterm deadline noise. Main log: no structured_agent_session_unsupported from the user toggle; explorer FileListingCancelledError only.

Gaps (not overstated)

  • Full process restart restoration was not re-run at this HEAD; refusal was shown on the live session.tabs.listAll wire after disable, not after a cold start.
  • No paired mobile or remote/relay client in this rig.
  • The live-mounted off-toggle used the persisted settings action rather than clicking the switch while the composer was still visible, because Settings navigation unmounts the pane first. The switch was then confirmed off in the Experimental pane.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Final review status

Ready from code and validation perspective at cf05c8631a2.

  • Merged origin/main with merge commit a14528d5202; the sole conflict in session-tab-agent-status-projection.test.ts was resolved by preserving both main’s newer coverage and this PR’s all-client setting policy.
  • Review found and fixed the post-disable cleanup regression so admitted clients can still release/unsubscribe without bypassing capability checks or creating a host (0450cc27f10).
  • Fixed the same-version desktop projection test fixture exposed by the first CI run (cf05c8631a2).
  • Final readiness review: zero proven P0/P1/P2 findings; 151 focused tests plus 43 settings tests passed, pnpm tc:node passed, changed-code quality reported zero findings, and cross-version wire compatibility passed.
  • All applicable GitHub checks are green, including all eight Node 24 shards and macOS/Windows packaging. GitHub reports MERGEABLE / CLEAN and the remote PR head exactly matches cf05c8631a2.
  • Electron QA passed for setting-on structured launch, live setting-off removal/cleanup, and setting-off terminal fallback; screenshots and detailed evidence are in fix(runtime): apply the structured-chat setting to every RPC caller #18700 (comment).

The PR remains intentionally draft; the only remaining step is honoring the prerequisite merge order documented in the PR body, then marking it ready.

Merge Sim added 3 commits September 5, 2026 01:02
Resolves one add/add conflict in session-tabs-structured-restore.test.ts,
where this branch and main independently added the same file covering
different callers. Keeps both suites: this branch's desktop-renderer and
in-process cases, and main's mobile cases, rewritten onto the shared
makeRuntime helper and snapshot fixture rather than main's inline copies.
…tructured policy

The merge with main left three fixtures written for the old mobile-only rule:
a duplicate getClientSettings key, a create fixture with no host settings at
all, and a projection call whose 'old client' is now the mobile fallback-title
case.
Three conflicts, all keeping both sides:
- gate: this branch's requireStructuredCleanupHost alongside main's rewritten
  doc for the host-building path (attach plus hold and reveal).
- unsubscribe: this branch's cleanup gate, so an admitted caller can still
  retire resources it owns after the setting is disabled, with main's
  extracted subscriptionBaseFor helper for the key.
- test stub: main's real status feed plus this branch's release stub.
@brennanb2025
brennanb2025 marked this pull request as ready for review September 6, 2026 18:52
@coderabbitai

coderabbitai Bot commented Sep 6, 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: Team

Run ID: 2852a059-7716-41f6-b439-a69a6049f25a

📥 Commits

Reviewing files that changed from the base of the PR and between 90978f4 and fc3e8b3.

📒 Files selected for processing (1)
  • src/main/agent-hooks/first-work-branch-rename.test.ts
💤 Files with no reviewable changes (1)
  • src/main/agent-hooks/first-work-branch-rename.test.ts

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


📝 Walkthrough

Walkthrough

The change makes experimentalStructuredNativeChat explicit across structured session policy and session-tab projection APIs. Host settings now apply to all caller kinds, while remote callers still require the negotiated capability. Cleanup operations use a capability-only host gate so release and unsubscribe can complete after the setting is disabled. Session-tab handlers pass the setting for all client kinds. Tests add shared fixtures and coverage for projection, restoration, policy, cleanup, and integration runtime settings.

Merge Risk: 🔵 Low · up to fc3e8

The setting change remains covered for its primary behavior, but cleanup with an existing host and subscribe retention need additional test coverage before relying on those paths as fully validated.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description gives a clear ELI5 summary, rationale, scope, behavior changes, evidence, and merge-order context. However, it omits required template sections and information, including the Linked Is… Add the missing template sections. Provide the required issue reference after “Fixes #”, state testing steps and platform coverage, complete or mark the testing checkboxes, complete the AI Disclosure section as applicable, address Review an…
Docstring Coverage ⚠️ Warning Docstring coverage is 16.13% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 31 functions across 26 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: applying the structured-chat setting to every RPC caller.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description gives a clear ELI5 summary, rationale, scope, behavior changes, evidence, and merge-order context. However, it omits required template sections and information, including the Linked Issue, explicit What Changed and Why sections, Testing checklist, AI Disclosure, Review, Agent skill upstream boundary, Notes, and final Checklist.

Resolution

Add the missing template sections. Provide the required issue reference after “Fixes #”, state testing steps and platform coverage, complete or mark the testing checkboxes, complete the AI Disclosure section as applicable, address Review and Agent skill upstream boundary, add Notes for security, cross-platform, SSH, mobile, compatibility, and performance impact, and complete the final Checklist.

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

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

🧹 Nitpick comments (1)
src/main/runtime/rpc/methods/structured-agent-session.test.ts (1)

470-487: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a positive cleanup test with the setting disabled.

This case sets the host to null, so both the old requireStructuredHost path and the new requireStructuredCleanupHost path return an unsupported error. It does not verify the changed contract.

Keep this refusal test. Add a case that installs hostStub(), sets experimentalStructuredNativeChat to false, and verifies successful agentSession.release and agentSession.unsubscribe calls.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 2953ba81-6903-4029-8b87-91b56c3e2296

📥 Commits

Reviewing files that changed from the base of the PR and between ffbf35e and d847364.

📒 Files selected for processing (23)
  • src/main/ipc/runtime.test.ts
  • src/main/runtime/claude-structured-session-integration.test.ts
  • src/main/runtime/rpc/methods/session-tab-agent-capability-mutations.test.ts
  • src/main/runtime/rpc/methods/session-tab-agent-status-projection.test.ts
  • src/main/runtime/rpc/methods/session-tab-agent-status-projection.ts
  • src/main/runtime/rpc/methods/session-tab-close-methods.ts
  • src/main/runtime/rpc/methods/session-tab-mutation-methods.ts
  • src/main/runtime/rpc/methods/session-tabs-inventory.ts
  • src/main/runtime/rpc/methods/session-tabs-snapshot.test-fixture.ts
  • src/main/runtime/rpc/methods/session-tabs-structured-restore.test.ts
  • src/main/runtime/rpc/methods/session-tabs.test.ts
  • src/main/runtime/rpc/methods/session-tabs.ts
  • src/main/runtime/rpc/methods/structured-agent-session-gate.ts
  • src/main/runtime/rpc/methods/structured-agent-session-hold.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session-hold.ts
  • src/main/runtime/rpc/methods/structured-agent-session-policy.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session-policy.ts
  • src/main/runtime/rpc/methods/structured-agent-session-precommit-refusal.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session.ts
  • src/main/runtime/structured-agent-session-integration-replay.test.ts
  • src/main/runtime/structured-agent-session-integration.test.ts
  • tests/e2e/cross-version-wire/cross-version-agent-session-wire.unit.test.ts

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

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

Important

agentSession.close is still gated on the host setting, but it is also a teardown path that must survive the setting being disabled. The cleanup exemption this PR introduces should extend to it (see inline comment).

Reviewed changes

  • Unified the structured-chat gate — supportsStructuredAgentSessions now consults experimentalStructuredNativeChat for every caller (runtime, mobile, in-process), and the capability check is split out as supportsStructuredAgentSessionCapability so the two terms stay independently auditable.
  • Made the projection argument required — structuredNativeChatProjectionEnabled / projectSessionTabAgentStatus now take a non-optional structuredNativeChatEnabled, and the eight non-mobile call sites that previously passed undefined now read the host setting.
  • Split cleanup off the settings gate — release and unsubscribe route through a new requireStructuredCleanupHost that checks capability only, so an admitted caller can retire resources it owns after the setting is disabled.
  • Stopped host-side restoration when off — with the flag off, session.tabs.list/listAll no longer run structured-tab restoration for the desktop renderer, via the unified supportsStructuredAgentSessions that restoreStructuredTabsIfSupported already delegates to.
  • Tests — new structured-agent-session-policy.test.ts covers the caller matrix; the restore and hold suites were rewritten onto a shared fixture; capability-mutation and projection fixtures were settled against the new single rule. Assertions are exact (call-count and projection-equality, not truthiness).

ℹ️ Nitpicks

  • isStructuredNativeChatEnabled calls runtime.getClientSettings(), which returns the full projected settings object (hostSettingOverrides via Object.fromEntries). This now runs on the desktop session.tabs.subscribe change path (onMobileSessionTabsChanged → projectSessionTabsForClient), where before the argument was undefined and short-circuited. Non-blocking, but worth a targeted boolean accessor if the change path is hot.

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

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron validation (Grok) — structured-chat settings gate

Isolated ORCA_BACKGROUND_LAUNCH=1 instance at HEAD d8473641d5, identity pr18700-review-final @ d8473641d5, CDP 127.0.0.1:9334 / renderer 5176.

Scenario: Settings → Experimental → enable Chat UI → Default view Chat UI → toggle Use updated structured native chat off/on → New tab → Codex → toggle off again.

Visible: structured toggle hidden until Chat UI + Chat UI default; Codex opened as a Codex Chat composer (not a PTY); turning the setting off removed the Codex Chat tab, leaving Terminal 1.

Host (desktop renderer runtime caller):

  • setting off → agentSession.createSupport → structured_agent_session_unsupported
  • setting on → { supported: true } for Codex/Claude; session.tabs.listAll included { type: "agent-session", title: "Codex Chat" }
  • setting off after launch → createSupport refused again; listAll no longer had the agent-session row

Not verified here: process-restart restoration, mobile/paired clients, Claude launch, sending a prompt, SSH/WSL fallback.

Screenshots (not committed):

Structured toggle off
04-structured-toggle-off.png

Structured toggle on
05-structured-toggle-on.png

New tab → Codex
07-new-tab-agent-picker.png

Codex structured chat (setting on)
08-codex-structured-chat-on.png

Toggle off after session
09-structured-toggle-off-after-session.png

Workspace after disable — Codex Chat tab gone
10-workspace-after-structured-off.png

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status for current head d8473641d551aab8339995642eee684268545150: clean after fresh review.

What I checked:

  • Re-reviewed the current diff from scratch after the two main merges and test fix, with special attention to structured-agent-session-gate.ts, structured-agent-session.ts, and structured-agent-session.test.ts merge resolutions.
  • Verified the caller policy shape: the structured-chat setting gates mobile callers, desktop/runtime callers, and in-process callers with clientKind undefined; negotiated capability is still required for remote clients.
  • Verified the cleanup carve-out shape: agentSession.release / cleanup-only paths bypass the setting only after capability negotiation and only against an already-installed host, so turning the setting off mid-session does not strand held resources.
  • Ran start and end readiness-checklist passes via subagents, plus a separate senior review/fix-loop subagent. No proven P0/P1/P2 issues were found and no code changes were needed.
  • Used Electron/CDP validation in an isolated background Orca profile. Evidence comment with screenshots: fix(runtime): apply the structured-chat setting to every RPC caller #18700 (comment)

Local verification passed:

  • pnpm test src/main/runtime/rpc/methods/structured-agent-session-policy.test.ts src/main/runtime/rpc/methods/structured-agent-session.test.ts src/main/runtime/rpc/methods/structured-agent-session-hold.test.ts — 58 tests passed.
  • pnpm test src/main/runtime/rpc/methods/session-tabs-structured-restore.test.ts src/main/runtime/rpc/methods/session-tab-agent-status-projection.test.ts tests/e2e/cross-version-wire/cross-version-agent-session-wire.unit.test.ts — 34 tests passed.
  • pnpm run check:code-quality:changed — 0 new findings across 23 changed files.

Residual gaps: full-repo typecheck/full test suite, native mobile emulator pairing flow, process-restart restoration with a persisted structured session, Claude launch, SSH/WSL coverage, and prompt send were not exercised in this review pass. Based on the inspected code, focused tests, and Electron evidence, I found no blocker to landing this PR.

Merge Sim added 2 commits September 6, 2026 13:28
…ng is off

Turning `experimentalStructuredNativeChat` off revoked admission for every
`agentSession.*` method, including `close`. A chat opened while the setting was
on stays mounted, so its owner was left with a live provider child and an X
button that answered `structured_agent_session_unsupported`.

Split the surface by what a method does to work in flight rather than by how it
sounds, and write that rule where the gate lives so the next method lands on the
right side: starting, extending, retaining or reading needs admission; stopping
or retiring work the caller already owns does not. Moves `close` and `cancel`
onto the cleanup gate alongside `unsubscribe` and `release`.

The tightening is unchanged - the cleanup gate still demands the negotiated wire
capability and never creates a host, so an incapable client still cannot see the
surface and no method that starts work is reachable with the setting off.

Extracts the dispatcher harness and the method-to-gate table into fixtures so
the new admission suite can share them without a max-lines disable.
@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@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 — the prior agentSession.close finding is resolved cleanly.

Reviewed changes

  • Extended the cleanup exemption to close and cancel — both now route through requireStructuredCleanupHost instead of requireHost, so an admitted caller can stop an in-flight turn or close a chat after the host setting is disabled, matching the rationale documented on the gate.
  • Added a method-to-gate classification fixture — structured-agent-session-gate-classification.test-fixture.ts pins every agentSession.* method to exactly one of CLEANUP_METHODS / ADMISSION_METHODS, with the gate's doc comment as the source of truth.
  • Added an admission-revocation suite — structured-agent-session-admission.test.ts verifies cleanup methods stay served (and the durable tab is retired via setSessionTabVisibility) once the setting is off, while every admission method stays refused with an exact structured_agent_session_unsupported error.
  • Extracted a shared dispatcher harness — structured-agent-session-rpc.test-fixture.ts centralizes the wire-boundary stub, hostCalls/runtimeCalls identity, and the call helper.
  • Settled integration fixtures on the setting — the replay, integration and cross-version wire fixtures now provide getClientSettings, so they exercise the new single rule rather than the pre-change short-circuit.

Pullfrog  | View workflow run | Using DeepSeek Pro (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: Team

Run ID: c43f60d4-64c4-4ed7-8a6b-177905e45267

📥 Commits

Reviewing files that changed from the base of the PR and between 15d0f8a and b18ec98.

📒 Files selected for processing (26)
  • src/main/ipc/runtime.test.ts
  • src/main/runtime/claude-structured-session-integration.test.ts
  • src/main/runtime/rpc/methods/session-tab-agent-capability-mutations.test.ts
  • src/main/runtime/rpc/methods/session-tab-agent-status-projection.test.ts
  • src/main/runtime/rpc/methods/session-tab-agent-status-projection.ts
  • src/main/runtime/rpc/methods/session-tab-close-methods.ts
  • src/main/runtime/rpc/methods/session-tab-mutation-methods.ts
  • src/main/runtime/rpc/methods/session-tabs-inventory.ts
  • src/main/runtime/rpc/methods/session-tabs-snapshot.test-fixture.ts
  • src/main/runtime/rpc/methods/session-tabs-structured-restore.test.ts
  • src/main/runtime/rpc/methods/session-tabs.test.ts
  • src/main/runtime/rpc/methods/session-tabs.ts
  • src/main/runtime/rpc/methods/structured-agent-session-admission.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session-gate-classification.test-fixture.ts
  • src/main/runtime/rpc/methods/structured-agent-session-gate.ts
  • src/main/runtime/rpc/methods/structured-agent-session-hold.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session-hold.ts
  • src/main/runtime/rpc/methods/structured-agent-session-policy.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session-policy.ts
  • src/main/runtime/rpc/methods/structured-agent-session-precommit-refusal.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session-rpc.test-fixture.ts
  • src/main/runtime/rpc/methods/structured-agent-session.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session.ts
  • src/main/runtime/structured-agent-session-integration-replay.test.ts
  • src/main/runtime/structured-agent-session-integration.test.ts
  • tests/e2e/cross-version-wire/cross-version-agent-session-wire.unit.test.ts
🚧 Files skipped from review as they are similar to previous changes (21)
  • tests/e2e/cross-version-wire/cross-version-agent-session-wire.unit.test.ts
  • src/main/ipc/runtime.test.ts
  • src/main/runtime/rpc/methods/session-tabs.test.ts
  • src/main/runtime/rpc/methods/session-tabs.ts
  • src/main/runtime/rpc/methods/session-tabs-inventory.ts
  • src/main/runtime/claude-structured-session-integration.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session-policy.ts
  • src/main/runtime/structured-agent-session-integration-replay.test.ts
  • src/main/runtime/rpc/methods/session-tab-agent-status-projection.ts
  • src/main/runtime/rpc/methods/session-tabs-snapshot.test-fixture.ts
  • src/main/runtime/rpc/methods/structured-agent-session-precommit-refusal.test.ts
  • src/main/runtime/rpc/methods/session-tab-agent-capability-mutations.test.ts
  • src/main/runtime/rpc/methods/session-tab-agent-status-projection.test.ts
  • src/main/runtime/rpc/methods/session-tab-close-methods.ts
  • src/main/runtime/rpc/methods/structured-agent-session-policy.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session-hold.ts
  • src/main/runtime/structured-agent-session-integration.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session-gate.ts
  • src/main/runtime/rpc/methods/session-tab-mutation-methods.ts
  • src/main/runtime/rpc/methods/structured-agent-session-hold.test.ts
  • src/main/runtime/rpc/methods/session-tabs-structured-restore.test.ts

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

Comment on lines +181 to +182
unsubscribe: vi.fn(),
release: vi.fn()

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

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Confirm which host members the registered structured session methods require.
set -euo pipefail

fd -t f 'structured-agent-session-host.ts' -x ast-grep outline {} --items all

fd -t f 'structured-agent-session*.ts' -E '*.test.ts' -E '*.test-fixture.ts' \
  | xargs rg -n -C2 '\bhost\.(hold|release|unsubscribe)\s*\('

fd -t f 'structured-agent-session-hold.ts' -x rg -n -C4 'requireStructured|\.hold\(|defineMethod' {}

Repository: stablyai/orca

Length of output: 5368


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- fixture ---'
sed -n '105,190p' src/main/runtime/rpc/methods/structured-agent-session-rpc.test-fixture.ts

printf '%s\n' '--- subscribe handler ---'
sed -n '225,275p' src/main/runtime/rpc/methods/structured-agent-session.ts

printf '%s\n' '--- hold contract and implementation ---'
rg -n -C5 'hold\s*[:(]|async hold|hold\(' \
  src/main/native-chat/agent-session-wire/structured-agent-session-host.ts \
  src/main/native-chat/agent-session-wire/structured-agent-session-host-types.ts \
  src/main/runtime/rpc/methods/structured-agent-session-hold.ts

Repository: stablyai/orca

Length of output: 8125


Add a hold mock to hostStub().

The agentSession.subscribe and agentSession.hold handlers call host.hold(...). The fixture does not define this member, and the cast hides the mismatch. These handlers therefore fail when used through this fixture.

🐛 Proposed fix
     unsubscribe: vi.fn(),
-    release: vi.fn()
+    release: vi.fn(),
+    hold: vi.fn(async () => undefined)

StructuredAgentSessionHost.hold returns Promise<void>.

📝 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
unsubscribe: vi.fn(),
release: vi.fn()
unsubscribe: vi.fn(),
release: vi.fn(),
hold: vi.fn(async () => undefined)

One conflict in structured-agent-session.test.ts: this branch extracted the
inline test helpers into shared fixtures while main edited them in place. Kept
the fixture imports after verifying every helper value is identical on both
sides, so none of main's edits are lost, and all 36 of its tests survive.

Also restores journal.lastActivityAt on the fixture's status stub. The
extraction had dropped it, which broke agentSession.subscribeStatus with
"journal.lastActivityAt is not a function" — it is where the expected
updatedAt comes from.
@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

The main commit this branch merged (fb32204) had two lastActivityAt
properties in the same object literal at both journal stubs, which fails
TS1117 and oxlint. Upstream has since kept only the later value; match it.

Not introduced here, but merged in, so it has to be fixed here.
@brennanb2025
brennanb2025 merged commit ba4e79c into main Sep 7, 2026
28 checks passed
nwparker added a commit that referenced this pull request Sep 7, 2026
…tured gate (#19246)

Semantic conflict between two green PRs. #19176 added this replay test while
`agentSession.*` still admitted a `runtime` client on its negotiated capability
alone; #18700 then made `experimentalStructuredNativeChat` one rule for every
caller. Neither branch saw the other, and main runs no post-merge test gate, so
`agentSession.create` started refusing at the envelope level and the test's
`ok: true` expectation broke.

#18700's rule is the intended behaviour and `create` starts work, so it belongs
behind the gate. The fixture is what is stale: it builds a real
`OrcaRuntimeService` whose client settings are unset. Enable the setting the way
#18700 already did for the sibling pre-commit fixture. The assertions about
durable-identity replay are untouched and now actually run.
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 7, 2026
…tablyai#18700)

* fix(runtime): apply the structured-chat setting to every RPC caller

supportsStructuredAgentSessions only consulted experimentalStructuredNativeChat
when clientKind === 'mobile', so identical host settings admitted desktop and
in-process callers while refusing a phone. The server branched on client surface.

The setting is now one rule for every caller. The negotiated capability stays a
wire term asked of remote clients only, so a capability-less in-process caller is
still admitted on the setting alone.

Making the projection's structuredNativeChatEnabled argument required surfaced
eight call sites that passed `undefined` for non-mobile clients; they now read the
host setting, so tab projection follows the same single rule.

Announced behaviour change: with the flag off, session.tabs.list/listAll no longer
restore structured tabs for desktop. The desktop renderer already discards them in
that state, and startup record/lease reconciliation is unaffected.

* fix(runtime): keep structured session cleanup available

* test(runtime): enable structured chat in desktop projection fixture

* test(agent-session): settle merged fixtures against the all-clients structured policy

The merge with main left three fixtures written for the old mobile-only rule:
a duplicate getClientSettings key, a create fixture with no host settings at
all, and a projection call whose 'old client' is now the mobile fallback-title
case.

* fix(native-chat): let an admitted caller close a chat after the setting is off

Turning `experimentalStructuredNativeChat` off revoked admission for every
`agentSession.*` method, including `close`. A chat opened while the setting was
on stays mounted, so its owner was left with a live provider child and an X
button that answered `structured_agent_session_unsupported`.

Split the surface by what a method does to work in flight rather than by how it
sounds, and write that rule where the gate lives so the next method lands on the
right side: starting, extending, retaining or reading needs admission; stopping
or retiring work the caller already owns does not. Moves `close` and `cancel`
onto the cleanup gate alongside `unsubscribe` and `release`.

The tightening is unchanged - the cleanup gate still demands the negotiated wire
capability and never creates a host, so an incapable client still cannot see the
surface and no method that starts work is reachable with the setting off.

Extracts the dispatcher harness and the method-to-gate table into fixtures so
the new admission suite can share them without a max-lines disable.

* Drop a duplicate lastActivityAt key carried in from main

The main commit this branch merged (fb32204) had two lastActivityAt
properties in the same object literal at both journal stubs, which fails
TS1117 and oxlint. Upstream has since kept only the later value; match it.

Not introduced here, but merged in, so it has to be fixed here.

---------

Co-authored-by: Merge Sim <sim@local>
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 7, 2026
…tured gate (stablyai#19246)

Semantic conflict between two green PRs. stablyai#19176 added this replay test while
`agentSession.*` still admitted a `runtime` client on its negotiated capability
alone; stablyai#18700 then made `experimentalStructuredNativeChat` one rule for every
caller. Neither branch saw the other, and main runs no post-merge test gate, so
`agentSession.create` started refusing at the envelope level and the test's
`ok: true` expectation broke.

stablyai#18700's rule is the intended behaviour and `create` starts work, so it belongs
behind the gate. The fixture is what is stale: it builds a real
`OrcaRuntimeService` whose client settings are unset. Enable the setting the way
stablyai#18700 already did for the sibling pre-commit fixture. The assertions about
durable-identity replay are untouched and now actually run.
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