Skip to content

fix(macos): prevent stale UI surfaces after wake - #11226

Merged
Jinwoo-H merged 1 commit into
mainfrom
fix-macos-wake-stale-surface
Jul 28, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
fix-macos-wake-stale-surface

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Preserve macOS main-window background throttling and its hidden-window battery/GPU savings.
  • Give native Electron windows a stable percentage-height chain while retaining dynamic viewport units for the web/mobile client.
  • Remove wake-time device emulation on macOS 26 while preserving the native frame-mutation guard, pre-macOS 26 repaint jiggle, compositor invalidation, and renderer terminal/WebGL wake recovery.

Screenshots

No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Validated with:

  • 97 focused window, viewport, system-resume, and terminal wake-recovery tests
  • changed-code quality, type-aware quality, React Doctor, oxlint, and max-lines gates
  • production Electron/Vite desktop build
  • production web build and web artifact verification

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.

@greptile-apps

greptile-apps Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR fixes macOS overnight sleep/wake stale-surface failures by replacing the device-emulation-based dvh reflow with a stable percentage-height chain for native Electron shells, and removing the device emulation step from the macOS 26 forceRepaint path entirely.

  • renderer-viewport-reflow.ts deleted: The enableDeviceEmulation/disableDeviceEmulation cycle that forced a dvh reflow after wake is removed because device emulation can itself strand the compositor; the root cause (unstable dvh sizing in native windows) is fixed instead.
  • Stable height: 100% chain for native shells: index.html and popout.html gain class="native-shell"; a CSS override block sets html, body, #root, .app-layout to height: 100% for that class, making layout independent of the viewport unit resolution that was going stale after wake.
  • macOS 26 forceRepaint simplified: isMacosTahoeOrNewer() now calls invalidate() and returns immediately — no frame mutation, no emulation — while the pre-Tahoe size-jiggle path and the renderer system:resumed relay are preserved unchanged.

Confidence Score: 5/5

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

Important Files Changed

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])
Loading

Reviews (2): Last reviewed commit: "fix(macos): avoid wake-time compositor r..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Updates 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 native-shell class with stable full-height sizing, while web rendering retains dynamic viewport behavior. Associated native layout and macOS repaint tests were updated.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
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 (4 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 is concise and accurately summarizes the main macOS wake stale-surface fix.
Description check ✅ Passed The description follows the template and includes summary, screenshots, testing, AI review, security audit, and notes.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@Jinwoo-H
Jinwoo-H force-pushed the fix-macos-wake-stale-surface branch from a0df6e6 to 0bdf308 Compare July 28, 2026 22:33
@Jinwoo-H

Copy link
Copy Markdown
Contributor Author

Revised the fix to preserve macOS background throttling. The PR now targets only the Orca-specific wake sequence: native dvh dependence and device-scale emulation. Tests explicitly assert that setBackgroundThrottling(true) remains in place while macOS 26 wake performs invalidation without frame mutation or device emulation.

@Jinwoo-H
Jinwoo-H merged commit a6423d5 into main Jul 28, 2026
26 checks passed
@Jinwoo-H
Jinwoo-H deleted the fix-macos-wake-stale-surface branch July 28, 2026 23:37
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