Skip to content

fix(runtime): recognize a resting DeepSeek Harness as tui-idle - #22880

Closed
innocarpe wants to merge 1 commit into
stablyai:mainfrom
innocarpe:fix/dsh-tui-idle-ready
Closed

innocarpe wants to merge 1 commit into
stablyai:mainfrom
innocarpe:fix/dsh-tui-idle-ready

Conversation

@innocarpe

Copy link
Copy Markdown
Contributor

Summary

terminal wait --for tui-idle timed out on a ready DeepSeek Harness (dsh-tui 0.11.0) pane. The composer was already showing ❯, and the OSC title was ✦ 🐋.

That star is Gemini CLI's working glyph, so the wait classifier never treated the resting title as idle. A running turn uses ⠂/⠐ plus esc to interrupt and still does not settle.

  • A resting ✦ 🐋 title is explicit idle for tui-idle only. Sidebar status classification is unchanged.
  • The ready screen is also recognized from the dsh-tui banner, the model row, and a lone ❯ composer, unless the bottom of the screen is still a live turn.

Preserves

Gemini titles that start with ✦ and do not include the whale stay unchanged. A shell that only echoed dsh-tui is not ready. A question row such as ❯● Tea is not the idle composer.

Tests

  • pnpm exec vitest run src/main/runtime/terminal-wait-detection.test.ts src/main/runtime/terminal-wait-name-only-idle.test.ts
  • Targeted oxlint and oxfmt checks

DSH-TUI rests on a title of "✦ 🐋". That star is Gemini's working glyph, so
terminal wait --for tui-idle ran until timeout while the composer was already
ready. A running turn uses a braille spinner and "esc to interrupt", and those
must not settle.

The ready screen is also recognized from the dsh-tui banner plus an idle ❯
composer, so a pane that has not published an OSC title can settle the same way.
@coderabbitai

coderabbitai Bot commented Sep 25, 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 change adds DeepSeek Harness title and composer-prompt readiness checks. Terminal wait detection uses resting titles as explicit idle signals and includes ready-prompt indexes in startup-modal and known-prompt detection. Tests cover resting and working titles, ready composers, and screens that should not indicate readiness.

Priority: ⬇️ Low

Merge Risk: 🟡 Moderate · up to 5dab7

terminal wait --for tui-idle can report idle too early in three cases: when a Gemini working title contains a whale emoji, when a shell has only echoed the DeepSeek Harness command, or when a question below an earlier prompt still needs an answer. Tighten these checks before merging.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 5dab7

A pane can now be reported idle from its title or visible text even when other status evidence indicates work is ongoing. That could release an automation wait early. The reviewed privileged launch path checks session identity separately before focusing a terminal; no direct privilege escalation was established.

Retained concerns

  • Low · security · inferred: A DSH-shaped pane title can satisfy tui-idle ahead of a fresh working-status veto. An automation consumer that treats the wait result as proof that the pane is safe for its next action could proceed early; the effect on consumers beyond the traced launch path is unresolved.
Security review details

Security Blast Radius

  • inferred — The immediate effect is a readiness result for the terminal handle being waited on. Whether another production consumer turns that result into a sensitive action without independent proof remains unestablished.

Security Findings and Attack Paths

  • inferred — A party able to influence a pane title could supply DSH-shaped markers and make a tui-idle wait settle despite a fresh working-status signal. This establishes a premature-readiness path, not a verified path to privileged action.

Trust Boundaries and Controls

  • observed — Screen provenance and active-turn checks constrain body-based readiness. The examined structured-session path requires provider-specific proof after the wait and before terminal focus; those controls do not change the shared wait result itself.

Hardening Proposals

  • proposed — Where tui-idle gates a sensitive follow-on action, corroborate a DSH-shaped title with fresh provider or pane-state evidence, or require an independent ownership check before that action.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the problem, behavior changes, preserved cases, and targeted tests. It does not follow the required template and omits the ELI5, What Changed, Why, Linked Issue, Visual Proof,… Rewrite the description using the repository template. Add the required issue reference, visual proof or N/A with a reason, testing checklist details and platforms, AI disclosure if applicable, review and boundary sections, compatibility …
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main runtime change: recognizing a resting DeepSeek Harness as tui-idle.
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.
Full details: Description check

Explanation

The description explains the problem, behavior changes, preserved cases, and targeted tests. It does not follow the required template and omits the ELI5, What Changed, Why, Linked Issue, Visual Proof, Review, boundary, Notes, and Checklist sections.

Resolution

Rewrite the description using the repository template. Add the required issue reference, visual proof or N/A with a reason, testing checklist details and platforms, AI disclosure if applicable, review and boundary sections, compatibility notes, and checklist status.

  • 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: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: fa464273-60ac-46b1-abc0-2a9c9b12e373

📥 Commits

Reviewing files that changed from the base of the PR and between 646e9a5 and 5dab73c.

📒 Files selected for processing (4)
  • src/main/runtime/dsh-terminal-readiness.ts
  • src/main/runtime/terminal-wait-detection.test.ts
  • src/main/runtime/terminal-wait-detection.ts
  • src/main/runtime/terminal-wait-name-only-idle.test.ts

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

/** A finished DSH pane titles itself `✦ 🐋 …`. A running turn uses `⠂`/`⠐` instead. */
export function isDshRestingTitle(title: string): boolean {
const trimmed = title.trim()
return trimmed.startsWith(DSH_REST_PREFIX) && trimmed.includes(DSH_WHALE)

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

Require the whale next to the resting glyph.

A Gemini working title such as ✦ Write about 🐋 starts with ✦ and contains a whale. This predicate reports it as DSH idle, so tui-idle can settle during a Gemini turn. Match the DSH ✦ 🐋 prefix rather than a whale anywhere in the title.

Comment on lines +27 to +32
const headerIndex = normalized.lastIndexOf('dsh-tui')
if (headerIndex === -1) {
return null
}
const segment = normalized.slice(headerIndex)
if (!segment.includes('deepseek-flash') && !segment.includes('max effort')) {

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

Require a DSH banner and model row, not just matching text.

If a shell echoes dsh-tui deepseek-flash and later displays a lone ❯ prompt, this function reports a ready DSH pane. The checks accept both identifiers on a shell command line; they do not establish the banner or model row. Match those identifiers in their respective screen lines before accepting the composer.

if (!segment.includes('deepseek-flash') && !segment.includes('max effort')) {
return null
}
const composerIndex = findLastLoneComposerIndex(segment)

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

Do not accept a composer above a later question row.

If the preview retains an earlier ⌸ ❯ line and then shows ❯● Tea, findLastLoneComposerIndex returns the earlier composer. The later question row does not trigger either active-turn check, so isKnownReadyPromptPreview reports idle while the question needs input. Check the current input area after the candidate composer, and add a fixture with both rows present.

@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.

Important

The DSH screen rule is pinned only to a hand-typed five-line fixture, and its model-row guard is loose enough to match a non-DSH pane. Details and one inline comment below.

Reviewed changes

  • New src/main/runtime/dsh-terminal-readiness.ts — isDshRestingTitle reads a ✦ …🐋… OSC title as idle; findDshReadyPromptIndex accepts a dsh-tui banner plus a deepseek-flash/max effort row and a lone ❯ composer, vetoing when the last 12 lines show esc to interrupt or a braille frame [\u2802\u2810].
  • Wiring in terminal-wait-detection.ts — the title check short-circuits computeExplicitIdleStatusFromTitle before the generic classifier, and the body matcher joins findKnownReadyPromptIndex (tier-1 body evidence) and findDismissedStartupModalIndex.
  • Tests — resting/working title cases plus five body-preview cases (lone composer, live-turn veto, echoed launcher, question row).

⚠️ The screen rule has no captured transcript behind it

findDshReadyPromptIndex is a rule over what DSH paints on the terminal, but every string it keys on was typed by hand into a five-line fixture. AGENTS.md ("Agent Terminal Screens") requires such rules to be written against a captured transcript, and docs/reference/antigravity-readiness-evidence.md documents that three of four Antigravity rules written from typed-from-memory screens were "found worse than the bug they replaced." A real dsh-tui capture would also settle the questions the inline comment and the isDshRestingTitle/wrapper caveats below cannot answer.

Technical details
# DSH readiness needs a committed PTY transcript

## Affected sites
- `src/main/runtime/dsh-terminal-readiness.ts:26-45` — the body rule; every token it keys on (`dsh-tui`, `deepseek-flash`, `max effort`, `❯`, `esc to interrupt`, `⠂`/`⠐`) comes from the hand-typed screen at `terminal-wait-detection.test.ts:591-597`.
- `src/main/runtime/terminal-wait-detection.test.ts:590-637` — asserts against `buildTerminalWaitText` output, not raw bytes through the runtime.
- `src/main/runtime/terminal-wait-detection.ts:102,112` — the wiring inherits any false positive/negative of that rule.

## Required outcome
- A committed `src/main/runtime/__fixtures__/dsh-*.txt` + `.meta.json`, captured from a live `dsh-tui` with `config/scripts/capture-agent-pty-transcript.mjs` (resting, mid-turn, and if reachable a startup dialog), replayed through `createTranscriptPane` in a `dsh-readiness-transcript.test.ts`, per `docs/reference/agent-pty-transcript-capture.md`.

## Suggested approach (optional)
- Mirror `antigravity-readiness-transcripts.test.ts` / `muse-readiness-transcript.test.ts`.
- The capture would settle three currently-unverifiable points: whether the idle composer is truly a lone `❯` (decorations/placeholder text), whether a running turn always carries `esc to interrupt` or a `⠂`/`⠐` frame inside the bottom 12 lines, and whether DSH paints its composer beneath a startup/trust dialog (which `findDismissedStartupModalIndex` would then read as "modal dismissed").

## Open questions for the human (optional)
- Was the cited v0.11.0 capture on `dsh 0.1.7-rc.1` saved anywhere that can be committed?

ℹ️ Nitpicks

  • isDshRestingTitle accepts any ✦ …🐋… title, so a Gemini CLI working title whose free-form task text contains a whale (✦ Explain the 🐋 marker) now reads as idle; the whale is the only discriminator because there is no dsh agent identity.
  • isDshRestingTitle uses startsWith('✦') while the generic glyph classifier uses includes, so a wrapper-prefixed title (tmux: ✦ 🐋 …) will not settle via the title path and falls through to the body rule.
  • terminal-wait-name-only-idle.test.ts:240 ("does not treat a working DeepSeek Harness title as idle") sets lastAgentStatus: null, so it cannot reach the DSH path and passes with or without the change; the assertion that actually pins the behavior is terminal-wait-detection.test.ts:603.

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

Comment on lines +31 to +33
const segment = normalized.slice(headerIndex)
if (!segment.includes('deepseek-flash') && !segment.includes('max effort')) {
return null

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.

max effort is a generic phrase, and this matcher is unscoped tier-1 body evidence — unlike Muse's hasQuietMuseReadyPrompt, it gets no agent gate and no quiescence. Combined with a bare ❯ prompt (the default glyph of starship/pure shells), a non-DSH pane whose retained tail contains dsh-tui + max effort — e.g. an Orca agent that cats or greps this PR's own test file — can settle tui-idle immediately. Requiring the deepseek-flash model token (or an actual DSH banner shape) instead of the max effort alternative would tighten this, and a scrollback-quoting regression test would pin it.

Technical details
# Unscoped, loosely-guarded DSH body matcher

## Affected sites
- `src/main/runtime/dsh-terminal-readiness.ts:32` — `segment.includes('deepseek-flash') || segment.includes('max effort')`; `max effort` also appears in prose in `docs/site/content/docs/agents/glm-agent.mdx:46`.
- `src/main/runtime/dsh-terminal-readiness.ts:39-44` — the 12-line veto only excludes `esc to interrupt` and the two braille frames, so a shell prompt tail passes.
- `src/main/runtime/terminal-wait-detection.ts:112` — joins `findKnownReadyPromptIndex`, whose result is consumed as tier-1 evidence in `tui-idle-evidence.ts:165`.

## Required outcome
- A non-DSH pane must not satisfy `tui-idle` from scrollback that merely quotes DSH identifiers.

## Suggested approach (optional)
- Drop the generic `max effort` alternative, or require the banner/model-row shape together with a version token.
- Add a regression test mirroring `terminal-wait-name-only-idle.test.ts:252` ("never settles another agent quoting Muse in its scrollback").

@innocarpe

Copy link
Copy Markdown
Contributor Author

Closing this in favor of the first-party done lane on #22468.

terminal wait --for tui-idle settles through isTuiIdleSatisfied. DeepSeek Harness cannot use the title lane: its rest prefix is ✦, which is Gemini CLI's working glyph, so a title match (including ✦ plus a whale anywhere in the title) can report a Gemini turn as idle. The screen matcher has the same problem from the other side. max effort and a bare ❯ are not specific to this TUI, and an older composer line can sit above a question row.

#22468 treats a fresh hook done for dsh as tier-1 evidence instead. normalizeDshEvent drops SubagentStart / SubagentStop, so that done is the lead's, not a child finishing early. That matches the adhoc run this PR was opened from: the pane was already state: done with a ready composer, and the wait still timed out because nothing read the hook row.

The review notes on this PR (whale-anywhere title, shell echo, question row, unscoped max effort) are the reason not to land this screen lane beside that hook lane.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant