Repository navigation
fix(runtime): apply the structured-chat setting to every RPC caller - #18700
Conversation
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.
Visual proof — runtime differential on a real Electron instanceTested at 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 BEFORE — fix ablated to the pre-PR predicate,
|
…merge-final # Conflicts: # src/main/runtime/rpc/methods/session-tab-agent-status-projection.test.ts
Electron QA — structured-chat setting at
|
Final review statusReady from code and validation perspective at
The PR remains intentionally draft; the only remaining step is honoring the prerequisite merge order documented in the PR body, then marking it ready. |
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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughThe change makes Merge Risk: 🔵 Low · up to 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)
✅ Passed checks (3 passed)
Full details: Description checkExplanation 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.
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/runtime/rpc/methods/structured-agent-session.test.ts (1)
470-487: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a positive cleanup test with the setting disabled.
This case sets the host to
null, so both the oldrequireStructuredHostpath and the newrequireStructuredCleanupHostpath return an unsupported error. It does not verify the changed contract.Keep this refusal test. Add a case that installs
hostStub(), setsexperimentalStructuredNativeChattofalse, and verifies successfulagentSession.releaseandagentSession.unsubscribecalls.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 2953ba81-6903-4029-8b87-91b56c3e2296
📒 Files selected for processing (23)
src/main/ipc/runtime.test.tssrc/main/runtime/claude-structured-session-integration.test.tssrc/main/runtime/rpc/methods/session-tab-agent-capability-mutations.test.tssrc/main/runtime/rpc/methods/session-tab-agent-status-projection.test.tssrc/main/runtime/rpc/methods/session-tab-agent-status-projection.tssrc/main/runtime/rpc/methods/session-tab-close-methods.tssrc/main/runtime/rpc/methods/session-tab-mutation-methods.tssrc/main/runtime/rpc/methods/session-tabs-inventory.tssrc/main/runtime/rpc/methods/session-tabs-snapshot.test-fixture.tssrc/main/runtime/rpc/methods/session-tabs-structured-restore.test.tssrc/main/runtime/rpc/methods/session-tabs.test.tssrc/main/runtime/rpc/methods/session-tabs.tssrc/main/runtime/rpc/methods/structured-agent-session-gate.tssrc/main/runtime/rpc/methods/structured-agent-session-hold.test.tssrc/main/runtime/rpc/methods/structured-agent-session-hold.tssrc/main/runtime/rpc/methods/structured-agent-session-policy.test.tssrc/main/runtime/rpc/methods/structured-agent-session-policy.tssrc/main/runtime/rpc/methods/structured-agent-session-precommit-refusal.test.tssrc/main/runtime/rpc/methods/structured-agent-session.test.tssrc/main/runtime/rpc/methods/structured-agent-session.tssrc/main/runtime/structured-agent-session-integration-replay.test.tssrc/main/runtime/structured-agent-session-integration.test.tstests/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.
There was a problem hiding this comment.
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 —
supportsStructuredAgentSessionsnow consultsexperimentalStructuredNativeChatfor every caller (runtime,mobile, in-process), and the capability check is split out assupportsStructuredAgentSessionCapabilityso the two terms stay independently auditable. - Made the projection argument required —
structuredNativeChatProjectionEnabled/projectSessionTabAgentStatusnow take a non-optionalstructuredNativeChatEnabled, and the eight non-mobile call sites that previously passedundefinednow read the host setting. - Split cleanup off the settings gate —
releaseandunsubscriberoute through a newrequireStructuredCleanupHostthat 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/listAllno longer run structured-tab restoration for the desktop renderer, via the unifiedsupportsStructuredAgentSessionsthatrestoreStructuredTabsIfSupportedalready delegates to. - Tests — new
structured-agent-session-policy.test.tscovers 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
isStructuredNativeChatEnabledcallsruntime.getClientSettings(), which returns the full projected settings object (hostSettingOverridesviaObject.fromEntries). This now runs on the desktopsession.tabs.subscribechange path (onMobileSessionTabsChanged→projectSessionTabsForClient), where before the argument wasundefinedand short-circuited. Non-blocking, but worth a targeted boolean accessor if the change path is hot.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Electron validation (Grok) — structured-chat settings gateIsolated 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
Not verified here: process-restart restoration, mobile/paired clients, Claude launch, sending a prompt, SSH/WSL fallback. Screenshots (not committed): |
|
Review status for current head What I checked:
Local verification passed:
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. |
…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.
|
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. |
There was a problem hiding this comment.
✅ No new issues found — the prior
agentSession.closefinding is resolved cleanly.
Reviewed changes
- Extended the cleanup exemption to
closeandcancel— both now route throughrequireStructuredCleanupHostinstead ofrequireHost, 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.tspins everyagentSession.*method to exactly one ofCLEANUP_METHODS/ADMISSION_METHODS, with the gate's doc comment as the source of truth. - Added an admission-revocation suite —
structured-agent-session-admission.test.tsverifies cleanup methods stay served (and the durable tab is retired viasetSessionTabVisibility) once the setting is off, while every admission method stays refused with an exactstructured_agent_session_unsupportederror. - Extracted a shared dispatcher harness —
structured-agent-session-rpc.test-fixture.tscentralizes the wire-boundary stub,hostCalls/runtimeCallsidentity, and thecallhelper. - 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.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: c43f60d4-64c4-4ed7-8a6b-177905e45267
📒 Files selected for processing (26)
src/main/ipc/runtime.test.tssrc/main/runtime/claude-structured-session-integration.test.tssrc/main/runtime/rpc/methods/session-tab-agent-capability-mutations.test.tssrc/main/runtime/rpc/methods/session-tab-agent-status-projection.test.tssrc/main/runtime/rpc/methods/session-tab-agent-status-projection.tssrc/main/runtime/rpc/methods/session-tab-close-methods.tssrc/main/runtime/rpc/methods/session-tab-mutation-methods.tssrc/main/runtime/rpc/methods/session-tabs-inventory.tssrc/main/runtime/rpc/methods/session-tabs-snapshot.test-fixture.tssrc/main/runtime/rpc/methods/session-tabs-structured-restore.test.tssrc/main/runtime/rpc/methods/session-tabs.test.tssrc/main/runtime/rpc/methods/session-tabs.tssrc/main/runtime/rpc/methods/structured-agent-session-admission.test.tssrc/main/runtime/rpc/methods/structured-agent-session-gate-classification.test-fixture.tssrc/main/runtime/rpc/methods/structured-agent-session-gate.tssrc/main/runtime/rpc/methods/structured-agent-session-hold.test.tssrc/main/runtime/rpc/methods/structured-agent-session-hold.tssrc/main/runtime/rpc/methods/structured-agent-session-policy.test.tssrc/main/runtime/rpc/methods/structured-agent-session-policy.tssrc/main/runtime/rpc/methods/structured-agent-session-precommit-refusal.test.tssrc/main/runtime/rpc/methods/structured-agent-session-rpc.test-fixture.tssrc/main/runtime/rpc/methods/structured-agent-session.test.tssrc/main/runtime/rpc/methods/structured-agent-session.tssrc/main/runtime/structured-agent-session-integration-replay.test.tssrc/main/runtime/structured-agent-session-integration.test.tstests/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.
| unsubscribe: vi.fn(), | ||
| release: vi.fn() |
There was a problem hiding this comment.
🩺 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.tsRepository: 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.
| 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.
|
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.
…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.
…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>
…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.
















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:
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.listAllcallrestoreStructuredTabsIfSupportedunconditionally, and the desktop renderer calls those routinely. With the setting off, that still ranrestoreStructuredAgentSessionTabsOnce— 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
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 passingundefined; those now read the host setting.Evidence
refreshLocalStructuredSessionTabs()over the real wire rather than relying on the automatic startup path.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.