Skip to content

feat(native-chat): Codex structured native chat restructure - #16729

Merged
brennanb2025 merged 61 commits into
mainfrom
tmp/native-chat-recovery-main-integration
Aug 28, 2026
Merged

brennanb2025 merged 61 commits into
mainfrom
tmp/native-chat-recovery-main-integration

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 234 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​34856 $\color{#cf222e}{\Huge{\mathbf{−}}}$​496 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​34360
Prod 381 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​29652 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1146 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​28506

Summary

Codex host-owned structured native chat behind the existing experimental native-chat setting (default off): durable journal/recovery, single-writer ownership, restart reconciliation, tab/session restoration, and provider capability/refusal gates.

Branch state

  • Final head: 2c8c21b960fe20c51ce989ce5d529253e415b0b1.
  • Latest merged main: 4cb013c0a9251275fa3d20ea33b45429e07aa6be, integrated by normal merge commit 2c8c21b960.
  • GitHub reports the open PR MERGEABLE / merge state CLEAN.

Final verification

  • PR Checks 33219108286: success on the exact final head (26 success, 1 path-skipped), including Node 24 typecheck, static/type-aware/changed-code analysis, reliability manifest, 8 unit shards, cross-version wire, Git/shell contracts, macOS/Windows packaging, changed-spec e2e, Docker SSH isolation/readiness, and aggregate verify.
  • Computer-use e2e 33219108009: success (3 native smoke/owner-loss jobs, 3 platform path-skips). PR test LoC 33219107988: success. Total: 30 successful jobs, 4 intentional skips.
  • After the final main integration: 11 focused daemon/PTY/structured-session files, 113 tests passed; Node 24 pnpm tc passed. The preceding full focused branch suite passed 32 files / 408 tests.
  • Changed-code quality, type-aware quality, React Doctor, exact format across 613 branch files, git diff --check, deletion/status checks passed; reliability manifest: 99/99 gates.
  • Changed-code wrapper caveat: the standard script also scanned protected untracked qa-* evidence and reported 19 findings; the tracked-only execution of the same gate passed with 0 findings across 604 files, and those QA artifacts were preserved untouched.
  • QA-wrapper caveat: a supplied mobile test path is outside the root Vitest transform/discovery surface and was ignored, so no mobile QA result is claimed. The desktop cross-client integration test source-pins the shipping mobile payload builder.
  • Earlier cross-version wire compatibility failures were branch-owned release-checkout harness defects, fixed by the race-safe materialization/import/lifecycle changes; the final exact-head cross-version lane is green.

Reliability contract

  • Invariant: the execution host is the authoritative single writer for structured provider ownership and durable session state; lost contact is never treated as process exit, and disjoint persisted-UI updates must not restore stale sibling fields.
  • Oracle: ownership/lease/journal/restart/outbox/startup tests plus exact-head cross-version, SSH/e2e, typecheck, static analysis, and visible Electron persistence checks.
  • Gate: agent-session.provider-ownership (included in the 99/99 passing reliability manifest).
  • Provider coverage: Codex structured adapter is covered. No Claude structured adapter or entry point ships; unsupported Windows/WSL/SSH/remote execution paths refuse structured mode and retain terminal fallback.
  • Performance: ack-window UI edits remain debounced/coalesced rather than flushing at IPC-ack rate; journal/history bounds, cleanup, and single-flight behavior remain contract-tested.
  • Diagnostics: refusal/recovery/exit proofs, unhandled provider frames, write-gate failures, and restart reconciliation have explicit test/telemetry surfaces; final Electron validation showed no product console errors.
  • Residual gaps: no live two-client desktop/mobile race was run; no mobile QA is claimed; real Windows/WSL/SSH fallback hosts and final-head packaged Linux/Windows builds were not manually exercised.

Electron proof

  • Earlier isolated macOS proof at d351842f0e: fresh profile, default-off confirmed, structured chat enabled through the real experimental toggle, Codex structured send → response, restart preservation, and toggle-off terminal fallback.
  • Post-8cf7c692 UI-integration CDP proof: activated the real finback workspace and rendered a monitoring agent through the real status store; the workspace card, inline agent row, and terminal tab all showed the heartbeat design, with 3 glyphs, 2 accessible Monitoring background tasks labels, the expected hover tooltip, and zero console errors. The later 4cb013c0 integration changed daemon tests only, so no additional rendered behavior was introduced.

structured chat toggle
codex structured response

Scope & platform disclaimer

  • Feature is experimental and default-off; enabling is an explicit per-user setting. Structured mode is limited to eligible local macOS/Linux sessions.
  • Windows, WSL, SSH, and remote execution hosts are capability-gated/refused and continue through the existing terminal flow.
  • Excluded from this PR: Claude structured adapter, mobile client work, and terminal↔native one-click switching. Legacy terminal sessions remain supported.
  • Remaining manual gaps are final-head packaged behavior and live fallback exercises on real Windows/WSL/SSH hosts. Known non-blocking follow-ups remain provider-owned activity-indicator UX (ORC-8), reconnect retry backoff, and packaged listener warning cleanup.

Ad-hoc build

…covery

Rebuilds the desktop structured native-chat implementation from
brennanb2025/native-chat-restructure-recovery (tip 4e31c08) on top of
current main as a single commit, scoped to the local Codex path.

Ported:
- Structured agent-session core: durable record store + single-writer lease,
  canonical journal, agent-session wire host/attach/eviction/subscribers,
  `agentSession.*` RPC surface (registered via ALL_RPC_METHODS; host-side
  mobile allowlist included for wire compat), pty write gate, transcript
  additions, and the Codex app-server adapter/launch resolution.
- Renderer: NativeChatStructuredSession view/composer stack, structured
  launch path with the single-flight guard, local structured session tabs
  sync, activation gate + structured inventory (read-only
  `agentSession.handoffStatus` probe), agent-session tabs in the tab strip,
  AI-vault structured session activation, and the settings pane with the
  parent Experimental Chat UI toggle plus the nested "Use updated structured
  native chat" toggle. New sessions require both flags, agent codex, no
  prompt, and a local non-WSL, non-Windows-host execution host
  (structured-native-chat-availability).
- Fixes 72c013c (verified Codex launch recovery), 8ddbaf5 (defer
  native terminal view switching affordances), and 4e31c08 (release the
  launch gate after a visibility retry) with their regression tests,
  including the third-launch-after-retry guard case.
- Cross-version agent-session wire test + CI lane, packaging entries
  (proper-lockfile, agent-tooling asar excludes), and the wire-compat doc
  section.

Deliberately not ported: mobile/ changes, the Claude structured runtime
(only the claude-transcript-branch-proof and claude-structured-owner-identity
leaf modules remain, backing the kept TUI-recovery arms), the terminal↔chat
adoption/handoff flow (`agentSession.adoptTerminal`/`requestHandoff`, the
handoff request engine, TUI adoption machinery, orca-runtime adoption
methods), renderer switching affordances and their dead leftovers, the
hook/subagent-status refactor cluster, and unrelated branch changes. The
crash-during-acquisition recovery path (restart handoff adjudication,
restore/reverse re-acquire, lease schema handoff keys) is kept because every
plain direct launch depends on it; a trimmed handoff coordinator exposes
only status/restore/close.

Branch edits that targeted files main has since split (ipc/pty.ts,
worktrees.ts, rpc/methods/terminal.ts, useIpcEvents, pty-connection,
store/slices/terminals.ts, runtime-types, web preload) were re-applied to
the split modules, preserving main's newer logic (Windows CIM fallback,
browser tab close rework, cold-restore resume flow, dispatcher threading).

Known seam: the mobile clipboard image-provenance CONSUMER gate ships
(agentSession.send refuses unproven mobile image refs with
agent_session_image_untrusted) but the producer hunk in
rpc/methods/clipboard.ts stays with the unported mobile cluster, so mobile
image sends into structured chat fail closed until that side ports.
…ge dir

gyp expands the node-addon-api dependency by probing node, whose cwd
resolves to the package's physical directory in the store, so the emitted
target is a store-relative ../../../../node-addon-api@... hop. gyp then
resolves that hop against the rebuild cwd; from the node_modules
symlink/junction it escapes the store and configure fails with
"node_addon_api.gyp not found" (run 32999886072).

Rebuild from realpath(package dir) so both bases agree, matching how the
package manager itself runs native install scripts. The regression test
replays gyp's expansion+resolution against the planned cwd and fails
without the fix.
…empty-worktree launches

Two proven blockers in the native Codex tab contract:

closeTerminalTab pre-empted the canonical unified close. With one terminal
left it deactivated the worktree on a terminal/editor/browser-only check,
blanking a workspace that still held a renderable agent-session tab; with
two or more it pre-picked a successor from terminal entities only,
re-stamping the group active before closeUnifiedTab's MRU/neighbor repair
could land on the chat tab. Successor choice now defers to the unified
contract whenever the terminal has a unified row, and deactivation is
gated on the unified renderable count (matching leaveWorktreeIfEmpty),
with the legacy pre-pick kept only for terminals without a unified row.

A structured session created on an empty worktree was published into the
host's headless group while preserveLocalLayout froze the local layout,
leaving the tab in store but permanently off screen. A preserveLocalLayout
owner now always takes client-owned placement — repairing a rendered
leaf whose group record is missing, or materializing a rendered group on a
truly empty worktree — and applies the client-derived layout repair while
still rejecting host-authored layout.

Regression tests drive the real store through closeTerminalTab (git
worktree and folder workspace) and the real snapshot applier for the
empty-worktree adoption states; all fail without the fixes.
…hat-current-main

# Conflicts:
#	src/main/index.ts
…ery-main-integration

# Conflicts:
#	src/main/runtime/orca-runtime.ts
#	src/main/startup/desktop-startup-ordering.test.ts
#	src/shared/child-process/__fixtures__/child-process-import-allowlist.txt
…6117)

* fix(native-chat): anchor an unmatched chat echo where it was sent

The reported symptom was old user messages replaying below every new turn, so the
conversation read as scrambled. The cause was not that the echo failed to match a
transcript row. Claude consumes a mid-turn send through a `queued_command`
attachment and writes no `type:"user"` record for it, so some echoes can never
match, and no amount of matching will change that. The cause was WHERE an
unmatched echo rendered: buildMobileNativeChatTransientData appended every pending
item after the entire transcript, so it re-read below each turn that landed
afterwards.

Render each echo directly after the transcript row it was sent against, using the
baseline the send already captures. An unmatched echo is then at worst a duplicate
in the right position rather than a scrambled one, and it stays visible. Echoes
sharing an anchor keep send order; a send with no baseline, or one whose anchor
folding dropped, still falls back to the tail.

Deliberately NOT fixed by deleting the echo. Inferring from send ordering that an
echo can never match, then removing it, loses the user's own text for a message
the agent did receive, and it cannot fire in the common case anyway - measured
drain groups are 1,017 of size 1 against 55 larger. It also escalates an existing
gap: the count pass has no baseline-tail guard, unlike the glue pass, while
`messages` is a 40-row window that head-trims, resets on reconnect and grows at
the front on loadEarlier, so a false landing there would license deleting a
DIFFERENT outstanding message.

That count-pass gap is real and left for a separate change; anchoring makes its
worst case a duplicate in place rather than a scrambled conversation.

* fix(native-chat): preserve folded echo anchors

* fix(native-chat): preserve forward-folded echo anchors

* fix(native-chat): keep leading folded echoes in place
canUseStructuredNativeChat only refused win32 when a project runtime
resolved, so folder-workspace keys (and other keys with no project
runtime) failed open into structured chat on Windows. Fail closed on
win32 unconditionally after the host check, matching the settings copy:
local macOS/Linux only; Windows/WSL/SSH stay on terminal chat.
506d375 replaced the project-runtime checks with a bare platform test,
so a WSL or repair-required runtime resolution would no longer refuse
structured chat off-win32. Keep the unconditional win32 refusal and
re-run the runtime resolution after it, so the gate does not depend on
the resolver's own platform guard. Tests inject WSL and repair-required
resolutions on darwin/linux and fail against the regressed gate.
brennanb2025 pushed a commit that referenced this pull request Sep 3, 2026
… only

#16729 removed every user-facing terminal<->chat switching affordance as a
side effect of the structured Codex restructure ("renderer switching
affordances and their dead leftovers"). That was right for structured Codex
sessions, which render their own transcript with no live TUI underneath, but
it also took the switcher away from bridge native chat, which still reads the
terminal and has one to return to.

Restore all four surfaces, each gated so structured sessions keep the removal:

- pane header chat/terminal button (TerminalPaneHeaderOverlay)
- pane context-menu "Switch to chat/terminal view" (TerminalContextMenu)
- tab context-menu equivalent (SortableTabContextMenu)
- the keyboard chord, whose hook had survived uncalled since #16729

Gating is one rule in one place: `canSwitchNativeChatView` refuses whenever a
`structuredSessionId` is present, over the existing `canToggleNativeChat`
eligibility. Standalone structured tabs are already excluded by the
`contentType === 'terminal'` check; the new guard covers a terminal tab that
adopted a structured session. The shortcut hook applies the same rule.

The state plumbing (`viewMode`, `setTabViewMode`, `toggleTabViewMode`, host
mirroring, `native_chat_toggled` telemetry) was never removed, so this rewires
live actions rather than reintroducing logic.

SortableTab.tsx sat exactly at its 400-line cap, so its inline-rename state and
the window rename-request listener move to `use-sortable-tab-rename.ts` to make
room. No behavior change; its rename tests pass unmodified.

Two ratchets move for real, explained in place:
- store-subscription budget: per-pane listeners stay pinned at 17 (the folded
  action bundle is still one listener); only the counterfactual pre-fold
  constant grows 48 -> 49 for the added `toggleTabViewMode` key.
- hook-order parity: 204 -> 208 hooks for the four added `useCallback`s,
  useMemo count unchanged at 8.
brennanb2025 added a commit that referenced this pull request Sep 3, 2026
… only (#18532)

* feat(native-chat): restore the terminal/chat switcher for bridge chat only

#16729 removed every user-facing terminal<->chat switching affordance as a
side effect of the structured Codex restructure ("renderer switching
affordances and their dead leftovers"). That was right for structured Codex
sessions, which render their own transcript with no live TUI underneath, but
it also took the switcher away from bridge native chat, which still reads the
terminal and has one to return to.

Restore all four surfaces, each gated so structured sessions keep the removal:

- pane header chat/terminal button (TerminalPaneHeaderOverlay)
- pane context-menu "Switch to chat/terminal view" (TerminalContextMenu)
- tab context-menu equivalent (SortableTabContextMenu)
- the keyboard chord, whose hook had survived uncalled since #16729

Gating is one rule in one place: `canSwitchNativeChatView` refuses whenever a
`structuredSessionId` is present, over the existing `canToggleNativeChat`
eligibility. Standalone structured tabs are already excluded by the
`contentType === 'terminal'` check; the new guard covers a terminal tab that
adopted a structured session. The shortcut hook applies the same rule.

The state plumbing (`viewMode`, `setTabViewMode`, `toggleTabViewMode`, host
mirroring, `native_chat_toggled` telemetry) was never removed, so this rewires
live actions rather than reintroducing logic.

SortableTab.tsx sat exactly at its 400-line cap, so its inline-rename state and
the window rename-request listener move to `use-sortable-tab-rename.ts` to make
room. No behavior change; its rename tests pass unmodified.

Two ratchets move for real, explained in place:
- store-subscription budget: per-pane listeners stay pinned at 17 (the folded
  action bundle is still one listener); only the counterfactual pre-fold
  constant grows 48 -> 49 for the added `toggleTabViewMode` key.
- hook-order parity: 204 -> 208 hooks for the four added `useCallback`s,
  useMemo count unchanged at 8.

* fix(native-chat): restore bridge chat escape hatch

* test: update pane agent identity inventory

---------

Co-authored-by: Merge Sim <sim@local>
brennanb2025 added a commit that referenced this pull request Sep 4, 2026
* Keep the floating workspace above a working native chat pane

While an agent is streaming, `data-native-chat-working='true'` promoted the
native chat pane shell from z-10 to z-50, above the floating workspace panel's
z-45. Both compete in the root stacking context, so the chat column painted
over a summoned floating workspace and only the sliver past the chat's right
edge stayed visible.

Lower the working-state rule to z-44. It still clears the z-40 updater and
onboarding chrome the rule was added for (#16729) and the 41-44 band was
otherwise empty. Raising the panel instead would put it over the z-50 modal
layer it deliberately sits under.

The existing layering test pinned z-index 50 with no upper bound, which is
what let this through; it now derives both bounds from source.

* Stop the layering test reading a comment as the panel class

The panel's z-index was read with a lazy match from the data attribute to the
first `z-[NN]`. Nearby comments cite bare tiers (the toggle button's own note
mentions z-[45]), so a reworded comment landing after the attribute would be
read as the class. Strip comments and anchor to `className=`.

---------

Co-authored-by: Merge Sim <sim@local>
cgv-diit added a commit to cgv-diit/orca that referenced this pull request Sep 4, 2026
PR stablyai#16729 dropped the header-cluster toggle between the terminal and
the native Chat UI along with the keyboard shortcut and the tab
context-menu entry. The underlying machinery (canToggleNativeChat,
isChatEligibleForLeaf, isChatViewMode, unifiedTabId, setTabViewMode,
switchNativeChatToTerminal) survived untouched and already had a
consumer via use-terminal-pane-chat-state, so this restores only the
header button by composing over that hook instead of reintroducing
the pre-deletion helpers.

The keyboard shortcut and context-menu entry stay out of scope: the
shortcut's Ctrl+Shift+J collides with worktree.palette on Windows and
Linux and was never registered in the keybindings catalog, so
reactivating it needs a conflict-checked catalog entry, which is an
upstream product decision.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KetK6tmDdthGpg793tBFJr
cgv-diit added a commit to cgv-diit/orca that referenced this pull request Sep 4, 2026
PR stablyai#16729 dropped the header-cluster toggle between the terminal and
the native Chat UI along with the keyboard shortcut and the tab
context-menu entry. The underlying machinery (canToggleNativeChat,
isChatEligibleForLeaf, isChatViewMode, unifiedTabId, setTabViewMode,
switchNativeChatToTerminal) survived untouched and already had a
consumer via use-terminal-pane-chat-state, so this restores only the
header button by composing over that hook instead of reintroducing
the pre-deletion helpers.

The keyboard shortcut and context-menu entry stay out of scope: the
shortcut's Ctrl+Shift+J collides with worktree.palette on Windows and
Linux and was never registered in the keybindings catalog, so
reactivating it needs a conflict-checked catalog entry, which is an
upstream product decision.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KetK6tmDdthGpg793tBFJr
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…#16729)

* feat(native-chat): port structured Codex sessions from restructure-recovery

Rebuilds the desktop structured native-chat implementation from
brennanb2025/native-chat-restructure-recovery (tip 4e31c08) on top of
current main as a single commit, scoped to the local Codex path.

Ported:
- Structured agent-session core: durable record store + single-writer lease,
  canonical journal, agent-session wire host/attach/eviction/subscribers,
  `agentSession.*` RPC surface (registered via ALL_RPC_METHODS; host-side
  mobile allowlist included for wire compat), pty write gate, transcript
  additions, and the Codex app-server adapter/launch resolution.
- Renderer: NativeChatStructuredSession view/composer stack, structured
  launch path with the single-flight guard, local structured session tabs
  sync, activation gate + structured inventory (read-only
  `agentSession.handoffStatus` probe), agent-session tabs in the tab strip,
  AI-vault structured session activation, and the settings pane with the
  parent Experimental Chat UI toggle plus the nested "Use updated structured
  native chat" toggle. New sessions require both flags, agent codex, no
  prompt, and a local non-WSL, non-Windows-host execution host
  (structured-native-chat-availability).
- Fixes 72c013c (verified Codex launch recovery), 8ddbaf5 (defer
  native terminal view switching affordances), and 4e31c08 (release the
  launch gate after a visibility retry) with their regression tests,
  including the third-launch-after-retry guard case.
- Cross-version agent-session wire test + CI lane, packaging entries
  (proper-lockfile, agent-tooling asar excludes), and the wire-compat doc
  section.

Deliberately not ported: mobile/ changes, the Claude structured runtime
(only the claude-transcript-branch-proof and claude-structured-owner-identity
leaf modules remain, backing the kept TUI-recovery arms), the terminal↔chat
adoption/handoff flow (`agentSession.adoptTerminal`/`requestHandoff`, the
handoff request engine, TUI adoption machinery, orca-runtime adoption
methods), renderer switching affordances and their dead leftovers, the
hook/subagent-status refactor cluster, and unrelated branch changes. The
crash-during-acquisition recovery path (restart handoff adjudication,
restore/reverse re-acquire, lease schema handoff keys) is kept because every
plain direct launch depends on it; a trimmed handoff coordinator exposes
only status/restore/close.

Branch edits that targeted files main has since split (ipc/pty.ts,
worktrees.ts, rpc/methods/terminal.ts, useIpcEvents, pty-connection,
store/slices/terminals.ts, runtime-types, web preload) were re-applied to
the split modules, preserving main's newer logic (Windows CIM fallback,
browser tab close rework, cold-restore resume flow, dispatcher threading).

Known seam: the mobile clipboard image-provenance CONSUMER gate ships
(agentSession.send refuses unproven mobile image refs with
agent_session_image_untrusted) but the producer hunk in
rpc/methods/clipboard.ts stays with the unported mobile cluster, so mobile
image sends into structured chat fail closed until that side ports.

* fix(native-chat): trust only authenticated local image uploads

* fix(build): preserve Windows process-tree patch application

* test(windows): include process creation time in addon fixture

* fix(build): run windows-process-tree node-gyp from the physical package dir

gyp expands the node-addon-api dependency by probing node, whose cwd
resolves to the package's physical directory in the store, so the emitted
target is a store-relative ../../../../node-addon-api@... hop. gyp then
resolves that hop against the rebuild cwd; from the node_modules
symlink/junction it escapes the store and configure fails with
"node_addon_api.gyp not found" (run 32999886072).

Rebuild from realpath(package dir) so both bases agree, matching how the
package manager itself runs native install scripts. The regression test
replays gyp's expansion+resolution against the planned cwd and fails
without the fix.

* fix(native-chat): keep chat tabs visible through terminal closes and empty-worktree launches

Two proven blockers in the native Codex tab contract:

closeTerminalTab pre-empted the canonical unified close. With one terminal
left it deactivated the worktree on a terminal/editor/browser-only check,
blanking a workspace that still held a renderable agent-session tab; with
two or more it pre-picked a successor from terminal entities only,
re-stamping the group active before closeUnifiedTab's MRU/neighbor repair
could land on the chat tab. Successor choice now defers to the unified
contract whenever the terminal has a unified row, and deactivation is
gated on the unified renderable count (matching leaveWorktreeIfEmpty),
with the legacy pre-pick kept only for terminals without a unified row.

A structured session created on an empty worktree was published into the
host's headless group while preserveLocalLayout froze the local layout,
leaving the tab in store but permanently off screen. A preserveLocalLayout
owner now always takes client-owned placement — repairing a rendered
leaf whose group record is missing, or materializing a rendered group on a
truly empty worktree — and applies the client-derived layout repair while
still rejecting host-authored layout.

Regression tests drive the real store through closeTerminalTab (git
worktree and folder workspace) and the real snapshot applier for the
empty-worktree adoption states; all fail without the fixes.

* fix(native-chat): close stale turns and retry rejected sends

* fix(native-chat): retire hosted rows on structured tab activation

* fix(native-chat): preserve rpc defaults across main merge

* chore: format remote wire compatibility guide

* test(native-chat): cover retry after unconfirmed send

* fix(native-chat): reload outbox on session switch

* docs(settings): disclose structured chat platform limits

* fix(native-chat): await Codex launch-home preparation

* fix(codex): align child-process allowlist with async trust bridge

* test(identity): update inventory for tab surface refactor

* fix(windows): preserve process-tree CRLF patch sources

* fix(native-chat): anchor an unmatched chat echo where it was sent (stablyai#16117)

* fix(native-chat): anchor an unmatched chat echo where it was sent

The reported symptom was old user messages replaying below every new turn, so the
conversation read as scrambled. The cause was not that the echo failed to match a
transcript row. Claude consumes a mid-turn send through a `queued_command`
attachment and writes no `type:"user"` record for it, so some echoes can never
match, and no amount of matching will change that. The cause was WHERE an
unmatched echo rendered: buildMobileNativeChatTransientData appended every pending
item after the entire transcript, so it re-read below each turn that landed
afterwards.

Render each echo directly after the transcript row it was sent against, using the
baseline the send already captures. An unmatched echo is then at worst a duplicate
in the right position rather than a scrambled one, and it stays visible. Echoes
sharing an anchor keep send order; a send with no baseline, or one whose anchor
folding dropped, still falls back to the tail.

Deliberately NOT fixed by deleting the echo. Inferring from send ordering that an
echo can never match, then removing it, loses the user's own text for a message
the agent did receive, and it cannot fire in the common case anyway - measured
drain groups are 1,017 of size 1 against 55 larger. It also escalates an existing
gap: the count pass has no baseline-tail guard, unlike the glue pass, while
`messages` is a 40-row window that head-trims, resets on reconnect and grows at
the front on loadEarlier, so a false landing there would license deleting a
DIFFERENT outstanding message.

That count-pass gap is real and left for a separate change; anchoring makes its
worst case a duplicate in place rather than a scrambled conversation.

* fix(native-chat): preserve folded echo anchors

* fix(native-chat): preserve forward-folded echo anchors

* fix(native-chat): keep leading folded echoes in place

* fix(workspace-cleanup): show git status for every row (stablyai#16690)

* fix(native-chat): refuse structured chat on every Windows execution path

canUseStructuredNativeChat only refused win32 when a project runtime
resolved, so folder-workspace keys (and other keys with no project
runtime) failed open into structured chat on Windows. Fail closed on
win32 unconditionally after the host check, matching the settings copy:
local macOS/Linux only; Windows/WSL/SSH stay on terminal chat.

* fix(native-chat): restore runtime refusals behind the win32 gate

506d375 replaced the project-runtime checks with a bare platform test,
so a WSL or repair-required runtime resolution would no longer refuse
structured chat off-win32. Keep the unconditional win32 refusal and
re-run the runtime resolution after it, so the gate does not depend on
the resolver's own platform guard. Tests inject WSL and repair-required
resolutions on darwin/linux and fail against the regressed gate.

* fix structured session journal durability

* fix structured tab active pointer after restart

* fix(native-chat): await optional lease renewal callbacks

* refactor(skills): extract install error messages

* fix(agent-session): harden recovery ownership

* fix(native-chat): retain panes across tab activation

* fix(native-chat): address round-one review findings

* test(native-chat): align integration coverage after main merge

* fix(native-chat): harden round-two reliability

* fix(native-chat): harden round-three reliability

* fix(native-chat): close round-four recovery gaps

* fix(native-chat): separate bounded journal key forms

* fix(native-chat): reset outbox error in render on session switch

The switch effect adjusted error state after the sessionId prop changed,
tripping react-doctor's no-adjust-state-on-prop-change on the changed-code
gate and flashing the old session's banner for a frame. Reset it with the
render-time previous-value guard instead.

* fix(native-chat): invalidate stale outbox settlements

* test(native-chat): restore settled-error session-switch regression

a6e2379 replaced this test with the in-flight settlement race test,
leaving the render-time error reset unpinned: deleting the reset block
still passed the whole native-chat suite. Keep both scenarios pinned;
they are distinct (settled error clears on switch vs stale settlement
invalidated in the commit-to-passive window).

* test(wire): make release checkouts race safe

* test(wire): pin cross-process checkout single-flight and importer specifier contract

* test(wire): harden release checkout lifecycle

* fix(build): drop CR-byte residue from windows-process-tree patch

The two trailing CR bytes on the patch's deletion lines are a proven
no-op: pnpm hashes patches CRLF-normalized (both forms hash to the
lockfile's 946ffb2b) and materializes this package without applying the
patch in either form, so the load-bearing build edits come solely from
applyWindowsProcessTreeBuildFixes() (stablyai#16947), which handles both source
EOL forms. Restore byte-identity with main and repin the contract test
to the post-stablyai#16947 reality: LF-only patch bytes plus lockfile hash sync.

* fix(native-chat): skip empty startup recovery
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
… only (stablyai#18532)

* feat(native-chat): restore the terminal/chat switcher for bridge chat only

stablyai#16729 removed every user-facing terminal<->chat switching affordance as a
side effect of the structured Codex restructure ("renderer switching
affordances and their dead leftovers"). That was right for structured Codex
sessions, which render their own transcript with no live TUI underneath, but
it also took the switcher away from bridge native chat, which still reads the
terminal and has one to return to.

Restore all four surfaces, each gated so structured sessions keep the removal:

- pane header chat/terminal button (TerminalPaneHeaderOverlay)
- pane context-menu "Switch to chat/terminal view" (TerminalContextMenu)
- tab context-menu equivalent (SortableTabContextMenu)
- the keyboard chord, whose hook had survived uncalled since stablyai#16729

Gating is one rule in one place: `canSwitchNativeChatView` refuses whenever a
`structuredSessionId` is present, over the existing `canToggleNativeChat`
eligibility. Standalone structured tabs are already excluded by the
`contentType === 'terminal'` check; the new guard covers a terminal tab that
adopted a structured session. The shortcut hook applies the same rule.

The state plumbing (`viewMode`, `setTabViewMode`, `toggleTabViewMode`, host
mirroring, `native_chat_toggled` telemetry) was never removed, so this rewires
live actions rather than reintroducing logic.

SortableTab.tsx sat exactly at its 400-line cap, so its inline-rename state and
the window rename-request listener move to `use-sortable-tab-rename.ts` to make
room. No behavior change; its rename tests pass unmodified.

Two ratchets move for real, explained in place:
- store-subscription budget: per-pane listeners stay pinned at 17 (the folded
  action bundle is still one listener); only the counterfactual pre-fold
  constant grows 48 -> 49 for the added `toggleTabViewMode` key.
- hook-order parity: 204 -> 208 hooks for the four added `useCallback`s,
  useMemo count unchanged at 8.

* fix(native-chat): restore bridge chat escape hatch

* test: update pane agent identity inventory

---------

Co-authored-by: Merge Sim <sim@local>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…i#18692)

* Keep the floating workspace above a working native chat pane

While an agent is streaming, `data-native-chat-working='true'` promoted the
native chat pane shell from z-10 to z-50, above the floating workspace panel's
z-45. Both compete in the root stacking context, so the chat column painted
over a summoned floating workspace and only the sliver past the chat's right
edge stayed visible.

Lower the working-state rule to z-44. It still clears the z-40 updater and
onboarding chrome the rule was added for (stablyai#16729) and the 41-44 band was
otherwise empty. Raising the panel instead would put it over the z-50 modal
layer it deliberately sits under.

The existing layering test pinned z-index 50 with no upper bound, which is
what let this through; it now derives both bounds from source.

* Stop the layering test reading a comment as the panel class

The panel's z-index was read with a lazy match from the data attribute to the
first `z-[NN]`. Nearby comments cite bare tiers (the toggle button's own note
mentions z-[45]), so a reworded comment landing after the attribute would be
read as the class. Strip comments and anchor to `className=`.

---------

Co-authored-by: Merge Sim <sim@local>
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