agent-console 1.3.3: reconnect on return, sidebar dots, permission-wait, chat icon (#760)

qingnian108's follow-up to #747 and #758, on top of 1.3.2.

- A permission request still open when its turn ends is cancelled by the
  daemon (manager and ACP session both), and an ACP request the Agent
  withdraws ($/cancel_request, through the handler's AbortSignal) closes
  as cancelled. The page waits only on cards that still show buttons, so
  a finished turn no longer leaves 等待授权 with nothing to click. The
  等待授权 pill scrolls to the waiting card.
- 添加到对话 uses a speech-bubble icon.
- Sidebar dot: blinks while running, green after a completed turn, red
  on failure, amber while waiting.
- Wrapper: every disconnect / invalid-link end state offers Reconnect;
  the last safe back URL is kept in sessionStorage (safeBack re-checked
  on read). Coming back to the page (visible / focus) probes the child
  for 4 s instead of waiting out timers pushed back while hidden.

Review (head 0c8ee32b): every changed source line read. 1.3.2's Codex
model_catalog_json change is kept (codex/provider.ts untouched, rebuilt
dist still carries it). No new network in tests, page text set through
textContent/React, no new timers in the page or daemon; the wrapper's
sessionStorage back passes the same loopback check (tested with an evil
stored value).

Run (mote, macOS), standalone copy of packages/agent-console:
- npm ci; npm run check OK.
- vitest: 65 files, 489 passed / 17 skipped.
- npm run build, then verify:build: committed app/ and daemon/dist
  identical to the rebuild.
On the PR merged onto main 5026f636: root `bun test
packages/agent-console` 6/6, `bun scripts/check.mjs` exit 0.

Not tried: scripts/e2e-v1.mjs (Playwright, scenario 28), the page with a
live Cursor/Claude/Codex, Windows/Linux.
This commit is contained in:
qingnian108
2026-11-05 18:14:53 +08:00
committed by GitHub
parent 5026f6362e
commit 41e90a18d3
30 changed files with 870 additions and 131 deletions
+40 -2
View File
@@ -884,14 +884,52 @@ async function scenario15() {
record("场景15 终端:echo→输出→刷新→历史仍在", true);
}
async function scenario28() {
// Nolan's 1.2.0 bug: Cursor asked for permission, its stream died and the turn ended with the request open; the top
// bar kept 等待授权 and the composer stayed locked with no card to click. /perm-abandon does the same in the mock.
await newThread();
await send("/perm-abandon");
await waitIdle();
await sleep(300);
const state = () => page.evaluate(() => ({
wait: !!document.querySelector(".tb-pill.wait"),
locked: !!document.querySelector(".cp-ta")?.disabled,
pending: window.__tl?.getState?.().pending?.length ?? -1,
}));
const live = await state();
await page.reload({ waitUntil: "domcontentloaded" });
await page.waitForFunction(() => window.__ws && window.__ws.getState() === "open", { timeout: 10000 });
await page.waitForSelector(".card.perm", { timeout: 10000 });
await sleep(500);
const reloaded = await state();
const cancelled = await page.$eval(".card.perm", (e) => e.textContent.includes("已取消"));
// A request that does wait: the 等待授权 pill brings its card into view from the top of a long conversation
await send("/perm");
await page.waitForSelector(`${sel.permCard} button:has-text("允许")`, { timeout: 15000 });
await page.evaluate(() => { const el = document.querySelector(".tl-wrap") ?? document.querySelector("[data-index]")?.parentElement?.parentElement; if (el) el.scrollTop = 0; });
const pillBtn = await page.$("button.tb-pill.wait");
await pillBtn?.click();
await sleep(400);
const inView = await page.evaluate(() => {
const cards = [...document.querySelectorAll(".card.perm")].filter((c) => c.querySelector(".perm-btns"));
const r = cards[0]?.getBoundingClientRect();
return !!r && r.bottom > 0 && r.top < window.innerHeight;
});
await page.click(`${sel.permCard} button:has-text("允许")`);
await waitIdle();
const ok = !live.wait && !live.locked && live.pending === 0 && !reloaded.wait && !reloaded.locked && reloaded.pending === 0 && cancelled && !!pillBtn && inView;
record("场景28 Agent 自己结束了带着授权请求的一轮:不卡等待授权;等待授权胶囊可跳到卡片", ok,
JSON.stringify({ live, reloaded, cancelled, pillBtn: !!pillBtn, inView }));
}
async function main() {
await setup();
try {
await newProjectFlow();
// E2E_ONLY_13=1 runs just the 1.3 scenarios (20–27) and the console-error check
const all = [scenario2, scenario3, scenario4, scenario5, scenario6, scenario7, scenario8, scenario9, scenario10, scenario11,
scenario12, scenario13, scenario14, scenario15, scenario16, scenario17, scenario18, scenario20, scenario21, scenario22, scenario23, scenario24, scenario25, scenario26, scenario27, scenario19];
const only13 = new Set([scenario20, scenario21, scenario22, scenario23, scenario24, scenario25, scenario26, scenario27, scenario19]);
scenario12, scenario13, scenario14, scenario15, scenario16, scenario17, scenario18, scenario20, scenario21, scenario22, scenario23, scenario24, scenario25, scenario26, scenario27, scenario28, scenario19];
const only13 = new Set([scenario20, scenario21, scenario22, scenario23, scenario24, scenario25, scenario26, scenario27, scenario28, scenario19]);
for (const f of all) if (!process.env.E2E_ONLY_13 || only13.has(f)) await f();
} catch (e) {
record("中途异常", false, String(e?.message ?? e).slice(0, 600) + " ||daemon:" + daemonErr.slice(-4).join("|").slice(0, 400));