Skip to content

fix(kimi): recognize the sessionless startup composer - #22726

Closed
kinescoper wants to merge 5 commits into
stablyai:mainfrom
kinescoper:fix/kimi-startup-readiness
Closed

kinescoper wants to merge 5 commits into
stablyai:mainfrom
kinescoper:fix/kimi-startup-readiness

Conversation

@kinescoper

@kinescoper kinescoper commented Sep 24, 2026 •

Copy link
Copy Markdown

ELI5

Kimi Code 2.0.2 can be ready for its first message while Orca still waits for it to become ready. Recognize its captured empty startup input when Orca has independently identified Kimi, so a sessionless startup can finish its readiness wait.

What Changed

  • Match the captured welcome metadata, lazy-session notice and empty input box. A banner alone, model picker, or subsequent ordinary output is insufficient.
  • Require resolved Kimi identity from the existing launch or foreground-process metadata at every readiness caller. An unknown pane cannot establish Kimi readiness from screen text alone; a sessionless Kimi with known identity remains supported.
  • Keep Kimi working/blocked/waiting status authoritative regardless of age. Only a subsequent done status or the existing provider-generation reset clears this veto.
  • Fence asynchronous screen reads to the original PTY ID and incarnation. A replacement cannot reuse its predecessor's screen even when the handle and PTY ID survive. Recheck current agent identity and status before settling; blocked prompts remain reported separately.

Adds two sanitized raw PTY captures and 30 Kimi runtime cases. Merged upstream main c220d92c, retaining its removal of the obsolete structured-session adapter.

Why

Before Kimi's first message there is no session hook to rely on. This uses the existing terminal readiness, process identity and first-party status paths without sending a probe prompt, adding a timeout heuristic, or changing model settings. Readiness does not itself authenticate a dispatch destination. The new Kimi rule requires independent identity rather than promoting an unknown pane based on its output.

The matcher deliberately remains narrow: unrecognized sizes or future startup layouts time out rather than use a looser banner-and-silence fallback. Scope is initial sessionless readiness, not general post-turn idle detection or end-to-end prompt delivery.

Linked Issue

Related to #10336 and #10369. Those track early prompt injection in older Kimi versions; this addresses the distinct ready-but-unrecognized sessionless startup in Kimi Code 2.0.2. It does not claim to close the original injection issue.

Visual Proof

N/A — no rendered UI changes. Before this change, the captured sessionless empty composer times out; after it, an identified Kimi pane satisfies the readiness wait. Transcript replay also checks these boundaries:

Input or transition Expected result
Identified sessionless Kimi, local or simulated SSH pane Ready, including repeated waits and waits registered before startup output
Model picker or new ordinary output after startup Not ready
Known Codex/Claude or identity-unknown pane displaying the Kimi capture Not ready
Unknown pane identified as Kimi while its screen is read Ready if the PTY incarnation is unchanged
Unknown pane identified as Codex/Claude during the read Not ready
PTY incarnation replaced during the read, same handle and PTY ID Discard predecessor screen
Retained startup with working/blocked/waiting status, fresh or older than 30 minutes Not ready
Working status followed by done during the read, including after 30 minutes Ready
Waiting status with a recognized trust prompt Report the blocked prompt separately

Raw captures include metadata and same-width username redaction. CR/ANSI bytes and padding are intentionally preserved; they are test fixtures required by the terminal-screen contributor guidance, not screenshot attachments.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated

Captured Kimi Code 2.0.2 on macOS at 120x40 with the repository recorder, without submitting a model prompt. Validated the patched runtime through transcript replay; no patched Electron app, live SSH, Linux or Windows validation is claimed.

Passed on upstream main c220d92c plus this patch:

ORCA_BACKGROUND_LAUNCH=1 pnpm exec vitest run --config config/vitest.config.ts \
  src/main/runtime/kimi-visible-probe-status.test.ts \
  src/main/runtime/kimi-readiness-transcripts.test.ts \
  src/main/runtime/terminal-wait-detection.test.ts \
  src/main/runtime/terminal-wait-name-only-idle.test.ts \
  src/main/runtime/runtime-terminal-idle-polls.test.ts \
  src/main/runtime/tui-idle-evidence.test.ts \
  src/main/runtime/tui-idle-delivery-and-quiescence.test.ts \
  src/main/runtime/structured-worker-agent-presence.test.ts \
  src/main/runtime/orca-runtime-hook-agent-status-projection.test.ts \
  config/scripts/pty-transcript-secret-scan.test.mjs
# 172 tests passed across 10 files

ORCA_BACKGROUND_LAUNCH=1 pnpm exec tsc --noEmit -p config/tsconfig.node.json

Changed-file oxlint and commit-hook checks also pass. Full lint/typecheck/test/build remain for CI; only node typecheck and the listed focused suites were run locally.

AI Disclosure

OpenAI Codex assisted with implementation, real terminal capture, regression tests, and this PR description.

Review

Cross-agent readiness, mid-read status changes, mid-read identity changes, and aged non-done status were reproduced by failing tests before their fixes. The final follow-up also reproduced acceptance of a predecessor screen after a same-handle PTY replacement and acceptance of an unidentified pane in both readiness paths. Those cases now fail closed, while confirmed foreground Kimi without launch metadata remains supported.

Please review the incarnation fence, the independently resolved identity requirement, and the Kimi-specific precedence of unfinished status. Method documentation explains the distinction between presence and readiness.

Agent skill upstream boundary

  • Not applicable: no skill-installer source or content is copied.

Notes

If Kimi's completion signal is lost, its non-done veto can now yield a timeout rather than false readiness. The shared freshness policy for other agents is unchanged. Sessionless is distinct from identity-unknown: startup works with launch or confirmed foreground identity, but an unidentified pane may time out until identified.

No new dependencies, wire formats, model settings or platform-specific execution are introduced by this patch. The simulated SSH case exercises the common runtime path, not a live remote deployment.

Checklist

  • This PR is small and focused
  • Explained the user-facing change, mechanism and tradeoffs
  • Visual evidence or N/A with reason supplied
  • Self-reviewed correctness, security and performance
  • Cross-platform, SSH/remote and folder-workspace impact considered
  • Focused tests, node typecheck and changed-file lint pass; full checks remain for CI

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No critical issues — one deferred observation on the matcher's forward compatibility.

Reviewed changes

Kimi 2 creates its session lazily, so its sessionless startup composer has no SessionStart/Stop hook and tui-idle waits timed out. This PR recognizes the captured startup screen and lets Kimi's own status outrank a retained startup frame. Reviewed the complete diff at 624f78e:

  • New Kimi readiness matcher (kimi-terminal-readiness.ts): locates the last welcome to kimi code!, requires the sessionless notice after it with directory:/model:/version: in between, then requires the tail after the notice to be exactly three non-blank rows (notice, ╭─╮, │ > │).
  • Wired into tier-1 evidence (terminal-wait-detection.ts): added to findKnownReadyPromptIndex.
  • Kimi-specific precedence (tui-idle-evidence.ts): a fresh working/blocked/waiting first-party status now returns false before the tier-1 positive check, so Kimi's own account of itself outranks the retained startup frame.
  • Two captured fixtures + sidecars and a 8-case transcript suite covering pre-registered waits, local and simulated-SSH panes, repeated waits, model-picker refusal, retained-tail veto under fresh status, and ordinary-output refusal.

I traced the tail normalization: the fixture's trailing cursor-up ([3A) splices the rows below the input line, so the retained tail genuinely is the three-row composer — the lines.length !== 3 guard is what rejects both the model-picker and ordinary-output fixtures. Tests pass (new suite 8/8; related suites 78/78), and oxlint is clean on the changed sources. The Kimi-specific precedence is consistent with the existing delivery gate (a working agent should not be typed into), and the guard correctly does not fire during the initial sessionless wait, where firstPartyStatus is null.

ℹ️ The exact-row match silently reverts the fix when Kimi's screen shifts

The matcher is a byte-exact three-row tail (kimi-terminal-readiness.ts:24-31). That is the right call for pinning a captured screen, but it also means the failure mode is invisible: a Kimi patch that adds a hints row, wraps the notice at a narrower width, or a different --cols all make recognition stop, and the wait simply returns to the original silent timeout with no signal that the screen changed. The author already flagged that later revisions will need new fixtures; worth deciding now whether a cheap fallback (a looser body match held to quiescence, like the Muse lane) or at least a distinguishable timeout reason is warranted before this ships as the only signal for sessionless Kimi readiness.

Technical details
# Kimi sessionless match has no degradation path

## Affected sites
- `src/main/runtime/kimi-terminal-readiness.ts:24-31` — `lines.length !== 3` plus the two exact row regexes is the whole match; no partial/looser evidence tier.

## Required outcome
- Decide whether a screen the matcher no longer recognizes should fail identically to "agent never became ready" (current behavior: a bare `timeout`), or whether it should degrade to a weaker signal or surface a distinct reason so the regression is diagnosable.

## Open questions for the human
- Is the three-row tail stable across the Kimi versions/terminal sizes Orca targets, or is a capture per size expected?
- Would a lower-tier "startup banner seen, stream quiet" fallback (mirroring `hasQuietMuseReadyPrompt`) be acceptable, or does it risk the mid-turn settle the model-picker fixture guards against?

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 6840c394-43a0-4214-ac46-7b3c5ba8f2d1

📥 Commits

Reviewing files that changed from the base of the PR and between 1f32bb0 and 911b77e.

📒 Files selected for processing (7)
  • src/main/runtime/kimi-readiness-transcripts.test.ts
  • src/main/runtime/kimi-visible-probe-status.test.ts
  • src/main/runtime/orca-runtime-resolve-exit-waiters.ts
  • src/main/runtime/orca-runtime-start-tui-idle-visible-read-probe.ts
  • src/main/runtime/runtime-terminal-agent-presence.ts
  • src/main/runtime/runtime-terminal-wait.ts
  • src/main/runtime/terminal-wait-detection.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/runtime/runtime-terminal-agent-presence.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The change adds fixtures and detection for Kimi’s sessionless ready prompt. Runtime readiness checks now pass pane-agent identity to known-ready prompt detection. Kimi idle checks treat any non-null first-party status other than done as an unfinished turn, regardless of age. The visible-read probe also verifies PTY identity before it classifies a screen. New tests cover prompt recognition, agent identity, status metadata, and visible-read outcomes.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 911b7

The reviewed startup-readiness change is mergeable after normal checks. An unidentified pane will wait for Kimi identity to be confirmed rather than report readiness from its screen alone.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 911b7

This changes when automated work may proceed. Identity checks and activity-state checks limit false readiness, but the freshness of some screen reads remains unverified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The newly accepted text can affect terminal-readiness decisions for identified Kimi panes across multiple wait paths, including the simulated SSH-pane case; the supplied impact map identifies no changed service dependency edge.

Trust Boundaries and Controls

  • observed — Screen content is readiness evidence, not the source of pane identity. The Kimi candidate requires a separately resolved identity, while current non-done status vetoes a positive idle decision.

Resilience and Maintainability Implications

  • observed — The probe ignores a late read after its waiter is removed and rejects a result from a different PTY incarnation. The inspected consumer does not establish a content-version check within one incarnation.

Hardening Proposals

  • proposed — Establish or document whether a visible-screen projection is fresh at wait settlement for an unchanged PTY incarnation, especially when no explicit activity status is available.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 11 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the main change: recognizing Kimi’s sessionless startup composer.
Description check ✅ Passed The description is complete and follows the required template. It explains the user impact, implementation, rationale, linked issues, visual-proof rationale, testing scope, AI use, review focus, compa…
  • Fix all pre-merge checks with AI

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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: bd93029a-eeaf-4732-80e1-f2c8e4801022

📥 Commits

Reviewing files that changed from the base of the PR and between f0b3f44 and 624f78e.

📒 Files selected for processing (8)
  • src/main/runtime/__fixtures__/kimi-sessionless-model-picker.meta.json
  • src/main/runtime/__fixtures__/kimi-sessionless-model-picker.txt
  • src/main/runtime/__fixtures__/kimi-sessionless-ready.meta.json
  • src/main/runtime/__fixtures__/kimi-sessionless-ready.txt
  • src/main/runtime/kimi-readiness-transcripts.test.ts
  • src/main/runtime/kimi-terminal-readiness.ts
  • src/main/runtime/terminal-wait-detection.ts
  • src/main/runtime/tui-idle-evidence.ts

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


function findKnownReadyPromptIndex(normalized: string): number | null {
const indexes = [
findKimiSessionlessReadyPromptIndex(normalized),

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '70,135p' src/main/runtime/terminal-wait-detection.ts
sed -n '35,190p' src/main/runtime/tui-idle-evidence.ts
sed -n '40,110p' src/main/runtime/runtime-terminal-wait.ts
rg -n 'findKnownReadyPromptIndex|isKnownReadyPromptPreview|isTuiIdleSatisfied' src/main/runtime

Repository: stablyai/orca

Length of output: 19366


🏁 Script executed:

sed -n '1,75p' src/main/runtime/terminal-wait-detection.ts
sed -n '1,130p' src/main/runtime/kimi-terminal-readiness.ts
sed -n '320,440p' src/main/runtime/terminal-wait-detection.test.ts
sed -n '1,130p' src/main/runtime/kimi-readiness-transcripts.test.ts
sed -n '95,220p' src/main/runtime/orca-runtime-resolve-exit-waiters.ts
sed -n '105,215p' src/main/runtime/runtime-terminal-idle-polls.ts
rg -n "getPaneAgent|resolve.*Agent|TuiAgent|agent.*kimi|kimi" src/main/runtime src/main/shared src/shared

Repository: stablyai/orca

Length of output: 42067


🏁 Script executed:

rg -n "getPaneAgentForTuiIdle|getPaneAgent|createTranscriptPane|launchAgent|paneTitle|foregroundProcess" src/main src/shared --glob '*.ts' | head -240
sed -n '130,210p' src/main/runtime/tui-idle-evidence.ts
sed -n '1,180p' src/main/runtime/agent-transcript-pane-test-harness.ts

Repository: stablyai/orca

Length of output: 32159


Exclude Kimi readiness from known non-Kimi panes.

getPaneAgentForTuiIdle resolves the pane agent from launchAgent or foregroundAgent, but isKnownReadyPromptPreview does not receive that identity. A known non-Kimi pane can therefore match the Kimi welcome metadata and empty-composer frame in its retained transcript.

All tui-idle callers treat this match as positive evidence before the general non-done status veto. The wait can resolve while the non-Kimi pane is still active. The same predicate also gates mailbox delivery, which can inject input into a running pane.

Pass the resolved agent to the detector from every tui-idle caller. Suppress only the Kimi candidate for known non-Kimi agents. Keep it available for unknown agents because an unknown pane may be a sessionless Kimi pane.

Suggested fix
+import type { TuiAgent } from '../../shared/tui-agent'
+
-export function isKnownReadyPromptPreview(preview: string): boolean {
+export function isKnownReadyPromptPreview(
+  preview: string,
+  agent?: TuiAgent | null
+): boolean {
   const normalized = preview.toLowerCase()
-  const readyIndex = findKnownReadyPromptIndex(normalized)
+  const readyIndex = findKnownReadyPromptIndex(normalized, agent)
@@
-function findKnownReadyPromptIndex(normalized: string): number | null {
+function findKnownReadyPromptIndex(
+  normalized: string,
+  agent?: TuiAgent | null
+): number | null {
   const indexes = [
-    findKimiSessionlessReadyPromptIndex(normalized),
+    agent === null || agent === undefined || agent === 'kimi'
+      ? findKimiSessionlessReadyPromptIndex(normalized)
+      : null,
     findCodexReadyPromptIndex(normalized),
     findAntigravityReadyPromptIndex(normalized),
     findCursorReadyPromptIndex(normalized)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 4c038bc2-4cbe-4119-973e-fc933895477c

📥 Commits

Reviewing files that changed from the base of the PR and between 624f78e and 967b9af.

📒 Files selected for processing (8)
  • src/main/runtime/kimi-readiness-transcripts.test.ts
  • src/main/runtime/orca-runtime-resolve-exit-waiters.ts
  • src/main/runtime/orca-runtime-start-tui-idle-visible-read-probe.ts
  • src/main/runtime/orca-runtime-stop-structured-session-process.ts
  • src/main/runtime/runtime-terminal-agent-presence.ts
  • src/main/runtime/runtime-terminal-idle-polls.ts
  • src/main/runtime/runtime-terminal-wait.ts
  • src/main/runtime/terminal-wait-detection.ts

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

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

This run covers the delta since the prior pullfrog review (624f78e): commit 967b9af scopes the Kimi startup matcher to the pane's resolved agent and adds three regression cases.

  • Agent-gated Kimi matcher — isKnownReadyPromptPreview now takes the pane's resolved TuiAgent, and findKnownReadyPromptIndex runs the Kimi sessionless finder only when the agent is kimi or unresolved. A known Codex/Claude pane can no longer settle on a quoted Kimi frame.
  • Agent threaded through every satisfaction site — the resolved pane agent (launch authority, then foreground) is now passed at each isTuiIdleSatisfied / presence / visible-read call site, so the immediate check and the poll agree about the same pane.
  • Three regression cases — a working Codex and Claude pane displaying the Kimi capture must time out, and an unknown-agent pane with the same capture must still settle.

I confirmed the new gate is load-bearing rather than decorative: removing it makes the two cross-agent cases resolve satisfied: true where a timeout is required, so the tests genuinely fail with the bug present. The agent value is sourced identically everywhere (ptysById.get(ptyId)?.launchAgent ?? foregroundAgent, including getTrackedPty in the presence path), so no site can rank the same pane differently. The Kimi suite is 11/11 and the related readiness suites pass (87 tests). The Kimi precedence early return and the narrow exact-row match are unchanged from the reviewed commit.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

This run covers the delta since the prior pullfrog review (967b9af): commit 32c8f0c closes a stale-snapshot race in the single-shot visible-screen probe and adds a six-case suite.

  • Live-status recheck in the visible-screen probe — the probe bypasses isTuiIdleSatisfied, so after the async screen read returns it now re-resolves the pane agent and, for Kimi, refuses to settle on a ready snapshot when a fresh working/blocked/waiting first-party status arrived while the read was in flight. The guard is skipped when blockedReason is set, so a blocked prompt still reports.
  • Six regression cases (kimi-visible-probe-status.test.ts) — working/blocked/waiting arriving mid-read must not settle, a ready snapshot with no status settles, working→done settles on the latest status, and a waiting status with a blocked tail still reports agent-trust-workspace.

I confirmed the guard is load-bearing: forcing its condition false makes the three mid-read cases resolve satisfied: true where a timeout is required. I also traced every direct buildTerminalWaitResult/buildPtyTerminalWaitResult site and every other tui-idle settle path routes through isTuiIdleSatisfied, so the visible probe was the only path bypassing the Kimi status veto. New suite 6/6; related suites (kimi-readiness-transcripts, terminal-wait-detection, tui-idle-evidence) 69/69; oxlint clean on both changed files.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 Minor · Reject a visible snapshot when the effective… · orca-runtime-start-tui-idle-visible-read-probe.ts:84-101

src/main/runtime/orca-runtime-start-tui-idle-visible-read-probe.ts:84-101
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Reject a visible snapshot when the effective agent changes.

An adopted PTY can keep the same handle while its foregroundAgent changes. The probe captures the original agent before readTerminal starts, then classifies the completed snapshot with that captured agent. The current-agent check only rejects fresh Kimi working status. An old Kimi ready snapshot can therefore resolve the current wait as idle after the PTY changes to another agent.

Suggested fix
+        const ptyId =
+          this.getLivePtyForHandle(waiter.handle)?.pty.ptyId ??
+          this.getLiveLeafForHandle(waiter.handle).leaf.ptyId
+        const liveAgent = this.getPaneAgentForTuiIdle(ptyId)
+        if (liveAgent !== agent) {
+          return
+        }
         const snapshotText =
-          agent === 'antigravity'
+          liveAgent === 'antigravity'
             ? [...projection.tail, projection.draft ?? ''].join('\n')
             : projection.tail.join('\n')
         const blockedReason = detectTerminalWaitBlockedReason(snapshotText)
         const ready =
-          agent === 'antigravity'
+          liveAgent === 'antigravity'
             ? isAntigravityReadyPromptSnapshot(snapshotText)
-            : isKnownReadyPromptPreview(snapshotText, agent)
+            : isKnownReadyPromptPreview(snapshotText, liveAgent)
         if (!blockedReason && !ready) {
           return
         }
         // The agent can become busy while the provider's screen read is in flight.
-        const ptyId =
-          this.getLivePtyForHandle(waiter.handle)?.pty.ptyId ??
-          this.getLiveLeafForHandle(waiter.handle).leaf.ptyId
-        const liveAgent = this.getPaneAgentForTuiIdle(ptyId) ?? agent
         if (

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 31ba5139-d5d5-4f57-9e49-391070d87a05

📥 Commits

Reviewing files that changed from the base of the PR and between 967b9af and 32c8f0c.

📒 Files selected for processing (2)
  • src/main/runtime/kimi-visible-probe-status.test.ts
  • src/main/runtime/orca-runtime-start-tui-idle-visible-read-probe.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/runtime/orca-runtime-start-tui-idle-visible-read-probe.ts

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

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

This run covers the delta since the prior pullfrog review (32c8f0c): commit 1f32bb0 makes the Kimi status veto age-independent and re-resolves the pane's live identity in the single-shot visible-screen probe.

  • Age-independent Kimi status veto — hasUnfinishedKimiTurn replaces the freshness-bounded check in isTuiIdleSatisfied, so a Kimi working/blocked/waiting status keeps vetoing readiness past the 30-minute window; only a subsequent done status or the provider-generation reset clears it.
  • Live pane identity in the visible-screen probe — after the async read returns, the probe re-resolves ptyId and the pane's current agent and classifies the snapshot with it (isAntigravityReadyPromptSnapshot or isKnownReadyPromptPreview(text, liveAgent)), then applies the same hasUnfinishedKimiTurn veto. A pane that changes identity mid-read is now ranked by its current agent, so a retained Kimi frame cannot settle a pane that has since become Codex/Claude.
  • Regression coverage — aged (31-minute) working/blocked/waiting statuses in both the transcript and probe paths, unknown→Codex/Claude/Kimi identity changes during a read, and completion after an aged working status.

I confirmed the new age-independence tests are load-bearing: under the old freshness gate a 31-minute-old working status would not veto, so tier-1 body evidence would settle where these tests require a timeout. Traced both call sites — the isTuiIdleSatisfied early return (which already outranked tier-1 body evidence for Kimi) only loses the freshness window, and the probe's veto is still skipped when blockedReason is set, so blocked prompts keep reporting. Suites pass: kimi-readiness-transcripts 14/14, kimi-visible-probe-status 13/13, terminal-wait-detection 50/50, tui-idle-evidence 8/8; oxlint clean on the four changed files.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: f4e2d799-f657-4317-ae5f-16bc2fbb5e2a

📥 Commits

Reviewing files that changed from the base of the PR and between 32c8f0c and 1f32bb0.

📒 Files selected for processing (4)
  • src/main/runtime/kimi-readiness-transcripts.test.ts
  • src/main/runtime/kimi-visible-probe-status.test.ts
  • src/main/runtime/orca-runtime-start-tui-idle-visible-read-probe.ts
  • src/main/runtime/tui-idle-evidence.ts

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

Comment on lines +77 to +80
const ptyId =
this.getLivePtyForHandle(waiter.handle)?.pty.ptyId ??
this.getLiveLeafForHandle(waiter.handle).leaf.ptyId
const liveAgent = this.getPaneAgentForTuiIdle(ptyId) ?? agent

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Inspect whether a waiter and screen read can survive PTY replacement.
set -euo pipefail
rg -n -C 5 'getLivePtyForHandle\(|getLiveLeafForHandle\(|startTuiIdleVisibleReadProbe\(' src/main/runtime
rg -n -C 5 'terminalWaiters\.(resolve|reject|delete|remove|clear)|registerPty\(|visibleScreenOnly' src/main/runtime

Repository: stablyai/orca

Length of output: 45667


🏁 Script executed:

set -euo pipefail
printf '%s\n' '--- probe ---'
cat -n src/main/runtime/orca-runtime-start-tui-idle-visible-read-probe.ts | sed -n '1,135p'
printf '%s\n' '--- waiter symbols ---'
rg -n -C 8 'type TerminalWaiter|interface TerminalWaiter|terminalWaiters|startTuiIdleVisibleReadProbe|readTerminal\(' src/main/runtime -g '*.ts' -g '!*.test.ts'
printf '%s\n' '--- replacement and registration symbols ---'
rg -n -C 10 'registerPty|replace.*Pty|rebind|handleByPtyId|handles\.set|onPtyExit|waiter' src/main/runtime -g '*.ts' -g '!*.test.ts' | head -n 1600
printf '%s\n' '--- provider read implementation ---'
cat -n src/main/runtime/orca-runtime-capture-provider-terminal-buffer.ts | sed -n '120,190p'

Repository: stablyai/orca

Length of output: 45647


🏁 Script executed:

set -euo pipefail
printf '%s\n' '--- candidate files ---'
rg -l 'class .*Waiter|terminalWaiters|registerPty\(|bindPty|rebind.*handle|handleByPtyId' src/main/runtime -g '*.ts' -g '!*.test.ts' | sort -u
printf '%s\n' '--- waiter-store definitions ---'
rg -n -C 12 'class .*Waiter|terminalWaiters\s*=|rejectHandle\(|remove\(waiter|resolve\(waiter|rejectAll\(' src/main/runtime -g '*.ts' -g '!*.test.ts' | head -n 1200
printf '%s\n' '--- register/rebind definitions ---'
rg -n -C 15 '^[[:space:]]*(protected |private |public )?(async )?(registerPty|bindPty|rebindPty|replacePty|onPtyExit)\b|registerPty\s*\(' src/main/runtime -g '*.ts' -g '!*.test.ts' | head -n 1600

Repository: stablyai/orca

Length of output: 42728


🏁 Script executed:

set -euo pipefail
printf '%s\n' '--- waiter registry ---'
cat -n src/main/runtime/runtime-terminal-waiter-registry.ts
printf '%s\n' '--- bind incarnation handle ---'
cat -n src/main/runtime/orca-runtime-bind-pty-incarnation-handle.ts
printf '%s\n' '--- register pty ---'
cat -n src/main/runtime/orca-runtime-register-pty.ts
printf '%s\n' '--- invalidate handles ---'
cat -n src/main/runtime/orca-runtime-invalidate-all-handles-for-pty.ts
printf '%s\n' '--- handle/pty maps and binding callers ---'
rg -n -C 12 'bindPtyIncarnationHandle|issuePtyHandle|handleByPtyId|handleByPtyIncarnation|invalidateAllHandlesForPty|rejectWaitersForHandle|registerPty\(' src/main/runtime/orca-runtime*.ts src/main/runtime/runtime-terminal*.ts -g '*.ts' -g '!*.test.ts' | head -n 1800

Repository: stablyai/orca

Length of output: 42774


🏁 Script executed:

set -euo pipefail
printf '%s\n' '--- invalidate all handles ---'
cat -n src/main/runtime/orca-runtime-invalidate-all-handles-for-pty.ts
printf '%s\n' '--- bind/reconcile callers ---'
rg -n -C 18 'bindPtyIncarnationHandle\(|invalidatePtyIncarnationHandle\(|invalidateLeafHandle\(|adoptFirstPtyForLeafHandle\(|reconcilePtyIncarnationHandles\(' src/main/runtime/orca-runtime*.ts -g '*.ts' -g '!*.test.ts'
printf '%s\n' '--- graph sync relevant section ---'
rg -n -C 20 'reconcilePtyIncarnationHandles|invalidateLeafHandle|adoptFirstPtyForLeafHandle|handleByLeafKey|ptyId.*changed|previous.*pty' src/main/runtime/orca-runtime-sync-window-graph.ts src/main/runtime/orca-runtime*.ts -g '*.ts' -g '!*.test.ts' | head -n 1200

Repository: stablyai/orca

Length of output: 42165


🏁 Script executed:

set -euo pipefail
printf '%s\n' '--- lifecycle generation definitions and writes ---'
rg -n -C 12 'ptyLifecycleGenerationById|getPtyLifecycleGeneration|increment.*Lifecycle|lifecycleGeneration' src/main/runtime -g '*.ts' -g '!*.test.ts' | head -n 1600
printf '%s\n' '--- provider read entry and serialization ---'
rg -n -C 18 'readTerminal\(|readProviderTerminalTailLines|serializeProviderTerminalBuffer|parseVisibleSnapshot|visibleScreenOnly' src/main/runtime/orca-runtime*.ts src/main/runtime/runtime*.ts -g '*.ts' -g '!*.test.ts' | head -n 1800

Repository: stablyai/orca

Length of output: 42688


🏁 Script executed:

set -euo pipefail
rg -n -C 20 'advancePtyLifecycleGeneration\(|ptyLifecycleGenerationById\.set|nextPtyLifecycleGeneration|incarnationChanged|rememberPtyHandleReplacementFence|invalidateAllHandlesForPty\(ptyId\)' src/main/runtime -g '*.ts' -g '!*.test.ts' | head -n 1800

Repository: stablyai/orca

Length of output: 43039


Fence the visible projection to the PTY incarnation used by the read.

readTerminal checks only the ptyId after the screen read. A replacement can preserve the same direct handle and ptyId while changing the PTY incarnation. The pending waiter then remains registered, and the callback can classify the predecessor screen with the replacement agent and status.

Capture the PTY ID and incarnation before readTerminal, then reject the projection when either value changes.

🐛 Suggested fix
+    const readPty = this.getLivePtyForHandle(waiter.handle)
+    const readPtyId =
+      readPty?.pty.ptyId ?? this.getLiveLeafForHandle(waiter.handle).leaf.ptyId
+    const readIncarnationId = readPty?.pty.incarnationId ?? null
     void withTimeout(
...
-        const ptyId =
-          this.getLivePtyForHandle(waiter.handle)?.pty.ptyId ??
+        const livePty = this.getLivePtyForHandle(waiter.handle)
+        const ptyId =
+          livePty?.pty.ptyId ??
           this.getLiveLeafForHandle(waiter.handle).leaf.ptyId
+        if (
+          ptyId !== readPtyId ||
+          (livePty?.pty.incarnationId ?? null) !== readIncarnationId
+        ) {
+          return
+        }
         const liveAgent = this.getPaneAgentForTuiIdle(ptyId) ?? agent

Merge upstream main c220d92, retain its removal of the obsolete structured-session adapter, and require resolved Kimi identity for sessionless readiness.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

This run covers the delta since the prior pullfrog review (1f32bb0): commit 911b77e fences the visible-screen probe to the live PTY incarnation and requires resolved Kimi identity for the sessionless matcher, on top of merging upstream main (c220d92c).

  • Incarnation fence in the visible-screen probe — captures the PTY id and incarnation before the read and discards the snapshot if either changed by the time it returns, so a replacement that reuses both the handle and PTY id cannot settle on its predecessor's screen.
  • Resolved Kimi identity required — findKnownReadyPromptIndex runs the Kimi sessionless finder only when the pane agent is exactly kimi, dropping the previous agent == null escape; an unidentified pane can no longer settle from the captured Kimi screen, while a foreground-confirmed Kimi without launch metadata still does.
  • Probe classification uses the live agent only — the ?? agent fallback is removed, so a pane that loses identity mid-read fails closed.
  • Merge of upstream main — c220d92c folded in; the obsolete structured-session adapter it removed stays removed, so that file drops out of the PR's changed set.
  • Regression coverage — predecessor-screen and unidentified-pane cases added to kimi-visible-probe-status.test.ts; the transcript suite now asserts the unknown pane times out and the foreground-Kimi path settles.

I confirmed both new probe tests are load-bearing: disabling the incarnation fence makes the predecessor-screen case resolve satisfied: true where a timeout is required. The focused suites pass (88 tests across kimi-visible-probe-status, kimi-readiness-transcripts, terminal-wait-detection, tui-idle-evidence).

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker

Copy link
Copy Markdown
Contributor

Thanks for this. Kimi worker-start readiness on Windows and macOS works on current main without this change (see the #25253 retest), so closing as superseded.

@nwparker nwparker closed this Oct 25, 2026
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.

2 participants