Skip to content

Fix Grok and Pi terminal title normalization and status detection#7880

Merged
AmethystLiang merged 2 commits into
mainfrom
fix-grok-title-mobile
Jul 9, 2026
Merged

Fix Grok and Pi terminal title normalization and status detection#7880
AmethystLiang merged 2 commits into
mainfrom
fix-grok-title-mobile

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

Summary

Collapses high-churn rotating terminal title frames (such as Grok spinner frames and Pi idle frames) at the observation boundary in the runtime. This prevents mobile session tabs and snapshots from thrashing and republishing on every single animation frame. It also ensures normalized titles (e.g., bare "Pi" or collapsed "⠋ Grok") are correctly seeded during hydration and still classify under their respective idle or working statuses.

Screenshots

No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

AI Review Report

The code review verified that collapsing rotating spinner/tool frames at the main observation boundary successfully stabilizes mobile session tabs without affecting state transitions. Cross-platform compatibility for macOS, Linux, and Windows was explicitly reviewed; terminal title sequence extraction and Unicode-based spinner regexes behave identically across all target platforms.

Security Audit

The security audit evaluated the new regular expressions for ReDoS risks. The updated GROK_ROTATING_FRAME_RE uses structured boundaries and does not suffer from catastrophic backtracking under expected terminal title lengths. No new IPC, command execution, or sensitive path manipulation hazards were introduced.

Notes

No platform-specific regressions are expected as the title parsing and normalization logic relies on cross-platform core runtime services.

AmethystLiang and others added 2 commits July 8, 2026 19:04
…on boundary

Desktop already collapses Grok Build's rotating working frames via the
renderer's normalizeTerminalTitle, but the main process stored raw OSC
titles, so mobile session tabs (fed from pty.lastOscTitle) still saw a
distinct title every spinner frame and re-touched snapshots each time.

Apply normalizeTerminalTitle once where main records an observed OSC
title, before the prevTitle comparison that gates session-tab and
mobile-snapshot touches, and normalize hydration-seeded titles the same
way so the first live frame after a seed compares equal. Agent status
stays detected from the raw title, mirroring the renderer tracker.

Covers remoted/SSH PTYs too since they surface through the same main
observation path.

Co-authored-by: Orca <help@stably.ai>
- Require a strict "spinner - phrase - grok" pattern for Grok working
  titles to prevent false positives on other agent tasks ending in
  "- grok" (such as Claude or Codex).
- Treat collapsed "Pi" and "OMP" synthetic titles as idle by default
  to prevent them from reverting to neutral status after normalization.
- Prevent duplicate mobile session tab updates during Grok status
  frame rotations by ensuring they normalize to a stable title.
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 311e4919-2632-4abf-a706-f40580c5d79a

📥 Commits

Reviewing files that changed from the base of the PR and between 7e1a777 and aa4550a.

📒 Files selected for processing (7)
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/renderer/src/lib/agent-status.test.ts
  • src/shared/agent-detection.test.ts
  • src/shared/pi-compatible-synthetic-title.ts
  • src/shared/terminal-title-agent-type.test.ts
  • src/shared/terminal-title-agent-type.ts

📝 Walkthrough

Walkthrough

This PR modifies terminal title handling for agent status detection. orca-runtime.ts now normalizes OSC-derived titles before storing them (via a new oscTitle/seededTitle derived from normalizeTerminalTitle), while agent status classification continues to use the raw, unnormalized title. terminal-title-agent-type.ts tightens Grok rotating-frame detection with a stricter regex requiring the full spinner-delimiter-identity shape. pi-compatible-synthetic-title.ts simplifies idle detection by removing a regex check and defaulting to 'idle' after permission checks. Corresponding test files were updated/extended across shared, renderer, and main modules to cover the new normalization and detection behavior; no production exported/public API signatures changed.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: Grok and Pi terminal title normalization and status detection.
Description check ✅ Passed All required sections are present, including summary, screenshots, testing, AI review, security audit, and notes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@AmethystLiang AmethystLiang merged commit 6b4831d into main Jul 9, 2026
2 checks passed
Jinwoo-H added a commit that referenced this pull request Jul 9, 2026
36 commits from main incl. the v1.4.130 release. Two conflicts, both the
branch-guide pattern (our restructured shape wins; main's new semantics graft in):

- pty-dispatcher.ts (eager-buffer exitHandler): kept our releaseDeliveryInterest()
  (hidden-delivery-gate ref-count invariant) AND grafted main's identity guard
  (#7894 detach/attach remount race) around the handler deletions.
- orca-runtime.ts: (1) kept our isCursorNativeAgentTitle import; (2) OSC-title
  path — kept our 4-arg trackHeadlessTerminalData(...forwardQueryReplies) and the
  shared per-PTY title tracker, dropped main's superseded inline OSC extraction.

Grafting main's #7863 Grok/#7880 Pi title-normalization required a real fix, not
just keeping our block: the runtime's normalizeTerminalTitle re-export chain
(agent-detection → agent-title-status.ts) lacked the Grok-collapse branch main
added to the sibling terminal-title-display.ts impl. Added isGrokRotatingWorkingTitle
collapsing to agent-title-status.ts and made applyTrackedPtyTitle store the
NORMALIZED title (matching main's inline block) — restores 4 Grok/Pi runtime tests.

Gates: typecheck 0 errors; lint 0 errors; terminal-pane+ipc/pty+daemon+pane-manager
4574 passed; runtime+renderer-runtime+shared 4063 passed / 0 failed.

Co-authored-by: Orca <help@stably.ai>
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