conversation-session-dynamic-workflow-gray-always-on-transcript.test.ts 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. import { TID_CHAT_WORKFLOW_RUN_DIGEST } from "@zcode/shared";
  2. import { TID_LOGIN_USE_API_KEY_BUTTON, TID_TASK_ITEM, testId } from "@zcode/shared/test-ids";
  3. import { getLatestUpstreamToolResultByToolCallId } from "#e2e/helpers/conversation-session-network";
  4. import { clearAppData, pinE2ELocale } from "#e2e/helpers/desktop-app";
  5. import { releaseControlledReplay } from "#e2e/helpers/controlled-replay";
  6. import {
  7. approveV4Permission,
  8. getV4PaneSnapshot,
  9. loginWithApiKey,
  10. prepareV4ConversationE2E,
  11. selectV4TaskById,
  12. sendV4Prompt,
  13. waitForV4AssistantMessageContaining,
  14. waitForV4Pane,
  15. waitForV4PermissionDialog,
  16. } from "#e2e/helpers/v4-conversation";
  17. // 脚本 transcript(docs/dynamic-workflow/transcript-and-notifications.md「The script transcript」
  18. // 「The epilogue fold」、docs/dynamic-workflow/authoring.md「Running commands: `world.run`」
  19. // 「Progress: `log` and `report`」):
  20. // 第一阶段「检查」跑四条确定性的 `node -e` 命令——成功带 stdout、非零退出带 stderr、260 行长输出
  21. // (正文按 200 行截)、`output: { tail: 16 }` 只留尾巴——前后各一条 `log`;第二阶段一个子代理复核。
  22. //
  23. // 文件名带 `gray-always-on`:配置 mock 网关按文件名下发 alwaysOn,工作流工具才在工具集里。
  24. // case-local 回放只决定模型调用;命令由真实 run 引擎执行并写 journal,面板读的是真实的两条 journal 查询。
  25. // 复核员的回答用受控流挂起:run 停在第二阶段时断言面板的运行态,再释放,不靠延时抢时序。
  26. const RUN_NAME = "E2E 检查命令";
  27. const RUN_DIGEST = `[data-testid^="${TID_CHAT_WORKFLOW_RUN_DIGEST}"]`;
  28. const HELD_AGENT_FIXTURE = "dwt-agent";
  29. const OK_STDOUT = "E2E_DWT_OK_1\nE2E_DWT_OK_2\nE2E_DWT_OK_3\nE2E_DWT_OK_4\n";
  30. // 卡片按 argv 展示命令行:带空格或引号的实参用 JSON 字符串加引号(formatCommandLine)。
  31. const COMMANDS = [
  32. `node -e "console.log('E2E_DWT_OK_1');console.log('E2E_DWT_OK_2');console.log('E2E_DWT_OK_3');console.log('E2E_DWT_OK_4')"`,
  33. `node -e "console.error('Error: E2E_DWT_BAD config missing');process.exit(3)"`,
  34. `node -e "for(let i=1;i<=260;i++)console.log('E2E_DWT_LONG_'+i)"`,
  35. `node -e "process.stdout.write('E2E_DWT_HEAD_'.repeat(20)+'E2E_DWT_TAIL_END')"`,
  36. ];
  37. interface ScriptCard {
  38. key: string | null;
  39. status: string | null;
  40. open: boolean;
  41. firstLine: string;
  42. command: string;
  43. statusWord: string;
  44. statusFailed: boolean;
  45. statusTitle: string | null;
  46. result: string;
  47. peek: { text: string; error: boolean }[];
  48. }
  49. let sessionId = "";
  50. let runId = "";
  51. let cardsBeforeReload: ScriptCard[] = [];
  52. function paneSelector() {
  53. return `[data-testid="workflow-workspace-pane"][data-workflow-run-id="${runId}"]`;
  54. }
  55. /** 读出面板里每张卡的可见素材(用 textContent:到场动画期间 getText 可能是空串)。 */
  56. function readScriptCards(): Promise<ScriptCard[]> {
  57. return browser.execute((selector: string) => {
  58. const pane = document.querySelector<HTMLElement>(selector);
  59. if (!pane) return [];
  60. const text = (element: Element | null | undefined) =>
  61. (element?.textContent ?? "").replace(/\s+/g, " ").trim();
  62. return Array.from(
  63. pane.querySelectorAll<HTMLElement>('[data-testid="workflow-workspace-card"]'),
  64. ).map((card) => {
  65. const status = card.querySelector<HTMLElement>('[data-testid="workflow-workspace-status"]');
  66. const peek = card.querySelector<HTMLElement>('[data-testid="workflow-workspace-peek"]');
  67. return {
  68. key: card.dataset.cardKey ?? null,
  69. status: card.dataset.status ?? null,
  70. open: card.dataset.open === "true",
  71. // 中间一列的第一行:动词 + 命令行。
  72. firstLine: text(card.children[1]?.firstElementChild),
  73. command: card.querySelector("code")?.textContent ?? "",
  74. statusWord: text(status),
  75. statusFailed: status?.dataset.failed === "true",
  76. statusTitle: status?.getAttribute("title") ?? null,
  77. result: text(card.querySelector('[data-testid="workflow-workspace-result"]')),
  78. peek: Array.from(peek?.children ?? []).map((line) => ({
  79. text: line.textContent ?? "",
  80. error: line.classList.contains("text-destructive"),
  81. })),
  82. };
  83. });
  84. }, paneSelector());
  85. }
  86. /** 等四张卡都画出、收起的卡 peek 都取回(peek 在卡滚进视口时才取正文;展开的卡没有 peek)。 */
  87. async function waitForSettledCards(timeoutMsg: string): Promise<ScriptCard[]> {
  88. let cards: ScriptCard[] = [];
  89. await browser.waitUntil(
  90. async () => {
  91. cards = await readScriptCards();
  92. return (
  93. cards.length === 4 &&
  94. cards.every((card) => card.status === "completed" && (card.open || card.peek.length > 0))
  95. );
  96. },
  97. { timeout: 60000, timeoutMsg: `${timeoutMsg};最后一次读到 ${JSON.stringify(cards)}` },
  98. );
  99. return cards;
  100. }
  101. /** 点卡的结果行切换展开:卡的正中可能落在 peek 上,而 peek 里的点击不折叠(文档「Cards」)。 */
  102. async function toggleCard(index: number) {
  103. const card = (await $(paneSelector()).$$('[data-testid="workflow-workspace-card"]'))[index]!;
  104. await card.$('[data-testid="workflow-workspace-result"]').click();
  105. return card;
  106. }
  107. /** 展开的卡:等正文取回(页脚出现),读出正文、stderr 段、页脚与截断说明。 */
  108. async function readCardBody(index: number) {
  109. let body: {
  110. text: string;
  111. stdout: string;
  112. stderr: string | null;
  113. footer: string;
  114. note: string | null;
  115. } | null = null;
  116. await browser.waitUntil(
  117. async () => {
  118. body = await browser.execute(
  119. (selector: string, position: number) => {
  120. const card = document.querySelectorAll(
  121. `${selector} [data-testid="workflow-workspace-card"]`,
  122. )[position];
  123. const root = card?.querySelector('[data-testid="workflow-workspace-card-body"]');
  124. const footer = root?.querySelector('[data-testid="workflow-workspace-card-footer"]');
  125. if (!root || !footer) return null;
  126. // 正文的 stdout 是命令行之后、stderr 段之外的第一个 <pre>。
  127. const stdout = Array.from(root.querySelectorAll("pre")).find(
  128. (pre) =>
  129. !pre.closest('[data-testid="workflow-workspace-stderr"]') &&
  130. pre.previousElementSibling?.textContent !== "$",
  131. );
  132. const stderr = root.querySelector('[data-testid="workflow-workspace-stderr"] pre');
  133. return {
  134. text: root.textContent ?? "",
  135. stdout: stdout?.textContent ?? "",
  136. stderr: stderr?.textContent ?? null,
  137. footer: (footer.textContent ?? "").replace(/\s+/g, " ").trim(),
  138. note: footer.querySelector("p")?.textContent ?? null,
  139. };
  140. },
  141. paneSelector(),
  142. index,
  143. );
  144. return body !== null;
  145. },
  146. { timeout: 30000, timeoutMsg: `第 ${index + 1} 张卡的正文没有取回` },
  147. );
  148. return body!;
  149. }
  150. /** 从 run 卡的「检查」站点开脚本 transcript(药丸的无障碍名是「打开 {phase} 处的脚本步骤」)。 */
  151. async function openScriptTranscript() {
  152. const pill = await $(`${RUN_DIGEST}[data-workflow-run-id="${runId}"]`).$(
  153. 'button[data-testid="workflow-agent-pill"][aria-label="打开 检查 处的脚本步骤"]',
  154. );
  155. await pill.waitForClickable({ timeout: 60000 });
  156. await pill.click();
  157. await $(paneSelector()).waitForDisplayed({ timeout: 30000 });
  158. }
  159. /** renderer 重载:Host 与 CLI 不动,只换一份新的 renderer(取正文的缓存随之清空)。 */
  160. async function reloadRenderer() {
  161. await browser.refresh();
  162. const login = $(`[data-testid="${TID_LOGIN_USE_API_KEY_BUTTON}"]`);
  163. const task = $(`[data-testid="${testId(TID_TASK_ITEM, sessionId)}"]`);
  164. await browser.waitUntil(async () => (await login.isDisplayed()) || (await task.isExisting()), {
  165. timeout: 60000,
  166. timeoutMsg: "renderer 重载后既没有登录页也没有任务项",
  167. });
  168. if (await login.isDisplayed()) await loginWithApiKey();
  169. // 语言固定只在内存里;新 renderer 要重新固定。
  170. await pinE2ELocale("zh-CN");
  171. if ((await getV4PaneSnapshot()).sessionId !== sessionId) {
  172. await selectV4TaskById(sessionId, 60000);
  173. }
  174. await waitForV4Pane(
  175. (snapshot) => snapshot.sessionId === sessionId,
  176. `没有重新打开会话 ${sessionId}`,
  177. 60000,
  178. );
  179. }
  180. describe("动态工作流 · 脚本 transcript", () => {
  181. before(async () => {
  182. await prepareV4ConversationE2E();
  183. // 断言中文文案:固定界面语言,不跟随宿主系统语言(容器里默认英文)。
  184. await pinE2ELocale("zh-CN");
  185. });
  186. after(async () => {
  187. await browser.electron.restoreAllMocks();
  188. await clearAppData();
  189. });
  190. it("DWT-01 从「检查」站的脚本药丸打开 tab:表头写 run 名与运行中,一章四张命令卡按执行顺序,log 不成卡;成功卡 peek 末三行、展开有 $ 命令行与 Copy;失败卡退出码 3 标红、stderr 单独成段", async function () {
  191. this.timeout(300000);
  192. await sendV4Prompt("E2E_DWT_START 用工作流跑几条检查命令,再让子代理复核。");
  193. await waitForV4PermissionDialog();
  194. await approveV4Permission();
  195. await browser.waitUntil(
  196. async () =>
  197. (await getLatestUpstreamToolResultByToolCallId("toolu_dwt_create"))?.isError === false,
  198. { timeout: 60000, timeoutMsg: "CreateWorkflow 未执行成功" },
  199. );
  200. const toolResult = await getLatestUpstreamToolResultByToolCallId("toolu_dwt_create");
  201. const launched = /started in the background with ID: (\S+?)\./.exec(toolResult?.content ?? "");
  202. expect(launched).not.toBeNull();
  203. runId = launched![1]!;
  204. await waitForV4AssistantMessageContaining("E2E_DWT_STARTED", 60000);
  205. sessionId = (await getV4PaneSnapshot()).sessionId ?? "";
  206. expect(sessionId).not.toBe("draft");
  207. // run 停在第二阶段:复核员的回答被挂起,四条命令已经跑完。
  208. const digest = await $(`${RUN_DIGEST}[data-workflow-run-id="${runId}"]`);
  209. await digest.waitForDisplayed({ timeout: 120000 });
  210. await browser.waitUntil(
  211. async () =>
  212. (await digest.$$('[data-testid="workflow-agent-pill"][data-agent-status="running"]')
  213. .length) === 1,
  214. { timeout: 120000, timeoutMsg: "复核员没有进入运行态" },
  215. );
  216. await openScriptTranscript();
  217. const pane = $(paneSelector());
  218. await expect(pane.$('[data-testid="workflow-workspace-title"]')).toHaveText(RUN_NAME);
  219. await expect(pane.$('[data-testid="workflow-workspace-run-status"]')).toHaveText("运行中");
  220. const cards = await waitForSettledCards("面板没有画出四张已结束的命令卡");
  221. // 一张卡对应一次 world.run,按准入顺序;`log` 没有站点、不进 journal,不成卡。
  222. expect(cards.map((card) => card.command)).toEqual(COMMANDS);
  223. for (const card of cards) {
  224. expect(card.firstLine.startsWith("已执行")).toBe(true);
  225. expect(card.firstLine).not.toContain("E2E_DWT_LOG");
  226. }
  227. // 章:同一阶段的连续卡成一章,章头是阶段名与「4 步」;表头第二行数阶段、步数与时长。
  228. const chapters = await pane.$$('[data-testid="workflow-workspace-chapter"]');
  229. expect(chapters).toHaveLength(1);
  230. const chapterText = await chapters[0]!.getText();
  231. expect(chapterText).toContain("检查");
  232. expect(chapterText).toContain("4 步");
  233. const summary = await pane.$('[data-testid="workflow-workspace-summary"]').getText();
  234. expect(summary).toContain("1 个阶段");
  235. expect(summary).toContain("4 步");
  236. // 成功卡:退出码 0 绿色;收起时 peek 是 stdout 的最后三行非空行。
  237. const [ok, bad] = cards;
  238. expect(ok!.statusWord).toBe("退出码 0");
  239. expect(ok!.statusFailed).toBe(false);
  240. expect(ok!.peek.map((line) => line.text)).toEqual([
  241. "E2E_DWT_OK_2",
  242. "E2E_DWT_OK_3",
  243. "E2E_DWT_OK_4",
  244. ]);
  245. // 失败卡:非零退出是值,状态词「退出码 3」标红,悬停给命令行;stdout 为空时 peek 取 stderr,
  246. // 像错误的行标红。结果行的字节数是 stdout 的 0 B。
  247. expect(bad!.statusWord).toBe("退出码 3");
  248. expect(bad!.statusFailed).toBe(true);
  249. expect(bad!.statusTitle).toBe(COMMANDS[1]);
  250. expect(bad!.result).toContain("0 B");
  251. expect(bad!.peek).toEqual([{ text: "Error: E2E_DWT_BAD config missing", error: true }]);
  252. // 展开成功卡:`$ 命令行`、stdout、页脚「退出码 0」与 Copy;没有 stderr 段与截断说明。
  253. await toggleCard(0);
  254. const okBody = await readCardBody(0);
  255. expect(okBody.text).toContain(`$${COMMANDS[0]}`);
  256. expect(okBody.stdout).toBe(OK_STDOUT);
  257. expect(okBody.stderr).toBeNull();
  258. expect(okBody.footer).toContain("退出码 0");
  259. expect(okBody.note).toBeNull();
  260. // 展开后 peek 让位给正文。
  261. expect((await readScriptCards())[0]!.peek).toEqual([]);
  262. // Copy 复制 stdout;正文里的点击不折叠卡。
  263. await browser.electron.execute((electron) => electron.clipboard.clear());
  264. const copy = (await pane.$$('[data-testid="workflow-workspace-card"]'))[0]!.$(
  265. '[data-testid="workflow-workspace-copy"]',
  266. );
  267. await copy.click();
  268. // 「已复制」只停 1.5 s:先等它,再核对剪贴板。
  269. await expect(copy).toHaveText(expect.stringContaining("已复制"));
  270. // 失败原因:Windows 系统剪贴板把纯文本的 LF 存成 CRLF,读回来是 `\r\n`;应用写入的
  271. // 仍是 stdout 原文。按 LF 归一后再比,断言的仍是“复制的是 stdout 原文”。
  272. let clipboardText = "";
  273. await browser
  274. .waitUntil(
  275. async () => {
  276. clipboardText = await browser.electron.execute((electron) =>
  277. electron.clipboard.readText(),
  278. );
  279. return clipboardText.replaceAll("\r\n", "\n") === OK_STDOUT;
  280. },
  281. { timeout: 10000, timeoutMsg: "Copy 没有把 stdout 写进剪贴板" },
  282. )
  283. .catch((error: unknown) => {
  284. throw new Error(`Copy 没有把 stdout 写进剪贴板: ${JSON.stringify(clipboardText)}`, {
  285. cause: error,
  286. });
  287. });
  288. expect((await readScriptCards())[0]!.open).toBe(true);
  289. // 展开失败卡:没有 stdout 时不写「没有输出」,stderr 在单独的一段里;页脚「退出码 3」。
  290. await toggleCard(1);
  291. const badBody = await readCardBody(1);
  292. expect(badBody.text).toContain(`$${COMMANDS[1]}`);
  293. expect(badBody.stderr).toBe("Error: E2E_DWT_BAD config missing\n");
  294. expect(badBody.text).not.toContain("没有输出");
  295. expect(badBody.footer).toContain("退出码 3");
  296. });
  297. it("DWT-02 长输出:peek 是最后三行,展开只画前 200 行并写截断说明;tail 模式的卡写的是保留下来的 16 B,正文只有尾巴", async function () {
  298. this.timeout(120000);
  299. if (!runId) throw new Error("DWT-01 没有留下 run");
  300. const cards = await readScriptCards();
  301. const [, , long, tail] = cards;
  302. // 260 行 stdout:peek 取最后三行非空行;结果行写 stdout 的字节数(4312 B)。
  303. expect(long!.statusWord).toBe("退出码 0");
  304. expect(long!.peek.map((line) => line.text)).toEqual([
  305. "E2E_DWT_LONG_258",
  306. "E2E_DWT_LONG_259",
  307. "E2E_DWT_LONG_260",
  308. ]);
  309. expect(long!.result).toContain("4.2 KB");
  310. await toggleCard(2);
  311. const longBody = await readCardBody(2);
  312. const shown = longBody.stdout.split("\n");
  313. expect(shown).toHaveLength(200);
  314. expect(shown[0]).toBe("E2E_DWT_LONG_1");
  315. expect(shown[199]).toBe("E2E_DWT_LONG_200");
  316. expect(longBody.stdout).not.toContain("E2E_DWT_LONG_201");
  317. expect(longBody.note).toMatch(
  318. /^只显示前 200 行(共 [\d.]+ (B|KB));完整结果仍在 journal 里。$/,
  319. );
  320. // `output: { tail: 16 }`:进程打印 276 字节,journal 只存最后 16 字节,卡上写的是 16 B。
  321. expect(tail!.statusWord).toBe("退出码 0");
  322. expect(tail!.result).toContain("16 B");
  323. expect(tail!.peek.map((line) => line.text)).toEqual(["E2E_DWT_TAIL_END"]);
  324. await toggleCard(3);
  325. const tailBody = await readCardBody(3);
  326. expect(tailBody.stdout).toBe("E2E_DWT_TAIL_END");
  327. expect(tailBody.note).toBeNull();
  328. expect(tailBody.footer).toContain("16 B");
  329. });
  330. it("DWT-03 run 结束后表头转为已完成;子代理 transcript 里 ask 正文之外的引擎尾注折进默认收起的披露;renderer 重载后重开 tab,从 journal 画出同样的卡与正文", async function () {
  331. this.timeout(300000);
  332. if (!runId || !sessionId) throw new Error("DWT-01 没有留下会话与 run");
  333. await releaseControlledReplay(HELD_AGENT_FIXTURE);
  334. const digest = $(`${RUN_DIGEST}[data-workflow-run-id="${runId}"]`);
  335. await browser.waitUntil(
  336. async () => (await digest.getAttribute("data-workflow-run-status")) === "completed",
  337. { timeout: 120000, timeoutMsg: "run 没有到达完成态" },
  338. );
  339. // 面板订阅父会话投影:run 的状态词跟着变。
  340. await expect($(paneSelector()).$('[data-testid="workflow-workspace-run-status"]')).toHaveText(
  341. "已完成",
  342. );
  343. await waitForV4AssistantMessageContaining("E2E_DWT_DONE", 120000);
  344. // 把前两例展开的卡收起,peek 回来:重载后的展开态记忆是空的,比的是同一副收起的样子。
  345. for (const [index, card] of (await readScriptCards()).entries()) {
  346. if (card.open) await toggleCard(index);
  347. }
  348. cardsBeforeReload = await waitForSettledCards("完成后面板的四张卡没有停在已结束");
  349. expect(cardsBeforeReload.every((card) => !card.open && card.peek.length > 0)).toBe(true);
  350. // 子代理 transcript:气泡正文是脚本写的指令(带上 world.run 的退出码),质量尾注折进
  351. // 「工作流引擎附加说明」,默认收起;展开后去掉开头的 `---`,等宽显示。
  352. let opened = false;
  353. for (const pill of await digest.$$(
  354. '[data-testid="workflow-agent-pill"][data-agent-open="true"]',
  355. )) {
  356. if ((await pill.getText()).includes("复核员")) {
  357. await pill.click();
  358. opened = true;
  359. break;
  360. }
  361. }
  362. expect(opened).toBe(true);
  363. const readBubble = () =>
  364. browser.execute(() => {
  365. const bubble = Array.from(
  366. document.querySelectorAll<HTMLElement>(
  367. '[data-session-id^="sess_dwf-"] [data-v4-user-input-bubble="true"]',
  368. ),
  369. ).find((element) => (element.textContent ?? "").includes("E2E_DWT_TASK"));
  370. if (!bubble) return null;
  371. const fold = bubble.querySelector<HTMLElement>('[data-v4-user-input-epilogue="true"]');
  372. const toggle = fold?.querySelector<HTMLButtonElement>("button");
  373. const body = fold?.querySelector<HTMLElement>('[data-v4-user-input-epilogue-body="true"]');
  374. return {
  375. text: bubble.textContent ?? "",
  376. label: toggle?.textContent ?? null,
  377. expanded: toggle?.getAttribute("aria-expanded") ?? null,
  378. body: body?.textContent ?? null,
  379. };
  380. });
  381. let bubble: Awaited<ReturnType<typeof readBubble>> = null;
  382. await browser.waitUntil(
  383. async () => {
  384. bubble = await readBubble();
  385. return bubble !== null && bubble.label !== null;
  386. },
  387. {
  388. timeout: 60000,
  389. timeoutMsg: `子代理 transcript 没有画出带尾注披露的 ask 气泡;最后一次读到 ${JSON.stringify(bubble)}`,
  390. },
  391. );
  392. expect(bubble!.text).toContain("E2E_DWT_TASK 依据两条检查的退出码 0 与 3 给出一句结论。");
  393. expect(bubble!.label).toBe("工作流引擎附加说明");
  394. expect(bubble!.expanded).toBe("false");
  395. expect(bubble!.body).toBeNull();
  396. expect(bubble!.text).not.toContain("Standard for this result");
  397. await browser.execute(() => {
  398. const bubble = Array.from(
  399. document.querySelectorAll<HTMLElement>(
  400. '[data-session-id^="sess_dwf-"] [data-v4-user-input-bubble="true"]',
  401. ),
  402. ).find((element) => (element.textContent ?? "").includes("E2E_DWT_TASK"));
  403. bubble
  404. ?.querySelector<HTMLButtonElement>('[data-v4-user-input-epilogue="true"] button')
  405. ?.click();
  406. });
  407. await browser.waitUntil(async () => (await readBubble())?.body != null, {
  408. timeout: 10000,
  409. timeoutMsg: "点开披露后没有出现尾注正文",
  410. });
  411. const epilogue = (await readBubble())!.body!;
  412. expect(epilogue.startsWith("Standard for this result:")).toBe(true);
  413. expect(epilogue).toContain("call `escalate`");
  414. // 冷读:renderer 重载清空正文缓存与展开态记忆;重开 tab,清单与正文都从 journal 重读。
  415. await reloadRenderer();
  416. await openScriptTranscript();
  417. const cardsAfterReload = await waitForSettledCards("重载后面板没有画出四张已结束的命令卡");
  418. expect(cardsAfterReload).toEqual(cardsBeforeReload);
  419. await toggleCard(1);
  420. const badBody = await readCardBody(1);
  421. expect(badBody.stderr).toBe("Error: E2E_DWT_BAD config missing\n");
  422. expect(badBody.footer).toContain("退出码 3");
  423. });
  424. });