Skip to content

fix(pi): clear the titlebar spinner after a stale paint - #14412

Closed
bbingz wants to merge 1 commit into
stablyai:mainfrom
bbingz:fix/14400-pi-titlebar-stale-ctx
Closed

bbingz wants to merge 1 commit into
stablyai:mainfrom
bbingz:fix/14400-pi-titlebar-stale-ctx

Conversation

@bbingz

@bbingz bbingz commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Stop Pi's 80 ms titlebar animation when painting fails after a session/context replacement. The current title painter already catches stale-context errors, but its caller ignored the failure and kept waking the animation timer.

The frame now reports whether painting succeeded; a failed first frame does not start the interval, and a later failed frame clears it. This clears the spinner timer only, preserving the separate dialog-marker timer and existing idle-compaction bounds. Related: #14400.

Testing and review

At 75ae60fdc13311fdb888376cd920d86fbc0249b4, independent verification passed 68 tests across 3 titlebar test files, the Node TypeScript check (--composite false), changed-file lint/format and diff whitespace. The regression makes session-name lookup become stale after animation starts and verifies no remaining interval or subsequent title writes.

Independent Cursor review passed for this exact SHA (spec-compliance PASS; quality APPROVED). Full repository tests, packaging and live Pi/SSH/Windows/Linux smoke were not run. CLI/Web checks were not repeated for this generated main-process extension source.

AI disclosure

Cursor implemented the remaining timer fix; Codex independently checked the original scope, source and verification results.

@coderabbitai

coderabbitai Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

renderFrame() now returns a success flag. The titlebar extension stops animation when frame rendering reaches the idle-compaction cap or when paintTitle fails. startAnimation() does not schedule frames after an initial failure and clears the interval after a later failure. A Vitest test verifies spinner cleanup when getSessionName throws after session replacement.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 75ae6

The change stops titlebar spinner updates after stale-context paint failures, avoiding repeated failed title updates. The running-spinner failure path is covered, while the initial-failure path needs a focused test before this behavior is fully protected against regression.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description explains the change, motivation, testing, limitations, linked issue, and AI use. However, it does not follow the required template and omits the required Visual Proof section, ELI5, ex… Update the description to use the repository template. Add the missing sections and checklist details. Include visual proof or write N/A with a reason if there is no visual or interaction change. Use an explicit issue reference such as "Fix…
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly identifies the main change: stopping the Pi titlebar spinner after a stale paint failure.
Full details: Description check

Explanation

The description explains the change, motivation, testing, limitations, linked issue, and AI use. However, it does not follow the required template and omits the required Visual Proof section, ELI5, explicit What Changed and Why sections, checklist items, platform-impact notes, and the required Linked Issue format.

Resolution

Update the description to use the repository template. Add the missing sections and checklist details. Include visual proof or write N/A with a reason if there is no visual or interaction change. Use an explicit issue reference such as "Fixes #14400".

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

🧹 Nitpick comments (1)
src/main/pi/titlebar-extension-source.test.ts (1)

104-147: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add tests for title-update failures and shutdown timer cleanup.

The stale-context tests only make pi.getSessionName() throw. They do not execute either new catch path for a throwing ctx.ui.setTitle().

Add an interval test that makes setTitle throw. Assert that no error escapes and vi.getTimerCount() becomes zero.

Add a session_shutdown test after agent_start with a stale getSessionName. Assert that shutdown clears the active timer. This verifies both failure types required by this change.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0aa92592-780e-4f00-b70a-ec5eff4c217b

📥 Commits

Reviewing files that changed from the base of the PR and between 8c3a119 and 95e69f3a1bf94a0ee2fbefefd07bf8f07c10559c.

📒 Files selected for processing (2)
  • src/main/pi/titlebar-extension-source.test.ts
  • src/main/pi/titlebar-extension-source.ts

@bbingz

bbingz commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

Community PR: please Approve and run workflows on head 95e69f3a1bf9 when convenient (fork CI stays gated). Stop titlebar spinner from crashing on stale session ctx.

paintTitle already returned false on replaced session ctx, but renderFrame ignored that and left the interval armed. Fail the frame closed and stop the timer without stopAnimation so marker reassert stays.

Co-authored-by: Cursor <[email protected]>
@bbingz
bbingz force-pushed the fix/14400-pi-titlebar-stale-ctx branch from 95e69f3 to 75ae60f Compare September 8, 2026 22:47
@bbingz bbingz changed the title fix(pi): stop titlebar spinner from crashing on stale session ctx fix(pi): clear the titlebar spinner after a stale paint Sep 8, 2026
@coderabbitai

coderabbitai Bot commented Sep 8, 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.

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

🧹 Nitpick comments (1)
src/main/pi/titlebar-extension-source.test.ts (1)

555-581: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for an initial frame failure.

This test covers failure after the 80 ms interval starts. Add a companion case where getSessionName() throws before agent_start completes. Assert that no interval exists and no title is emitted. This covers the early return at src/main/pi/titlebar-extension-source.ts:225.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 845f4331-0fcb-455f-99cb-4c26c681c1b9

📥 Commits

Reviewing files that changed from the base of the PR and between 12f2c6b and 75ae60f.

📒 Files selected for processing (2)
  • src/main/pi/titlebar-extension-source.test.ts
  • src/main/pi/titlebar-extension-source.ts

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

@bbingz

bbingz commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded by current origin/main.

This PR's remaining delta was: on a stale getSessionName/setTitle during the 80ms spinner, stop the animation interval (clearAnimation) without letting the throw escape.

Current main already does that, and more tightly:

  • paintTitle catches paint failures and calls clearOwnedTimers() (src/main/pi/titlebar-extension-source.ts)
  • tests: retires a stale %s during animation without throwing or rescheduling, does not schedule a timer when the first frame fails, clears animation and pending idle checks on session replacement

Rebase would only fight the later lifetime/disposed work (getPiTitlebarLifetimeSourceLines) without adding behavior. No further changes from this branch.

@bbingz bbingz closed this Sep 14, 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.

4 participants