收口桌面壳深链诊断日志

桌面壳深链注册和当前链接读取失败只记录固定标签

扩展桌面壳配置门禁禁止 deep-link 插件错误详情进入日志

补充宿主壳方案和共享决策中的深链诊断边界
This commit is contained in:
2026-06-21 01:18:15 +08:00
parent 6ba22b214c
commit f262c69041
4 changed files with 37 additions and 7 deletions
@@ -3323,9 +3323,11 @@ for (const snippet of [
'log_desktop_deep_link_register_result(app.deep_link().register_all())',
'desktop host event failed for deep_link.register',
'desktop_deep_link_register_result_reports_success_and_failure',
'desktop_deep_link_register_result_logs_stable_label_only',
'log_desktop_deep_link_current_result(app.deep_link().get_current())',
'desktop host event failed for deep_link.current',
'desktop_deep_link_current_result_reports_success_empty_and_failure',
'desktop_deep_link_current_result_logs_stable_label_only',
'log_desktop_deep_link_window_missing("open")',
'log_desktop_deep_link_window_missing("current")',
'desktop_deep_link_window_missing_reports_failure',
@@ -3334,3 +3336,14 @@ for (const snippet of [
throw new Error(`desktop shell deep-link registration logging missing ${snippet}`);
}
}
if (
desktopShellDeepLinkSource.includes(
'desktop host event failed for deep_link.register: {error}',
) ||
desktopShellDeepLinkSource.includes(
'desktop host event failed for deep_link.current: {error}',
)
) {
throw new Error('desktop deep-link diagnostics must not log plugin error details');
}
@@ -81,8 +81,8 @@ fn log_desktop_deep_link_register_result(
) -> bool {
match result {
Ok(()) => true,
Err(error) => {
eprintln!("desktop host event failed for deep_link.register: {error}");
Err(_error) => {
eprintln!("desktop host event failed for deep_link.register");
false
}
}
@@ -93,8 +93,8 @@ fn log_desktop_deep_link_current_result(
) -> Option<Vec<Url>> {
match result {
Ok(urls) => urls,
Err(error) => {
eprintln!("desktop host event failed for deep_link.current: {error}");
Err(_error) => {
eprintln!("desktop host event failed for deep_link.current");
None
}
}
@@ -278,6 +278,13 @@ mod tests {
)));
}
#[test]
fn desktop_deep_link_register_result_logs_stable_label_only() {
assert!(!log_desktop_deep_link_register_result(Err(
tauri_plugin_deep_link::Error::UnsupportedPlatform
)));
}
#[test]
fn desktop_deep_link_current_result_reports_success_empty_and_failure() {
let urls = vec![Url::parse("genarrative://open/works/detail?work=PZ-1").expect("url")];
@@ -294,6 +301,16 @@ mod tests {
);
}
#[test]
fn desktop_deep_link_current_result_logs_stable_label_only() {
assert_eq!(
log_desktop_deep_link_current_result(Err(
tauri_plugin_deep_link::Error::UnsupportedPlatform
)),
None
);
}
#[test]
fn desktop_deep_link_window_missing_reports_failure() {
assert!(!log_desktop_deep_link_window_missing("open"));
@@ -2954,14 +2954,14 @@
## 2026-06-20 桌面壳深链注册失败不可静默
- 背景:Tauri 桌面壳深链 scheme 注册决定已安装桌面包能否从系统链接唤醒;如果 `register_all()` 失败后静默继续,用户会看到深链无反应且没有可排查日志。
- 决策:`register_desktop_deep_link_schemes(...)` 必须把 `app.deep_link().register_all()` 结果交给同日志格式的 `log_desktop_deep_link_register_result(...)`,并返回布尔结果供测试和门禁反查;桌面壳配置检查拒绝重新出现 `let _ = app.deep_link().register_all()`
- 决策:`register_desktop_deep_link_schemes(...)` 必须把 `app.deep_link().register_all()` 结果交给同日志格式的 `log_desktop_deep_link_register_result(...)`,并返回布尔结果供测试和门禁反查;失败日志只记录 `desktop host event failed for deep_link.register` 固定标签,不输出 deep-link 插件错误详情;桌面壳配置检查拒绝重新出现 `let _ = app.deep_link().register_all()`
- 影响范围:`apps/desktop-shell/src-tauri/src/shell/deep_link.rs``apps/desktop-shell/scripts/check-config.mjs`
- 验证方式:`cargo test --manifest-path apps/desktop-shell/src-tauri/Cargo.toml shell::deep_link``npm run desktop-shell:typecheck``npm run check:native-shells``npm run check:encoding``git diff --check`
## 2026-06-20 桌面壳冷启动深链读取失败不可静默
- 背景:Tauri deep-link 插件在桌面壳冷启动时通过 `get_current()` 交出系统传入的初始 URL;如果读取失败后只回到默认首页,用户会看到深链启动目标丢失,开发侧也无法区分是链接被拒绝、插件不支持还是系统读取异常。
- 决策:桌面壳冷启动当前 deep link 读取必须经过 `log_desktop_deep_link_current_result(...)`;读取失败记录 `desktop host event failed for deep_link.current` 后安全回到默认入口,读取为空继续无声 no-op,读取成功再逐条执行受控 URL 归一和打开。桌面壳配置检查拒绝重新出现 `if let Ok(Some(urls)) = app.deep_link().get_current()` 静默分支。
- 决策:桌面壳冷启动当前 deep link 读取必须经过 `log_desktop_deep_link_current_result(...)`;读取失败记录 `desktop host event failed for deep_link.current` 固定标签后安全回到默认入口,不输出 deep-link 插件错误详情;读取为空继续无声 no-op,读取成功再逐条执行受控 URL 归一和打开。桌面壳配置检查拒绝重新出现 `if let Ok(Some(urls)) = app.deep_link().get_current()` 静默分支。
- 影响范围:`apps/desktop-shell/src-tauri/src/shell/deep_link.rs``apps/desktop-shell/scripts/check-config.mjs`、宿主壳方案文档。
- 验证方式:`cargo test --manifest-path apps/desktop-shell/src-tauri/Cargo.toml shell::deep_link``npm run desktop-shell:typecheck``npm run check:native-shells``npm run check:encoding``git diff --check`
@@ -453,7 +453,7 @@ GameBridge 禁止:
2026-06-18 追加:桌面壳启用 Tauri 窗口状态持久化。`shell/window_state.rs` 只配置 `tauri-plugin-window-state` 保存主窗口大小、位置和最大化状态,并排除可见性、全屏和装饰状态;插件注册顺序固定为 single-instance 优先,其后才是窗口状态、deep-link 和其它系统能力插件。该能力不进入 HostBridge 清单,不向 H5 暴露任意窗口状态读写,也不改变托盘关闭隐藏、单实例唤醒和托盘恢复主窗口的既有语义。`apps/desktop-shell/scripts/check-config.mjs` 会反查 `desktop_window_state_flags_keep_visible_state_out_of_persistence` 单测,避免后续把可见性、全屏或装饰状态误纳入持久化。
2026-06-18 追加:桌面壳接入 Tauri deep-link 插件,但不开放插件 JS guest API,也不把 deep-link 命令加入 capability。桌面配置只注册 `genarrative` schemeRust 层只接受 `genarrative://open/...``genarrative://app/...``genarrative://<path>``https://app.genarrative.world/...`,统一跳到同源 H5 路径并补写 `clientRuntime=native_app``hostShell=tauri_desktop`、当前平台、版本与真实 `hostCapabilities`。外域、`http:``mailto:``javascript:``file:` 等来源不进入主 WebView;冷启动当前 deep link 读取失败、归一成功后的 `window.navigate(...)` 与主窗口恢复 / 聚焦失败必须记录桌面宿主事件日志,不能静默吞错。
2026-06-18 追加:桌面壳接入 Tauri deep-link 插件,但不开放插件 JS guest API,也不把 deep-link 命令加入 capability。桌面配置只注册 `genarrative` schemeRust 层只接受 `genarrative://open/...``genarrative://app/...``genarrative://<path>``https://app.genarrative.world/...`,统一跳到同源 H5 路径并补写 `clientRuntime=native_app``hostShell=tauri_desktop`、当前平台、版本与真实 `hostCapabilities`。外域、`http:``mailto:``javascript:``file:` 等来源不进入主 WebView;冷启动当前 deep link 读取失败、归一成功后的 `window.navigate(...)` 与主窗口恢复 / 聚焦失败必须记录桌面宿主事件日志,不能静默吞错。2026-06-21 调整:deep-link scheme 注册失败和冷启动当前链接读取失败只记录 `desktop host event failed for deep_link.register` / `desktop host event failed for deep_link.current` 固定标签,不把插件错误详情写入可分发桌面壳 stderr。
2026-06-20 追加:移动壳 production bundle smoke 必须读取 Metro 导出的 iOS / Android JS bundle,并确认 bundle 内包含共享 HostBridge 契约中的生产 H5 URL、`native_app` 宿主上下文、`expo_mobile` 壳标识以及 `hostCapabilities` / `hostVersion` / `bridgeVersion` 等启动 query token,且不包含 `http://localhost``http://127.0.0.1``http://[::1]` 这类本机开发 H5 入口。开发态仍允许 `EXPO_PUBLIC_GENARRATIVE_WEB_URL` 指向本机 Vite,但可分发包验收不能让本机 URL 混入生产 bundle,也不能丢掉 H5 进入原生宿主运行态所需的上下文 token。