Skip to content

fix(orchestration): scope active-coordinator fallback to the handle's worktree - #11203

Merged
OrcaWin merged 12 commits into
stablyai:mainfrom
Jaeyoung22:fix/sidebar-agent-cross-session-attribution
Aug 4, 2026
Merged

OrcaWin merged 12 commits into
stablyai:mainfrom
Jaeyoung22:fix/sidebar-agent-cross-session-attribution

Conversation

@Jaeyoung22

@Jaeyoung22 Jaeyoung22 commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • In the Projects sidebar, an agent could render nested under a different, unrelated session's card. Reported with a live repro (screenshot below): an Orchestration... agent row under "Status check" that actually belonged to the separate "deadcode-cleanup" session.
  • Root cause: getAgentStatusOrchestrationContextForHandle (src/main/runtime/orca-runtime.ts) falls back to db.getActiveCoordinatorRun() whenever a dispatched task's created_by_terminal_handle is unset. That query is unscoped — SELECT * FROM coordinator_runs WHERE status = 'running' ORDER BY created_at DESC LIMIT 1 — so it returns the single most-recently-started coordinator run app-wide, regardless of which worktree it belongs to.
  • Fix: added getWorktreeIdForTerminalHandle() (mirrors the existing getPaneKeyForTerminalHandle pattern) and only use the globally-active coordinator run as a fallback parent when its coordinator terminal lives in the same worktree as the handle being resolved. task.created_by_terminal_handle, which is already correctly session-scoped when present, is untouched and still takes priority.

Scope, honestly

  • created_by_terminal_handle is populated on essentially every task created through the current bundled CLI (it resolves a sender or throws — see resolveCoordinatorTerminalHandle in src/cli/handlers/orchestration.ts), so the main realistic path to hitting the unscoped fallback today is task rows from before the created_by_terminal_handle column existed (added via a bare ALTER TABLE ... ADD COLUMN with no backfill) — i.e. users who've been running Orca across schema versions, not "any time two orchestrations run concurrently."
  • This does not fully close cross-session attribution: getActiveCoordinatorRun() itself (src/main/runtime/orchestration/db.ts) is still an unscoped "globally most recent running" query. Two coordinators running concurrently in the same worktree can still pick the wrong one of each other — that's the pre-existing, broader problem tracked in [Bug]: Multiple orchestrators in a single workspace kill each other #4389 ("Multiple orchestrators in a single workspace kill each other") and out of scope here.
  • Blast radius is display-only: parentPaneKey/coordinatorHandle from this context are read only by sidebar/dashboard grouping and naming (agent-row-lineage-model.ts, worktree-agent-orchestration-index.ts, build-dashboard-snapshot.ts, use-agent-row-conversation-name.ts) — no dispatch, message-routing, or hibernation logic depends on it.

Net: a small, safe, regression-tested UI-correctness fix for a bug that's confirmed to happen in practice, not a full fix for cross-session orchestration attribution.

Repro

The "Status check" session shows an Orchestration... agent row nested under it, even though that agent actually belongs to the separate deadcode-cleanup session (visible right below it):

Status check session showing an Orchestration agent row that actually belongs to the separate deadcode-cleanup session

Test plan

  • Added a regression test (does not attribute a dispatch to an active coordinator run from a different worktree) — confirmed it fails without the fix and passes with it.
  • npx vitest run src/main/runtime/orca-runtime.test.ts — 1012/1013 passing (1 pre-existing skip), after merging up to current main.
  • pnpm typecheck and oxlint clean on touched files.
  • Independent cross-review pass Linux support #1 (Codex) on the diagnosis and fix — agreed this is a correct, minimal fix; no regression in the scoping logic (null-handling, mid-move, stale-PTY cases checked). Flagged two other pre-existing call sites of getActiveCoordinatorRun() (worker-escalation routing, worktree-lineage capture) with the same unscoped-singleton risk — left out of this PR since they're separable and not introduced/worsened here.
  • Independent cross-review pass Fix Ctrl+Backspace not deleting word in terminal #2 (Codex, adversarial) specifically on whether this is a meaningful fix or an over-narrow edge case — verdict: real and worth shipping as a small defensive correctness fix, but confirmed the narrower scope described above (migration-dependent NULL reachability, does not solve same-worktree concurrent coordinators).

No visual/UI change beyond agents now nesting under the correct session card in the sidebar.

Cross-platform / SSH / remote: this is a main-process orchestration-state fix with no OS-specific or transport-specific code paths; behavior is identical on macOS/Linux/Windows and local/SSH/remote worktrees.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The runtime now scopes active coordinator-run attribution to the worktree associated with the current terminal handle. It resolves worktree metadata from live PTY records or stored handle metadata, rejects unknown or cross-runtime handles, and uses the scoped run for parent, coordinator, and orchestration fields. Tests cover cross-worktree attribution and coordinator race authority. The reliability gate adds creator and Run-generation fencing and indexed retained-Run performance coverage.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary fix: scoping the active-coordinator fallback to the handle's worktree.
Description check ✅ Passed The description clearly covers the change, repro, testing, review, visual impact, platform scope, and known limitations, but lacks a separate security audit section.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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/orca-runtime.ts (1)

27168-27201: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Worktree-scoping fix looks correct; consider using runtimeWorktreeIdsEqual for the comparison.

The gating logic itself is sound: scopedActiveRun is only used when getWorktreeIdForTerminalHandle(handle) and getWorktreeIdForTerminalHandle(activeRun.coordinator_handle) resolve to the same worktree, and it safely falls back to no attribution when either side is unresolvable. However, this compares two worktree-id strings with strict ===, while the rest of the file consistently normalizes such comparisons through runtimeWorktreeIdsEqual (e.g. in recordPtyWorktree, getSummaryForRuntimeWorktreeId) to tolerate path-representation differences across sources (PTY-derived vs handle-record-derived ids). If the two handles' worktree ids ever differ only in representation, this would silently drop a legitimate attribution instead of scoping it correctly.

♻️ Suggested fix
-    const scopedActiveRun =
-      activeRun &&
-      handleWorktreeId &&
-      this.getWorktreeIdForTerminalHandle(activeRun.coordinator_handle) === handleWorktreeId
-        ? activeRun
-        : undefined
+    const scopedActiveRun =
+      activeRun &&
+      handleWorktreeId &&
+      runtimeWorktreeIdsEqual(
+        this.getWorktreeIdForTerminalHandle(activeRun.coordinator_handle) ?? '',
+        handleWorktreeId
+      )
+        ? activeRun
+        : undefined

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d68f99de-8719-44d5-a1f0-e12b194d214e

📥 Commits

Reviewing files that changed from the base of the PR and between 0404f27 and ea7b730f5553301eb310e1df55a341b4c592aa7e.

📒 Files selected for processing (2)
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts

Comment thread src/main/runtime/orca-runtime.ts Resolved
@greptile-apps

greptile-apps Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR fixes a cross-worktree misattribution bug where an agent from one session's orchestration flow would incorrectly appear nested under a different session's card in the Projects sidebar. The root cause was getActiveCoordinatorRun() returning a globally-unscoped singleton result (the most recently started coordinator run app-wide), so with two concurrent orchestration flows the worker dispatch in worktree A could pick up worktree B's coordinator as its parent.

  • Adds getWorktreeIdForTerminalHandle() following the same pattern as the existing getPaneKeyForTerminalHandle(), resolving worktree ID first from the live PTY and falling back to the handle record.
  • Introduces scopedActiveRun which only accepts the global coordinator run as a parent when its coordinator terminal lives in the same worktree as the handle being resolved — using the existing runtimeWorktreeIdsEqual comparator for path-normalized equality.
  • Adds a regression test that confirms a cross-worktree coordinator run is not attributed to a worker handle in a different worktree; all 896 existing tests continue to pass.

Confidence Score: 5/5

Safe to merge — the change is a narrow, well-scoped fix that only tightens the fallback attribution logic without touching the primary task.created_by_terminal_handle path.

The new getWorktreeIdForTerminalHandle method mirrors the established getPaneKeyForTerminalHandle pattern exactly, uses the existing runtimeWorktreeIdsEqual comparator, and handles all null/stale cases conservatively (fails closed by dropping the attribution rather than misattributing). The regression test directly reproduces the reported scenario and confirms the fix. All 896 existing tests pass, and tsc/oxlint are clean.

Files Needing Attention: No files require special attention.

Important Files Changed

Filename Overview
src/main/runtime/orca-runtime.ts Adds getWorktreeIdForTerminalHandle() and scopedActiveRun guard; logic is correct, null-safe, and consistent with the existing getPaneKeyForTerminalHandle pattern.
src/main/runtime/orca-runtime.test.ts Adds a focused regression test for the cross-worktree misattribution scenario; test setup and assertion are correct and directly target the fixed code path.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[getAgentStatusOrchestrationContextForHandle] --> B{dispatch found?}
    B -- No --> Z[return undefined]
    B -- Yes --> C{dispatch completed?}
    C -- Yes --> D[activeRun = undefined]
    C -- No --> E[activeRun = db.getActiveCoordinatorRun]
    D --> F[handleWorktreeId = getWorktreeIdForTerminalHandle]
    E --> F
    F --> G[coordinatorWorktreeId = getWorktreeIdForTerminalHandle coordinator]
    G --> H{handleWorktreeId AND coordinatorWorktreeId AND same worktree?}
    H -- Yes --> I[scopedActiveRun = activeRun]
    H -- No --> J[scopedActiveRun = undefined]
    I --> K{task.created_by_terminal_handle?}
    J --> K
    K -- Present --> L[parentTerminalHandle = task.created_by_terminal_handle]
    K -- Absent --> M{scopedActiveRun.coordinator_handle != handle?}
    M -- Yes --> N[parentTerminalHandle = scopedActiveRun.coordinator_handle]
    M -- No --> O[parentTerminalHandle = undefined]
    L --> P[Return orchestration context]
    N --> P
    O --> P
Loading

Reviews (2): Last reviewed commit: "refactor(orchestration): drop redundant ..." | Re-trigger Greptile

@OrcaWin
OrcaWin force-pushed the fix/sidebar-agent-cross-session-attribution branch from 502a714 to 94cb0d6 Compare August 3, 2026 14:31

@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)
config/reliability-gates.jsonc (1)

6460-6476: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add evidence for the newly declared creator-authority command and assertions.

This change adds a new command and test file (orchestration-creator-authority-performance.test.ts), a new assertionRefs block for it, and two new assertions in the existing orca-runtime.test.ts block ("retained renderer output remains readable through the recovered terminal" and "a creator pane and process reminted into Run B cannot parent its retained Run A worker"). Update invariant, oracle, and performanceBudget text to match.

No entry in evidenceRuns runs the new command or re-runs orca-runtime.test.ts to demonstrate these new assertions pass. redGreenEvidence and knownGaps also do not mention this addition.

Every other command in this gate (and across the file) has a matching dated evidenceRuns entry with a pass/fail result and summary. Without one here, the gate documents claimed coverage ("indexed retained-Run lookup scaling", "creator pane/process/Run-generation fencing") that has no recorded execution proof in this file.

Add an evidenceRuns entry for the orchestration-creator-authority-performance.test.ts command, and extend redGreenEvidence to cover the reminted creator-pane/process fencing assertion, consistent with how this file documents every other coverage claim.

Also applies to: 6489-6495, 6507-6508, 6626-6626


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b03ff3d1-7cee-4a6f-81df-169fc5deb659

📥 Commits

Reviewing files that changed from the base of the PR and between bb30d7e36b82d4ee615791c782c9f2960016f3fd and 94cb0d68a40887be2af3734a96258ed9e0bbb806.

📒 Files selected for processing (1)
  • config/reliability-gates.jsonc

@OrcaWin

OrcaWin commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

PR #11203 terminal disposition

Disposition

Approved and left open. The validated candidate was pushed to the existing contributor branch; no
merge or replacement PR was created. GitHub reports the PR mergeable and clean.

Exact topology

  • Old reviewed base: e08eba674c195596228834bf3c1ef4f94e6b118e
  • Fetched current base: e08eba674c195596228834bf3c1ef4f94e6b118e
  • Published contributor head: 502a7142852066161c84894c853d3cd2484dd639
  • Verified evidence candidate: 94cb0d68a40887be2af3734a96258ed9e0bbb806
  • Fourth-correction implementation: 8a6dc248fbb7842b9e2be8131053191a2883081d
  • Rejected final3: 00e32e680d554baa454ee500159d612985c07cda
  • Supplied verified direct-child revert: bf0b432cc9721d8f4cafcc1fc1135e161cc39321
  • Terminal pushed head: d2d765181f6305287b4b4743abf1d74ea33b78d4
  • Terminal direct-child revert: 677f09fc7ffb11c6fad92bdc988dd2c328a979ff
  • Rejected-final3 tree restored by both reverts: b45a5ec9ee21d110dddd3a7a6ab500427560b804

Base-advance gate

Fetching origin/main, refs/pull/11203/head, and the contributor branch produced the exact old
base and published head above. old-base..new-base is empty, so there were no owner, dependency,
protocol, build, workflow, or executable seams to reconcile. Rebasing the verified candidate was a
no-op with no conflicts or dropped commits; all nine commits range-diffed identically and the
pre/post aggregate stable patch ID was f67745d048bc3ce40f8a83b9ff630c229727c2c5.

The terminal head adds only two CI corrections after the verified candidate: a69c4071543689f00c738a1ca4912e7b7dc28efa
removes validation reports from the PR tree after the root-directory guard rejected the new
top-level folder, and d2d765181f6305287b4b4743abf1d74ea33b78d4 supplies authenticated
dispatch authority to the existing takeover-race test so it reaches its intended asynchronous
revalidation boundary. Production files remain byte-identical to implementation 8a6dc248....

Final status is clean except for the intentionally untracked workspace evidence directory. The
merge-base is exactly current origin/main, and git diff --check passes.

Push leases

  • 502a714285... -> 94cb0d68a4... with exact
    --force-with-lease=refs/heads/fix/sidebar-agent-cross-session-attribution:502a714285....
  • 94cb0d68a4... -> a69c407154... with exact lease on 94cb0d68a4....
  • a69c407154... -> d2d765181f... with exact lease on a69c407154....
  • Final contributor ref and PR head both resolve to d2d765181f6305287b4b4743abf1d74ea33b78d4.

Security and workflow audit

The candidate changes no workflows, local actions, scripts, package manifests, lockfiles, file
modes, executables, or download logic. The base-owned pull_request workflow uses read-only
contents permission, no secrets, and checkout with persisted credentials disabled. Its local
dependency action and reusable E2E workflow were inspected; the existing Git 2.25 download is
checksum-verified, and no candidate-controlled workflow privilege or credential path was found.

Fork workflow runs 30823093278, 30823415157, and final 30823770653 were approved only after
that audit. The first candidate-caused root-guard failure and the second candidate-caused Node
24/26 shard-15 fixture failure were investigated and corrected; the final run is terminal green.

Validation and CI

  • Refreshed locally: six changed runtime/DB/RPC/renderer suites, 1,254 passed and 1 skipped.
  • Takeover-race regression after the CI correction: 15/15 passed.
  • Full TypeScript compilation passed before and after the CI correction.
  • Preserved expensive evidence remains applicable because the base did not advance and production
    code is unchanged from the twice-verified candidate: six authority oracles, four production
    creation paths, six actual-runtime authority paths, runtime/DB/RPC/renderer/federation/SSH/folder
    gates, schema-v24 migration/reopen, query-plan/history/retention controls, and 20k/50k bounds.
  • Final CI: PR Checks run 30823770653,
    41 successful jobs and 1 expected skipped E2E job. Aggregate verify passed.

Review state and remaining gaps

The sole review thread was already resolved and remains genuinely satisfied; there are zero
unresolved threads. The PR is approved, open, mergeable, and clean. No headed Electron, physical
Windows/Linux/WSL, live Docker SSH, or paired desktop/headless journey was newly run; deterministic
coverage and final CI cover the proportional scope, while remote worker-side Task/Run projection
remains separate pre-existing protocol debt.

Next action: repository maintainer owns the normal merge decision; this review owner must not merge.

@OrcaWin OrcaWin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed and validated at d2d765181f6305287b4b4743abf1d74ea33b78d4. Base gate, security/workflow audit, exact-lease push, proportional local validation, and terminal CI are green; no unresolved threads remain.

@OrcaWin
OrcaWin force-pushed the fix/sidebar-agent-cross-session-attribution branch from d2d7651 to 0921a84 Compare August 4, 2026 03:54
@OrcaWin
OrcaWin force-pushed the fix/sidebar-agent-cross-session-attribution branch from 0921a84 to 20b256a Compare August 4, 2026 04:00
Jaeyoung22 and others added 10 commits August 4, 2026 00:01
… worktree

getAgentStatusOrchestrationContextForHandle fell back to the app-wide
getActiveCoordinatorRun() (an unscoped "most recently started" query
over coordinator_runs) whenever a task lacked created_by_terminal_handle.
With two orchestration sessions running in different worktrees at once,
this attributed one worktree's dispatch to another worktree's coordinator,
making agents from one session render nested under an unrelated session
in the sidebar. Only trust the active run when its coordinator terminal
lives in the same worktree as the handle being resolved.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…or scope

Compare with the file's existing runtimeWorktreeIdsEqual instead of ===
so PTY-derived vs handle-record-derived worktree ids that differ only
in path representation (e.g. across SSH/Windows) still match, instead
of silently dropping a legitimate parent attribution.

Addresses CodeRabbit review feedback on stablyai#11203.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
TerminalHandleRecord.worktreeId is typed string, so the `?? null`
guard in getWorktreeIdForTerminalHandle could never activate.

Addresses Greptile review feedback on stablyai#11203.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@OrcaWin
OrcaWin force-pushed the fix/sidebar-agent-cross-session-attribution branch from 20b256a to daa4a1d Compare August 4, 2026 04:03

@OrcaWin OrcaWin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed and validated at daa4a1d on base a6b14eb. Conflict/base-advance equivalence, workflow/security audit, exact-lease push, independent final review, proportional local validation, and terminal CI run 30876530034 are green; no unresolved threads remain.

@OrcaWin
OrcaWin merged commit 3d6d6dd into stablyai:main Aug 4, 2026
42 checks passed
nwparker added a commit that referenced this pull request Aug 4, 2026
…h guard

#11203 taught pane lookup to recover a reminted tab id by leaf id, so the old
fixture (new tab id, live leaf id) resolved and bumped the snapshot a second
time once this branch merged with main.

Co-authored-by: Orca <help@stably.ai>
nwparker added a commit that referenced this pull request Aug 4, 2026
…s on a paired headless server (#12223)

* fix(native-chat): show Claude's AskUserQuestion card when the agent runs on a paired headless host

Three gaps kept the question card off the desktop when the agent ran on a
remote `orca serve` host:

- The `session.tabs` projection reduced HTTP agent-hook rows to identity only,
  hard-coding `state: 'done'` and an empty prompt, so `toolName` and the full
  `interactivePrompt` never left the host. It now publishes the newest fresh
  hook row's status fields, bounded by the same staleness window `agentType`
  uses, excluding `providerSessionOnly` resume rows, and yielding to live
  title evidence unless a question is actually pending.
- Nothing republished `session.tabs` when only a hook row changed, and the
  re-emit carried an unchanged `snapshotVersion` that clients drop on their
  monotonic gate. Material hook transitions and pane/SSH status clears now
  bump the version and schedule a coalesced emit.
- The desktop card resolved only from live status. It now falls back to the
  pending ask in the transcript, matching mobile, so a relay gap can no longer
  leave the composer mounted over a pane parked on a selector.

Closes #11761

Co-authored-by: Orca <help@stably.ai>

* fix(native-chat): date the hook-row recency guard against a real clock

`resolveHookLiveAgentRow` compared a hook `receivedAt` (epoch ms) against
title stamps that are title-observation sequence numbers, so the guard could
never fire — any fresh hook row overrode live title-derived state, and a manual
rename (the one epoch writer) inverted it. Stamp the live OSC title path with
wall-clock ms and compare against that alone.

The regression test fabricated epoch-valued title stamps production never
writes; it now drives the title through `onPtyData`, and a new case pins the
opposite direction (hook row newer than the title wins).

Co-authored-by: Orca <help@stably.ai>

* fix(native-chat): stop an orphaned tool call from pinning a dead question card

extractPendingAsk pairs tool results to calls by a global FIFO (tool_use_id
is dropped at decode time), so one call that never gets a result desyncs the
queue for the rest of the transcript and strands an answered ask as pending.
Real transcripts also hold asks the user escaped and typed past. On desktop
that card replaces the composer, so the pane became unsendable.

Drop in-flight calls at a turn boundary — a user turn or the decoders'
interrupt row — since the turn that owned them is over. Claude's tool-result
turns decode as role 'tool', so normal FIFO resolution is untouched.

Co-authored-by: Orca <help@stably.ai>

* refactor(native-chat): trim the headless AskUserQuestion projection

Reuse rather than restate: the invalidator now takes the shared
`AgentHookEventPayload` instead of a locally redeclared row shape, and the
hook live row is a `Pick<>` of the retained OSC snapshot so one projection
branch consumes either carrier. Fold the immediate/coalesced session-tabs
emit into one method (also drops a redundant re-emit on the
provider-session push). Drop card tests that re-route shared-parser
assertions through React. Isolate pane-status-clear subscribers and prove
the no-republish case by version arithmetic instead of a timed silence.

Co-authored-by: Orca <help@stably.ai>

* test(native-chat): pin the AskUserQuestion card render under real Electron

Why: the 13 parser unit tests pin extraction, but nothing proved a card
actually renders where an inert tool call used to. This spec reproduces the
paired-headless topology from the client side — live status carrying agent
identity and state 'working' but no interactivePrompt/toolName, with the
pending ask present only in the transcript — and fails on main.

Refs #11761

Co-authored-by: Orca <help@stably.ai>

* test(native-chat): drop the unused testInfo parameter

Why: oxlint no-unused-vars fails the lint gate on an unused test parameter.

Co-authored-by: Orca <help@stably.ai>

* test(native-chat): drop leftover proof scaffolding from the ask-card spec

The env-var screenshot label and the fixed 2s settle only existed to make
the pre-fix capture comparable; the card assertion already waits.

Co-authored-by: Orca <help@stably.ai>

* test(runtime): use a truly unresolvable pane key in the hook republish guard

#11203 taught pane lookup to recover a reminted tab id by leaf id, so the old
fixture (new tab id, live leaf id) resolved and bumped the snapshot a second
time once this branch merged with main.

Co-authored-by: Orca <help@stably.ai>

* fix(runtime): refuse a hydrated unconfirmed hook row as live pane status

#12346 landed on main after this branch was cut: a nonterminal row restored from
last-status.json is stamped `restoredUnconfirmed` because its transition may have
fired while no receiver was up, and every freshness gate treats it as never-fresh.
The new headless `live` projection here only checked `receivedAt`, so a restart
inside the 30-minute window would republish the hydrated row — resurrecting the
AskUserQuestion card with no agent left to answer it.

`agentType` still reads those rows: they prove identity, just not liveness.

Co-authored-by: Orca <help@stably.ai>

---------

Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Neil <nwparker@users.noreply.github.com>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…1203)

Use durable Task-to-Run ownership and current pane, process-incarnation, and Run-generation authority for sidebar agent lineage. Add schema migrations, bounded lookup indexes, fail-closed renderer cleanup, and runtime/RPC regression coverage.

Co-authored-by: Jaeyoung22 <89302528+Jaeyoung22@users.noreply.github.com>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…s on a paired headless server (stablyai#12223)

* fix(native-chat): show Claude's AskUserQuestion card when the agent runs on a paired headless host

Three gaps kept the question card off the desktop when the agent ran on a
remote `orca serve` host:

- The `session.tabs` projection reduced HTTP agent-hook rows to identity only,
  hard-coding `state: 'done'` and an empty prompt, so `toolName` and the full
  `interactivePrompt` never left the host. It now publishes the newest fresh
  hook row's status fields, bounded by the same staleness window `agentType`
  uses, excluding `providerSessionOnly` resume rows, and yielding to live
  title evidence unless a question is actually pending.
- Nothing republished `session.tabs` when only a hook row changed, and the
  re-emit carried an unchanged `snapshotVersion` that clients drop on their
  monotonic gate. Material hook transitions and pane/SSH status clears now
  bump the version and schedule a coalesced emit.
- The desktop card resolved only from live status. It now falls back to the
  pending ask in the transcript, matching mobile, so a relay gap can no longer
  leave the composer mounted over a pane parked on a selector.

Closes stablyai#11761

Co-authored-by: Orca <help@stably.ai>

* fix(native-chat): date the hook-row recency guard against a real clock

`resolveHookLiveAgentRow` compared a hook `receivedAt` (epoch ms) against
title stamps that are title-observation sequence numbers, so the guard could
never fire — any fresh hook row overrode live title-derived state, and a manual
rename (the one epoch writer) inverted it. Stamp the live OSC title path with
wall-clock ms and compare against that alone.

The regression test fabricated epoch-valued title stamps production never
writes; it now drives the title through `onPtyData`, and a new case pins the
opposite direction (hook row newer than the title wins).

Co-authored-by: Orca <help@stably.ai>

* fix(native-chat): stop an orphaned tool call from pinning a dead question card

extractPendingAsk pairs tool results to calls by a global FIFO (tool_use_id
is dropped at decode time), so one call that never gets a result desyncs the
queue for the rest of the transcript and strands an answered ask as pending.
Real transcripts also hold asks the user escaped and typed past. On desktop
that card replaces the composer, so the pane became unsendable.

Drop in-flight calls at a turn boundary — a user turn or the decoders'
interrupt row — since the turn that owned them is over. Claude's tool-result
turns decode as role 'tool', so normal FIFO resolution is untouched.

Co-authored-by: Orca <help@stably.ai>

* refactor(native-chat): trim the headless AskUserQuestion projection

Reuse rather than restate: the invalidator now takes the shared
`AgentHookEventPayload` instead of a locally redeclared row shape, and the
hook live row is a `Pick<>` of the retained OSC snapshot so one projection
branch consumes either carrier. Fold the immediate/coalesced session-tabs
emit into one method (also drops a redundant re-emit on the
provider-session push). Drop card tests that re-route shared-parser
assertions through React. Isolate pane-status-clear subscribers and prove
the no-republish case by version arithmetic instead of a timed silence.

Co-authored-by: Orca <help@stably.ai>

* test(native-chat): pin the AskUserQuestion card render under real Electron

Why: the 13 parser unit tests pin extraction, but nothing proved a card
actually renders where an inert tool call used to. This spec reproduces the
paired-headless topology from the client side — live status carrying agent
identity and state 'working' but no interactivePrompt/toolName, with the
pending ask present only in the transcript — and fails on main.

Refs stablyai#11761

Co-authored-by: Orca <help@stably.ai>

* test(native-chat): drop the unused testInfo parameter

Why: oxlint no-unused-vars fails the lint gate on an unused test parameter.

Co-authored-by: Orca <help@stably.ai>

* test(native-chat): drop leftover proof scaffolding from the ask-card spec

The env-var screenshot label and the fixed 2s settle only existed to make
the pre-fix capture comparable; the card assertion already waits.

Co-authored-by: Orca <help@stably.ai>

* test(runtime): use a truly unresolvable pane key in the hook republish guard

stablyai#11203 taught pane lookup to recover a reminted tab id by leaf id, so the old
fixture (new tab id, live leaf id) resolved and bumped the snapshot a second
time once this branch merged with main.

Co-authored-by: Orca <help@stably.ai>

* fix(runtime): refuse a hydrated unconfirmed hook row as live pane status

stablyai#12346 landed on main after this branch was cut: a nonterminal row restored from
last-status.json is stamped `restoredUnconfirmed` because its transition may have
fired while no receiver was up, and every freshness gate treats it as never-fresh.
The new headless `live` projection here only checked `receivedAt`, so a restart
inside the 30-minute window would republish the hydrated row — resurrecting the
AskUserQuestion card with no agent left to answer it.

`agentType` still reads those rows: they prove identity, just not liveness.

Co-authored-by: Orca <help@stably.ai>

---------

Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Neil <nwparker@users.noreply.github.com>
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.

3 participants