Skip to content

Coalesce renderer worktree change refreshes - #6020

Merged
OrcaWin merged 1 commit into
stablyai:mainfrom
OrcaWin:OrcaWin/win-crashes
Jun 22, 2026
Merged

OrcaWin merged 1 commit into
stablyai:mainfrom
OrcaWin:OrcaWin/win-crashes

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Jun 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • add a renderer-side per-repo queue for worktree change refreshes
  • collapse Windows/OneDrive-style same-repo change bursts to one active refresh plus one trailing refresh
  • preserve rename events so worktree id migration still runs in order

Reproduction / verification

  • Deterministic harness: worktree-change-refresh-queue.test.ts reproduces the suspected pre-crash trigger by enqueueing repeated same-repo worktree change events while the first refresh is still in flight.
  • I was not able to reproduce the literal Electron renderer process_gone / reason=killed / exit_code=1 crash inside this CLI session, so the remaining Windows manual validation is to rerun the OneDrive worktree-create/sidebar-switch loop from the handoff on this branch.

Tests

  • pnpm vitest run --config config/vitest.config.ts src/renderer/src/hooks/worktree-change-refresh-queue.test.ts
  • pnpm typecheck:web
  • pnpm exec oxlint src/renderer/src/hooks/worktree-change-refresh-queue.ts src/renderer/src/hooks/worktree-change-refresh-queue.test.ts src/renderer/src/hooks/useIpcEvents.ts

Open in Stage

@ghost

ghost commented Jun 22, 2026 •

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 3 individual chapters for you:

Title
1 Implement worktree change refresh queue
2 Integrate refresh queue into IPC event handling
3 Verify refresh queue behavior with tests
Open in Stage

Chapters generated by Stage for commit d1f61f7 on Jun 22, 2026 1:31am UTC.

@coderabbitai

coderabbitai Bot commented Jun 22, 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: 7cc1f9fd-e128-4ce8-af29-4b08ba92e2a5

📥 Commits

Reviewing files that changed from the base of the PR and between bf3ed403c6a73771ea9e4793c7d22effab95c452 and d1f61f7.

📒 Files selected for processing (3)
  • src/renderer/src/hooks/useIpcEvents.ts
  • src/renderer/src/hooks/worktree-change-refresh-queue.test.ts
  • src/renderer/src/hooks/worktree-change-refresh-queue.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer/src/hooks/worktree-change-refresh-queue.ts
  • src/renderer/src/hooks/useIpcEvents.ts

📝 Walkthrough

Walkthrough

A new createWorktreeChangeRefreshQueue function is introduced in worktree-change-refresh-queue.ts. It maintains a per-repoId FIFO queue with a running flag, coalesces burst non-rename change events into a single trailing entry, appends rename events unconditionally, and serially drains queued items by awaiting the provided async handler. Handler errors are caught per-item and logged without halting the drain. In useIpcEvents.ts, both the runtime worktreesChanged event path and the window.api.worktrees.onChanged callback are updated to enqueue via worktreeChangeRefreshQueue.enqueue(...) instead of directly invoking handleWorktreesChanged. Vitest tests validate coalescing, sequential non-overlap, per-repo independence, error resilience, and rename payload forwarding.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description covers the summary, testing approach, and verification steps, but is missing required sections: Screenshots, checklist confirmation for lint/typecheck/test/build, AI Review Report with cross-platform compatibility check, and Security Audit. Add missing sections: Screenshots (mark as 'No visual change'), complete the testing checklist with results, add AI Review Report confirming cross-platform checks, and include Security Audit summary.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Coalesce renderer worktree change refreshes' is clear, specific, and directly describes the main change implemented in the PR—a queuing mechanism that coalesces rapid worktree change events.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@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

Run ID: ce3afedf-ff90-463c-9b8a-f5b55e01b852

📥 Commits

Reviewing files that changed from the base of the PR and between 9534c75 and bf3ed403c6a73771ea9e4793c7d22effab95c452.

📒 Files selected for processing (3)
  • src/renderer/src/hooks/useIpcEvents.ts
  • src/renderer/src/hooks/worktree-change-refresh-queue.test.ts
  • src/renderer/src/hooks/worktree-change-refresh-queue.ts

Comment thread src/renderer/src/hooks/useIpcEvents.ts Resolved
@OrcaWin
OrcaWin force-pushed the OrcaWin/win-crashes branch from bf3ed40 to d1f61f7 Compare June 22, 2026 01:30
@OrcaWin
OrcaWin merged commit 2ed4346 into stablyai:main Jun 22, 2026
1 check passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 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.

2 participants