Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(work-panel): resolve plugin views before the startup artifact restore

Tioit-Wang68dc4136c5b0
diff --git a/apps/desktop/src/stores/app-store.ts b/apps/desktop/src/stores/app-store.ts
index e7965b6be..db56efe64 100644
--- a/apps/desktop/src/stores/app-store.ts
+++ b/apps/desktop/src/stores/app-store.ts
@@ -672,6 +672,12 @@ export const useAppStore = create<AppState>((set, get) => {
unreadNotificationCount: notifications.unreadCount,
sessionOutcomes: latestSessionOutcomes(notifications.notifications),
});
+
+ // The artifact's surface depends on which plugin views are launchable, and
+ // the launcher list is only read after `ready`. Resolve it before the
+ // restore, so the approval artifact does not fall back to the host file tab
+ // and then take a second tab from `selectSession`.
+ await get().refreshPluginViews();
for (const proposal of activePendingPlans) {
openPlanArtifact(
proposal,
diff --git a/apps/desktop/test/plan-mode-source-contract.test.mjs b/apps/desktop/test/plan-mode-source-contract.test.mjs
index e9b93cb19..5e569bfa3 100644
--- a/apps/desktop/test/plan-mode-source-contract.test.mjs
+++ b/apps/desktop/test/plan-mode-source-contract.test.mjs
@@ -179,6 +179,17 @@ test("plan approval sends exact identities and waits for host confirmation", ()
assert.doesNotMatch(resolveBlock, /finally[\s\S]*pendingPlans/);
});
+test("the startup artifact restore resolves launchable views first", () => {
+ // The artifact's surface comes from the launchable plugin views, and the
+ // renderer only reads that list after `ready`. Opening the artifact before
+ // that read used the host file tab and then took a second tab when
+ // `selectSession` restored the same approval.
+ assert.match(
+ storeSource,
+ /await get\(\)\.refreshPluginViews\(\);[\s\S]{0,400}?openPlanArtifact\(/,
+ );
+});
+
test("plan approval bar paints the composer plate over the transparent dock", () => {
const barRule = composerCss.match(/\.plan-approval-bar \{[\s\S]*?\n\}/)?.[0] ?? "";
assert.match(barRule, /background:\s*var\(--ds-bg-composer\)/);
diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.md
index a5de73b71..4ce8b7b6f 100644
--- a/docs/spec/04-ux/08-component-spec.md
+++ b/docs/spec/04-ux/08-component-spec.md
@@ -2396,6 +2396,11 @@ bytes. The submitted question/description, status, validity/deadline, inline
Markdown, SHA-256, byte size, and revision/feedback controls are not rendered
card content.
+Because the bundled file view can edit and save the file it opened (ADR 0241),
+an artifact changed before Approve no longer matches the recorded hash: the host
+fails that approval closed with `PLAN_ARTIFACT_HASH_MISMATCH` until the proposal
+is rejected and resubmitted.
+
### 10A.3 Actions and states
| State | Actions | Contract |
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index d8dc0812c..557a97838 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -5445,8 +5445,8 @@ identify the platform validation still needed.
title/question, and never lets the renderer or sidecar write or replace it.
The title-derived artifact filename is recognizable from the title, including
non-ASCII title characters. The card shows the title and opens the artifact in
- the bundled file view, falling back to the host file tab when that view is
- absent (D452);
+ the bundled file view, falling back to the host file tab when that view is not
+ launchable (D452);
it does not require inline question/Markdown/hash/size or a validity/deadline
indicator. The selected approval mode is remembered locally for the next
approval.
diff --git a/docs/zh-CN/spec/04-ux/08-component-spec.md b/docs/zh-CN/spec/04-ux/08-component-spec.md
index 07c26d27a..06a15a18c 100644
--- a/docs/zh-CN/spec/04-ux/08-component-spec.md
+++ b/docs/zh-CN/spec/04-ux/08-component-spec.md
@@ -1761,6 +1761,10 @@ Agent 并保存在新的不可变 `.pi/<kind>/*.md` 工件中。它是独特的
描述、状态、validity/deadline、内联 Markdown、SHA-256、字节大小、
和 revision/feedback 控件不渲染卡片内容。
+由于内置文件视图可以编辑并保存它打开的文件(ADR 0241),在 Approve 之前被改动的
+工件不再匹配记录的哈希:宿主会以 `PLAN_ARTIFACT_HASH_MISMATCH` 让该次审批失败关闭,
+直到提议被拒绝并重新提交。
+
### 10A.3 动作和状态
| 状态 | 行动 | 合同 |
diff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
index 6050ad411..2c303dd45 100644
--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
@@ -3754,7 +3754,8 @@ IPC 请求无法关闭。
独特的神器,记录其相关的 path/hash/size 与结构化
title/question,并且绝不让渲染器或 sidecar 写入或替换它。
标题衍生的工件文件名可以从标题中识别出来,包括
- 非 ASCII 标题字符。卡牌显示标题,打开神器;
+ 非 ASCII 标题字符。卡牌显示标题,并在内置文件视图中打开神器,
+ 该视图不可启动时回退到宿主机文件标签(D452);
它不需要内联 question/Markdown/hash/size 或 validity/deadline
指标。选择的审批方式会被本地记住,以便下次使用
批准。