Skip to content

fix: avoid Tauri window access in browser mode - #179

Merged
Lampese merged 4 commits into
Lampese:mainfrom
squarepots:fix/browser-runtime-safe
Sep 30, 2026
Merged

Lampese merged 4 commits into
Lampese:mainfrom
squarepots:fix/browser-runtime-safe

Conversation

@squarepots

Copy link
Copy Markdown

本 PR 修复 plain browser/LAN 模式在 React mount 前访问 Tauri window API 导致的空白页。所有原生窗口操作现在都通过 lazy runtime boundary:只有检测到 window.__TAURI_INTERNALS__ 后才解析并缓存 Tauri window。

drag、双击 maximize、resize listener、minimize、maximize 和 close 都使用该 helper;浏览器模式不渲染原生窗口控件,Tauri desktop 保留现有窗口交互。

验证

  • pnpm test:browser-runtime:2 项通过,覆盖无 window 和 plain browser-like window
  • pnpm test:desktop-reopen:7 项通过
  • pnpm test:close-preference:3 项通过
  • pnpm test:reset-credits:3 项通过
  • pnpm build:通过

Closes #145


This PR fixes the blank page in plain browser/LAN mode caused by accessing the Tauri window API before React mounts. Native window operations now go through a lazy runtime boundary that resolves and caches the Tauri window only when window.__TAURI_INTERNALS__ is present.

Dragging, double-click maximize, resize listeners, minimize, maximize, and close all use the helper. Browser mode does not render native window controls, while the Tauri desktop keeps its existing window interactions.

Validation

  • pnpm test:browser-runtime: 2 passed, covering no window and a plain browser-like window
  • pnpm test:desktop-reopen: 7 passed
  • pnpm test:close-preference: 3 passed
  • pnpm test:reset-credits: 3 passed
  • pnpm build: passed

Closes #145

Restores #166 after the source fork was accidentally deleted.

@Lampese Lampese added bug Something isn't working priority:P1 Address first: auth, data integrity, security, startup or release validation. area:web Browser dashboard, HTTP concurrency and remote access. status:needs-review Maintainer review required; this label is not merge approval. status:needs-ci No check rollup is visible for the current PR head; validate before landing. labels Sep 30, 2026
@Lampese
Lampese merged commit 39c42c0 into Lampese:main Sep 30, 2026
6 checks passed
@Lampese Lampese removed status:needs-review Maintainer review required; this label is not merge approval. status:needs-ci No check rollup is visible for the current PR head; validate before landing. labels Sep 30, 2026
@squarepots
squarepots deleted the fix/browser-runtime-safe branch October 3, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:web Browser dashboard, HTTP concurrency and remote access. bug Something isn't working priority:P1 Address first: auth, data integrity, security, startup or release validation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Web/LAN mode renders a blank page: getCurrentWindow() called at module scope

2 participants