Skip to content

Commit 3a5e0e3

Browse files
author
baiqing
committed
docs(startup): clarify catch rationale + improve warn diagnostics
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
1 parent 16c66d9 commit 3a5e0e3

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

openless-all/app/src/App.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,18 @@ export function App({ isCapsule, isQa }: AppProps) {
5353
const prefs = await getSettings();
5454
if (prefs.startMinimized) return;
5555
} catch (err) {
56-
// 安全侧默认 = 不弹窗。autostart 早期 IPC 抖动会让 getSettings() 偶发
57-
// 失败,旧逻辑(fall through to show)会在用户明明开了静默启动时仍把
58-
// 主窗口弹出来 —— issue #468 复现路径。宁可让用户从 tray 手动唤起,
59-
// 也不要在 autostart 抖动时强 show 一个白色 / 透明主窗口。
60-
console.warn('[startup] read startMinimized failed; staying hidden to avoid #468', err);
56+
// 安全侧默认 = 不弹窗。Rust 端 get_settings 签名是
57+
// `pub fn get_settings(...) -> UserPreferences`(非 Result),所以
58+
// 该 catch 唯一会被触发的场景是 Tauri IPC 基础设施抖动(autostart 早期
59+
// __TAURI_INTERNALS__ 还没就绪)。旧逻辑 fall-through to show 会在用户
60+
// 开了静默启动时仍把主窗口弹出来 —— #468 复现路径。
61+
//
62+
// 此时 tray 已由 Rust 端 setup() 在 webview 加载前注册完成,是稳定的
63+
// 兜底入口;宁可让用户从 tray 手动唤起,也不要在抖动时强 show 一个白色
64+
// / 透明主窗口。首次安装的"prefs 不存在"场景不走这里 —— Rust 端会返回
65+
// 默认 UserPreferences。
66+
const detail = err instanceof Error ? err.message : String(err);
67+
console.warn('[startup] read startMinimized failed; staying hidden to avoid #468:', detail, err);
6168
return;
6269
}
6370
const { getCurrentWindow } = await import('@tauri-apps/api/window');

0 commit comments

Comments
 (0)