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
@@ -1,13 +1,13 @@
// Current conversation timeline: threads.get snapshot + thread:<id> channel increments → DisplayItem[].
import { create } from "zustand";
import type { TimelineEvent } from "../timeline/types";
import { applyEvent, newTimelineState, reduceTimeline, type DisplayItem } from "../timeline/reducer";
import { applyEvent, newTimelineState, pendingRequests, reduceTimeline, type DisplayItem } from "../timeline/reducer";
import { ws } from "../main";
import type { SlashCommand } from "../composer/slashMenu";
import { Outbox, newClientId, withOutbox, type SendDisplay, type SendPayload } from "../timeline/outbox";
export type QueueItem = { id: string; text: string; attachments?: { path: string; mime: string }[] };
export type PendingReq = { requestId: string; kind: "permission" | "question" };
export type PendingReq = { requestId: string; kind: "permission" | "question"; key?: string };
type TlStore = {
threadId: string | null;
@@ -92,17 +92,16 @@ export const useTimeline = create<TlStore>((set, get) => {
}
applyEvent(st, ev);
// pending is derived from timeline items (pending permission/question → composer waiting state)
const pending = st.items
.filter((i) => (i.kind === "permission" || i.kind === "question") && i.status === "pending")
.map((i) => ({ requestId: (i as { requestId: string }).requestId, kind: i.kind as "permission" | "question" }));
set({ ...view(threadId), pending });
set({ ...view(threadId), pending: pendingRequests(st.items) });
return;
}
if (data.type === "status" && data.status) {
runtimeStatus = data.status;
if (busyStatus(runtimeStatus) || runtimeStatus === "error" || runtimeStatus === "closed") outbox.busy(threadId);
syncRuntimeFlags();
set(view(threadId));
// Going idle closes the open cards (syncRuntimeFlags): the waiting state follows them, or the top bar would
// keep 等待授权 with no card to click
set({ ...view(threadId), pending: pendingRequests(st.items) });
return;
}
if (data.type === "queue" && data.queue) {
@@ -110,7 +109,8 @@ export const useTimeline = create<TlStore>((set, get) => {
return;
}
if (data.type === "pending" && data.pending) {
set({ pending: data.pending });
// Only requests the timeline shows a live card for
set({ pending: pendingRequests(st.items).filter((p) => data.pending!.some((d) => d.requestId === p.requestId)) });
return;
}
if (data.type === "commands" && data.commands) {
@@ -158,7 +158,9 @@ export const useTimeline = create<TlStore>((set, get) => {
syncRuntimeFlags();
set({
...view(threadId),
queue: g.queue ?? [], pending: g.pending ?? [], lastUserText: r.lastUserText,
// Not g.pending: the daemon's list could hold a request the timeline already closed (a 1.2 daemon kept
// one whose turn had ended). Waiting follows the cards that show buttons.
queue: g.queue ?? [], pending: pendingRequests(st.items), lastUserText: r.lastUserText,
});
// Subscribe only once the snapshot is ready: the server replays events after afterSeq=stSeqMax, joining the snapshot seamlessly
if (get().threadId === threadId) subscribeChannel(threadId);