Repository navigation
fix(macos): prevent stale UI surfaces after wake - #11226
Conversation
Greptile SummaryThis PR fixes macOS overnight sleep/wake stale-surface failures by replacing the device-emulation-based
Confidence Score: 5/5Safe to merge — the change removes a privileged Chromium path rather than adding one, and the layout fix is well-scoped to Electron shells only. The device emulation module is deleted cleanly, the forceRepaint simplification is a strict reduction in surface area, and the height: 100% override is correctly scoped to html.native-shell with higher specificity than the layered base rules. Web clients retain 100dvh unchanged. Tests cover the native/web split, the absence of device emulation calls, and the unchanged pre-Tahoe jiggle path. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/main/window/createMainWindow.ts | Removed the reflowRendererViewport (device emulation) call from forceRepaint for macOS 26; the function now calls invalidate() and returns early for Tahoe+, preserving the pre-Tahoe size-jiggle path untouched. |
| src/main/window/createMainWindow.test.ts | Tests updated to drop enableDeviceEmulation/disableDeviceEmulation mocks and assertions, reordered throttling assertions, and renamed test cases to reflect that macOS 26 now uses invalidate-only repaint. |
| src/main/window/renderer-viewport-reflow.ts | Deleted — the device-emulation-based viewport reflow module is no longer needed because native shells now use a stable height: 100% chain instead of dvh. |
| src/main/window/renderer-viewport-reflow.test.ts | Deleted — all 17 tests for the now-removed reflowRendererViewport module are gone; the underlying functionality is no longer needed. |
| src/renderer/index.html | Added class="native-shell" to to enable the CSS percentage-height chain override for the main Electron window. |
| src/renderer/popout.html | Added class="native-shell" to to enable the CSS percentage-height chain override for the popout Electron window. |
| src/renderer/src/App.tsx | Root div class changed from Tailwind utilities flex flex-col h-dvh w-screen overflow-hidden to the custom app-layout class, which carries the same properties in CSS plus the native-shell height: 100% override. |
| src/renderer/src/assets/main.css | Added html.native-shell percentage-height override block; base rules for body, #root, and .app-layout retain height: 100dvh so web clients are unaffected. |
| src/renderer/src/web/web-viewport-shell.test.ts | Added a new test that verifies the native-shell CSS regex, HTML class markers, and App.tsx usage are coherent; removed App.tsx from the h-dvh Tailwind check since native App now uses .app-layout. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A([System resume / show / restore / focus]) --> B[forceRepaint called]
B --> C{window or webContents destroyed?}
C -- Yes --> D([return])
C -- No --> E[webContents.invalidate]
E --> F{isMacosTahoeOrNewer?}
F -- Yes macOS 26+ --> G([return — invalidate only, no frame mutation, no device emulation])
F -- No pre-macOS 26 --> H{maximized / fullscreen or active jiggle?}
H -- Yes --> I([return])
H -- No --> J[setTimeout 0ms: setSize width+1]
J --> K[setTimeout 32ms: restore original size]
K --> L([WeakSet cleared])
M([powerMonitor resume]) --> B
M --> N[send system:resumed to renderer]
N --> O([Terminal + WebGL wake recovery in renderer])
Reviews (2): Last reviewed commit: "fix(macos): avoid wake-time compositor r..." | Re-trigger Greptile
📝 WalkthroughWalkthroughUpdates macOS window repaint behavior to avoid renderer viewport reflow on macOS Tahoe and newer, keep background throttling enabled, and use invalidate-only repaint assertions. Native renderer entrypoints now use a 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
a0df6e6 to
0bdf308
Compare
|
Revised the fix to preserve macOS background throttling. The PR now targets only the Orca-specific wake sequence: native |
Co-authored-by: OrcaWin <[email protected]>
Summary
Screenshots
No visual change.
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildValidated with:
The repository-wide test invocation was stopped after unrelated local PTY shell-wrapper tests failed; all targeted suites for this change pass. The first CI run passed all checks before the throttling-preservation amendment; the amended commit triggers a fresh run.
AI Review Report
Reviewed the wake, visibility, viewport, and reload/session-preservation paths end to end. The review checked that macOS 26 never mutates the native frame or invokes device emulation during show, restore, reveal, or resume; macOS background throttling remains enabled; pre-macOS 26 repaint behavior remains; and the existing safe reload path continues to preserve live sessions.
Cross-platform review confirmed that Linux and Windows repaint behavior is unchanged, browser/mobile clients retain dynamic viewport sizing, and no shortcut, label, path, shell, Git, SSH, folder-workspace, or provider behavior changes.
The main residual risk is that the field failure was not reproduced deterministically. This revision deliberately targets the Orca-specific wake-time viewport/emulation sequence without weakening the background power optimization.
Security Audit
No new input handling, command execution, path handling, authentication, secrets, dependencies, or IPC surface. Existing renderer-reveal sender validation is preserved. The change removes a privileged Chromium emulation path rather than adding one.
Notes
This targets the macOS overnight sleep/unlock failure where agents and processes remain live but WindowServer presents a stale, unresponsive frame. Background parking remains enabled; this PR introduces no intentional hidden-window battery or GPU regression.