From 16c66d9fe469ed7504f30e7947ad29cfac899c48 Mon Sep 17 00:00:00 2001 From: baiqing Date: Mon, 18 May 2026 18:31:35 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(startup):=20autostart=20catch=20?= =?UTF-8?q?=E5=9D=97=E7=BC=BA=20return=20=E5=AF=BC=E8=87=B4=E5=A4=8D?= =?UTF-8?q?=E6=B4=BB=E4=B8=BB=E7=AA=97=E5=8F=A3=20(#468)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #474 引入的"前端兜底"useEffect 在 webview ready 后读 prefs.startMinimized,true 则跳过 currentWindow.show()。但 catch 块只 console.warn 没有 return,控制流继续走到 show()——等于"prefs 读失败 = 强 show"。 autostart 早期 IPC 抖动时 getSettings() 偶发失败,旧逻辑让用户明明开了 静默启动仍把主窗口弹出来。 修复: catch 块加 return,安全侧默认 = 当作 startMinimized=true 保持隐藏。 宁可让用户从 tray 手动唤起,也不要在 autostart 抖动时强 show 一个白色 / 透明主窗口。 LSUIElement 不在本 PR 范围: 那是全局 macOS UX 决策,会影响 Finder 双击 / Spotlight / Launchpad 启动场景,应单独 PR + 单独评审。 正确做法是 Rust 端动态切 activationPolicy 而非 plist 静态写死。 Refs #468 --- openless-all/app/src/App.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/openless-all/app/src/App.tsx b/openless-all/app/src/App.tsx index 40231e5b..05c3ffeb 100644 --- a/openless-all/app/src/App.tsx +++ b/openless-all/app/src/App.tsx @@ -53,9 +53,12 @@ export function App({ isCapsule, isQa }: AppProps) { const prefs = await getSettings(); if (prefs.startMinimized) return; } catch (err) { - // 读 prefs 失败兜底走原有 show 行为:让权限探测失败的用户也能进 UI, - // 避免透明 / 空白窗口前卡死(issue #163 引入这个 show 的原始意图)。 - console.warn('[startup] read startMinimized failed, falling back to show', err); + // 安全侧默认 = 不弹窗。autostart 早期 IPC 抖动会让 getSettings() 偶发 + // 失败,旧逻辑(fall through to show)会在用户明明开了静默启动时仍把 + // 主窗口弹出来 —— issue #468 复现路径。宁可让用户从 tray 手动唤起, + // 也不要在 autostart 抖动时强 show 一个白色 / 透明主窗口。 + console.warn('[startup] read startMinimized failed; staying hidden to avoid #468', err); + return; } const { getCurrentWindow } = await import('@tauri-apps/api/window'); if (cancelled) return; From 3a5e0e3af4bf6639efa31d4c7fe27779779395bc Mon Sep 17 00:00:00 2001 From: baiqing Date: Mon, 18 May 2026 18:48:27 +0800 Subject: [PATCH 2/2] docs(startup): clarify catch rationale + improve warn diagnostics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both local review and PR-Agent bot flagged the "fallback when settings read fails" semantic reversal. Re-analysis confirms the change is correct, but the rationale needs to be explicit in the code: - Rust `get_settings` signature is `pub fn -> UserPreferences` (not Result), so this catch is unreachable from a normal first-launch scenario (returns defaults). Only Tauri IPC infrastructure failures (e.g. __TAURI_INTERNALS__ not ready during autostart early-mount) reach this branch. - Tray is registered by Rust setup() before webview ready, so it remains the universal fallback entry point — no "user locked out" risk. - Improved console.warn to include err.message for diagnostics, since raw err objects serialize as [object Object] in Tauri devtools. No behavior change; comment + log improvement only. Refs review of #488 --- openless-all/app/src/App.tsx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/openless-all/app/src/App.tsx b/openless-all/app/src/App.tsx index 05c3ffeb..08ce2665 100644 --- a/openless-all/app/src/App.tsx +++ b/openless-all/app/src/App.tsx @@ -53,11 +53,18 @@ export function App({ isCapsule, isQa }: AppProps) { const prefs = await getSettings(); if (prefs.startMinimized) return; } catch (err) { - // 安全侧默认 = 不弹窗。autostart 早期 IPC 抖动会让 getSettings() 偶发 - // 失败,旧逻辑(fall through to show)会在用户明明开了静默启动时仍把 - // 主窗口弹出来 —— issue #468 复现路径。宁可让用户从 tray 手动唤起, - // 也不要在 autostart 抖动时强 show 一个白色 / 透明主窗口。 - console.warn('[startup] read startMinimized failed; staying hidden to avoid #468', err); + // 安全侧默认 = 不弹窗。Rust 端 get_settings 签名是 + // `pub fn get_settings(...) -> UserPreferences`(非 Result),所以 + // 该 catch 唯一会被触发的场景是 Tauri IPC 基础设施抖动(autostart 早期 + // __TAURI_INTERNALS__ 还没就绪)。旧逻辑 fall-through to show 会在用户 + // 开了静默启动时仍把主窗口弹出来 —— #468 复现路径。 + // + // 此时 tray 已由 Rust 端 setup() 在 webview 加载前注册完成,是稳定的 + // 兜底入口;宁可让用户从 tray 手动唤起,也不要在抖动时强 show 一个白色 + // / 透明主窗口。首次安装的"prefs 不存在"场景不走这里 —— Rust 端会返回 + // 默认 UserPreferences。 + const detail = err instanceof Error ? err.message : String(err); + console.warn('[startup] read startMinimized failed; staying hidden to avoid #468:', detail, err); return; } const { getCurrentWindow } = await import('@tauri-apps/api/window');