Skip to content

fix(runtime): recognize Pi/OMP state-marker idle titles in tui-idle detection - #24113

Closed
AhmedNAgy25 wants to merge 4 commits into
stablyai:mainfrom
AhmedNAgy25:fix/tui-idle-pi-omp-state-separator-readiness
Closed

AhmedNAgy25 wants to merge 4 commits into
stablyai:mainfrom
AhmedNAgy25:fix/tui-idle-pi-omp-state-separator-readiness

Conversation

@AhmedNAgy25

Copy link
Copy Markdown
Contributor

ELI5

Recognize Pi and OMP state-marker idle titles (e.g. π > <dir> or OMP > <dir>) as explicit idle readiness signals in terminal wait and active send detection.

What Changed

  • Before: Orca explicit idle title checks required an exact π - prefix (PI_IDLE_PREFIX = '\u03c0 - '). Modern OMP and Pi (v17.2+ and v18.x) write dynamic state separators between the brand and label (π > <dir> for idle, π : <dir> for working, π ! <dir> for permission). Because π > <dir> did not start with π - , computeExplicitIdleStatusFromTitle and isExplicitIdleSendTitle rejected it as an explicit idle signal. During orchestration worker-start --agent omp, readiness waited for timeout instead of recognizing the idle prompt.
  • After: Both computeExplicitIdleStatusFromTitle and isExplicitIdleSendTitle check getPiStateTitleStatus(title) === 'idle', recognizing π > <dir>, OMP > <dir>, and Pi > <dir> as strong idle signals while continuing to recognize legacy π - titles and rejecting working (:) or permission (!) markers.
  • Mechanism: Leveraged canonical getPiStateTitleStatus from src/shared/pi-state-title-marker.ts in src/main/runtime/terminal-wait-detection.ts and src/renderer/src/lib/agent-send-title-status.ts. Added comprehensive unit tests in terminal-wait-detection.test.ts and agent-send-title-status.test.ts.

Why

Pi and OMP encode their operational turn state directly in the title separator (:, !, >). Orca title parser already extracts this marker via getPiStateTitleStatus(). Wiring this check into explicit idle detection ensures managed worker launches (worker-start), orca terminal wait --for tui-idle, and note/prompt dispatch immediately recognize when a fresh Pi or OMP session is idle and ready for input.

Linked Issue

If you do not have one and are an outside contributors, your PR wiil be ignored. Refs is not sufficient. Link an actual issue

Fixes #24068

Visual Proof

N/A — Background terminal readiness and title status detection change; no UI layout or styling modifications.

Testing

  • Manually verified state title detection on π > ..., OMP > ..., Pi > ..., π : ..., and π ! ....

  • Automated tests added and passed:

    • src/main/runtime/terminal-wait-detection.test.ts (64 tests pass)
    • src/renderer/src/lib/agent-send-title-status.test.ts (13 tests pass)
  • Full regression suites passed:

    • tui-idle-evidence.test.ts, terminal-wait-name-only-idle.test.ts, tui-idle-delivery-and-quiescence.test.ts, runtime-terminal-idle-polls.test.ts, pi-state-title-marker.test.ts, omp-pi-semantic-title-preservation.test.ts, omp-owner-state-title.test.ts (190 tests pass).
  • Quality gates passed:

    • check-changed-code-quality.mjs passed with 0 findings across all changed files.
    • tsc on node and web passed with 0 errors.
    • oxfmt formatting verification passed.
  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Assisted by Google DeepMind Antigravity agent.

Review

No changes to security boundaries, protocol shapes, or remote wire interfaces. Backward-compatible across Linux, Windows, macOS, and SSH workspaces.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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

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: 8bb27deb-30a9-45fa-8a6d-7ebef2d25e60

📥 Commits

Reviewing files that changed from the base of the PR and between 04a7a04 and f083e53.

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

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


📝 Walkthrough

Walkthrough

Terminal wait and renderer send-title checks now use Pi state-title classification to recognize idle titles. Runtime records store and propagate stale-working-title-clear metadata. TUI idle evaluation ignores the matching cleared OSC title and suppresses adopted-PTY idle evidence when that flag is set. Tests cover title-state classification, stale-cleared titles, and first-party working status.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🟡 Moderate · up to f083e

The added test fixture breaks the repository’s node typecheck workflow. Fix the fixture before merging; no production failure is established.

Security Architecture Review

Security architecture risk: 🔵 Low · up to f083e

The change recognizes additional idle markers and prevents timer-cleared titles from falsely proving readiness. Permission handling remains distinct, and no introduced security issue was established. However, enforcement immediately before terminal input was not fully verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — A process able to emit titles in an existing terminal can influence readiness hints and notes-target discoverability. The inspected notes path confines target selection to the selected worktree's live panes and runtime inventory; it does not establish title-based authority over arbitrary terminals or environments.

Trust Boundaries and Controls

  • observed — Permission-classified notes targets are disabled. On explicit user selection, eligibility is refreshed, the target is resolved through runtime inventory, and sending delegates to guarded paste-and-enter with legacy fallback disabled. The downstream guard implementation was not fully inspected, so these calls do not prove final process or ownership enforcement.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 9 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description follows the repository template and explains the user-facing change, mechanism, motivation, linked issue, visual-proof status, testing, AI disclosure, compatibility considerations, and…
Title check ✅ Passed The title is concise, specific, and accurately summarizes the main runtime change: recognizing Pi/OMP state-marker idle titles during TUI idle detection.
Linked Issues check ✅ Passed Issue #24068 requires a fresh idle OMP pane with a π > <dir> title to be ready. detectExplicitIdleStatusFromTitle accepts getPiStateTitleStatus(title) === 'idle', and evaluateTuiIdle treats a …
Out of Scope Changes check ✅ Passed The changes remain connected to issue #24068. The terminal-wait and active-send checks share Pi/OMP title-state handling. Stale working-title metadata prevents a timer-cleared title from creating fals…
  • 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.

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[Medium risk] Refines idle detection for Pi and OMP agent state markers.

The PR is not ready to merge because an adopted pane can time out on tui-idle after its title reports idle.

Findings

  1. P1 Stale titles appear ready ▶

Summary

The PR recognizes Pi/OMP state-marker titles as explicit idle signals and adds provenance checks for timer-cleared working titles. The latest change also moves ready-body evidence behind fresh first-party working status, which inadvertently demotes adopted panes' explicit idle titles.

Reviews (4) · Last reviewed commit: "fix(runtime): prevent retained body evid..."

title.includes(GEMINI_IDLE_PREFIX) ||
title.startsWith(PI_IDLE_PREFIX)
title.startsWith(PI_IDLE_PREFIX) ||
getPiStateTitleStatus(title) === 'idle'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Stale titles appear ready

When a Pi/OMP working title stops updating but output continues, the existing three-second timer can change π : … to π > … without the agent reporting that it is idle. This new check treats that timer-generated title as strong readiness evidence, so a tui-idle wait can finish and pending input can be sent while the agent is still working—even if a fresh working status exists. The new send-title check also makes the rewritten title eligible for an immediate send. These readiness checks need to distinguish timer-generated clears from agent-emitted idle titles.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in a6e2cd8:

  1. Tracked lastOscTitleStaleWorkingClear in PTY and leaf records whenever applyTrackedPtyTitle receives meta?.staleWorkingTitleClear.
  2. Guarded hasExplicitIdleTitle so timer-synthesized cleared titles are excluded from explicit idle evidence.
  3. Evaluated fresh first-party working status before explicit idle titles in evaluateTuiIdle, ensuring an active working account always vetoes title settlement.
  4. Added meta?.staleWorkingTitleClear suppression to detectAgentSendTitleStatus to reject immediate send eligibility on timer-cleared titles.

@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

  • Recognize Pi/OMP state-marker idle titles in main tui-idle detection — computeExplicitIdleStatusFromTitle now accepts getPiStateTitleStatus(title) === 'idle', so π > <dir> / OMP > <dir> / Pi > <dir> count as explicit idle evidence, while : (working) and ! (permission) keep their prior classification.
  • Mirror the check in the renderer send gate — isExplicitIdleSendTitle gains the same disjunct, so immediate sends to an idle Pi/OMP pane are no longer rejected as non-explicit.
  • Tests — π >, OMP >, Pi >, wrapper-prefixed zsh | π >, legacy π - , plus rejection of :, !, and braille-work titles in both terminal-wait-detection.test.ts and agent-send-title-status.test.ts.

This reuses the canonical getPiStateTitleStatus parser rather than adding a parallel one, and the outer gate (detectAgentStatusFromTitle) already returns idle for these markers, so the new condition only promotes an idle title to explicit — no base-status change and no regression for working/permission markers. The legacy π - prefix must stay because - is intentionally not a table marker. Grep confirms no other file defines a parallel explicit-idle check.

The added tests are real regressions: without the source change both functions return null for π > …. Verified locally with pnpm test src/main/runtime/terminal-wait-detection.test.ts src/renderer/src/lib/agent-send-title-status.test.ts (77 passed).

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

Comment thread src/main/runtime/tui-idle-evidence.ts Resolved

@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 new stale-title-clear provenance flag is only reliably read on the PTY record; the leaf copy is dropped on every renderer graph publish, so a leaf-based tui-idle wait can still settle on a timer-synthesized idle title. Details inline.

Reviewed changes

  • Added stale-clear provenance to terminal records — lastOscTitleStaleWorkingClear is written on PTY and leaf records in applyTrackedPtyTitle, reset on provider-generation change, and added to the runtime record and evidence types.
  • Refused timer-synthesized titles in readiness — hasExplicitIdleTitle now skips a title whose stale-clear flag is set, and evaluateTuiIdle reorders a fresh first-party working status ahead of the explicit-idle and body-evidence checks.
  • Added a renderer meta parameter — detectAgentSendTitleStatus accepts { staleWorkingTitleClear } and returns null for flagged titles, with a matching unit test.
  • Retained commit 1's state-marker recognition — π > / OMP > / Pi > stay recognized as explicit idle in both the main wait detector and the renderer send gate, with unit tests.

ℹ️ PR description predates the second commit

The description and testing notes cover only the Pi/OMP state-marker recognition (commit eb7686b). They do not mention the stale-clear provenance plumbing, the evaluateTuiIdle tier reorder, or the new renderer parameter added in a6e2cd8. Refreshing it would help reviewers and the agent_readiness history see the full behavior change.

Technical details
# PR description does not cover commit 2

## Affected sites
- PR body "What Changed" / "Testing" — describes only commit `eb7686b`.

## Required outcome
- The description should state the second behavior change (rejecting timer-synthesized idle titles, and the working-vs-title precedence reorder) and its tests, so the change is reviewable on its own terms.

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

Comment thread src/main/runtime/tui-idle-evidence.ts Resolved
Comment thread src/main/runtime/tui-idle-evidence.ts Resolved

@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: 67adfa17-9736-4cae-ab68-b5b0d410a130

📥 Commits

Reviewing files that changed from the base of the PR and between eb7686b and a6e2cd8.

📒 Files selected for processing (6)
  • src/main/runtime/orca-runtime-apply-tracked-pty-title.ts
  • src/main/runtime/runtime-terminal-state-records.ts
  • src/main/runtime/tui-idle-evidence.test.ts
  • src/main/runtime/tui-idle-evidence.ts
  • src/renderer/src/lib/agent-send-title-status.test.ts
  • src/renderer/src/lib/agent-send-title-status.ts

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

Comment thread src/main/runtime/tui-idle-evidence.ts Resolved
…idle titles

- Maintain tier 1 precedence in evaluateTuiIdle so genuine explicit idle
  titles (not synthesized by timer) settle ready-strong over retained
  working status.
- Guard adopted PTY idle status against lastOscTitleStaleWorkingClear.
- Copy lastOscTitleStaleWorkingClear in syncWindowGraph rebuilt leaves
  and reset it in provider generation change.
- Remove unused meta parameter from detectAgentSendTitleStatus.

@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

One new issue: the added ptyTuiIdleEvidence test builds a TuiIdleEvidenceSource that omits the required getTabTitle, so pnpm typecheck:node fails.

Reviewed changes

  • Restored tier-1 precedence — evaluateTuiIdle now checks the explicit idle title / positive body evidence before a fresh first-party working status, so a genuine Pi/OMP idle title settles while timer-synthesized ones stay rejected. Against main this is only a clarifying comment; the previous reorder is undone.
  • Dropped the unwired renderer meta parameter — detectAgentSendTitleStatus no longer accepts { staleWorkingTitleClear }; the inert early return and its test are removed.
  • Fixed leaf stale-clear provenance — syncWindowGraph now copies lastOscTitleStaleWorkingClear from its tail source beside lastOscTitle, and resetTrackedTerminalStateForProviderGeneration clears it on the leaf.
  • Guarded the adopted-PTY idle branch — ptyTuiIdleEvidence.readPositiveBodyEvidence refuses getAdoptedPtyIdleStatus(...) === 'idle' when the PTY's stale-clear flag is set.
  • Tests — added stale-clear rejection and genuine-idle cases in tui-idle-evidence.test.ts, plus state-marker cases in terminal-wait-detection.test.ts and agent-send-title-status.test.ts.

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

Comment on lines +335 to +336
const source: TuiIdleEvidenceSource = {
getPaneAgent: () => 'omp',

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 new test builds a TuiIdleEvidenceSource without getTabTitle, which is a required member of the type (tui-idle-evidence.ts:328). pnpm typecheck:node currently fails here with TS2741, so the typecheck gate is red even though the runtime tests pass. Add the missing stub — the PTY lane never reads it, since ptyTuiIdleEvidence reads only record.lastOscTitle.

Suggested change
const source: TuiIdleEvidenceSource = {
getPaneAgent: () => 'omp',
const source: TuiIdleEvidenceSource = {
getTabTitle: () => null,
getPaneAgent: () => 'omp',

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Comments Outside Diff

These findings could not be posted inline.

  • P1 Adopted idle titles get vetoed src/main/runtime/tui-idle-evidence.ts:295 ▶

    When an adopted PTY's pane title reports idle but an earlier OSC 9999 working status is still fresh, this check returns working before reading the adopted title. That title enters through readPositiveBodyEvidence(), rather than hasExplicitIdleTitle(), so tui-idle can time out even though the agent's title says it is ready.

@AhmedNAgy25

Copy link
Copy Markdown
Contributor Author

Fixed in commit f083e53. Separated the explicit idle title check from positive body evidence in evaluateTuiIdle. Genuine Pi/OMP explicit idle titles continue to outrank older working status, while positive body evidence (retained prompts in the terminal tail) is evaluated after fresh first-party working status so it cannot bypass active turn reports. Added regression test in tui-idle-evidence.test.ts.

@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 comment-documentation nit inline.

Reviewed changes

  • Demoted positive body evidence below a fresh first-party status — evaluateTuiIdle now runs readPositiveBodyEvidence() after the fresh done/working/blocked/waiting checks, so a ready prompt retained in the terminal tail no longer settles ready-strong over an active turn. This is a broad behavior change (all agents, not just Pi/OMP), but it is consistent with the existing rule that a blocked/waiting account stays pending, and all affected suites pass.
  • Added a regression test — a pane reporting fresh working with positive body evidence now returns working.
  • The prior review's tui-idle-evidence.ts:78 / :279 / agent-send-title-status.ts:21 threads from review 5365163192 remain addressed (resolved).

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

? WORKING
: { kind: 'pending', quietForeground: 'closed' }
}
// Why positive body evidence after fresh working status: a retained prompt from a previous turn

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.

Moving body evidence below a fresh first-party status contradicts this module's canonical ranking, which still lists it under tier 1: the header comment (tui-idle-evidence.ts:30-31, "an explicit idle marker in its own title, or a known ready-prompt body") and the readPositiveBodyEvidence JSDoc (tui-idle-evidence.ts:203, "Tier 1 body evidence") both describe it as tier 1. Since a fresh working now outranks it, updating those two spots keeps the tier numbering a reader can trust.

@nwparker

nwparker commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Closing as superseded — the linked issue (#24068) has been resolved on main by #24295 (44a2ee54bb). Thanks for the contribution!

@nwparker nwparker closed this Nov 5, 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.

[Bug]: worker-start --agent omp fails at agent_readiness: OMP 18.4 idle title "π > dir" is not recognised as idle

2 participants