Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix: 保留系统通知之前子代理的运行状态
geng yue5d6e14e5ce77
diff --git a/apps/desktop/src/lib/live-delegation-entries.ts b/apps/desktop/src/lib/live-delegation-entries.tsindex fca5d65bd..26291577f 100644--- a/apps/desktop/src/lib/live-delegation-entries.ts+++ b/apps/desktop/src/lib/live-delegation-entries.ts@@ -15,8 +15,10 @@ export function collectLiveDelegationEntries(live.set(entry.id, true);} else if (entry.kind === "message") {const { message } = entry;+ // 运行中的系统提示不会结束回合,与 steering 一样保留前面的子代理状态。+ if (message.role === "system") continue;if (message.role === "user" && message.steering) continue;- if (message.role === "user" || message.role === "system") break;+ if (message.role === "user") break;}}return live;diff --git a/apps/desktop/test/live-delegation-system-row.test.mjs b/apps/desktop/test/live-delegation-system-row.test.mjsnew file mode 100644index 000000000..9692cc264--- /dev/null+++ b/apps/desktop/test/live-delegation-system-row.test.mjs@@ -0,0 +1,34 @@+import assert from "node:assert/strict";+import test from "node:test";+import { register } from "node:module";+register(new URL("./helpers/ts-import-hooks.mjs", import.meta.url));+const { buildTranscriptEntries } = await import("../src/lib/assistant-turns.ts");+const { collectLiveDelegationEntries } = await import("../src/lib/live-delegation-entries.ts");+const { collectDelegationStatuses, subagentOutcome } = await import("../src/lib/subagent-topology.ts");+const row = (id, role, extra = {}) => ({ id, role, content: "", createdAt: "2026-11-08T00:00:00Z", ...extra });+const task = row("task", "tool", { toolName: "Task", toolCallId: "call", status: "complete", toolResult: { details: { delegationId: "delegate", status: "running" } } });++test("running delegation behind a system update stays running after transcript reconstruction", () => {+ const { entries } = buildTranscriptEntries([+ row("prompt", "user", { content: "Inspect" }), task,+ row("system", "system", { content: "Runtime configuration updated" }),+ ]);+ const history = entries.slice(0, -1);+ const live = collectLiveDelegationEntries(history, entries.at(-1), true);+ const turn = history.find(entry => entry.kind === "assistant-turn");+ const items = turn.parts.flatMap(part => part.kind === "activity" ? part.items : []);+ const statuses = collectDelegationStatuses(items, { turnLive: live.has(turn.id) });+ assert.equal(subagentOutcome(task, statuses), "running");+ assert.equal(collectLiveDelegationEntries(history, entries.at(-1), false).size, 0);+ const settled = collectDelegationStatuses(items, { turnLive: false });+ assert.equal(subagentOutcome(task, settled), "aborted");+});++test("a new ordinary prompt still separates earlier delegation state", () => {+ const { entries } = buildTranscriptEntries([+ row("prompt", "user"), task,+ row("system", "system", { content: "Runtime configuration updated" }),+ row("next", "user", { content: "New task" }),+ ]);+ assert.equal(collectLiveDelegationEntries(entries.slice(0, -1), entries.at(-1), true).size, 0);+});diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.mdindex 184989401..8ede295b6 100644--- a/docs/spec/04-ux/08-component-spec.md+++ b/docs/spec/04-ux/08-component-spec.md@@ -1,5 +1,9 @@# 08. Component Spec+Live delegation reconstruction crosses system notices as well as steering+messages. An ordinary user prompt remains the run boundary. A running Task+behind a system notice must not become aborted on navigation (Refs #1990).+### Copied directory referencesNative folder paste adds compact cards in a wrapping row above the editablediff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex 6b73f1bfb..4adefe706 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -1,5 +1,14 @@# 04. E2E Test Plan+### E2E-SUBAGENT-system-notice-reconstruction++Reconstruct a transcript with a running Task followed by a system notice.+The production entry builder, live-delegation selector and outcome resolver+keep the Task running. End the session or add a new ordinary prompt and verify+that historical Tasks are no longer live. Coverage:+`live-delegation-system-row.test.mjs`; `turn-process.test.mjs` checks the+matching turn boundary and `turn-process-header.test.mjs` the rendered labels.+## E2E-SCHEDULED-independent-loading-and-route-return- **Preconditions:** Synthetic tasks; controllable task, latest-run, history anddiff --git a/docs/zh-CN/spec/04-ux/08-component-spec.md b/docs/zh-CN/spec/04-ux/08-component-spec.mdindex 07b6adced..4e54c6d72 100644--- a/docs/zh-CN/spec/04-ux/08-component-spec.md+++ b/docs/zh-CN/spec/04-ux/08-component-spec.md@@ -1,5 +1,8 @@# 08. 组件规格+运行中子代理状态重建跨过系统通知及 steering 消息,普通用户提示仍作为回合边界。+系统通知之前仍在运行的 Task 不会因导航而显示已停止(Refs #1990)。+> **翻译说明:** 本页是与 [英文源规格](/spec/04-ux/08-component-spec) 一一对应的机器辅助翻译。代码、协议字段和标识符保持原文;如翻译与英文源事实有歧义,以英文版本为准。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.mdindex d5ea19d98..27863c555 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@@ -1,5 +1,12 @@# 04. E2E 测试 Plan+### E2E-SUBAGENT-system-notice-reconstruction++重建运行中的 Task 后接系统通知的会话,生产条目构建、运行状态选择及结果+解析保留 Task 运行状态。结束会话或追加普通用户提示后,历史 Task 不再存活。+覆盖:`live-delegation-system-row.test.mjs`;`turn-process.test.mjs` 验证对应+回合边界,`turn-process-header.test.mjs` 验证渲染状态标签。+## E2E-SCHEDULED-independent-loading-and-route-return- **Preconditions:** Synthetic tasks; controllable task, latest-run, history anddiff --git a/scripts/e2e/transcript-render.tsx b/scripts/e2e/transcript-render.tsxindex 1c8d90736..ee27c6745 100644--- a/scripts/e2e/transcript-render.tsx+++ b/scripts/e2e/transcript-render.tsx@@ -19,7 +19,8 @@ import {useContextMenu,} from "../../apps/desktop/src/components/ContextMenu";import { Markdown } from "../../apps/desktop/src/components/Markdown";-import { AssistantTurn } from "../../apps/desktop/src/features/chat/transcript/AssistantTurn";+import { AssistantTurn, TranscriptHistory } from "../../apps/desktop/src/features/chat/transcript/AssistantTurn";+import { collectLiveDelegationEntries } from "../../apps/desktop/src/lib/live-delegation-entries";import { ChatTranscript } from "../../apps/desktop/src/features/chat/transcript/ChatTranscript";import { buildTranscriptEntries } from "../../apps/desktop/src/lib/assistant-turns";import { assistantErrorMessage } from "../../apps/desktop/src/stores/helpers/store-helpers";@@ -680,6 +681,27 @@ globalThis.transcriptRenderProbe = async () => {"Task completion timing did not update to 4s",);+ // 系统通知后重建会话时,仍运行的 Task 不应变成已停止。+ for (const smoothStreaming of [false, true]) {+ for (const inlineVisualizations of [false, true]) {+ flushSync(() => useAppStore.setState({ settings: {+ ...useAppStore.getState().settings!, smoothStreaming, inlineVisualizations,+ } }));+ const entries = buildTranscriptEntries([+ message("native-user", "user", "Delegate"), task,+ message("system-notice", "system", "Runtime configuration updated"),+ ]).entries;+ const history = entries.slice(0, -1);+ const live = collectLiveDelegationEntries(history, entries.at(-1), true);+ flushSync(() => root.render(<I18nextProvider i18n={i18n}><span>Other session</span></I18nextProvider>));+ flushSync(() => root.render(<I18nextProvider i18n={i18n}>+ <TranscriptHistory entries={history} isRunning liveDelegations={live} />+ </I18nextProvider>));+ assert(container.querySelector(".has-subagents")?.classList.contains("active"),+ "a system-tailed running Task was stopped after session reconstruction");+ }+ }+const statusLifecycle = await transcriptStatusProbe();const markdownLinks = await markdownLinkInteractionProbe(i18n);const contextMenuSubmenu = await contextMenuSubmenuInteractionProbe();