From ce310918bd658120f96a43f23bf731bbb0724e24 Mon Sep 17 00:00:00 2001 From: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com> Date: Thu, 15 Oct 2026 18:03:40 +0800 Subject: [PATCH] fix(dsh): bind scoped views to session UI lifecycle Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com> --- .../ci-c21a1753e-result.json | 145 +++++++ .../operation-details-host-result.json | 394 ++++++++++++++++++ .../session-adapter-disposal-result.json | 24 ++ .../add-dsh-native-plugin/acceptance.md | 3 +- .../dsh-integration-design.md | 2 + .../changes/add-dsh-native-plugin/tasks.md | 2 +- plugins/dsh/bun.lock | 3 + plugins/dsh/package.json | 4 +- plugins/dsh/src/client/index.tsx | 3 +- plugins/dsh/src/host/runtime-compatibility.ts | 1 + .../dsh/test/client-entry-lifecycle.test.ts | 3 +- .../dsh/test/client-slot-lifecycle.test.ts | 46 ++ .../test/integration/dual-upgrade-restart.py | 24 +- .../integration/upgrade-recovery-probe.mjs | 66 ++- 14 files changed, 703 insertions(+), 17 deletions(-) create mode 100644 docs/research/dsh-native-plugin-2026-10-12/ci-c21a1753e-result.json create mode 100644 docs/research/dsh-native-plugin-2026-10-12/operation-details-host-result.json create mode 100644 docs/research/dsh-native-plugin-2026-10-12/session-adapter-disposal-result.json diff --git a/docs/research/dsh-native-plugin-2026-10-12/ci-c21a1753e-result.json b/docs/research/dsh-native-plugin-2026-10-12/ci-c21a1753e-result.json new file mode 100644 index 000000000..a5ddc9956 --- /dev/null +++ b/docs/research/dsh-native-plugin-2026-10-12/ci-c21a1753e-result.json @@ -0,0 +1,145 @@ +{ + "commit": "c21a1753ebd6cc251f7a01efd43473a00248d270", + "workflow": "https://github.com/iflytek/skillhub/actions/runs/38711569258", + "conclusion": "success", + "reports": [ + { + "artifact": "skillhub-dsh-host-smoke-macos-latest-node-24", + "summary": { + "passed": true, + "platform": "darwin", + "node": "24.21.0", + "dsh": "0.2.0-rc.2", + "pnpm": "10.33.0", + "artifactSha256": "8f1ce4a5421282f2848698b212730daab8e66f1f216f3310bca784301d8513d0", + "modelCalled": false, + "stage": "complete", + "probes": [ + { + "name": "runtime-baseline", + "passed": true + }, + { + "name": "plugin-lifecycle", + "passed": true + } + ] + } + }, + { + "artifact": "skillhub-dsh-host-smoke-macos-latest-node-24.2.0", + "summary": { + "passed": true, + "platform": "darwin", + "node": "24.2.0", + "dsh": "0.2.0-rc.2", + "pnpm": "10.33.0", + "artifactSha256": "8f1ce4a5421282f2848698b212730daab8e66f1f216f3310bca784301d8513d0", + "modelCalled": false, + "stage": "complete", + "probes": [ + { + "name": "runtime-baseline", + "passed": true + }, + { + "name": "plugin-lifecycle", + "passed": true + } + ] + } + }, + { + "artifact": "skillhub-dsh-host-smoke-ubuntu-latest-node-24", + "summary": { + "passed": true, + "platform": "linux", + "node": "24.21.0", + "dsh": "0.2.0-rc.2", + "pnpm": "10.33.0", + "artifactSha256": "8f1ce4a5421282f2848698b212730daab8e66f1f216f3310bca784301d8513d0", + "modelCalled": false, + "stage": "complete", + "probes": [ + { + "name": "runtime-baseline", + "passed": true + }, + { + "name": "plugin-lifecycle", + "passed": true + } + ] + } + }, + { + "artifact": "skillhub-dsh-host-smoke-ubuntu-latest-node-24.2.0", + "summary": { + "passed": true, + "platform": "linux", + "node": "24.2.0", + "dsh": "0.2.0-rc.2", + "pnpm": "10.33.0", + "artifactSha256": "8f1ce4a5421282f2848698b212730daab8e66f1f216f3310bca784301d8513d0", + "modelCalled": false, + "stage": "complete", + "probes": [ + { + "name": "runtime-baseline", + "passed": true + }, + { + "name": "plugin-lifecycle", + "passed": true + } + ] + } + }, + { + "artifact": "skillhub-dsh-host-smoke-windows-latest-node-24", + "summary": { + "passed": true, + "platform": "win32", + "node": "24.21.0", + "dsh": "0.2.0-rc.2", + "pnpm": "10.33.0", + "artifactSha256": "c939d54323234969ba3be5aedce1e9c0bcab9dbfbf1c475ce245dfe65071646d", + "modelCalled": false, + "stage": "complete", + "probes": [ + { + "name": "runtime-baseline", + "passed": true + }, + { + "name": "plugin-lifecycle", + "passed": true + } + ] + } + }, + { + "artifact": "skillhub-dsh-host-smoke-windows-latest-node-24.2.0", + "summary": { + "passed": true, + "platform": "win32", + "node": "24.2.0", + "dsh": "0.2.0-rc.2", + "pnpm": "10.33.0", + "artifactSha256": "c939d54323234969ba3be5aedce1e9c0bcab9dbfbf1c475ce245dfe65071646d", + "modelCalled": false, + "stage": "complete", + "probes": [ + { + "name": "runtime-baseline", + "passed": true + }, + { + "name": "plugin-lifecycle", + "passed": true + } + ] + } + } + ] +} diff --git a/docs/research/dsh-native-plugin-2026-10-12/operation-details-host-result.json b/docs/research/dsh-native-plugin-2026-10-12/operation-details-host-result.json new file mode 100644 index 000000000..15a9878f8 --- /dev/null +++ b/docs/research/dsh-native-plugin-2026-10-12/operation-details-host-result.json @@ -0,0 +1,394 @@ +{ + "artifact": { + "commit": "760368c70", + "rebuiltFromCurrentSource": true, + "sha256": "e4f5a3094049c4fa6588b7523c99e775506ed91c5997da93bdf386b525ac9b7c", + "installedMatches": 6, + "dsh": "0.2.0-rc.2", + "node": "24.2.0", + "modelCalled": false + }, + "successAfterHostRestart": { + "passed": true, + "node": "24.2.0", + "forcedProcessExit": false, + "oldHostExited": true, + "newHostStarted": true, + "distinctProcesses": true, + "samePort": true, + "targetCount": 2, + "mixedStateBeforeRestart": false, + "allTargetHashesRestored": false, + "inventoryUnchanged": false, + "operationRecovery": "not-needed", + "completedUpgrade": true, + "browser": { + "passed": true, + "operationId": "10787f4c-5cc5-4974-ab15-bf57f2ae11f1", + "expectedTargets": 2, + "submissions": 1, + "recoveries": 0, + "hostRestartRequested": true, + "originalOperationDetailsVerified": true, + "verifiedDetails": [ + { + "operationId": "10787f4c-5cc5-4974-ab15-bf57f2ae11f1", + "outcome": "upgraded", + "beforeVersion": "1.2.0", + "afterVersion": "1.3.0", + "targets": [ + { + "label": "目标 1(确认计划顺序)", + "outcome": "upgraded" + }, + { + "label": "目标 2(确认计划顺序)", + "outcome": "upgraded" + } + ], + "warnings": [] + } + ], + "errors": [] + } + }, + "recoveryAfterHostRestart": { + "passed": true, + "node": "24.2.0", + "forcedProcessExit": false, + "oldHostExited": true, + "newHostStarted": true, + "distinctProcesses": true, + "samePort": true, + "targetCount": 2, + "mixedStateBeforeRestart": true, + "allTargetHashesRestored": true, + "inventoryUnchanged": true, + "operationRecovery": "restored", + "completedUpgrade": false, + "browser": { + "passed": true, + "operationId": "2c6f209b-7c2c-4b12-ba46-cb85a6c2e9d1", + "submissions": 1, + "recoveries": 1, + "expectedTargets": 2, + "historyAfterReload": true, + "hostRestartRequested": true, + "forcedProcessExit": false, + "leaseRefusalAndExplicitRetryVerified": false, + "originalOperationDetailsVerified": true, + "verifiedDetails": [ + { + "operationId": "2c6f209b-7c2c-4b12-ba46-cb85a6c2e9d1", + "outcome": "unknown", + "beforeVersion": "1.2.0", + "afterVersion": null, + "targets": [ + { + "label": "目标 1(确认计划顺序)", + "outcome": "unknown" + }, + { + "label": "目标 2(确认计划顺序)", + "outcome": "unknown" + } + ], + "warnings": [] + }, + { + "operationId": "2c6f209b-7c2c-4b12-ba46-cb85a6c2e9d1", + "outcome": "restored", + "beforeVersion": "1.2.0", + "afterVersion": null, + "targets": [ + { + "label": "目标 1(确认计划顺序)", + "outcome": "restored" + }, + { + "label": "目标 2(确认计划顺序)", + "outcome": "restored" + } + ], + "warnings": [] + } + ], + "recoveryResponseLossVerified": true, + "oldVersionVisible": true, + "closeFocusVerified": true, + "errors": [] + } + }, + "priorRecoveryRun": { + "passed": false, + "errors": [ + "scope 'session-maybe' rendered without an installed adapter" + ] + }, + "remaining": "Missing session adapter during full Host disconnection remains unresolved. The uiSession dependency candidate still reproduces it; the no-plugin full Host control has not reached a disconnect cycle.", + "uiSessionDependencyCandidate": { + "artifact": { + "sourceIdentity": { + "commit": "c21a1753ebd6cc251f7a01efd43473a00248d270", + "uncommittedProductionDiffSha256": "9ed17a57ae08315ab01d29d2e47811f54f2bed1716c22a810c6ec23b601b88ed", + "productionSourceSha256": { + "plugins/dsh/package.json": "f0185715ee22e6f3e3a6e267f88fc35d2c7816377260f623983b1cfcbca176c3", + "plugins/dsh/bun.lock": "f2b41743243375ad62ccec69b68793ceb9aabe06ca89176c7d5d8f446bd497ab", + "plugins/dsh/src/client/index.tsx": "597c15b0aab1ca0583af8805caa803205cb1391471677b862ac0e569a5c8e09b", + "plugins/dsh/src/host/runtime-compatibility.ts": "2165d9d82a31f42154b8acc3413f3231473bb1acad4772bb3f50f9d9a78dfa5e" + } + }, + "rebuiltFromCurrentSource": true, + "sha256": "8a27c233ae84c2c3bc8444331853cdaad8d64336626d212d1ee8eee4bff07f91", + "installedMatches": 6, + "dsh": "0.2.0-rc.2", + "node": "24.2.0", + "modelCalled": false + }, + "runs": { + "recoveryImmediateFocus": { + "passed": false, + "stage": "close-result", + "operationId": "afed093f-764d-419b-b428-accf01405d4c", + "verifiedDetails": [ + { + "operationId": "afed093f-764d-419b-b428-accf01405d4c", + "outcome": "unknown", + "beforeVersion": "1.2.0", + "afterVersion": null, + "targets": [ + { + "label": "目标 1(确认计划顺序)", + "outcome": "unknown" + }, + { + "label": "目标 2(确认计划顺序)", + "outcome": "unknown" + } + ], + "warnings": [] + }, + { + "operationId": "afed093f-764d-419b-b428-accf01405d4c", + "outcome": "restored", + "beforeVersion": "1.2.0", + "afterVersion": null, + "targets": [ + { + "label": "目标 1(确认计划顺序)", + "outcome": "restored" + }, + { + "label": "目标 2(确认计划顺序)", + "outcome": "restored" + } + ], + "warnings": [] + } + ], + "errors": [], + "failureCode": "CLOSE_RESULT_FOCUS_NOT_RESTORED_AT_IMMEDIATE_CHECK" + }, + "successAfterHostRestart": { + "passed": false, + "stage": "restarted-history", + "operationId": "7f004432-bf35-4ccb-8eb0-d6ae84f1918f", + "verifiedDetails": [ + { + "operationId": "7f004432-bf35-4ccb-8eb0-d6ae84f1918f", + "outcome": "upgraded", + "beforeVersion": "1.2.0", + "afterVersion": "1.3.0", + "targets": [ + { + "label": "目标 1(确认计划顺序)", + "outcome": "upgraded" + }, + { + "label": "目标 2(确认计划顺序)", + "outcome": "upgraded" + } + ], + "warnings": [] + } + ], + "errors": [ + { + "stage": "waiting-host-restart", + "message": "scope 'session-maybe' rendered without an installed adapter" + } + ], + "failureCode": "SESSION_SCOPE_ADAPTER_MISSING_DURING_HOST_DISCONNECTION" + }, + "recoveryBoundedFocus": { + "passed": true, + "node": "24.2.0", + "forcedProcessExit": false, + "oldHostExited": true, + "newHostStarted": true, + "distinctProcesses": true, + "samePort": true, + "targetCount": 2, + "mixedStateBeforeRestart": true, + "allTargetHashesRestored": true, + "inventoryUnchanged": true, + "operationRecovery": "restored", + "completedUpgrade": false, + "browser": { + "passed": true, + "operationId": "1c9bef5a-72ae-4edb-b319-58d6cda07add", + "submissions": 1, + "recoveries": 1, + "expectedTargets": 2, + "historyAfterReload": true, + "hostRestartRequested": true, + "forcedProcessExit": false, + "leaseRefusalAndExplicitRetryVerified": false, + "originalOperationDetailsVerified": true, + "verifiedDetails": [ + { + "operationId": "1c9bef5a-72ae-4edb-b319-58d6cda07add", + "outcome": "unknown", + "beforeVersion": "1.2.0", + "afterVersion": null, + "targets": [ + { + "label": "目标 1(确认计划顺序)", + "outcome": "unknown" + }, + { + "label": "目标 2(确认计划顺序)", + "outcome": "unknown" + } + ], + "warnings": [] + }, + { + "operationId": "1c9bef5a-72ae-4edb-b319-58d6cda07add", + "outcome": "restored", + "beforeVersion": "1.2.0", + "afterVersion": null, + "targets": [ + { + "label": "目标 1(确认计划顺序)", + "outcome": "restored" + }, + { + "label": "目标 2(确认计划顺序)", + "outcome": "restored" + } + ], + "warnings": [] + } + ], + "recoveryResponseLossVerified": true, + "oldVersionVisible": true, + "closeFocusVerified": true, + "errors": [] + }, + "focusObservationDeadlineMs": 3000 + } + }, + "overallPassed": false, + "interpretation": "Result projection and recovery have passing evidence. A bounded-focus recovery pass does not erase the prior focus failure; the success run still records a missing session adapter during Host disconnection." + }, + "officialHostDisconnectControl": { + "status": "incomplete", + "dsh": "0.2.0-rc.2", + "node": "24.2.0", + "modelCalled": false, + "pluginInstalled": false, + "observerLoaded": false, + "freshProfileDependenciesEmpty": true, + "freshProfileDefaultOverlayUnmodified": true, + "officialClientModuleIdsObservedDuringEarlierPreparation": [ + "@deepseek-ai/dsh-api-gateway", + "@deepseek-ai/dsh-api-job-controller", + "@deepseek-ai/dsh-api-remotes", + "@deepseek-ai/dsh-api-session-controller", + "@deepseek-ai/dsh-api-terminal-controller", + "@deepseek-ai/dsh-api-workspace-controller", + "@deepseek-ai/dsh-api-workspace-files", + "@deepseek-ai/dsh-client-connection", + "@deepseek-ai/dsh-client-file-upload", + "@deepseek-ai/dsh-client-hmr", + "@deepseek-ai/dsh-client-locale", + "@deepseek-ai/dsh-client-modules", + "@deepseek-ai/dsh-client-resources", + "@deepseek-ai/dsh-client-shortcuts", + "@deepseek-ai/dsh-client-ui-agent-preset", + "@deepseek-ai/dsh-client-ui-approval", + "@deepseek-ai/dsh-client-ui-attachment", + "@deepseek-ai/dsh-client-ui-brand-official", + "@deepseek-ai/dsh-client-ui-chat", + "@deepseek-ai/dsh-client-ui-commands", + "@deepseek-ai/dsh-client-ui-conversation", + "@deepseek-ai/dsh-client-ui-cordis", + "@deepseek-ai/dsh-client-ui-deliverables", + "@deepseek-ai/dsh-client-ui-directory-picker-browse", + "@deepseek-ai/dsh-client-ui-goal", + "@deepseek-ai/dsh-client-ui-input-trigger", + "@deepseek-ai/dsh-client-ui-jobs", + "@deepseek-ai/dsh-client-ui-layout", + "@deepseek-ai/dsh-client-ui-message-feedback", + "@deepseek-ai/dsh-client-ui-model-selection", + "@deepseek-ai/dsh-client-ui-open-in-app", + "@deepseek-ai/dsh-client-ui-permission-presets", + "@deepseek-ai/dsh-client-ui-plan", + "@deepseek-ai/dsh-client-ui-plugin-manager", + "@deepseek-ai/dsh-client-ui-reference", + "@deepseek-ai/dsh-client-ui-renderer", + "@deepseek-ai/dsh-client-ui-session", + "@deepseek-ai/dsh-client-ui-settings", + "@deepseek-ai/dsh-client-ui-settings-account", + "@deepseek-ai/dsh-client-ui-settings-agent-loop", + "@deepseek-ai/dsh-client-ui-settings-general", + "@deepseek-ai/dsh-client-ui-settings-models", + "@deepseek-ai/dsh-client-ui-settings-plugin-inventory", + "@deepseek-ai/dsh-client-ui-settings-plugins", + "@deepseek-ai/dsh-client-ui-settings-session-log", + "@deepseek-ai/dsh-client-ui-settings-shell", + "@deepseek-ai/dsh-client-ui-settings-subagent", + "@deepseek-ai/dsh-client-ui-settings-web-search", + "@deepseek-ai/dsh-client-ui-shortcuts", + "@deepseek-ai/dsh-client-ui-sidebar", + "@deepseek-ai/dsh-client-ui-sidebar-documentpreview", + "@deepseek-ai/dsh-client-ui-sidebar-files", + "@deepseek-ai/dsh-client-ui-sidebar-right", + "@deepseek-ai/dsh-client-ui-sidebar-terminal", + "@deepseek-ai/dsh-client-ui-skill", + "@deepseek-ai/dsh-client-ui-subagent", + "@deepseek-ai/dsh-client-ui-theme", + "@deepseek-ai/dsh-client-ui-tool", + "@deepseek-ai/dsh-client-ui-trajectory", + "@deepseek-ai/dsh-client-ui-user-questions", + "@deepseek-ai/dsh-client-ui-workflow-run", + "@deepseek-ai/dsh-client-ui-workspace", + "@deepseek-ai/dsh-cordis-client-runner", + "@deepseek-ai/dsh-session-log-export", + "@deepseek-ai/dsh-typert-registry" + ], + "completedDisconnectCycles": 0, + "emptySessionCreationVerified": false, + "preparationFailures": [ + "DEFAULT_WORKSPACE_CREATION_UNAVAILABLE", + "CLIENT_SESSION_CONTEXT_NOT_READY", + "HOST_READY_TIMEOUT" + ], + "hostReadyTimeoutMs": 60000, + "startupTimeoutsObserved": 2, + "startupLogBytesAtTimeout": [ + 0, + 0 + ], + "retrySkipped": true, + "skipReason": "INSUFFICIENT_LOCAL_MEMORY", + "resourceObservation": { + "availableMemoryMiB": 838, + "swapTotalMiB": 8192, + "swapUsedMiB": 8192 + }, + "controlScriptSha256": "0030d8d2b707cc894528094131b08fa54b8976efff87bece1ffd5ec960a05640", + "interpretation": "No full official Host disconnect attribution is established. Resource pressure coincided with startup timeouts but causation was not proven. This turn did not retry because memory had not recovered." + } +} diff --git a/docs/research/dsh-native-plugin-2026-10-12/session-adapter-disposal-result.json b/docs/research/dsh-native-plugin-2026-10-12/session-adapter-disposal-result.json new file mode 100644 index 000000000..e5ecb5712 --- /dev/null +++ b/docs/research/dsh-native-plugin-2026-10-12/session-adapter-disposal-result.json @@ -0,0 +1,24 @@ +{ + "scope": "official-renderer-component-disposal", + "dsh": "0.2.0-rc.2", + "cordis": "4.0.4", + "react": "18.3.1", + "reactDom": "18.3.1", + "skillhubLoaded": false, + "modelCalled": false, + "rootRenderedBeforeDisposal": true, + "rootEmptyAfterDisposal": true, + "pageError": "scope 'session-maybe' rendered without an installed adapter", + "pageErrorCount": 3, + "scopeRevisionTrace": [ + { + "adapter": false, + "uiSession": false, + "consumerActive": true + } + ], + "consumerActiveAfterDisposal": false, + "conclusion": "The official root requires its session adapter even without SkillHub. Adapter disposal can be observed before dependent consumer cleanup completes.", + "limitation": "This component reproduction does not establish the adapter-disposal trigger during a real Host disconnect or restart. The full no-plugin Host restart comparison remains incomplete.", + "pluginFixBoundary": "The explicit uiSession dependency prevents premature SkillHub registration and removes its contributions when the service disappears; it does not protect the official outer root provider." +} diff --git a/openspec/changes/add-dsh-native-plugin/acceptance.md b/openspec/changes/add-dsh-native-plugin/acceptance.md index 2f6bc6aeb..08e1b09ad 100644 --- a/openspec/changes/add-dsh-native-plugin/acceptance.md +++ b/openspec/changes/add-dsh-native-plugin/acceptance.md @@ -138,9 +138,10 @@ A05/A11/A12 已取得模型安装、资源使用、歧义选择及官方停止 | --- | --- | --- | | 5.4 本地平台与远程 Host | Linux/Windows 有实包及生命周期分项报告;最近搜索条目改动已在两平台回归。独立远程 Host 未验证 | 提供授权测试 Host、连接配置位置及可写测试目录,核验远程用户/项目落点与浏览器机器不写技能文件;汇总最终平台报告 | | A13 当前服务端与 SaaS | 后端测试、OpenAPI 及真实开源测试实例有证据;不等同于当前工作树部署,也不等同于 SaaS | 在指定测试部署中验证当前后端契约;SaaS 按同步清单另行执行,未完成不声明兼容 | -| 10.4 远端 CI | Draft PR [#956](https://github.com/iflytek/skillhub/pull/956) 的 [ad54f1fa8 第二轮矩阵](../../../docs/research/dsh-native-plugin-2026-10-12/ci-ad54f1fa8-attempt2-result.json)六项通过,包含真实 Host 基线与生命周期;第一轮 Windows Node 24.2 下载超时报告保留。新增操作结果详情尚需最新提交的矩阵验证 | 在最终修复提交上完成工作流并保留产物证据;macOS 产品验收仍按用户决定后置 | +| 10.4 远端 CI | Draft PR [#956](https://github.com/iflytek/skillhub/pull/956) 的 [c21a1753e 矩阵](../../../docs/research/dsh-native-plugin-2026-10-12/ci-c21a1753e-result.json)六项通过,包含操作结果详情代码的真实 Host 基线与生命周期;此前 Windows Node 24.2 下载超时报告保留。本轮 uiSession 依赖修复仍需新提交矩阵验证 | 在最终修复提交上完成工作流并保留产物证据;macOS 产品验收仍按用户决定后置 | | 10.1/10.5 正式兼容基线 | RC.2 研发组合、门禁、混装拒绝和开发产物回退有证据;正式支持未声明 | 根据最终平台、宿主及回退报告确认唯一支持组合,不通过改写版本字段绕过检查 | | 9.5 候选与正式发布包 | 当前开发候选清单、身份检查和实包回归通过;没有已发布包 | 确认正式版本与发布权限,关联最终候选;获准发布后下载实际包并完成干净安装、功能与完整性验证 | +| 7.5 操作结果及重连 | [真实 Host 记录](../../../docs/research/dsh-native-plugin-2026-10-12/operation-details-host-result.json)保留双目标成功与恢复证据;uiSession 修复后恢复链路通过,成功升级重启期间仍有适配器缺失错误。[官方组件复现](../../../docs/research/dsh-native-plugin-2026-10-12/session-adapter-disposal-result.json)不能替代完整 Host 归因;无插件 Host 对照未完成,本轮因资源不足未重试 | 定位断线窗口问题,完成最终候选的成功及恢复重启回归;补齐 UI 新版本文本显式断言,不以 Remote 字段断言代替界面验收 | | 7.4 总体验收 | A01–A16 已有分组追踪;上述缺口仍存在 | 所有必需门禁都有对应环境证据后再关闭,不能以文档齐全或单平台通过代替 | 本表是现有任务的执行状态,不增加新产品范围,也不豁免原验收条件。开发版本仍为 `private: true`。已获准提交、推送并创建 Draft PR;部署、创建 tag 和发布尚未执行。已通过矩阵仅覆盖对应提交;新增实现仍需最终提交回归,未通过的门禁不标记完成。 diff --git a/openspec/changes/add-dsh-native-plugin/dsh-integration-design.md b/openspec/changes/add-dsh-native-plugin/dsh-integration-design.md index 6159922fb..1d4751230 100644 --- a/openspec/changes/add-dsh-native-plugin/dsh-integration-design.md +++ b/openspec/changes/add-dsh-native-plugin/dsh-integration-design.md @@ -113,6 +113,8 @@ stateDiagram-v2 apply 注册服务、Remote、UI、配置监听和定时查询时,要将 disposer 归属到 fiber。禁用后不再接受新写操作;当前事务的文件提交不能随组件卸载中断。正常退出尝试完成/恢复并落盘,进程被强制终止则由下次启动恢复核验。 +会话页面和工具视图贡献同时依赖 `remote.skillhub`、`slots`、会话 API 的 `sessions` 及会话 UI 的 `uiSession`。`sessions` 可用不表示 renderer 的 session 适配器已安装;声明 `session-maybe` 的贡献必须声明 `uiSession` 依赖。此依赖是插件生命周期前提,不保证宿主在适配器卸载窗口内的渲染原子性;断线与重连仍须独立验收。该服务移除时释放相关面板、工具视图与查询资源,恢复后重新注册且不重复贡献。插件 Client manifest 与兼容基线同步声明 `@deepseek-ai/dsh-client-ui-session`,版本沿用首版精确 DSH 基线。 + 插件不新增 WebServer 路由,跨端调用统一通过 Remote 服务。 服务名按原字符串注册;`super(ctx,'my-service')` 不会自动变为 `ctx.myService`。本插件应使用明确 service key 和 Context 类型声明。 diff --git a/openspec/changes/add-dsh-native-plugin/tasks.md b/openspec/changes/add-dsh-native-plugin/tasks.md index 04fd3dc34..2271244f8 100644 --- a/openspec/changes/add-dsh-native-plugin/tasks.md +++ b/openspec/changes/add-dsh-native-plugin/tasks.md @@ -66,7 +66,7 @@ - [x] 7.2 实现 openConversationDetail/acknowledgeConversationDetail 与原搜索引用到已查看固定版本的关联;多版本歧义阻断,不静默解析 latest。(实现及定向测试已补齐早期验证记录中的缺口,见“交付缺口核对”。) - [x] 7.3 安装工具仅返回 accepted;结果卡片从共享 OperationStore/getOperation 展示终态,历史来源、主机、时间来自原快照。(接受成功仅为 accepted;拒绝为 not-confirmed,见“交付缺口核对”。) - [ ] 7.4 按 acceptance.md 逐组留证;阶段顺序以 implementation-design.md 第 9 节为准,日志恢复不后置到写入口上线以后。 -- [ ] 7.5 补齐 lifecycle-design.md §9 与 interface-design.md §5.2 的操作结果展示:核验并提供受影响目标、旧新版本及安全告警信息,覆盖双目标升级与重启后的历史查询。已补 resultDetails 原日志投影、跨目标旧版本保护和四个入口的展示;核心定向回归与真实组件浏览器检查通过,仍待双目标真实 Host 升级和重启历史查询验收。不得透传事务内部路径或原始异常,也不得将当前清单状态冒充原操作结果。 +- [ ] 7.5 补齐 lifecycle-design.md §9 与 interface-design.md §5.2 的操作结果展示:核验并提供受影响目标、旧新版本及安全告警信息,覆盖双目标升级与重启后的历史查询。已补 resultDetails 原日志投影、跨目标旧版本保护和四个入口的展示;核心定向回归、真实组件浏览器、双目标真实 Host 升级成功及中断恢复后的历史查询已取得证据(operation-details-host-result.json)。已补齐 uiSession 依赖并通过 201 项插件测试;修复后完整恢复链路通过,但成功升级的 Host 重启断线窗口仍出现 session-maybe 适配器缺失。官方组件卸载可独立复现同类错误,完整无插件 Host 对照尚未完成,不能据此归因。待断线问题定位与回归后关闭。不得透传事务内部路径或原始异常,也不得将当前清单状态冒充原操作结果。 ## 8. 原生机制落地检查 diff --git a/plugins/dsh/bun.lock b/plugins/dsh/bun.lock index 3c08d4f2d..20839df35 100644 --- a/plugins/dsh/bun.lock +++ b/plugins/dsh/bun.lock @@ -21,6 +21,7 @@ "@deepseek-ai/dsh-client-ui-layout": "0.2.0-rc.2", "@deepseek-ai/dsh-client-ui-plugin-manager": "0.2.0-rc.2", "@deepseek-ai/dsh-client-ui-renderer": "0.2.0-rc.2", + "@deepseek-ai/dsh-client-ui-session": "0.2.0-rc.2", "@deepseek-ai/dsh-client-ui-settings": "0.2.0-rc.2", "@deepseek-ai/dsh-client-ui-sidebar": "0.2.0-rc.2", "@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.2", @@ -91,6 +92,8 @@ "@deepseek-ai/dsh-client-ui-renderer": ["@deepseek-ai/dsh-client-ui-renderer@0.2.0-rc.2", "https://registry.npmmirror.com/@deepseek-ai/dsh-client-ui-renderer/-/dsh-client-ui-renderer-0.2.0-rc.2.tgz", { "peerDependencies": { "@deepseek-ai/cordis": "~4.0.4" } }, "sha512-vQ/LH4A53K1J/UeF5fQs1Dj8km5cnVos7vO0rmj+pJROhE6Vs7pAAKGz5P2e02t2/2to6+iMDu2+SSITrcYWTQ=="], + "@deepseek-ai/dsh-client-ui-session": ["@deepseek-ai/dsh-client-ui-session@0.2.0-rc.2", "https://registry.npmmirror.com/@deepseek-ai/dsh-client-ui-session/-/dsh-client-ui-session-0.2.0-rc.2.tgz", { "peerDependencies": { "@deepseek-ai/cordis": "~4.0.4" } }, "sha512-QbavrwYkWqdmR4Be7Bv2tNqf+Gh1LV6+rlDkdukMWvdJFSeAmX9Fsctwn8yqgnPRGEHZUfZIjef8zKXIWexuYQ=="], + "@deepseek-ai/dsh-client-ui-settings": ["@deepseek-ai/dsh-client-ui-settings@0.2.0-rc.2", "https://registry.npmmirror.com/@deepseek-ai/dsh-client-ui-settings/-/dsh-client-ui-settings-0.2.0-rc.2.tgz", { "dependencies": { "@deepseek-ai/schemastery": "~3.18.4" }, "peerDependencies": { "@deepseek-ai/cordis": "~4.0.4" } }, "sha512-Kyho8FvRGYb7Ok1t7T429d4Dj/XF8+tE/+MX6T1s41RkXCe7v0sP89i4DUMo6OeUxyE+/uGoAVa5QZXY4O/y+g=="], "@deepseek-ai/dsh-client-ui-sidebar": ["@deepseek-ai/dsh-client-ui-sidebar@0.2.0-rc.2", "https://registry.npmmirror.com/@deepseek-ai/dsh-client-ui-sidebar/-/dsh-client-ui-sidebar-0.2.0-rc.2.tgz", { "peerDependencies": { "@deepseek-ai/cordis": "~4.0.4" } }, "sha512-qAvv42Jt36dVVHNuuZFUbR5kMofhPmGeFafBcOU1mlmUJitZFf31MFFF34UER3JSnByxwAeHsMx9JMq4k7nA4w=="], diff --git a/plugins/dsh/package.json b/plugins/dsh/package.json index a9047e2eb..225084229 100644 --- a/plugins/dsh/package.json +++ b/plugins/dsh/package.json @@ -61,7 +61,8 @@ "@deepseek-ai/dsh-client-ui-settings", "@deepseek-ai/dsh-client-ui-plugin-manager", "@deepseek-ai/dsh-client-ui-tool", - "@deepseek-ai/dsh-api-session-controller" + "@deepseek-ai/dsh-api-session-controller", + "@deepseek-ai/dsh-client-ui-session" ], "external": [ "react", @@ -98,6 +99,7 @@ "@deepseek-ai/dsh-client-ui-layout": "0.2.0-rc.2", "@deepseek-ai/dsh-client-ui-plugin-manager": "0.2.0-rc.2", "@deepseek-ai/dsh-client-ui-renderer": "0.2.0-rc.2", + "@deepseek-ai/dsh-client-ui-session": "0.2.0-rc.2", "@deepseek-ai/dsh-client-ui-settings": "0.2.0-rc.2", "@deepseek-ai/dsh-client-ui-sidebar": "0.2.0-rc.2", "@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.2", diff --git a/plugins/dsh/src/client/index.tsx b/plugins/dsh/src/client/index.tsx index ac17da8f5..56915bae5 100644 --- a/plugins/dsh/src/client/index.tsx +++ b/plugins/dsh/src/client/index.tsx @@ -5,6 +5,7 @@ import type {} from '@deepseek-ai/dsh-api-gateway/client'; import type {} from '@deepseek-ai/dsh-api-session-controller/client'; import type { AgentContext } from '@deepseek-ai/dsh-api-session-controller/client'; import type {} from '@deepseek-ai/dsh-client-ui-renderer/client'; +import type {} from '@deepseek-ai/dsh-client-ui-session/client'; import type {} from '@deepseek-ai/dsh-client-ui-sidebar/client'; import type { MainPanelId } from '@deepseek-ai/dsh-client-ui-layout/client'; import type {} from '@deepseek-ai/dsh-client-ui-settings/client'; @@ -43,7 +44,7 @@ export async function apply(ctx: Context): Promise<() => Promise> { name: 'plugins.bundle.config', key: '@astron-team/skillhub-dsh', }, () => )); }); - const panel = ctx.inject(['remote.skillhub', 'slots', 'sessions'], (ctx) => { + const panel = ctx.inject(['remote.skillhub', 'slots', 'sessions', 'uiSession'], (ctx) => { const client = new QueryClient(); ctx.slots.inject('tool.call.toolview', () => availability.enable('conversation')); const navigation = createCatalogNavigation(); diff --git a/plugins/dsh/src/host/runtime-compatibility.ts b/plugins/dsh/src/host/runtime-compatibility.ts index c23a6b650..4d6d4420d 100644 --- a/plugins/dsh/src/host/runtime-compatibility.ts +++ b/plugins/dsh/src/host/runtime-compatibility.ts @@ -26,6 +26,7 @@ export const clientPackageBaseline = [ '@deepseek-ai/dsh-client-ui-plugin-manager', '@deepseek-ai/dsh-client-ui-tool', '@deepseek-ai/dsh-api-session-controller', + '@deepseek-ai/dsh-client-ui-session', ] as const; interface RuntimeServices { diff --git a/plugins/dsh/test/client-entry-lifecycle.test.ts b/plugins/dsh/test/client-entry-lifecycle.test.ts index edcca4b88..01a4515c4 100644 --- a/plugins/dsh/test/client-entry-lifecycle.test.ts +++ b/plugins/dsh/test/client-entry-lifecycle.test.ts @@ -21,6 +21,7 @@ test('layout loss removes only catalog entries and preserves conversation regist const removeRemote = ctx.provide('remote', remote as never); const removeSkillHub = ctx.provide('remote.skillhub', {} as never); const removeSessions = ctx.provide('sessions', { scope: () => undefined } as never); + const removeUiSession = ctx.provide('uiSession', {} as never); const plugin = ctx.plugin(clientPlugin); const flush = async () => { await new Promise(resolve => setTimeout(resolve, 25)); }; try { @@ -40,6 +41,6 @@ test('layout loss removes only catalog entries and preserves conversation regist await plugin.dispose(); expect(entries.size).toBe(0); } finally { - await plugin.dispose(); await removeSessions(); await removeSkillHub(); await removeRemote(); await slots.dispose(); + await plugin.dispose(); await removeUiSession(); await removeSessions(); await removeSkillHub(); await removeRemote(); await slots.dispose(); } }); diff --git a/plugins/dsh/test/client-slot-lifecycle.test.ts b/plugins/dsh/test/client-slot-lifecycle.test.ts index f71d4f068..865c57312 100644 --- a/plugins/dsh/test/client-slot-lifecycle.test.ts +++ b/plugins/dsh/test/client-slot-lifecycle.test.ts @@ -44,6 +44,7 @@ test('official slot declaration loss preserves catalog and independently removes ctx.provide('sessions', { scope: () => undefined } as never), ctx.provide('layout', { selectPanel: () => {} } as never), ]; + providers.push(ctx.provide('uiSession', {} as never)); const plugin = ctx.plugin(clientPlugin); const flush = async () => { await new Promise(resolve => setTimeout(resolve, 25)); }; try { @@ -88,3 +89,48 @@ test('official slot declaration loss preserves catalog and independently removes root(); await renderer.dispose(); } }); + +test('session adapter loss removes scoped catalog contributions and restoration registers them once', async () => { + const SlotRegistry = await loadSlotRegistry(); + const ctx = new Context(); + const renderer = ctx.plugin({ apply: (ctx: Context) => { new SlotRegistry(ctx); } }); + await renderer; + const slots = ctx.slots as InstanceType; + const root = slots.register({ name: 'root', children: { + main: { kind: 'keyed', scope: 'session-maybe' }, + 'sidebar.panellist': { kind: 'list', scope: 'root' }, + } } as never, () => null); + const providers = [ + ctx.provide('remote', { $mount: async () => async () => {} } as never), + ctx.provide('remote.skillhub', {} as never), + ctx.provide('sessions', { scope: () => undefined } as never), + ctx.provide('layout', { selectPanel: () => {} } as never), + ]; + const plugin = ctx.plugin(clientPlugin); + const flush = async () => { await new Promise(resolve => setTimeout(resolve, 25)); }; + const source = { getSnapshot: () => ({ hooks: {}, keyedHooks: {}, props: {} }), subscribe: () => () => {} }; + const adapter = { current: source, bindingSource: () => source }; + let owner: ReturnType | undefined; + try { + await plugin; await flush(); + // sessions is available, but the session-maybe renderer cannot run without its UI adapter. + expect(slots.entriesOfSlot('main')).toHaveLength(0); + expect(slots.entriesOfSlot('sidebar.panellist')).toHaveLength(0); + for (let cycle = 0; cycle < 2; cycle++) { + owner = ctx.plugin({ inject: ['slots'], apply: (ctx: Context) => { + ctx.provide('uiSession', {} as never); + ctx.slots.installScope('session', adapter); + } }); + await owner; await flush(); + expect(slots.entriesOfSlot('main')).toHaveLength(1); + expect(slots.entriesOfSlot('sidebar.panellist')).toHaveLength(1); + await owner.dispose(); await flush(); + expect(slots.entriesOfSlot('main')).toHaveLength(0); + expect(slots.entriesOfSlot('sidebar.panellist')).toHaveLength(0); + } + } finally { + await plugin.dispose(); await owner?.dispose(); + for (const remove of providers.reverse()) await remove(); + root(); await renderer.dispose(); + } +}); diff --git a/plugins/dsh/test/integration/dual-upgrade-restart.py b/plugins/dsh/test/integration/dual-upgrade-restart.py index 40aca247b..720ed2534 100644 --- a/plugins/dsh/test/integration/dual-upgrade-restart.py +++ b/plugins/dsh/test/integration/dual-upgrade-restart.py @@ -8,10 +8,12 @@ parser=argparse.ArgumentParser(description='Verify dual-target upgrade recovery parser.add_argument('--root', required=True, type=Path) parser.add_argument('--node', required=True, type=Path) parser.add_argument('--chromium', required=True, type=Path) +parser.add_argument('--success', action='store_true', help='Verify completed dual-target upgrade history across Host restart') parser.add_argument('--crash', action='store_true', help='Kill the isolated Host while its upgrade transaction is paused') parser.add_argument('--unsupported-dsh-bin', type=Path, help='Boot an isolated unsupported DSH installation before returning to the original runtime') parser.add_argument('--replacement-tarball', type=Path, help='Replace the plugin from a retained local tarball while the Host is stopped') args=parser.parse_args() +assert not (args.success and args.crash) root=args.root.resolve() assert root != Path(tempfile.gettempdir()).resolve() and root.is_relative_to(Path(tempfile.gettempdir()).resolve()), 'Root must be an isolated temporary directory' assert (root/'home/profiles/skillhub-m0/package.json').is_file(), 'Initialize and install the isolated Profile first' @@ -45,7 +47,9 @@ def wait_file(path,process,timeout=60): return json.loads(path.read_text()) def start_host(port,first,bin_path=None,log_name=None): env=dict(os.environ,HOME=str(root/'native-install-home'),USERPROFILE=str(root/'native-install-home'),DSH_HOME=str(root/'home'),DSH_AGENTS_HOME=str(root/'agents'),DSH_TELEMETRY_DISABLED='1') - if first:env.update(DSH_UPGRADE_FIXTURE='1',DSH_UPGRADE_RECOVERY_FIXTURE='1',DSH_UPGRADE_TWO_TARGETS='1') + if first: + env.update(DSH_UPGRADE_FIXTURE='1',DSH_UPGRADE_TWO_TARGETS='1') + if not args.success:env['DSH_UPGRADE_RECOVERY_FIXTURE']='1' else:env['DSH_PROBE_SKIP_DISCOVERY']='1' if first and args.crash:env['DSH_UPGRADE_CRASH_FIXTURE']='1' logpath=out/(log_name or ('host-initial.log' if first else 'host-restarted.log')) @@ -73,14 +77,15 @@ try: before=[hashes(p) for p in targets];inventory=root/'native-install-home/.skillhub/inventory.json';inventory_before=inventory.read_bytes() shutil.copy2(repo/'plugins/dsh/test/integration/upgrade-recovery-probe.mjs',root/'upgrade-recovery-probe.mjs') env=dict(os.environ,DSH_PROBE_URL=entry,DSH_PROBE_OUTPUT=str(out),DSH_INSTALL_FIXTURE_TITLE=report['installFixtureTitle'],DSH_INSTALL_FIXTURE_WORKSPACE=report['installFixtureWorkspace'],DSH_PROBE_RESTART='1',DSH_UPGRADE_TWO_TARGETS='1',DSH_FIXTURE_UPDATE_STATE=str(root/'update-state'),DSH_PROBE_CHROMIUM=str(args.chromium.resolve())) + if args.success:env['DSH_UPGRADE_SUCCESS']='1' if args.crash:env['DSH_UPGRADE_CRASH_FIXTURE']='1' log=open(out/'browser.log','w');browser=subprocess.Popen(['node','upgrade-recovery-probe.mjs'],cwd=root,env=env,stdout=log,stderr=log);children.append(browser) op=wait_file(out/'restart-ready.json',browser,90)['operationId'];journal=root/'home/skillhub/operations'/f'{op}.json';j=json.loads(journal.read_text()) if args.crash: wait_file(root/'upgrade-crash-ready.json',old) assert j['operation']['status']['phase'] not in ['completed','failed','recovery-required'] - else:assert j['operation']['status']['phase']=='recovery-required' - target_states=[p.exists() for p in targets];assert sum(target_states)==1,target_states + else:assert j['operation']['status']['phase']==('completed' if args.success else 'recovery-required') + target_states=[p.exists() for p in targets];assert sum(target_states)==(2 if args.success else 1),target_states if args.crash:old.kill() else:old.terminate() old.wait(timeout=30) @@ -112,10 +117,15 @@ try: code=browser.wait(timeout=90) if code:print('Browser failed; inspect the private browser.log in the isolated result directory') assert code==0,'Browser failed' - assert inventory.read_bytes()==inventory_before - assert [hashes(p) for p in targets]==before - j=json.loads(journal.read_text());assert j['operation']['status']['recovery']=='restored' - result={'passed':True,'node':subprocess.check_output([node,'-p','process.versions.node'],text=True).strip(),'forcedProcessExit':args.crash,'oldHostExited':True,'newHostStarted':True,'distinctProcesses':True,'samePort':urlsplit(entry).port==urlsplit(new_entry).port,'targetCount':2,'mixedStateBeforeRestart':True,'allTargetHashesRestored':True,'inventoryUnchanged':True,'operationRecovery':'restored','browser':json.loads((out/'upgrade-result.json').read_text())} + if args.success: + assert all(json.loads((p/'.skillhub/metadata.json').read_text())['version']=='1.3.0' for p in targets) + assert all(hashes(p)!=old_hash for p,old_hash in zip(targets,before)) + else: + assert inventory.read_bytes()==inventory_before + assert [hashes(p) for p in targets]==before + j=json.loads(journal.read_text()) + assert j['operation']['status']['phase']=='completed' if args.success else j['operation']['status']['recovery']=='restored' + result={'passed':True,'node':subprocess.check_output([node,'-p','process.versions.node'],text=True).strip(),'forcedProcessExit':args.crash,'oldHostExited':True,'newHostStarted':True,'distinctProcesses':True,'samePort':urlsplit(entry).port==urlsplit(new_entry).port,'targetCount':2,'mixedStateBeforeRestart':not args.success,'allTargetHashesRestored':not args.success,'inventoryUnchanged':inventory.read_bytes()==inventory_before,'operationRecovery':j['operation']['status']['recovery'],'completedUpgrade':args.success,'browser':json.loads((out/'upgrade-result.json').read_text())} if replacement:result.update(replacementVersion=replacement['version'],replacementSha256=hashlib.sha256(args.replacement_tarball.read_bytes()).hexdigest(),replacementFilesMatched=6,pendingJournalUnchangedDuringPackageReplacement=True) if unsupported_version:result.update(unsupportedHostVersion=unsupported_version,unsupportedBundleRejected=True,pendingJournalUnchangedAcrossUnsupportedHost=True) (out/'host-files-result.json').write_text(json.dumps(result,indent=2));print(json.dumps(result,indent=2)) diff --git a/plugins/dsh/test/integration/upgrade-recovery-probe.mjs b/plugins/dsh/test/integration/upgrade-recovery-probe.mjs index be8062752..b35881013 100644 --- a/plugins/dsh/test/integration/upgrade-recovery-probe.mjs +++ b/plugins/dsh/test/integration/upgrade-recovery-probe.mjs @@ -9,21 +9,52 @@ if (!entry || !output || !title || !workspace || !state) throw new Error('Set is const browser = await chromium.launch({ headless: true, executablePath: process.env.DSH_PROBE_CHROMIUM }); const page = await browser.newPage({ viewport: { width: 1440, height: 1000 }, locale: 'en-US' }); const expectedTargets = process.env.DSH_UPGRADE_TWO_TARGETS === '1' ? 2 : 1; +const success = process.env.DSH_UPGRADE_SUCCESS === '1'; const restart = process.env.DSH_PROBE_RESTART === '1'; const crash = process.env.DSH_UPGRADE_CRASH_FIXTURE === '1'; const expectBusy = process.env.DSH_EXPECT_RECOVERY_BUSY === '1'; assert(!crash || restart, 'Crash verification requires Host restart'); assert(!expectBusy || crash, 'Lease contention probe requires forced Host exit'); const errors = []; +let stage = 'initial-load'; +const operationResponses = []; +const verifiedDetails = []; +page.on('response', async response => { + if (!new URL(response.url()).pathname.endsWith('/getOperation')) return; + try { const body = await response.json(); if (body.result?.ok && body.result.value) operationResponses.push(body.result.value); } catch { /* aborted navigation response */ } +}); let submissions = 0; let recoveries = 0; let operationId; -page.on('pageerror', error => errors.push(error.message.replace(/token=[^\s&]+/g, 'token=[redacted]'))); +page.on('pageerror', error => errors.push({ stage, message: error.message.replace(/token=[^\s&]+/g, 'token=[redacted]') })); page.on('request', request => { const path = new URL(request.url()).pathname; if (path.endsWith('/executePlan')) submissions++; if (path.endsWith('/recoverOperation')) recoveries++; }); +async function assertDetails(history, outcome, afterVersion) { + const deadline = Date.now() + 10000; + let operation; + while (Date.now() < deadline) { + operation = operationResponses.findLast(item => item.operationId === operationId && item.resultDetails?.targets.every(target => target.outcome === outcome)); + if (operation) break; + await delay(50); + } + assert(operation, 'Expected original operation Remote details'); + assert.equal(operation.resultDetails.beforeVersion, '1.2.0'); + assert.equal(operation.resultDetails.afterVersion, afterVersion); + assert.equal(operation.resultDetails.targets.length, expectedTargets); + assert(operation.resultDetails.warnings.every(warning => ['backup-cleanup', 'removal-cleanup', 'verification-required'].includes(warning))); + assert.equal(operation.resultDetails.warnings.length, operation.warningCount); + verifiedDetails.push({ operationId, outcome, ...operation.resultDetails }); + const details = history.locator('details').filter({ has: page.locator('summary', { hasText: '原操作结果详情' }) }); + if (await details.getAttribute('open') === null) await details.locator('summary').click(); + await details.getByText('操作前版本:1.2.0', { exact: true }).waitFor(); + await details.getByText(`操作后版本:${afterVersion ?? '未确认或不适用'}`, { exact: true }).waitFor(); + const label = { upgraded: '升级完成', unknown: '结果待核验', restored: '已恢复' }[outcome]; + assert.equal(await details.getByRole('listitem').filter({ hasText: label }).count(), expectedTargets); + await details.screenshot({ path: `${output}/operation-details-${outcome}.png` }); +} try { await page.goto(entry, { waitUntil: 'domcontentloaded' }); const welcome = page.getByRole('button', { name: 'Continue', exact: true }); @@ -57,12 +88,15 @@ try { operationId = result.value.operationId; await route.fulfill({ response }); }); + stage = 'execute-upgrade'; await detail.getByRole('button', { name: '确认升级', exact: true }).click(); if (crash) { const deadline = Date.now() + 15000; while (!operationId) { assert(Date.now() < deadline, 'Upgrade acceptance unavailable'); await delay(50); } - } else await detail.getByRole('button', { name: '核验并恢复', exact: true }).waitFor(); + } else if (success) await detail.getByText('技能文件升级完成:1.3.0。', { exact: true }).waitFor(); + else await detail.getByRole('button', { name: '核验并恢复', exact: true }).waitFor(); if (restart) { + stage = 'waiting-host-restart'; await writeFile(`${output}/restart-ready.json`, JSON.stringify({ operationId })); const deadline = Date.now() + 120000; let resumed; @@ -74,12 +108,24 @@ try { assert(resumed?.entry, 'Host restart did not complete'); assert.equal(new URL(resumed.entry).origin, new URL(entry).origin, 'Preserve origin for sessionStorage'); await unlink(`${output}/restart-resume.json`); + stage = 'restarted-navigation'; + operationResponses.length = 0; await page.goto(resumed.entry, { waitUntil: 'domcontentloaded' }); } else await page.reload({ waitUntil: 'domcontentloaded' }); await page.getByText('SkillHub', { exact: true }).click(); await plaza.getByRole('button', { name: '已安装', exact: true }).click(); + stage = 'restarted-history'; const history = installed.getByRole('region', { name: '未关闭的升级结果', exact: true }); + if (success) { + await history.getByText('技能文件升级完成:1.3.0。', { exact: true }).waitFor(); + await assertDetails(history, 'upgraded', '1.3.0'); + assert.equal(submissions, 1); assert.equal(recoveries, 0); assert.deepEqual(errors, []); + await page.screenshot({ path: `${output}/upgrade-success-restarted.png` }); + await writeFile(`${output}/upgrade-result.json`, JSON.stringify({ passed: true, operationId, expectedTargets, + submissions, recoveries, hostRestartRequested: restart, originalOperationDetailsVerified: true, verifiedDetails, errors }, null, 2)); + } else { await history.getByRole('button', { name: '核验并恢复', exact: true }).waitFor(); + await assertDetails(history, 'unknown', null); await page.route('**/recoverOperation', async route => { const response = await route.fetch(); const result = (await response.json()).result; @@ -95,6 +141,7 @@ try { assert.equal(result.value.recovery, 'restored'); await route.abort('failed'); }); + stage = 'explicit-recovery'; await history.getByRole('button', { name: '核验并恢复', exact: true }).click(); if (expectBusy) { await history.getByText('恢复结果未确认,请查询原操作并核对完整目标范围。', { exact: true }).waitFor(); @@ -103,25 +150,34 @@ try { // The production lock retains its 10s stale window. Retry is a second user action. await delay(11000); assert.equal(recoveries, 1, 'Waiting for the lease must not auto-submit recovery'); - await history.getByRole('button', { name: '核验并恢复', exact: true }).click(); + stage = 'explicit-recovery'; + await history.getByRole('button', { name: '核验并恢复', exact: true }).click(); } await history.getByText('升级未完成,恢复状态:已恢复旧版本。', { exact: true }).waitFor(); await installed.getByText('已安装版本 1.2.0', { exact: true }).first().waitFor(); assert.equal(await installed.getByText('已安装版本 1.2.0', { exact: true }).count(), expectedTargets); await history.getByText('恢复结果未确认,请查询原操作并核对完整目标范围。', { exact: true }).waitFor({ state: 'hidden' }); + await assertDetails(history, 'restored', null); await page.screenshot({ path: `${output}/upgrade-restored.png` }); + stage = 'close-result'; await history.getByRole('button', { name: '关闭本次结果', exact: true }).click(); await history.waitFor({ state: 'hidden' }); - assert(await installed.getByRole('combobox', { name: '筛选安装范围' }).evaluate(element => element === document.activeElement)); + const focusStarted = Date.now(); + const focusDeadline = focusStarted + 3000; + const scopeFilter = installed.getByRole('combobox', { name: '筛选安装范围' }); + while (!await scopeFilter.evaluate(element => element === document.activeElement) && Date.now() < focusDeadline) await delay(25); + assert(await scopeFilter.evaluate(element => element === document.activeElement), 'Closing the result must restore focus to the scope filter'); assert.equal(submissions, 1); assert.equal(recoveries, expectBusy ? 2 : 1); assert.deepEqual(errors, []); const result = { passed: true, operationId, submissions, recoveries, expectedTargets, historyAfterReload: true, hostRestartRequested: restart, forcedProcessExit: crash, leaseRefusalAndExplicitRetryVerified: expectBusy, - recoveryResponseLossVerified: true, oldVersionVisible: true, closeFocusVerified: true, errors }; + originalOperationDetailsVerified: true, verifiedDetails, recoveryResponseLossVerified: true, oldVersionVisible: true, closeFocusVerified: true, focusWaitMs: Date.now() - focusStarted, errors }; await writeFile(`${output}/upgrade-result.json`, JSON.stringify(result, null, 2)); console.log(JSON.stringify(result)); + } } catch (error) { + await writeFile(`${output}/upgrade-failure-result.json`, JSON.stringify({ passed: false, stage, operationId, verifiedDetails, errors, activeElement: await page.evaluate(() => ({ tag: document.activeElement?.tagName, label: document.activeElement?.getAttribute('aria-label') })) }, null, 2)); await page.screenshot({ path: `${output}/upgrade-failure.png` }); console.log(JSON.stringify({ passed: false, error: error.message.replace(/token=[^\s&]+/g, 'token=[redacted]'), errors })); process.exitCode = 1;