Skip to content

fix(pi): stop titlebar spinner timer when extension ctx turns stale - #14664

Closed
coding-susemi wants to merge 1 commit into
stablyai:mainfrom
coding-susemi:fix/titlebar-spinner-stale-ctx
Closed

coding-susemi wants to merge 1 commit into
stablyai:mainfrom
coding-susemi:fix/titlebar-spinner-stale-ctx

Conversation

@coding-susemi

Copy link
Copy Markdown

Summary

Fixes the pi process crash caused by the orca-titlebar-spinner extension when a session reload happens while the 80ms titlebar animation timer is running. See #14658.

Root cause

The extension's startAnimation starts a setInterval (80 ms) whose callback calls pi.getSessionName() on every tick. When a session reload happens, the pi runtime invalidates the extension context — any later call on the stale context throws stale extension generation after reload. If a timer tick lands after the invalidation, the exception escapes from the timer callback as an uncaughtException and terminates the entire pi process.

Fix

Wrap the interval callback body in try/catch. When the context turns stale, the catch block stops the timer instead of letting the exception crash the process.

timer = setInterval(() => {
  try {
    const frame = BRAILLE_FRAMES[frameIndex % BRAILLE_FRAMES.length]
    const cwd = process.cwd().split(/[\\/]/).filter(Boolean).at(-1) || process.cwd()
    const session = pi.getSessionName()
    const title = session ? `${frame} \u03c0 - ${session} - ${cwd}` : `${frame} \u03c0 - ${cwd}`
    ctx.ui.setTitle(title)
    frameIndex++
  } catch {
    // Session reload invalidated this extension ctx. Stop the timer instead
    // of letting the stale-ctx exception escape as an uncaughtException
    // (which kills the whole pi process).
    if (timer) {
      clearInterval(timer)
      timer = null
    }
  }
}, 80)

Verification

@coderabbitai

coderabbitai Bot commented Aug 15, 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 Plus

Run ID: 97c9a8d5-0db0-4644-b0bd-af551cf00b89

📥 Commits

Reviewing files that changed from the base of the PR and between 73bbe20 and 563e425.

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

📝 Walkthrough

Walkthrough

The titlebar animation interval now wraps frame rendering and title updates in error handling. When a stale extension context causes an error, the code clears the interval and resets its timer reference. The error no longer propagates as an uncaught process error. Normal frame rendering and title updates remain unchanged.

Merge Risk: ⚪ Minimal · up to 563e4

The change stops the titlebar animation timer when a session reload invalidates its context, preventing the stale-context exception from terminating the pi process. It is a localized fix with no actionable merge-blocking risk remaining after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the root cause, fix, linked issue, and verification, but it omits required template sections such as Visual Proof, Testing checkboxes, Review, Checklist, and Author. Add the missing required sections, include visual proof or N/A with a reason, document platform testing, and complete the checklist and review details.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main fix: stopping the titlebar spinner timer when the extension context becomes stale.
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.

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.

@coding-susemi

Copy link
Copy Markdown
Author

Closing this stale PR: it came from an older local setup that I no longer maintain. Thanks for the project!

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