Skip to content

fix: detect stable Cline startup composer from visible screen - #23269

Closed
texpress30 wants to merge 1 commit into
stablyai:mainfrom
texpress30:fix/cline-startup-readiness
Closed

texpress30 wants to merge 1 commit into
stablyai:mainfrom
texpress30:fix/cline-startup-readiness

Conversation

@texpress30

Copy link
Copy Markdown

ELI5

Cline can be ready for its first instruction while Orca keeps waiting until startup times out. Recognize its empty startup screen after it stays unchanged for three seconds.

What Changed

Adds a bounded Cline-specific visible-screen probe to the existing tui-idle waiter. It requires a connected Cline owner, no fresh explicit working status, complete running screen snapshots, no draft, and the captured zero-usage Act/auto-approve startup composer. It refuses overlays, changing screens, missing screen provenance and ownership changes. Other agents retain their existing probe behavior.

Why

Cline 3.0.65 does not match the existing ready-prompt detector. Its cursor-addressed output is reordered in retained textual history, so the probe uses the rendered visible screen. The matcher is intentionally limited to startup; it is not a general mid-turn completion signal.

Linked Issue

Fixes #23268

Visual Proof

N/A — no UI rendering changes. The change affects the runtime readiness waiter. A real Windows startup PTY capture and its metadata are included as regression fixtures; tests render it using xterm. Baseline waiter times out; fixed waiter resolves the stable empty composer, while an arriving explicit working status still times out. No claim of a packaged desktop release or end-to-end orchestration validation.

Testing

  • I manually tested these changes locally in a packaged desktop build
  • Automated tests added/updated

Windows: 25 focused tests passed initially across cline-readiness-transcript, cline-startup-probe, runtime-terminal-idle-polls, and tui-idle-evidence. After independent review, added an explicit working-status regression; both transcript tests passed (26 tests total across those files).

node node_modules/typescript/bin/tsc --noEmit -p config/tsconfig.node.json passed. Focused oxlint passed on all six changed TypeScript files. Tests cover captured startup, promotion/auth/permission/working overlays, typed drafts, unavailable/stream-only snapshots, truncated/limited/exited snapshots, changing screens, and ownership changes. Raw capture is preserved, including its terminal carriage returns; git diff --check reports those raw fixture bytes as whitespace. No full build, macOS/Linux/SSH live run, or packaged desktop smoke was performed; remaining CI coverage is required.

AI Disclosure

Implemented with OpenAI Codex and reviewed by a separate Codex reviewer.

Review

Independent review found no correctness defects. Its low-severity missing working-status test was added and passed.

Agent skill upstream boundary

  • Not applicable; no skill-installer code or artifacts are copied.

Notes

No renderer changes, shell command changes, installation changes or readiness bypass. Matching is intentionally conservative for the captured Cline layout. Application release and a live startup smoke remain necessary before relying on this for autonomous dispatch.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • N/A with reason provided for visual proof
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered; not live-tested outside Windows
  • Full lint/typecheck/test/build: focused local checks above; CI still required

@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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

📝 Walkthrough

Walkthrough

The runtime now recognizes Cline 3.0.65’s startup composer after three seconds of stable screen output. Cline panes can use the visible-read probe for tui-idle waits. The probe checks ownership, screen state, draft content, and fresh working status before it resolves a waiter. Added fixtures and tests cover startup detection and readiness outcomes.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🔵 Low · up to 36531

Cline startup readiness now works for the captured startup screen. Some workspace or branch names may still stop it from being recognized, and the wait then times out as it did before this change. That regression is bounded and easy to fix.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to 36531

A stable startup screen can now advance automated work. The checks are narrow, but it is not fully established how they behave when a terminal session is replaced or who can influence its displayed output.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed decision is scoped to waits on connected Cline terminal handles, but a satisfied wait can permit its caller to continue orchestration. No new cross-service dependency was identified in the available impact mapping.

Trust Boundaries and Controls

  • observed — Displayed terminal content is readiness evidence, not sufficient authority on its own: the probe also checks waiter registration, current connected Cline ownership, and fresh working status. The startup matcher rejects known working, permission, trust, and sign-in text.

Resilience and Maintainability Implications

  • observed — The probe looks up the current terminal by handle during observation and again when building the result. Handle invalidation normally rejects waiters, while the existing incarnation-change path can preserve a direct handle. The intended identity semantics of an in-flight wait across that transition are not established.

Hardening Proposals

  • proposed — Define whether a tui-idle wait survives terminal reincarnation. If it must not, bind the observation and final resolution to the original incarnation rather than only the current handle.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 6 files. (2 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: detecting a stable Cline startup composer from the visible screen.
Description check ✅ Passed The description follows the repository template and explains the user impact, implementation, rationale, linked issue, testing, limitations, and review status. It also documents that full build, cross…
Linked Issues check ✅ Passed Issue #23268 requires stable, complete rendered startup detection with owner, running-state, draft, permission-overlay, and fresh working-status guards, limited to startup. The PR adds `observeClineSt…
Out of Scope Changes check ✅ Passed The changed fixtures, startup probe, readiness matcher, tui-idle integration, and regression tests all support the startup-readiness objective in issue #23268. The changes preserve the existing prob…
Full details: Docstring Coverage

Explanation

Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 6 files. (2 skipped: 2 unsupported.)

  • 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: e0760240-2fec-427d-90ea-298bac4d2ca4

📥 Commits

Reviewing files that changed from the base of the PR and between abc4cb0 and 36531a3.

📒 Files selected for processing (8)
  • src/main/runtime/__fixtures__/cline-3-0-65-startup.meta.json
  • src/main/runtime/__fixtures__/cline-3-0-65-startup.txt
  • src/main/runtime/cline-readiness-transcript.test.ts
  • src/main/runtime/cline-startup-probe.test.ts
  • src/main/runtime/cline-startup-probe.ts
  • src/main/runtime/cline-terminal-readiness.ts
  • src/main/runtime/orca-runtime-start-tui-idle-visible-read-probe.ts
  • src/main/runtime/runtime-terminal-wait.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.

// Cline 3.0.65's captured startup composer; this is not a general mid-turn idle signal.
export function isClineStartupPromptPreview(preview: string): boolean {
const text = preview.trim()
if (/clinepass|sign in|log in|permission|trust|thinking|working|[\u2801-\u28ff]/i.test(text)) {

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 | 🟠 Major | ⚡ Quick win

Restrict overlay checks to overlay text.

The keyword check scans the entire screen. The footer includes a variable workspace or branch label. If that label contains working, trust, or permission, the predicate rejects an otherwise valid startup composer and the tui-idle wait can time out. Check the relevant overlay or status region instead of rejecting these words wherever they occur.

@texpress30 texpress30 closed this Sep 26, 2026

@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 — minor suggestions inline.

Reviewed changes

  • Cline composer matcher — new isClineStartupPromptPreview recognizes only the captured zero-usage Act/auto-approve startup composer and vetoes promotion/auth/permission/working overlays and braille spinners.
  • Stable-screen probe — new observeClineStartup samples the visible screen at ≤300 ms and settles after 3 s unchanged, refusing non-screen provenance, non-running/exited, truncated/limited snapshots, a non-empty draft, and ownership loss.
  • Probe wiring — startTuiIdleVisibleReadProbe routes cline panes to the new probe; runtime-terminal-wait now gates the probe on for any cline pane regardless of stale status/waitText. Other agents keep the existing single-shot probe.
  • Fixtures and tests — raw Windows node-pty capture plus metadata, and two suites covering startup, overlays, drafts, provenance, changing screens, incomplete snapshots, and an arriving explicit working status.

Verified this run: tsc -p config/tsconfig.node.json clean; oxlint clean on all six changed TS files; focused vitest suites pass (33 passed / 10 skipped across the cline, idle-polls, tui-idle-evidence, muse, and antigravity suites).

ℹ️ Cline readiness only covers the auto-approve composer

The matcher requires ⏵⏵ Auto-approve all enabled (Shift+Tab), which Cline renders only when launched with --auto-approve true — Orca's yolo permission mode (src/shared/tui-agent-permissions.ts:18). In manual mode that footer differs, so the wait still runs to timeout. The linked issue's capture is yolo, so this may be the intended scope; worth confirming whether manual-mode startup is expected to keep timing out.

Technical details
# Cline readiness scope

## Affected sites
- `src/main/runtime/cline-terminal-readiness.ts:7` — regex hardcodes the `Auto-approve all enabled (Shift+Tab)` footer.
- `src/shared/tui-agent-permissions.ts:18` — `--auto-approve true` is applied only in `yolo` mode.

## Required outcome
- Confirm the fix is meant to cover yolo dispatch only, or extend the matcher to the manual-mode composer.

## Open questions for the human
- Is manual-mode Cline startup in scope for #23268?

ℹ️ Nitpicks

  • runtime-terminal-wait.ts:157 — the comment above the gate still explains only why AGY is probed regardless of stale status; it now also covers cline. One clause would keep the rationale honest.

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

}
})
terminal.dispose()
const wait = runtime.waitForTerminal(handle, { condition: 'tui-idle', timeoutMs: 4200 })

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.

The ready case needs 3000 ms of unchanged screen but the waiter timeout is 4200 ms; in this run it resolved at 3085 ms, leaving only ~1.1 s of headroom. Under a loaded CI runner that margin can flip the case to a timeout rejection — consider widening the timeout (e.g. 6000–8000 ms) or making the settle window injectable so the test does not depend on real-timer slack.

Jinwoo-H added a commit that referenced this pull request Oct 1, 2026
…the live screen (#24222)

* fix(runtime): decide Antigravity readiness from the live screen

agy paints its composer with cursor addressing, so the line-folded wait
text misses the 1.2.14 accept-edits and plan composers and an ended turn,
while the grid keeps the bare `>` caret painted mid-turn and behind the
/model picker. Read the screen's bottom rows instead: rule, caret, rule,
`? for shortcuts`. A clocked pane is held to quiescence (tier 1b) because
the submit repaint reads ready for a moment; a clockless restored pane
settles from the screen alone. When a trustworthy screen exists it
decides, so the name-only title lane no longer settles an open picker.

Retires the visible-read probe's Antigravity branch: the probe now runs
the shared screen rule for any screen-ruled agent without an output
clock, and keeps its generic empty-pane read for everyone else.

Adds twelve agy 1.2.14 recordings and a replay suite shared by
screen-ruled agents. STA-8741.

* fix(runtime): decide Cline readiness from the live screen

Cline paints its composer box with cursor addressing on the alternate
screen, so no text rule saw it and worker-start timed out at
agent_readiness (#23268). Read the box off the grid: rule, an empty
composer with one of the captured placeholders, rule, the Plan/Act row
and the auto-approve row, with no braille spinner above it.

A streaming reply repaints the same box once its spinner has scrolled
away, so Cline is tier 1b only: a clocked pane waits for quiet and a
clockless one never settles from the screen. The screen now decides for
a Cline pane, which shuts the quiet-process lane that would have settled
its unworded tool-approval prompt and the Cline Desktop promo.

readLiveTerminalScreenLines now returns raw rows: the read projection
blanks a composer it takes for a draft, and it takes Cline's
placeholder for one, so a typed draft and an empty composer looked the
same.

Adds nine cline 3.0.66 recordings (macOS) and the 3.0.65 Windows capture
from #23269. STA-8741.

* fix(runtime): decide Prime Agent readiness from the live screen

Prime redraws its composer on the alternate screen, so the text tail
never showed a settled prompt and tui-idle timed out (#22153). Read the
grid instead: a bare `>` directly over the `<- manage` footer, with no
braille status row (`Writing - 6s`) above it. The footer and caret alone
stay painted for a whole turn.

Replayed chunk by chunk, Prime erases that status row before redrawing
it, and on first launch paints the idle composer just before the
trace-sharing question covers it. Both keep repainting, so a clocked
pane is held to quiescence (tier 1b); a clockless restored pane settles
from the screen alone.

Adds nine prime-agent 0.9.8 recordings (isolated HOME, OpenRouter) and
the two 0.9.5 captures from #22154. STA-8741.

* refactor(runtime): drop Cline-only readiness branches

Cline now follows the same pattern as Antigravity and Prime: a screen
rule plus table entries.

- Drop MID_TURN_COMPOSER_AGENTS. onPtyData stamps lastOutputAt on every
  chunk, so a re-attached streaming pane has an output clock from its
  first byte; the exception only guarded a pane that printed nothing
  since attach. A clockless Cline pane now settles from its screen like
  the other two.
- Drop the 'ready-body' rest-signal entries for all three agents. The
  rest signal is read only by quietForegroundLane, and a readable screen
  already shuts that lane and the title lane (isReadinessDecidedByScreen),
  so the entries only removed the quiet-process fallback for a pane with
  no trustworthy grid. The census now checks that screen-shut instead.
- Drop the Cline rule's auto-approve row check; no recorded verdict
  depends on it.

Kept: raw rows from readLiveTerminalScreenLines. Every frame of every
codex-* and qoder-* capture at 120x40, 80x24 and 100x32 gives the same
isKnownReadyPromptBody (with and without a clock) and
isQuietReadyScreenBody verdict through both readers.

Serializer known-failures for the new captures are pre-existing
serializer behaviour, not this branch: row-0 cells restore with a
true-colour background where the source has the default (the DSH
class), and Prime's cursor restores at column 119 instead of the pending
wrap at 120 (the qoder class). STA-8741.

* fix(runtime): trust a screen rule only on the PTY's own grid

Review findings on the screen-ruled readiness (STA-8741):

- A grid out of step with the PTY garbles cursor-addressed chrome, and a
  model resize does not make the TUI repaint. readLiveTerminalScreenLines
  now returns null unless the emulator's grid matches the PTY's reported
  size and was never reflowed without a repaint (a re-attach that learned
  the real size late), so the pre-existing lanes decide there instead of
  timing out.
- The visible-read probe reads the draft-blanking projection, which
  turns Cline's `❯ Ask anything...` into a bare `❯`. It now restores the
  blanked composer row before the rule reads it; `terminal read --screen`
  output is unchanged.
- The quiet lane no longer ORs the text rules over a trustworthy screen
  that refused; without one, tier 1 already ran them. No recorded
  verdict changes.

Tests: ready recordings on a mismatched and on a reflowed grid settle
through the old lanes; the restored-pane probe runs every ready
recording through the real projection; the rest-signal census checks
the lane verdict with and without a screen.

* test(runtime): trim STA-8741 recordings to the screens they prove

* refactor(runtime): one screen verdict for every screen-ruled lane

readScreenRuledReady, readScreenRuledQuietReady and isReadinessDecidedByScreen
each re-derived the same thing: the agent's rule applied to a trustworthy live
screen. They collapse into readScreenRuledVerdict (true / false / null), which
tier 1, tier 1b and the lane gate read.

This also makes a refusal final in tier 1: a clockless pane whose trustworthy
screen refused fell through to the text rules, so retained ready text could
settle over an open picker (Greptile review). The quiet tier already refused
there; now both do.

The tier-1b agent set derives the screen-ruled agents from the rule table
instead of listing them again, and the lane test that repeated the census
case is dropped.

* refactor(runtime): let the visible-read probe read its own output clock

The probe's clock was captured at start and threaded through the wait
dependencies as a one-off parameter. The probe now reads it from the live
record when its screen read returns, which is also the fresher answer.

* fix(runtime): trust a reflowed grid again once a PTY resize repaints it

The reattach-reflow flag was never cleared, so a pane stayed on the old lanes
for the rest of its life even after a real resize made the TUI repaint
(Greptile review). The record now keeps the reflowed grid, and a PTY resize
off that grid clears it; an echo of the same size sends no SIGWINCH and keeps
it.

Tests: the reflow case in every screen-ruled suite now includes a same-size
echo, and an Antigravity recording only the screen reads ready settles after a
resize and repaint.

* refactor(runtime): keep screen-rule trust and raw rows to screen-ruled agents

Two shared changes reached agents this PR does not target: the live
screen reader returned raw rows, and it refused a grid that did not
match the PTY. Both now live in readScreenRuledLines, which only the
screen-ruled agents read (screenReader picks it from the rule table);
readLiveTerminalScreenLines is main's again. The probe keeps main's
Antigravity-banner trigger, so a Codex or unknown pane is probed exactly
as before.

Proof: the non-screen-ruled suites give identical pass sets on this
branch and its base (1,781 tests), and replaying every other recording
frame by frame through the readiness and blocked verdicts, for its
agent and for an unknown pane, gives identical results (93 pairs). A new
test keeps a Codex pane reading its screen when the PTY reports another
grid; it fails if the trust check moves back into the shared reader.
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.

Cline 3.0.65 startup composer times out at agent readiness on Windows

1 participant