Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

fix(desktop): capture official boot failure page and pending-service plugin refs

hairyf42a30677ffb2
diff --git a/src-tauri/src/desktop/plugin_boot.js.inc b/src-tauri/src/desktop/plugin_boot.js.inc
index 80c16c4b..fc6e5c30 100644
--- a/src-tauri/src/desktop/plugin_boot.js.inc
+++ b/src-tauri/src/desktop/plugin_boot.js.inc
@@ -55,11 +55,28 @@
return root.querySelector('main, nav, [role="main"], button, input, textarea, form, iframe, [contenteditable="true"], [data-dsh-app-shell]') !== null
}
- function send(type) {
+ // 官方 boot 失败页:HARNESS wordmark + “Failed to load plugins” 标题 + 错误明细。
+ // 失败页与 splash 同构(#root 下单一 [data-dsh-boot] 根节点),但移除了 Loading
+ // plugins 提示且不含应用特征元素——isOfficialSplash/isApplicationShell 均判否,
+ // 若不加此分支会走 disarmSplash 静默路径,宿主错误界面永不出现。
+ function bootFailureText() {
+ var root = rootNode()
+ if (!root || root.childElementCount !== 1) return null
+ var boot = root.querySelector('[data-dsh-boot]')
+ if (!boot || boot.parentElement !== root) return null
+ if (!hasExactText(boot, 'Failed to load plugins')) return null
+ var text = normalizedText(boot)
+ var at = text.indexOf('Failed to load plugins')
+ // 去掉 HARNESS wordmark 前缀,只上报错误段落
+ return at >= 0 ? text.slice(at) : text
+ }
+
+ function send(type, detail) {
try {
window.parent.postMessage({
source: 'dsh-plugin-boot-bridge',
type: type,
+ detail: detail,
}, '*')
}
catch (_) {}
@@ -84,6 +101,14 @@
function evaluate() {
if (stopped) return
+ var failure = bootFailureText()
+ if (failure !== null) {
+ // 失败页已渲染:立即上报错误文本并停止观察(与 ready/stalled 同一桥通道,
+ // 宿主据此展示壳层错误界面,不再等 stalled 超时兜底)。
+ send('dsh://plugin-boot:failed', failure)
+ stop()
+ return
+ }
if (isApplicationShell()) {
if (sawSplash) send('dsh://plugin-boot:ready')
stop()
diff --git a/src-tauri/src/desktop/plugin_boot.rs b/src-tauri/src/desktop/plugin_boot.rs
index db436348..6889d2cf 100644
--- a/src-tauri/src/desktop/plugin_boot.rs
+++ b/src-tauri/src/desktop/plugin_boot.rs
@@ -21,6 +21,9 @@ mod tests {
assert!(PLUGIN_BOOT_RELOAD_JS.contains("pagehide"));
assert!(PLUGIN_BOOT_RELOAD_JS.contains("dsh://plugin-boot:stalled"));
assert!(PLUGIN_BOOT_RELOAD_JS.contains("dsh://plugin-boot:ready"));
+ assert!(PLUGIN_BOOT_RELOAD_JS.contains("dsh://plugin-boot:failed"));
+ assert!(PLUGIN_BOOT_RELOAD_JS.contains("bootFailureText"));
+ assert!(PLUGIN_BOOT_RELOAD_JS.contains("Failed to load plugins"));
assert!(!PLUGIN_BOOT_RELOAD_JS.contains("body.innerText"));
assert!(!PLUGIN_BOOT_RELOAD_JS.contains("location.reload"));
}
diff --git a/src-tauri/src/service/plugin/recovery/extract.rs b/src-tauri/src/service/plugin/recovery/extract.rs
index 33a6fdb3..91299def 100644
--- a/src-tauri/src/service/plugin/recovery/extract.rs
+++ b/src-tauri/src/service/plugin/recovery/extract.rs
@@ -17,6 +17,11 @@ static PLUGIN_REF_PATTERNS: LazyLock<Vec<Regex>> = LazyLock::new(|| {
r#"profile bundle\s+["']?([^"'\n]+)["']?\s+declares no dsh\.bundle"#,
// plugin(s) failed to load: <pkg>
r#"plugins? failed to load:\s*([A-Za-z0-9@/_.\-]+)"#,
+ // 启动卡在等待服务:<pkg>: pending (waiting for service: <svc>)
+ // (对齐 dsh-desktop harness-runtime.ts 的 extractPluginReferences pending 行;
+ // 形如 `dsh-tauri-rightclick: pending (waiting for service: remote.session)`,
+ // 此前因含冒号括号不被 is_package_name 接受而漏检)
+ r#"([A-Za-z0-9@/_.\-]+):\s*pending\s*\(waiting for service:[^)]*\)"#,
]
.iter()
.map(|p| Regex::new(p).expect("static plugin ref pattern"))
@@ -170,6 +175,30 @@ foo bar
assert!(!refs.iter().any(|r| r.contains("unknown")));
}
+ #[test]
+ fn extract_refs_from_pending_service_line() {
+ // 用户报告的真实失败行:含冒号括号,旧逻辑 is_package_name 无法接受
+ let log = "Failed to load plugins\nweb boot: 1 entry did not activate\ndsh-tauri-rightclick: pending (waiting for service: remote.session)\n";
+ let refs = extract_plugin_refs(log);
+ assert_eq!(refs, vec!["dsh-tauri-rightclick"]);
+ }
+
+ #[test]
+ fn extract_refs_from_pending_service_line_with_scope() {
+ let log = "@scope/dsh-plugin-x: pending (waiting for service: uiRenderer)\n";
+ let refs = extract_plugin_refs(log);
+ assert_eq!(refs, vec!["@scope/dsh-plugin-x"]);
+ }
+
+ #[test]
+ fn extract_refs_rejects_malformed_pending_line() {
+ // 缺 waiting for service 结构 → 不命中(防普通文本误报)
+ let log = "dsh-tauri-rightclick: pending (waiting for nothing)\n";
+ assert!(extract_plugin_refs(log).is_empty());
+ let log2 = "some package: pending without parentheses\n";
+ assert!(extract_plugin_refs(log2).is_empty());
+ }
+
#[test]
fn extract_duplicate_and_slot() {
let route_log = r#"duplicate prefix route "/sidebar/api""#;
diff --git a/src/hooks/use-iframe-shim.ts b/src/hooks/use-iframe-shim.ts
index 1da6bdc4..5baee456 100644
--- a/src/hooks/use-iframe-shim.ts
+++ b/src/hooks/use-iframe-shim.ts
@@ -43,7 +43,9 @@ interface ClipboardImageRequest {
interface PluginBootMessage {
source?: 'dsh-plugin-boot-bridge'
- type?: 'dsh://plugin-boot:stalled' | 'dsh://plugin-boot:ready'
+ type?: 'dsh://plugin-boot:stalled' | 'dsh://plugin-boot:ready' | 'dsh://plugin-boot:failed'
+ /** failed 消息携带官方失败页文本(如 web boot: 1 entry did not activate) */
+ detail?: string
}
export function useIframeShim(iframeRef: RefObject<HTMLIFrameElement | null>) {
@@ -161,6 +163,10 @@ export function useIframeShim(iframeRef: RefObject<HTMLIFrameElement | null>) {
}
if (data.type === 'dsh://plugin-boot:stalled') {
void store.harness.recoverIframeBoot()
+ return
+ }
+ if (data.type === 'dsh://plugin-boot:failed') {
+ void store.harness.handleIframeBootFailure(data.detail)
}
}
diff --git a/src/store/modules/harness/store.ts b/src/store/modules/harness/store.ts
index e6cd9393..faa79ea4 100644
--- a/src/store/modules/harness/store.ts
+++ b/src/store/modules/harness/store.ts
@@ -465,6 +465,32 @@ export const harness = defineStore({
this.fail(error.message, undefined, undefined, undefined, !result.notOwned)
},
+ /**
+ * iframe 内官方 boot 失败页上报(dsh://plugin-boot:failed):
+ * 立即把壳层切到错误界面并展示失败页文本(如 `web boot: 1 entry did not
+ * activate`),同时尝试从日志定位问题插件弹出修复界面。
+ */
+ async handleIframeBootFailure(detail?: string) {
+ const message = detail && detail.includes('Failed to load plugins')
+ ? detail
+ : i18next.t('errors.client_boot_failed')
+ const error = await attachStartupDiagnostics(new Error(message))
+ // 失败页文本是最直接的证据,优先作为日志行参与插件定位(pending 行正则
+ // 可命中 `dsh-tauri-rightclick: pending (waiting for service: remote.session)`)
+ const lines = [
+ ...(detail ? detail.split(/\n/) : []),
+ ...(error.logLines ?? error.logs ?? []),
+ ]
+ await this.reviewStartupRecovery(lines)
+ this.fail(
+ error.message,
+ error.logs,
+ error.pluginConflictHint,
+ error.inotifyLimitHint,
+ this.serviceRunning,
+ )
+ },
+
/** 安装进度流:只前进不后退,供首次安装/手动更新共用 */
async listenInstallProgress(): Promise<UnlistenFn> {
return listen<InstallProgress>('install-progress', (e) => {
@@ -882,6 +908,24 @@ export const harness = defineStore({
})
},
+ /** 进入安全模式:切到 safe 档案(仅核心 bundles、无用户插件)并重启服务。
+ * 启动失败的插件(如 pending waiting for service)被隔离,应用先恢复可用;
+ * 用户在档案列表切回原档案即退出安全模式。 */
+ async enterSafeMode() {
+ if (this.busyAction)
+ return
+ try {
+ await invoke('enter_safe_mode')
+ }
+ catch (err) {
+ console.error('[Harness] enter safe mode failed:', err)
+ const error = await attachStartupDiagnostics(err)
+ this.fail(error.message, error.logs, error.pluginConflictHint, error.inotifyLimitHint)
+ return
+ }
+ await this.restart()
+ },
+
/** 停止服务并回到停止态界面 */
async shutdown() {
if (this.busyAction)