Skip to content

fix: resolve Windows freeze when switching worktrees with right sidebar open - #628

Merged
Jinwoo-H merged 2 commits into
mainfrom
Jinwoo-H/improve-windows-performance
Apr 14, 2026
Merged

Jinwoo-H merged 2 commits into
mainfrom
Jinwoo-H/improve-windows-performance

Conversation

@Jinwoo-H

Copy link
Copy Markdown
Contributor

Summary

  • Defer WebGL context recreation — resumeRendering() moved into rAF so the browser paints one frame with the DOM renderer before blocking on ANGLE→D3D11 context creation (100–500ms per pane on Windows)
  • Epoch-based fit deduplication — prevents redundant terminal scrollback reflows between the isActive effect and ResizeObserver paths using a three-layer guard (staleness → dimension check → dedup)
  • proposeDimensions() guard — skips fitAddon.fit() entirely when terminal dimensions haven't changed, avoiding unnecessary _renderService.clear() + terminal.refresh() overhead
  • Remove sidebar panel remount — replaced key={activeWorktreeId} with worktree-change reset effects, eliminating the IPC storm (watchWorktree + readDir + git:branchCompare + …) on every switch
  • Watcher grace period — 30s delay before tearing down @parcel/watcher subscriptions so rapid worktree switches reuse existing native watchers
  • Intercept Ctrl+B/Ctrl+L in main process — added to before-input-event allowlist to prevent ^B/^L control characters from reaching xterm
  • Fix sidebar open transition — useLayoutEffect + direct DOM style.transition = 'none' kills the CSS transition before Chromium can start it (the old useState approach had a one-frame race)

Test plan

  • Switch between worktrees rapidly (10+ times) with sidebar open on Windows — stays responsive
  • Switch worktrees with sidebar open on macOS — verify no regressions
  • Verify FileExplorer shows correct files after switch (no stale data)
  • Verify SourceControl shows correct git status after switch
  • Verify terminal dimensions are correct after switch (type a long line, confirm wrapping)
  • Resize window while worktree is in background, switch to it — terminal refits correctly
  • Ctrl+L no longer types ^L in terminal
  • Ctrl+L in browser tab guest still focuses address bar
  • Drag-resize sidebar still works smoothly
  • Close and reopen sidebar — no freeze

@Jinwoo-H
Jinwoo-H force-pushed the Jinwoo-H/improve-windows-performance branch from db6ecae to 842a5da Compare April 14, 2026 07:38
…ar open

Multiple performance fixes that eliminate the multi-second freeze on Windows
when switching worktrees while the right sidebar is open:

- Defer WebGL context recreation into rAF so the browser paints one frame
  with the DOM renderer before blocking on ANGLE→D3D11 context creation
- Add epoch-based fit deduplication to prevent redundant terminal scrollback
  reflows between the isActive effect and ResizeObserver paths
- Add proposeDimensions() guard to skip fitAddon.fit() entirely when
  terminal dimensions haven't changed (common case on worktree switch)
- Remove key={activeWorktreeId} from sidebar panels to avoid full
  unmount/remount IPC storm (watchWorktree + readDir + git:branchCompare)
  on every switch; add reset effects for worktree-specific local state
- Add 30s grace period before tearing down @parcel/watcher subscriptions
  so rapid worktree switches reuse existing native watchers
- Intercept Ctrl+B/Ctrl+L via before-input-event in main process to
  prevent terminal control characters from reaching xterm
- Fix sidebar open transition suppression using useLayoutEffect + direct
  DOM style manipulation (the old useState approach had a one-frame race)
Add onToggleLeftSidebar and onToggleRightSidebar mock stubs to the
test's window.api.ui mock object so the test doesn't crash when
useIpcEvents subscribes to the new sidebar toggle IPC channels.
@Jinwoo-H
Jinwoo-H merged commit 170610d into main Apr 14, 2026
1 check passed
brennanb2025 added a commit that referenced this pull request Apr 19, 2026
Adds Playwright coverage for two high-regression areas identified from the
last 200 PRs:

- worktree-lifecycle.spec.ts: guards removeWorktree cleanup (#532),
  worktree switch with right sidebar open (#598/#628/#726), and
  cross-worktree tab isolation (#542/#554).
- tab-close-navigation.spec.ts: guards visual-neighbor activation on
  editor/diff close (#693) and Landing fallback when the last visible
  surface closes (#677).
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.

1 participant