Repository navigation
Conversation
A remote terminal whose daemon session is replaced can keep publishing the predecessor's automatic title, agent identity and completed status onto the successor handle, because the daemon stream, runtime parsers and durable records all key by PTY id while the replacement is only known after the spawn reply. The same replacement also leaves predecessor mouse modes armed. - carry the emitting session's incarnation on daemon stream data, gaps and background facts as optional fields, so observations keep their source through coalescing, NDJSON splitting, thinning and gaps - parse unadmitted automatic observations in source-scoped capsules and promote the winner inside the existing binding/registration commit, before the mobile and graph publication tail, so a rejected or superseded candidate cannot reach the accepted surface - retire predecessor-owned durable identity on a proven known-old to known-new replacement: automatic surface label, leaf pane title, hook live claims and restore seeds, keeping custom/generated/default labels, split siblings and resume identity - stop projecting a retained resume remnant onto the successor pane's status or published agent identity Preserves same-incarnation reattach, unknown or legacy panes, custom titles, history and resume addressability, and mixed-version clients (optional fields only, no new opcode).
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the complete diff — 100 files, ~5920 added lines — and validated the load-bearing paths against the surrounding sources.
- Daemon source provenance — an optional
incarnationIdrides data / data-gap / transient-fact / background-marker events through coalescing, NDJSON splitting, keep-tail thinning and gap accounting, so a successor's early bytes are never parsed as the predecessor's (daemon-stream-data-entry.ts,daemon-stream-data-split.ts,daemon-stream-keep-tail-drop.ts,BackgroundTransientFactRelay). - Runtime observation admission — unadmitted known-source observations parse into source-scoped capsules and are promoted inside the binding/registration commit, after persistence/CAS and final registration and before the publication tail; rejected, superseded or overflowing candidates cannot reach the accepted surface (
runtime-pty-observation-{capsule,admission,routing,promotion}.ts). - Durable identity retirement — a proven known-old → known-new replacement retires the predecessor-owned automatic surface label, leaf pane title, restore seeds and hook live claims while keeping the resume remnant (
runtime-pty-replacement-durable-retirement.ts,runtime-retired-pane-evidence.ts). - Renderer rebind —
remote-pty-incarnation-replacement.tsclears predecessor agent identity on a proved remote replacement; replay-drain and transport fence on the incarnation id. - Regression coverage — the paired Electron E2E is restored with host-side assertions, and the module-size / reaper / agent-identity ratchets are updated.
The central design is appropriately conservative: the retirement proof is a strict known-old → known-new incarnation transition, absence (untagged stream, registration without an incarnation, same-incarnation reattach, disconnect) is never treated as replacement, and all new wire fields are optional (no new opcode). The memory-reaping and token-lifecycle paths are audited by ratchet tests rather than trusted by name.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (51)
Files not reviewed due to moderation or processing errors (9)
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe change adds PTY incarnation metadata to daemon events and remote terminal updates. Runtime spawn flows now manage observation admissions and promote source-scoped parser state. Replacement handling records predecessor evidence and retires inherited identity and title state. Renderer rebind and replay paths check incarnation identity. The change also updates stream thinning, fit-override validation, and tests, including a paired remote-terminal replacement test. Fixed issue severity: Medium Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to Replacing a remote terminal is safer with this change, but two edge cases remain. A successor terminal's early title or status can still be lost during a cold replacement, and concurrent spawns may interfere with each other's admission state. Resolve or explicitly accept these before merging. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to The replacement safeguards appear to prevent an uncommitted terminal from taking over a pane’s identity. The change nevertheless affects several identity and recovery paths, and incomplete coverage leaves some failure and compatibility behavior uncertain. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 25.24% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 103 functions across 89 files. (1 skipped: 1 over the file limit.) Warning Review coverage is incomplete: 9 files could not be fully reviewed. Findings from completed review steps are included; see review info for details. 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.
Actionable comments posted: 6
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/daemon/daemon-terminal-admission.ts (1)
148-148: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winInclude the incarnation ID in the reattach background marker.
Line 148 emits a source-less
sessionBackgroundMarkerwhen a client attaches to an already backgrounded session.result.incarnationIdis available at this point. Without it, consumers cannot apply winner-only source admission to this marker.Proposed fix
payload: { - background: true + background: true, + incarnationId: result.incarnationId }This preserves the source-provenance contract described in the PR objective.
🧹 Nitpick comments (2)
src/renderer/src/components/terminal-pane/pty-connection-remote-snapshot-source-grid.test.ts (1)
400-402: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winThe ordering assertion can pass without proving order.
writes.indexOf('SUCCESSOR_FRAME')requires an element that equals the frame exactly. If the successor frame is ever coalesced with adjacent bytes into one write,indexOfreturns-1, andtoBeGreaterThan(-1)then succeeds for anyLIVE_ACKindex. The ordering guarantee is the point of this regression test, so assert that the successor frame index was found.Use
findIndexwith an inclusion check and require a non-negative index.💚 Proposed assertion change
- expect(writes.findIndex((data) => data.includes('LIVE_ACK'))).toBeGreaterThan( - writes.indexOf('SUCCESSOR_FRAME') - ) + const successorIndex = writes.findIndex((data) => data.includes('SUCCESSOR_FRAME')) + expect(successorIndex).toBeGreaterThanOrEqual(0) + expect(writes.findIndex((data) => data.includes('LIVE_ACK'))).toBeGreaterThan(successorIndex)src/renderer/src/components/terminal-pane/pane-foreground-agent-tracker.ts (1)
263-268: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winRelease the retained capability in
resetForPtyReplacement. The method cancels the read without scheduling a successor. Its only production caller clears the sample flags but does not runonVisibleForegroundSettled, which also revokes pending routing confirmation. CapturehasPendingRead()before cancellation and release the capability when a read is abandoned.♻️ Proposed change
resetForPtyReplacement() { + const hadReadAtReset = hasPendingRead() cancelPendingRead() + releaseRetainedCapability(hadReadAtReset) hasForegroundAgentEvidence = false hasKnownAgentEvidence = false hasAgentExpectation = false },
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 6bacb9ba-c81f-4038-83fe-b4a3fd438fd7
📒 Files selected for processing (100)
src/main/daemon/daemon-background-transient-facts.test.tssrc/main/daemon/daemon-background-transient-facts.tssrc/main/daemon/daemon-pty-adapter-session-adoption.test.tssrc/main/daemon/daemon-pty-adapter-source-incarnation.test.tssrc/main/daemon/daemon-pty-adapter.test.tssrc/main/daemon/daemon-pty-adapter.tssrc/main/daemon/daemon-pty-event-subscriptions.tssrc/main/daemon/daemon-pty-router-events.tssrc/main/daemon/daemon-pty-runtime-state.tssrc/main/daemon/daemon-server.tssrc/main/daemon/daemon-session-background-routing.tssrc/main/daemon/daemon-stream-data-batcher.tssrc/main/daemon/daemon-stream-data-entry.tssrc/main/daemon/daemon-stream-data-split.tssrc/main/daemon/daemon-stream-droppability-lifecycle.test.tssrc/main/daemon/daemon-stream-events.tssrc/main/daemon/daemon-stream-keep-tail-drop.tssrc/main/daemon/daemon-stream-source-incarnation.test.tssrc/main/daemon/daemon-terminal-admission.tssrc/main/daemon/session-live-stream-scan-state.test.tssrc/main/daemon/session-output-plane.tssrc/main/daemon/session.test.tssrc/main/daemon/session.tssrc/main/daemon/terminal-host-agent-session.test.tssrc/main/daemon/terminal-host-create-contract.tssrc/main/daemon/terminal-host-pty-owner-backend.test.tssrc/main/daemon/terminal-host-session-inspection-operations.tssrc/main/daemon/terminal-host.tssrc/main/ipc/pty-buffer-snapshot-dispatch.test.tssrc/main/ipc/pty-controller-spawn-admission.test.tssrc/main/ipc/pty-daemon-spawn-wsl-runtime.test.tssrc/main/ipc/pty-hidden-at-spawn-mark.test.tssrc/main/ipc/pty-ipc-hidden-delivery-gate.test.tssrc/main/ipc/pty-runtime-kill-and-exit.test.tssrc/main/ipc/pty-spawn-runtime-handle-binding.test.tssrc/main/ipc/pty/ipc/spawn-commit.tssrc/main/ipc/pty/ipc/spawn-execute.tssrc/main/ipc/pty/ipc/spawn-run.tssrc/main/ipc/pty/ipc/spawn-state.tssrc/main/ipc/pty/pane/spawn-observation-admission.tssrc/main/ipc/pty/provider/bind-listeners.tssrc/main/ipc/pty/runtime/spawn-commit-adopted-owner.test.tssrc/main/ipc/pty/runtime/spawn-commit-adopted-owner.tssrc/main/ipc/pty/runtime/spawn-commit.tssrc/main/ipc/pty/runtime/spawn-execute.tssrc/main/ipc/pty/runtime/spawn-state.tssrc/main/ipc/pty/runtime/spawn.tssrc/main/providers/pty-provider-events.tssrc/main/runtime/orca-runtime-build-pty-terminal-summary.tssrc/main/runtime/orca-runtime-emit-daemon-pty-transient-fact.tssrc/main/runtime/orca-runtime-get-unpersisted-tracked-title-for-pty.tssrc/main/runtime/orca-runtime-maybe-hydrate-headless-from-renderer.tssrc/main/runtime/orca-runtime-module-size.test.tssrc/main/runtime/orca-runtime-on-pty-data.tssrc/main/runtime/orca-runtime-on-pty-exit.tssrc/main/runtime/orca-runtime-preserved-branch-cleanup.tssrc/main/runtime/orca-runtime-prune-mobile-session-tab-group-layout.tssrc/main/runtime/orca-runtime-pty-observation-admission.tssrc/main/runtime/orca-runtime-pty-observation-routing.tssrc/main/runtime/orca-runtime-record-agent-prompt-lifecycle-state.tssrc/main/runtime/orca-runtime-register-pty.tssrc/main/runtime/orca-runtime-schedule-wait-blocked-check.tssrc/main/runtime/orca-runtime-state-fields.tssrc/main/runtime/orca-runtime-tests/pty-observation-admission.spec.tssrc/main/runtime/orca-runtime-write-orchestration-pointer-pty.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/pty-exit-per-pty-map-reaper-ratchet.test.tssrc/main/runtime/runtime-mobile-agent-status-builder.tssrc/main/runtime/runtime-mobile-session-projection-contract.tssrc/main/runtime/runtime-mobile-session-projection.tssrc/main/runtime/runtime-pty-observation-admission.test.tssrc/main/runtime/runtime-pty-observation-admission.tssrc/main/runtime/runtime-pty-observation-capsule.tssrc/main/runtime/runtime-pty-observation-promotion.tssrc/main/runtime/runtime-pty-replacement-durable-retirement.tssrc/main/runtime/runtime-pty-replacement-identity-retirement.test.tssrc/main/runtime/runtime-pty-replacement-identity-retirement.tssrc/main/runtime/runtime-pty-replacement-retired-evidence.test.tssrc/main/runtime/runtime-retired-pane-evidence.tssrc/main/startup/main-process-runtime-service.tssrc/renderer/src/components/terminal-pane/pane-foreground-agent-tracker.test.tssrc/renderer/src/components/terminal-pane/pane-foreground-agent-tracker.tssrc/renderer/src/components/terminal-pane/pty-connection-daemon-snapshot-replay.test.tssrc/renderer/src/components/terminal-pane/pty-connection-remote-snapshot-source-grid.test.tssrc/renderer/src/components/terminal-pane/pty-connection-replay-payload-handling.test.tssrc/renderer/src/components/terminal-pane/pty-connection/pane-pty-visibility-bind.tssrc/renderer/src/components/terminal-pane/pty-connection/pty-input-forward.tssrc/renderer/src/components/terminal-pane/pty-connection/remote-pty-incarnation-replacement.test.tssrc/renderer/src/components/terminal-pane/pty-connection/remote-pty-incarnation-replacement.tssrc/renderer/src/components/terminal-pane/pty-connection/replay-data-drain.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-incarnation-recovery.test.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-transport.tssrc/renderer/src/lib/pane-manager/pane-fit-unknown-owner-size.test.tssrc/renderer/src/lib/pane-manager/pane-fit.tssrc/renderer/src/runtime/web-session-terminal-handle-events.test.tssrc/renderer/src/runtime/web-session-terminal-handle-events.tssrc/shared/pane-agent-identity-inventory.test.tstests/e2e/helpers/remote-terminal-geometry-probe.tstests/e2e/paired-remote-terminal-replacement-state.spec.tstests/playwright.remote-replacement.config.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Review of the replacement-identity stack surfaced eight defects and one test-only weakness; each was reproduced before being fixed. - keep the observed source recorded as an explicit value so a delayed exit naming a superseded incarnation cannot dispose the successor's tracker - preserve the restore-seed fence, and the retired-evidence fence, through an unconfirmed SSH exit: loss of contact is not evidence of death, and the retained predecessor row must not be re-seeded or re-projected onto the successor while its liveness is unverifiable - make observation refusal explicit instead of sharing the live path's null result, so a capacity-refused source cannot mutate accepted state - release the pane-keyed retired-evidence record on the disconnect/prune path as well as on the certified exit - match a retired row by its own observation revision when both rows carry one, so a successor row reusing the same provider session, agent type and millisecond can no longer be filtered out and lose its live status - re-check the captured incarnation after each asynchronous replay write - stamp the reattach background marker with its emitting incarnation - make the replay-ordering assertion non-vacuous when frames coalesce The one remaining review item is rebutted in the thread: the foreground tracker's retained capability is released by its only caller.
|
Too many files changed for review (107 files, 100 file limit). Bypass the limit by tagging |
|
Addressed in a1d8a1c. All six inline threads are replied to and resolved; the outside-diff finding and both nitpicks are handled too.
Verification on the pushed commit: broad |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the delta since the prior review (c908516 → a1d8a1c), which addresses the reviewer findings on the replaced-terminal identity fix.
- Observed id-less source tracking —
BackgroundTransientFactRelay.sourceIncarnationsis nowMap<string, string | undefined>with ahas()-guarded stale-exit check, so a delayed predecessor exit can no longer dispose an id-less successor's tracker (daemon-background-transient-facts.ts). - Refusal as a first-class route —
resolvePtyObservationRoutereturnslive/capsule/refused, and all four call sites (emitDaemonPtyTransientFact,notePtyDataGap,setPtyTransientFactDelegation,onPtyData) now drop a capacity-rejected source's evidence source-locally instead of folding it into accepted state (orca-runtime-pty-observation-routing.ts). - Fence preservation across relay loss —
disposePtyObservationStatehonourspreserveRestoreSeedFence/preserveRetiredPaneEvidence, and the unconfirmed-SSH-exit branch keeps both fences through the reconnect grace (orca-runtime-pty-observation-admission.ts,orca-runtime-on-pty-exit.ts). - Observation-keyed retired rows —
RetiredPaneEvidencematches on the row's ownauthorityId+revision(the per-authority monotonic counter), with the timestamp composite kept only as the fallback for rows main never stamped (runtime-retired-pane-evidence.ts). - Prune releases retired evidence —
dropDisconnectedPtyRecordnow runs the same disposal, releasing the pane-keyed retired-evidence record instead of accumulating it (runtime-pty-replacement-durable-retirement.ts). - Reattach marker provenance + replay fence — the reattach
sessionBackgroundMarkercarriesincarnationId, andisCurrentPayloadre-checksremotePtyIncarnationIdafter every awaited write so a mid-write rebind can't paint the predecessor's remaining bytes onto the successor (daemon-terminal-admission.ts,replay-data-drain.ts).
The refactors are behaviour-preserving outside the addressed defects; each is pinned by a red-without-the-fix regression (delayed exit, refused fact/marker/gap, SSH-exit fence survival, same-millisecond successor row, prune release, mid-write rebind).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Conflict resolution keeps both sides in the mobile session projection contract and the prune host, and adapts the replacement path to the single hook-row store: - `resetTrackedTerminalStateForProviderGeneration` now owns the pane's hook-row reconcile (upstream's replacement for the deleted retained row store), and takes `preserveResumeIdentity` so a proven replacement keeps the retired row's resume remnant; the admission branches that prove the replacement pass it. - `retireReplacedPtyDurableIdentity` no longer reconciles a second time; it records the fenced evidence the remnant left, as the projection expects. - upstream's new `runtime-mobile-agent-status-builder.test.ts` host gains the required `getRetiredPaneEvidence`.
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 07547f82-4b4a-4c02-ba59-735e4a1b61b1
📒 Files selected for processing (18)
src/main/runtime/orca-runtime-apply-tracked-pty-title.tssrc/main/runtime/orca-runtime-build-pty-terminal-summary.tssrc/main/runtime/orca-runtime-on-pty-data.tssrc/main/runtime/orca-runtime-on-pty-exit.tssrc/main/runtime/orca-runtime-prune-mobile-session-tab-group-layout.tssrc/main/runtime/orca-runtime-pty-observation-admission.tssrc/main/runtime/orca-runtime-refresh-floating-workspace-pty-liveness.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/relay/relay-control-client-options.tssrc/main/runtime/relay/relay-control-protocol.tssrc/main/runtime/relay/relay-origin-pool.tssrc/main/runtime/runtime-mobile-agent-status-builder.test.tssrc/main/runtime/runtime-mobile-agent-status-builder.tssrc/main/runtime/runtime-mobile-session-projection-contract.tssrc/main/runtime/runtime-mobile-session-projection.tssrc/main/runtime/runtime-pty-replacement-durable-retirement.tssrc/main/startup/main-process-runtime-service.tstests/e2e/relay-region-compatibility.unit.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| const observationRoute = this.resolvePtyObservationRoute(ptyId, incarnationId) | ||
| if (observationRoute.kind !== 'live') { |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C6 \
'admittedPtyObservationSourceByPtyId\.(set|delete)|noteAdmittedPtyObservationSource|persistedIncarnationId|readKnownPredecessorPaneIncarnationForPty' \
src/main/runtime
rg -n -C8 \
'cold|restore|early.*title|persisted.*incarnation|observation.*admission' \
src/main/runtime/orca-runtime-tests/pty-observation-admission.spec.tsRepository: stablyai/orca
Length of output: 36460
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- on-pty-data ---'
cat -n src/main/runtime/orca-runtime-on-pty-data.ts | sed -n '1,120p'
printf '%s\n' '--- observation admission ---'
cat -n src/main/runtime/orca-runtime-pty-observation-admission.ts | sed -n '1,225p'
printf '%s\n' '--- relevant tests ---'
cat -n src/main/runtime/orca-runtime-tests/pty-observation-admission.spec.ts | sed -n '80,220p'
cat -n src/main/runtime/orca-runtime-tests/pty-observation-admission.spec.ts | sed -n '480,535p'
cat -n src/main/runtime/orca-runtime-tests/pty-observation-admission.spec.ts | sed -n '595,705p'Repository: stablyai/orca
Length of output: 33268
🤖 get_repo_knowledge executed:
get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings
Length of output: 17443
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- route and candidate bindings ---'
rg -n -C12 \
'resolvePtyObservationRoute|canSeedAdmittedPtyObservationSource|ptyObservationCapsulesByPtyId|observePtyAutomaticData|pendingPtyObservationAdmission' \
src/main/runtime/orca-runtime-pty-observation-admission.ts \
src/main/runtime/orca-runtime-on-pty-data.ts \
src/main/runtime/runtime-pty-observation-capsule.ts \
src/main/runtime/runtime-pty-observation-state.ts \
src/main/runtime
printf '%s\n' '--- cold replacement and early observation tests ---'
rg -n -C12 \
'cold|relaunch|successor|persistedIncarnationId|early.*(title|status|cwd)|CWD|cwd' \
src/main/runtime/orca-runtime-tests/pty-observation-admission.spec.tsRepository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- observation routing ---'
cat -n src/main/runtime/orca-runtime-pty-observation-routing.ts | sed -n '52,190p'
printf '%s\n' '--- capsule observation helpers ---'
cat -n src/main/runtime/orca-runtime-pty-observation-routing.ts | sed -n '190,330p'
printf '%s\n' '--- cold and successor tests ---'
rg -n -C8 \
'cold|relaunch|successor|early.*(title|status|cwd)|persistedIncarnationId' \
src/main/runtime/orca-runtime-tests/pty-observation-admission.spec.ts | head -n 240Repository: stablyai/orca
Length of output: 13070
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- admission reset path ---'
cat -n src/main/runtime/orca-runtime-pty-observation-admission.ts | sed -n '223,278p'
printf '%s\n' '--- reset implementation and state fields ---'
rg -n -C18 \
'resetTrackedTerminalStateForProviderGeneration|recordOsc7MetadataForPty|processAgentStatusOscForPty|lastOscTitle|lastAgentStatus|cwd' \
src/main/runtime/orca-runtime-*.ts src/main/runtime/runtime-*.ts | head -n 320Repository: stablyai/orca
Length of output: 31766
🏁 Script executed:
#!/bin/bash
set -euo pipefail
match=$(rg -l 'resetTrackedTerminalStateForProviderGeneration' src/main/runtime --glob '*.ts' | head -n 1)
printf '--- definition file: %s ---\n' "$match"
rg -n -C20 'resetTrackedTerminalStateForProviderGeneration' "$match"Repository: stablyai/orca
Length of output: 288
🏁 Script executed:
#!/bin/bash
set -euo pipefail
match=$(rg -l 'resetTrackedTerminalStateForProviderGeneration' src/main/runtime --glob '*.ts' | head -n 1)
echo "--- definition file: $match ---"
rg -n -C20 'resetTrackedTerminalStateForProviderGeneration' "$match"Repository: stablyai/orca
Length of output: 3217
🏁 Script executed:
#!/bin/bash
set -euo pipefail
while IFS= read -r match; do
case "$match" in
*.test.ts|*.spec.ts) continue ;;
esac
echo "--- definition file: $match ---"
rg -n -C24 'resetTrackedTerminalStateForProviderGeneration' "$match"
break
done < <(rg -l 'resetTrackedTerminalStateForProviderGeneration' src/main/runtime --glob '*.ts')Repository: stablyai/orca
Length of output: 250
Preserve early successor observations during cold replacement.
When no source exists in admittedPtyObservationSourceByPtyId, resolvePtyObservationRoute returns live for the tagged successor. The successor then updates live title, status, and CWD state. Later, acceptPtyObservationAdmission detects the persisted predecessor, resets that state, and has no capsule to restore. Seed the predecessor before stream ingestion, or route tagged data into a capsule until admission resolves.
| const existingToken = this.pendingPtyObservationAdmissionTokensByPtyId.get(ptyId) | ||
| if (existingToken) { | ||
| // Concurrent spawns for one pane share the audited candidate budget rather than doubling it. | ||
| return existingToken |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -euo pipefail
ast-grep outline src/main/runtime/orca-runtime-pty-observation-admission.ts \
--match 'beginPtyObservationAdmission|transferPtyObservationAdmission|cancelPtyObservationAdmission|acceptPtyObservationAdmission' \
--view expanded
rg -n -C8 \
'\b(begin|transfer|cancel|prepare|accept)PtyObservationAdmission\s*\(' \
src/mainRepository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- admission implementation ---'
sed -n '15,180p' src/main/runtime/orca-runtime-pty-observation-admission.ts
printf '%s\n' '--- production callers, excluding tests ---'
rg -n -g '!*.test.ts' -g '!*.spec.ts' -C6 \
'\b(beginPtyObservationAdmission|transferPtyObservationAdmission|cancelPtyObservationAdmission|preparePtyObservationAdmission|acceptPtyObservationAdmission)\s*\(' \
src/mainRepository: stablyai/orca
Length of output: 15728
🤖 get_repo_knowledge executed:
get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings
Length of output: 41093
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- admission token references outside tests ---'
rg -n -g '!*.test.ts' -g '!*.spec.ts' -C5 \
'observationAdmissionToken|commitRuntimePtySpawn|beginPtyObservationAdmission|cancelPtyObservationAdmission|preparePtyObservationAdmission|transferPtyObservationAdmission' \
src/main
printf '%s\n' '--- spawn wrapper candidates ---'
rg -n -g '!*.test.ts' -g '!*.spec.ts' -C4 \
'spawn.*pty|pty.*spawn|spawnRuntime|commit.*Spawn|registration lifetime|non-destructive cancellation' \
src/main/ipc src/main/runtimeRepository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- pane spawn reservation implementation ---'
sed -n '1,240p' src/main/ipc/pty/pane/spawn-reservation.ts
printf '%s\n' '--- runtime spawn orchestration ---'
sed -n '1,135p' src/main/ipc/pty/runtime/spawn.ts
sed -n '1,125p' src/main/ipc/pty/ipc/spawn-run.ts
printf '%s\n' '--- reservation call sites ---'
rg -n -g '!*.test.ts' -g '!*.spec.ts' -C7 \
'reservePaneSpawn|resolvePaneSpawnReservation|paneSpawnReservation|releaseWorktreeSpawn' \
src/main/ipc/ptyRepository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- runtime execution admission timing ---'
sed -n '1,115p' src/main/ipc/pty/runtime/spawn-execute.ts
sed -n '175,255p' src/main/ipc/pty/runtime/spawn-options.ts
printf '%s\n' '--- IPC execution admission timing ---'
sed -n '1,125p' src/main/ipc/pty/ipc/spawn-begin.ts
sed -n '1,115p' src/main/ipc/pty/ipc/spawn-execute.ts
printf '%s\n' '--- runtime spawn identity inputs ---'
sed -n '40,125p' src/main/ipc/pty/runtime/spawn-state.tsRepository: stablyai/orca
Length of output: 21242
Give each spawn lifetime independent admission ownership.
When IPC spawns omit a valid pane key, they skip pane reservation but still derive the same effective PTY ID and call beginPtyObservationAdmission. The shared token lets one failed spawn cancel the admission and candidate capsules needed by another spawn. The surviving spawn then prepares no admission, so acceptPtyObservationAdmission skips replacement retirement and promotion.
Use caller leases or reference-count the shared token. Otherwise serialize all spawn paths before admission.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the delta since the prior Pullfrog review — commit a98edfd, a merge of upstream main into the branch. The conflict resolutions adapt the terminal-identity work to upstream's deleted retained-row store without changing the PR's semantics.
- Hook-row reconcile moves onto the generation reset —
resetTrackedTerminalStateForProviderGenerationnow takespreserveResumeIdentityand forwards it toreconcileAgentStatusForEndedProcess. Both replacement branches (acceptPtyObservationAdmission,admitRegisteredPtyObservationSource) passtrue; the non-replacement path keeps upstream's exact call. - Retirement no longer reconciles twice —
retireReplacedPtyDurableIdentitydrops its own reconcile and only records the fenced evidence. That still reads the predecessor remnant because promotion writes no hook-store row (emitTerminalAgentStatusEventsfans out renderer events and records prompt lifecycle only). - Mobile projection adaptation — upstream's extraction of
runtime-mobile-agent-status-builder.tsand its newgetStatusSnapshot/getLiveBrowserTabscontract keep the PR'sgetRetiredPaneEvidence+excludeRetiredPaneEvidenceRowsfilter in both the projection'sgetHookRowsForPaneand the builder. - Coverage updated — the upstream
runtime-mobile-agent-status-builder.test.tshost gainsgetRetiredPaneEvidence; no other test changes were needed. Remaining range-diff entries (relay-control files, relay-region-compat test) are upstream formatting only.
The two invariants the PR established are intact: reconciliation with preserveResumeIdentity on a proven replacement, and retired evidence fenced by row instance. Targeted suites pass locally (62 tests across replacement identity, retired evidence, observation admission, hook projection, pty-exit reconciliation and the mobile builder).
openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
…nal-durable-identity-18464
Main now rejects unannotated `as` casts on changed lines. Give the replaced-identity code's test doubles and two-phase placeholders a SAFETY rationale, and drop the casts that bracket access or a discriminated flatMap make unnecessary.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the delta since the prior pullfrog review (a98edfd → 45ccca6): two merge integrations plus a test-only lint commit. The identity work survives the re-base intact.
- Re-based onto a much newer upstream
main(via PR 1's advanced branch) — the branch now sits on upstream's stream-queue accounting (accountDaemonStreamEntry/releaseDaemonStreamEntry, the per-session metadata budget) and on the movedDaemonPtyRouterDataEventtype. Source-scoped coalescing still keys onlast.incarnationId === options.incarnationId, thedataGapmerge still keys onpayload.incarnationId, everyencodeStreamDataEvent/writeStreamDataEventspath still threads the optionalincarnationId, anddaemon-server.tskeepsentry.incarnationIdon flush. - Listener payload types relocated — the optional
incarnationIdthat used to be added ondaemon-pty-event-subscriptions.tsanddaemon-pty-runtime-state.tsnow lives on the sharedDaemonPtyRouterDataEventindaemon-pty-router-events.ts; both consumers reference it. - Test-double and placeholder casts annotated —
45ccca6addsSAFETY:rationales to the replaced-identity test doubles, drops the casts that bracket access or a discriminatedflatMapmake unnecessary, and leaves the two-phase capsule/entry placeholders with a justification comment. Source files received comments only.
Verification: 49 targeted tests pass (daemon stream source incarnation, adapter source incarnation, replacement identity retirement, retired evidence, observation admission, pane-keyed reaper ratchet) and pnpm tc:node is clean. Durable identity retirement, retired-row evidence matching and the renderer replacement path are unchanged.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
When a remote terminal gets replaced (daemon restart or upgrade, shell respawn), the pane should describe the new terminal and stop describing the one that is gone. Before this change the host kept publishing the old process's title, its agent identity and a completed "Pi" row stamped onto the new terminal's handle — which is what made a recovered pane look alive with stale state. This change attributes every observation to the session that produced it, accepts automatic state only for the terminal that actually won the replacement, and retires the previous terminal's automatic identity only when a replacement is positively proven.
What Changed
Automatic clearing is no longer part of the pre-commit sequence reset, so a failed or cancelled spawn no longer wipes accepted state early. Raw output, query replies, model receipts and sequence accounting are unaffected while a candidate is unadmitted.
Why
Issue #18464's recording showed a recovered pane rendering blank; the follow-up diagnosis showed the host still publishing the predecessor's Pi title and a completed Pi row on the successor handle after a replacement. The cause spans three layers: the daemon stream and runtime parsers key by PTY id (so a successor's early bytes are indistinguishable from the predecessor's without source metadata); the runtime consumed automatic title/status before knowing which incarnation was finally admitted; and durable records (persisted tab label, leaf pane title, hook rows, restore seeds) were never retired because the exit path had already removed the very binding a naive "previous identity" lookup would read.
Each layer is fixed at its own boundary, which is also why the change is larger than a title-string clear: the alternative — comparing titles or clearing strings after the fact — cannot survive an identical successor title, and would either mask live state or delete a user's own rename.
Linked Issue
Fixes #18464
Stack 2/2. Built on top of #19925 (terminal recovery and replacement mouse state). Both PRs target
main, and this branch currently contains that PR's two commits; it will be rebased ontomainonce PR 1 merges. Either PR merged alone fixes a real part of the issue; this one is the part that stops stale agent identity being published.Visual Proof
Proven replacement in the isolated paired host/client scenario, after the replacement has settled. Before: the predecessor's Pi title, identity and completed agent row survive on the successor handle. After: the surface carries its stable label and the host publishes no predecessor identity or agent row.
Screenshots were captured through hidden CDP against disposable Linux fixtures; no native window was shown or focused.
Testing
Verification on this commit (all under a sanitized environment, disposable HOME, Xvfb,
ORCA_BACKGROUND_LAUNCH=1, no global E2E setup):orca-runtime-files-terminal-artifact-io,worktree-git-common-polling) were characterised by isolated re-runs; neither file is touched by this change and the final broad run is green.No native macOS/Windows or real SSH rendered validation; mixed-version coverage is protocol-level. Full repository lint/test/build suites are not claimed.
AI Disclosure
AI-assisted implementation with separate independent review at each stage (multiple assistant models), plus supervisor inspection of diffs, tests and evidence artifacts.
Review
The work was split into three reviewed stages — daemon source provenance, runtime observation admission, and durable identity retirement — each independently reviewed, with the reviewer's findings reproduced as failing tests before being fixed and then re-verified by the same reviewer:
src/sharedratchet that this work had left red was found by the broad gate and fixed.Security, cross-platform, SSH/remote, mobile and backwards-compatibility review: retirement is main-process-only and process-local, writes no liveness verdict, invents no exit or completion, adds no new opcode or required field, preserves resume/history addressability, and is bounded and reaped.
Agent skill upstream boundary
Notes
Known limitations, recorded deliberately rather than fixed here:
Terminal), which is a visible change from the previous behaviour.pane:Nsurfaces are outside the retirement, which applies to stable-pane surfaces.Checklist
pnpm lint,pnpm typecheck,pnpm test, andpnpm buildrun; targeted checks listed above