Skip to content

fix(windows): keep browser close marker URL absolute - #12038

Merged
nwparker merged 1 commit into
mainfrom
nwparker/black-screen
Aug 2, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/black-screen

Conversation

@nwparker

@nwparker nwparker commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Fix the all-black Windows window introduced in v1.4.164-rc.0 by making the synthetic browser close-policy preload marker absolute under Windows file-URL rules.
  • createMainWindow() previously constructed the BrowserWindow, then threw ERR_INVALID_FILE_URL_PATH while converting file:///__orca_window_close_allowed__, before the renderer document could load.
  • Add a regression test that runs fileURLToPath() with Windows semantics and pins the resulting absolute path.

ELI5

The previous browser fix needed a pretend “special permission sticker” for certain browser pages. It used the fake file address file:///__orca_window_close_allowed__ as that sticker.

Mac accepts that address as an absolute path. Windows requires a drive letter such as C:/, so it threw an error while reading the sticker. Orca had already created its window but had not loaded the UI yet, leaving a real but completely empty black window.

This PR makes the sticker Windows-valid (file:///C:/__orca_window_close_allowed__) and adds a test that reads it using Windows URL rules.

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

Focused validation completed:

  • pnpm exec vitest run --config config/vitest.config.ts src/main/window/createMainWindow.test.ts src/preload/browser-window-close.test.ts src/renderer/src/components/browser-pane/BrowserPane.webview-preferences.test.ts
  • pnpm run typecheck:node
  • pnpm run check:code-quality:changed
  • pnpm run check:reliability-gates
  • pnpm run build:electron-vite

AI Review Report

No findings remain. The review traced startup from BrowserWindow construction through the close-policy marker conversion and renderer load, and verified both raw-URL and normalized-path policy comparisons. Cross-platform review confirmed the marker converts to C:\\__orca_window_close_allowed__ under Windows rules and remains a valid absolute POSIX path on macOS/Linux; no shortcuts, labels, shell behavior, SSH routing, or workspace-path behavior changes.

Security Audit

The synthetic URL remains a policy marker only and is removed before the guest preload can run. The change does not broaden accepted navigation origins, add command execution, alter IPC authority, process user-controlled paths, touch auth or secrets, or add dependencies. The existing fail-closed webview policy remains intact.

Notes

The cause was confirmed from main.trace.ndjson: fileURLToPath() raised ERR_INVALID_FILE_URL_PATH in getPathFromURLWin32 immediately after the RC update. This is unrelated to GPU capability; the renderer was never loaded.

@coderabbitai

coderabbitai Bot commented Aug 2, 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: 6c7f88b3-26dd-45f1-9825-f71923fb1c5c

📥 Commits

Reviewing files that changed from the base of the PR and between 8ab85c9 and 7a2c111.

📒 Files selected for processing (2)
  • src/main/window/createMainWindow.test.ts
  • src/shared/browser-window-close-policy.ts

📝 Walkthrough

Walkthrough

The browser close-policy preload marker now uses an absolute Windows file URL with a C:/ path. A regression test verifies that fileURLToPath converts the marker to C:\__orca_window_close_allowed__ under Windows URL rules.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the Windows fix to keep the browser close marker URL absolute.
Description check ✅ Passed The description covers the summary, visual impact, testing, AI review, security audit, and platform-specific notes required by the template.
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.
✨ 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.

@greptile-apps

greptile-apps Bot commented Aug 2, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes an all-black Windows window regression introduced in v1.4.164-rc.0 by making the synthetic browser close-policy preload marker URL valid under Windows file-URL rules. file:///__orca_window_close_allowed__ lacks a drive letter and caused Node.js's fileURLToPath() to throw ERR_INVALID_FILE_URL_PATH before the renderer document could ever load on Windows.

  • browser-window-close-policy.ts: Changes the synthetic marker to file:///C:/__orca_window_close_allowed__, adding the required Windows drive letter. On macOS/Linux, fileURLToPath() now resolves to /C:/__orca_window_close_allowed__; the dual URL/path-form comparisons in createMainWindow.ts still handle both platforms correctly.
  • createMainWindow.test.ts: Adds a regression test that uses fileURLToPath(…, { windows: true }) to pin the resulting Windows path as C:\\__orca_window_close_allowed__, guarding against future regressions.

Confidence Score: 5/5

Safe to merge. The change is a minimal, targeted fix that restores Windows startup to a working state without altering any macOS/Linux behaviour or security boundaries.

The one-line constant change is correct: adding C: gives Windows fileURLToPath() the drive letter it requires while leaving the macOS/Linux resolved path as /C:/orca_window_close_allowed, which the dual URL/path comparison in createMainWindow.ts already handles. The regression test cleanly pins Windows semantics via the { windows: true } flag. No logic, security model, or cross-platform policy path was broken.

Files Needing Attention: No files require special attention.

Important Files Changed

Filename Overview
src/shared/browser-window-close-policy.ts One-line fix: adds a Windows drive letter to the synthetic marker URL so fileURLToPath() no longer throws ERR_INVALID_FILE_URL_PATH on Windows. macOS/Linux behaviour remains correct because the policy comparison in createMainWindow.ts checks both URL and path forms.
src/main/window/createMainWindow.test.ts Adds a regression test that pins the Windows path form using fileURLToPath with { windows: true }. Clean addition; no existing tests were modified.

Reviews (1): Last reviewed commit: "fix(windows): keep browser close marker ..." | Re-trigger Greptile

@nwparker
nwparker merged commit 9db4cde into main Aug 2, 2026
44 checks passed
@nwparker
nwparker deleted the nwparker/black-screen branch August 2, 2026 03:35
gal064 pushed a commit to gal064/orca that referenced this pull request Aug 3, 2026
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