Skip to content

fix(grok): mark sidebar done on idle_prompt and StopCancelled - #15230

Closed
ynjmxn wants to merge 5 commits into
stablyai:mainfrom
ynjmxn:fix/grok-sidebar-stuck-working
Closed

ynjmxn wants to merge 5 commits into
stablyai:mainfrom
ynjmxn:fix/grok-sidebar-stuck-working

Conversation

@ynjmxn

@ynjmxn ynjmxn commented Aug 18, 2026

Copy link
Copy Markdown

ELI5

Grok already finished and printed stop, but Orca kept the yellow working dot because it did not treat Grok''s current idle/cancel hook events as done, and a large Stop post could time out silently.

What Changed

  • Map Grok Notification types idle_prompt and task_complete to done (keep the old message-text fallback).
  • Install StopCancelled and map it to done (Grok 1.0+ fires this instead of Stop on Ctrl+C / Esc / max-turns).
  • Raise the Grok hook curl deadline from 1.5s to 8s so Stop bodies that include lastAssistantMessage can land. Other agents stay at 1.5s.

Why

A finished Grok turn can leave orca worktree ps at state: working after the TUI already shows stop [hooks: 1]. Title idle is suppressed while a fresh hook row says working. Grok 1.0.5 documents idle_prompt as the host idle signal and StopCancelled as the interrupt report; Orca previously ignored both. The 1.5s curl bound plus exit 0 also matches TUI-success / last-status-still-working.

Same machine contrast: software-copyright recorded hookEventName: stop → done; two idle grokdefault panes stayed on the previous tool event.

This is not #14828 (console flash). That is spawn visibility. This is the done-transition.

Linked Issue

Fixes #15225

Visual Proof

N/A — hook-event mapping and curl timeout only. Sidebar dot color follows the existing status renderer; no UI chrome, layout, or new controls.

Testing

  • Windows: pnpm exec vitest run --config config/vitest.config.ts src/shared/agent-hook-listener-grok.test.ts src/main/grok/hook-service.test.ts src/main/grok/windows-grok-hook-script.test.ts src/main/agent-hooks/remote-hook-service-installers.test.ts src/main/agent-hooks/installer-utils.test.ts — 127 passed, 5 skipped.

  • Added unit coverage for StopCancelled, idle_prompt / task_complete, legacy idle copy, install/matcher, and the Grok-only --max-time 8.

  • Did not re-run a live Grok turn against this build (running app is still 1.4.184). Repro evidence is in [Bug]: Grok sidebar stays working after the TUI Stop hook already ran #15225.

  • I manually tested these changes locally

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

AI Disclosure

Drafted with Grok 4.6 in the Orca checkout. Live repro and last-status evidence collected on Windows 1.4.184 + Grok 1.0.5.

Review

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.

Notes

Windows, Linux, and SSH/remote Grok installs all get StopCancelled and the longer Grok curl bound. idle_prompt mapping applies as soon as Notification is already installed; StopCancelled needs the next hook install/refresh.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • 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)

Author

  • X / Twitter:

Grok 1.0+ reports idle via Notification type idle_prompt/task_complete
and uses StopCancelled instead of Stop on interrupt. Orca only treated
Stop/SessionEnd/StopFailure and leftover TUI copy as done, so a finished
turn could stay working after the TUI already printed stop [hooks: 1].

Also raise the Grok hook curl deadline so Stop bodies that include
lastAssistantMessage can land.
Copilot AI lite review requested due to automatic review settings August 18, 2026 03:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

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: 0c1edf62-b318-4647-999d-835a767a0156

📥 Commits

Reviewing files that changed from the base of the PR and between 01e92e6 and a258ced.

📒 Files selected for processing (6)
  • src/main/agent-hooks/installer-utils.ts
  • src/main/agent-hooks/remote-hook-service-installers.test.ts
  • src/main/grok/grok-hook-script.ts
  • src/main/grok/hook-service.test.ts
  • src/shared/agent-hook-listener/providers/grok-events.ts
  • src/shared/agent-hook-listener/providers/grok-tool-fields.ts

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


📝 Walkthrough

Walkthrough

The change adds Grok StopCancelled hook registration and maps cancellation events to done. It recognizes typed idle_prompt and task_complete notifications while retaining legacy message matching. It enables pending result discovery and final-message extraction for cancelled sessions. Grok POSIX and Windows hooks now use a shared eight-second POST timeout. Tests cover hook registration, timeout generation, event normalization, prompt preservation, and result discovery.

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to a258c

Grok completion and cancellation events now transition status to done and allow larger final payloads additional delivery time. No concrete current-head merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.75% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 19 files. 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 identifies the main changes: marking Grok completion states as done for idle_prompt and StopCancelled events.
Description check ✅ Passed The description covers the required sections, explains the problem and solution, links issue #15225, documents testing, and marks visual proof as not applicable. The unchecked full validation command …
Linked Issues check ✅ Passed The changes satisfy issue #15225 by handling idle_prompt, task_complete, and StopCancelled events, increasing the Grok hook timeout, preserving fail-open behavior, and adding coverage for the relevant…
Out of Scope Changes check ✅ Passed The code and test changes remain focused on the linked Grok completion-state bug, hook installation, timeout handling, and related regression coverage. No unrelated changes are evident.
  • 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: Pro Plus

Run ID: cd2aeca3-7f6d-416d-8fd6-0bc922319a48

📥 Commits

Reviewing files that changed from the base of the PR and between 604169f and b70e748.

📒 Files selected for processing (8)
  • src/main/agent-hooks/installer-utils.ts
  • src/main/agent-hooks/remote-hook-service-installers.test.ts
  • src/main/grok/hook-service.test.ts
  • src/main/grok/hook-service.ts
  • src/main/grok/windows-grok-hook-script.test.ts
  • src/main/grok/windows-grok-hook-script.ts
  • src/shared/agent-hook-listener-grok.test.ts
  • src/shared/agent-hook-listener.ts

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

ynjmxn added 2 commits August 18, 2026 11:52
…uck-working

Resolve agent-hook-listener.ts by keeping the upstream split facade. Re-apply StopCancelled, idle_prompt, and task_complete handling in the new grok provider modules.
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

1 similar comment
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

…uck-working

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	src/main/grok/hook-service.ts
@ynjmxn
ynjmxn requested a review from brennanb2025 as a code owner August 27, 2026 01:12
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

…uck-working

# Conflicts:
#	src/renderer/src/i18n/locales/ko.json
#	src/renderer/src/i18n/locales/zh.json
@ynjmxn

ynjmxn commented Sep 15, 2026

Copy link
Copy Markdown
Author

Closing as superseded by #20523, which now registers StopCancelled and marks idle_prompt / stop_cancelled as done on main. That covers the sidebar-stuck-working case. I'm not carrying forward the leftover 8s hook curl timeout (main still uses 1.5s).

@ynjmxn ynjmxn closed this Sep 15, 2026
@ynjmxn
ynjmxn deleted the fix/grok-sidebar-stuck-working branch September 26, 2026 11:41
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]: Grok sidebar stays working after the TUI Stop hook already ran

2 participants