From 3789394c8592623aea3fe020ece017704595d275 Mon Sep 17 00:00:00 2001 From: yuez Date: Tue, 27 Oct 2026 09:26:36 +0800 Subject: [PATCH] refactor(web): remove the dead right-panel and subagent-preview code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit v0.1.1 replaced both surfaces: the session tray took the right panel's todo/tasks, and the in-place `?sub=` child view took the subagent preview. - delete `features/chat/side-panel.tsx` (nothing imported it since the tray landed) - delete `SubagentModal` and its private helpers (`SUB_BADGE`, `SUB_DOT`, `SubagentEntry`, `parseSubagentLines`, `SUB_ROLES`); the child view builds its timeline from the parent's entries instead of `subagent.read` - drop `chatCommands.readSubagent` (its only caller is gone) - drop the deprecated store slice `PreviewTarget` / `preview` / `setPreview`, including the session-migration re-key and the `PanelTab` alias - drop their exclusive CSS (`.sub-item*`, `.sub-preview*`, `.sub-steer`) and the 6 orphan catalog keys (chat.subagentTitle, chat.preview, chat.previewNote, chat.task, chat.currentSubagents, chat.steerRequired) - tests: remove the two SubagentModal cases and the preview/readSubagent expectations (295 tests, down from 297 — exactly the deleted cases) Verification: typecheck clean, vitest 295/295, vite build green, visual matrix 24/24 clean. --- docs/ui-parity.md | 5 +- web/src/features/chat/commands.ts | 2 - web/src/features/chat/modals.tsx | 232 +---------------------- web/src/features/chat/side-panel.tsx | 268 --------------------------- web/src/features/chat/store.ts | 25 +-- web/src/locales/en.json | 6 - web/src/locales/zh.json | 6 - web/src/styles/pages/chat.css | 51 ----- web/tests/chat.commands.test.tsx | 6 +- web/tests/chat.migration.test.tsx | 4 +- web/tests/chat.modals.test.tsx | 58 +----- web/tests/chat.tree.test.tsx | 2 +- 12 files changed, 12 insertions(+), 653 deletions(-) delete mode 100644 web/src/features/chat/side-panel.tsx diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 99e16f9..3a4d611 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -253,4 +253,7 @@ Chat:`≥1100` 树 280px + 流,`1000–1099` 树 240px,`<1000` 单栏 + - `chat.css` 已清理 v0.1.0 残留(`.tool` 卡片、`.diff` review、队列 chips、stream 固定 68rem/16px 间距、 连接 chip/右 panel 按钮等),样式所有权现在唯一:`tool-*.css` 管工具、`chat-msg.css` 管消息块、 `chat-stream.css` 管阅读列与间距、`chat-composer.css` 管状态条、`chat-tray.css` 管 tray/chips、 - `chat-telemetry.css` 管状态行。旧代码仍留 `side-panel.tsx`(未被引用,可单独删除)。 + `chat-telemetry.css` 管状态行。 +- v0.1.1 前夜的 dead code 已删:`side-panel.tsx`(右 panel)、`SubagentModal`(宽浮层子代理预览, + 由 `?sub=` child view 取代)、store 的 `preview`/`PreviewTarget` 切片、`chatCommands.readSubagent`, + 以及它们独占的 `.sub-item*`/`.sub-preview*`/`.sub-steer` 样式和 6 个孤儿词条。 diff --git a/web/src/features/chat/commands.ts b/web/src/features/chat/commands.ts index c2a7f57..90d8621 100644 --- a/web/src/features/chat/commands.ts +++ b/web/src/features/chat/commands.ts @@ -111,8 +111,6 @@ export const chatCommands = { steerSubagent: (sessionId: string, target: string, message: string): ChatCommand => command("subagent.steer", sessionId, { target, message }), - readSubagent: (sessionId: string, target: string): ChatCommand => - command("subagent.read", sessionId, { target }), stopTask: (sessionId: string, taskId: string): ChatCommand => command("task.stop", sessionId, { taskId }), diff --git a/web/src/features/chat/modals.tsx b/web/src/features/chat/modals.tsx index 5f2b47f..e8afd8d 100644 --- a/web/src/features/chat/modals.tsx +++ b/web/src/features/chat/modals.tsx @@ -1,21 +1,17 @@ -import type { ModelRef, SessionState, Subagent, TaskItem, ThinkingLevel } from "@protocol/types"; -import { useEffect, useMemo, useState } from "react"; +import type { ModelRef, SessionState, TaskItem, ThinkingLevel } from "@protocol/types"; +import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; -import { RelativeTime } from "@/components/shared/relative-time"; -import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Modal } from "@/components/ui/dialog"; import { KV } from "@/components/ui/kv"; import { Spinner } from "@/components/ui/spinner"; import { toast } from "@/components/ui/toast"; import { ApiError, errorI18nKey } from "@/lib/api"; -import { cn } from "@/lib/utils"; import { chatCommands, runCommand } from "./commands"; import type { ModelGroup } from "./data"; import { withCurrentModel } from "./data"; import { formatDuration, THINKING_LEVELS } from "./format"; -import { flattenSubagents } from "./session-state"; function rec(value: unknown): Record | undefined { return value && typeof value === "object" && !Array.isArray(value) ? (value as Record) : undefined; @@ -195,230 +191,6 @@ export function DispatchModal({ open, session, models, onClose, onDispatch }: Di ); } -/* ------------------------------------------------------------------ */ -/* subagent conversation (read-only tail + steer) */ -/* ------------------------------------------------------------------ */ - -const SUB_BADGE: Record = { - active: { tone: "info", key: "active" }, - completed: { tone: "ok", key: "completed" }, - failed: { tone: "err", key: "failed" }, - interrupted: { tone: "warn", key: "interrupted" }, - dormant: { tone: "default", key: "dormant" }, -}; - -const SUB_DOT: Record = { - active: "dot--busy", - completed: "dot--ok", - failed: "dot--err", - interrupted: "dot--attention", - dormant: "dot--exited", -}; - -/** - * One projected line of a sub-session file. - * - * `subagent.read` returns `{sessionFile, lines}` where each line is the plugin's - * text projection of a raw pi entry (`"[12] user: please fix it"`, see - * `pi.subsessions.read.project_entry`). - */ -export interface SubagentEntry { - id: string; - role: string; - text: string; -} - -const SUB_ROLES = new Set(["user", "assistant", "system", "notice", "toolResult", "toolUse"]); - -/** Parse `[] : ` back into role + text rows. */ -export function parseSubagentLines(lines: unknown): SubagentEntry[] { - if (!Array.isArray(lines)) return []; - const out: SubagentEntry[] = []; - lines.forEach((value, position) => { - const line = typeof value === "string" ? value : JSON.stringify(value); - if (!line) return; - const match = /^\[(\d+)\]\s*([A-Za-z_]+):\s?([\s\S]*)$/.exec(line); - if (match && SUB_ROLES.has(match[2] ?? "")) { - out.push({ id: `sub-${match[1]}`, role: match[2] ?? "system", text: match[3] ?? "" }); - return; - } - out.push({ id: `sub-line-${position}`, role: "system", text: line }); - }); - return out; -} - -export interface SubagentModalProps { - open: boolean; - session: SessionState; - subagent: Subagent | null; - onClose: () => void; - onBack: () => void; - onSteer: (subagent: Subagent, message: string) => void; -} - -export function SubagentModal({ open, session, subagent, onClose, onBack, onSteer }: SubagentModalProps) { - const { t } = useTranslation(); - const [steer, setSteer] = useState(""); - const [feed, setFeed] = useState([]); - const [sessionFile, setSessionFile] = useState(null); - const [error, setError] = useState(null); - const [loading, setLoading] = useState(false); - const badge = subagent ? (SUB_BADGE[subagent.status] ?? { tone: "default" as const, key: subagent.status }) : null; - - useEffect(() => { - if (!open || !subagent) return; - let cancelled = false; - setFeed([]); - setSessionFile(null); - setError(null); - setLoading(true); - const target = subagent.name ?? subagent.id; - void runCommand(chatCommands.readSubagent(session.sessionId, target)) - .then((response) => { - if (cancelled) return; - const raw = rec(response) ?? {}; - setSessionFile(str(raw.sessionFile) ?? null); - setFeed(parseSubagentLines(raw.lines ?? raw.entries)); - }) - .catch((cause: unknown) => { - if (cancelled) return; - setError(commandErrorText(cause, t)); - }) - .finally(() => { - if (!cancelled) setLoading(false); - }); - return () => { - cancelled = true; - }; - }, [open, session.sessionId, subagent, t]); - - const children = useMemo(() => (subagent ? flattenSubagents(subagent.children) : []), [subagent]); - - function sendSteer() { - if (!steer.trim()) { - toast.error(t("chat.steerRequired")); - return; - } - if (subagent) onSteer(subagent, steer.trim()); - setSteer(""); - } - - return ( - { - if (!next) onClose(); - }} - title={t("chat.subagentTitle", { name: subagent?.name ?? subagent?.id ?? "" })} - size="wide" - footer={ - <> - - - - } - > - {subagent ? ( -
-
- - {badge ? {t(`state.${badge.key}`)} : null} - {subagent.id} -
-
- {subagent.task ?? "—"} - - {subagent.model ?? "—"} - {subagent.thinking ? ` · ${subagent.thinking}` : ""} - - - - - - - -
- {children.length ? ( -
-
{t("chat.currentSubagents", { n: children.length })}
- {children.map(({ subagent: child, depth }) => ( -
- - - {child.name ?? child.id} - {child.model ?? "—"} - -
- ))} -
- ) : null} -
- {loading ? ( -
- {t("chat.loading")} -
- ) : error ? ( -
-
- {t("chat.error")} -
-
{error}
-
- ) : feed.length ? ( - feed.map((entry) => ( -
-
- - {entry.role} - - {entry.id} -
-
{entry.text}
-
- )) - ) : ( -
{t("chat.noOutput")}
- )} -
- {sessionFile ?
{sessionFile}
: null} -
{t("chat.previewNote")}
-
- setSteer(event.target.value)} - onKeyDown={(event) => { - if (event.key === "Enter" && !event.nativeEvent.isComposing) { - event.preventDefault(); - sendSteer(); - } - }} - /> - -
-
- ) : null} -
- ); -} - /* ------------------------------------------------------------------ */ /* task output */ /* ------------------------------------------------------------------ */ diff --git a/web/src/features/chat/side-panel.tsx b/web/src/features/chat/side-panel.tsx deleted file mode 100644 index 884f4b1..0000000 --- a/web/src/features/chat/side-panel.tsx +++ /dev/null @@ -1,268 +0,0 @@ -/** - * @deprecated v0.1.1 Chat IA v3 — the right panel is gone. Subagents live in the - * session tree / child view, and Todo + Tasks moved to the anchored session tray - * (`./session-tray.tsx`, triggered by the stream-head chips). This file is kept - * only because it still typechecks against the store and other pages may import - * it; nothing in the Chat page renders it any more. Delete once no importer - * remains. - */ -import type { SessionState, Subagent, TaskItem } from "@protocol/types"; -import { useTranslation } from "react-i18next"; - -import { Icon } from "@/components/icons"; -import { Badge, type BadgeProps } from "@/components/ui/badge"; -import { Empty } from "@/components/ui/empty"; -import { Progress } from "@/components/ui/progress"; -import { Spinner } from "@/components/ui/spinner"; -import { StatusDot } from "@/components/ui/status-dot"; -import { cn } from "@/lib/utils"; -import { TodoList } from "./blocks"; -import { formatDuration } from "./format"; -import { flattenSubagents } from "./session-state"; -import type { PanelTab } from "./store"; - -const SUB_BADGE: Record = { - active: { tone: "info", label: "active" }, - completed: { tone: "ok", label: "completed" }, - failed: { tone: "err", label: "failed" }, - interrupted: { tone: "warn", label: "interrupted" }, - dormant: { tone: "default", label: "dormant" }, -}; - -function subagentStatus(status: Subagent["status"]) { - return SUB_BADGE[status] ?? { tone: "default" as const, label: status }; -} - -function taskDot(status: TaskItem["status"]): "busy" | "ok" | "err" | "idle" { - if (status === "running") return "busy"; - if (status === "completed") return "ok"; - if (status === "failed") return "err"; - return "idle"; -} - -export interface SidePanelProps { - session: SessionState; - /** Legacy three-tab vocabulary; the deprecated `subagents` tab is still accepted. */ - tab: PanelTab | "subagents"; - onTab: (tab: PanelTab | "subagents") => void; - onDispatch: () => void; - onOpenSubagent: (subagent: Subagent) => void; - onOpenTask: (task: TaskItem) => void; - onStopTask: (task: TaskItem) => void; - onCloseDrawer?: () => void; - className?: string; -} - -/** Right panel: Subagents / Todo / Tasks (tabs + counts + empty states). */ -export function SidePanel({ - session, - tab, - onTab, - onDispatch, - onOpenSubagent, - onOpenTask, - onStopTask, - onCloseDrawer, - className, -}: SidePanelProps) { - const { t } = useTranslation(); - const subagents = flattenSubagents(session.subagents); - const tasks = session.tasks; - const tabs: { id: PanelTab | "subagents"; label: string; count: number }[] = [ - { id: "subagents", label: t("chat.tabSubagents"), count: subagents.length }, - { id: "todo", label: t("chat.tabTodo"), count: session.todos.length }, - { id: "tasks", label: t("chat.tabTasks"), count: tasks.length }, - ]; - - return ( -
-
- {tabs.map((item) => ( - - ))} -
- {onCloseDrawer ? ( - - ) : null} -
-
-
- {tab === "subagents" ? ( - <> -
- - {t("chat.currentSubagents", { n: subagents.length })} - - -
- {subagents.length ? ( -
- {subagents.map(({ subagent, depth }) => { - const badge = subagentStatus(subagent.status); - return ( -
0 && "sub-item--nested")} - style={depth ? { marginLeft: `${depth * 16}px` } : undefined} - role="button" - tabIndex={0} - onClick={() => onOpenSubagent(subagent)} - onKeyDown={(event) => { - if (event.key === "Enter" || event.key === " ") { - event.preventDefault(); - onOpenSubagent(subagent); - } - }} - > - - - {subagent.name ?? subagent.id} - - - {subagent.model ?? "—"} - {subagent.thinking ? ` · ${subagent.thinking}` : ""} - - - {t(`state.${badge.label}`)} -
- ); - })} -
- ) : ( - } - title={t("chat.noSubagents")} - description={t("chat.noSubagentsText")} - /> - )} - - ) : null} - - {tab === "todo" ? ( - session.todos.length ? ( - <> -
- - {t("chat.progress", { - done: session.todos.filter((item) => item.status === "completed").length, - total: session.todos.length, - })} - - {t("common.readonly")} -
- item.status === "completed").length} - max={session.todos.length || 1} - /> - -
{t("chat.todoNote")}
- - ) : ( - } - title={t("chat.noTodo")} - description={t("chat.noTodoText")} - /> - ) - ) : null} - - {tab === "tasks" ? ( - tasks.length ? ( - tasks.map((task) => { - const running = task.status === "running"; - const duration = running ? Date.now() - task.startTime : (task.durationMs ?? 0); - return ( -
onOpenTask(task)} - onKeyDown={(event) => { - if (event.key === "Enter" || event.key === " ") { - event.preventDefault(); - onOpenTask(task); - } - }} - > - - - - {task.command} - - - {running ? : null} - {formatDuration(duration)} - {task.exitCode != null ? ( - - {`exit ${task.exitCode}`} - - ) : ( - {t(`state.${task.status}`)} - )} - - - {running ? ( - - ) : null} -
- ); - }) - ) : ( - } - title={t("chat.noTasks")} - description={t("chat.noTasksText")} - /> - ) - ) : null} -
-
-
- ); -} diff --git a/web/src/features/chat/store.ts b/web/src/features/chat/store.ts index b0eee1e..1792481 100644 --- a/web/src/features/chat/store.ts +++ b/web/src/features/chat/store.ts @@ -11,12 +11,6 @@ import { prependUnique } from "@/lib/entry-projection"; */ export type TrayTab = "todo" | "tasks"; -/** - * @deprecated v0.1.1 IA: the right panel is gone. Kept as an alias so callers - * written against the panel still typecheck while they migrate to `TrayTab`. - */ -export type PanelTab = TrayTab; - /** localStorage key for the IA "active only" filter (default on). */ export const ACTIVE_ONLY_KEY = "pi2-active-only"; @@ -69,16 +63,6 @@ export const EMPTY_HISTORY: HistoryState = { resyncToken: 0, }; -/** - * @deprecated v0.1.1 replaced the "subagent preview modal" with the in-place - * child view (`?sub=` + `activeSubagentId`). The field is kept because the - * session-id migration still re-keys it; the UI no longer reads it. - */ -export interface PreviewTarget { - sessionId: string; - subagentId: string; -} - export interface ChatStore { history: Record; /** Active tray tab (`todo` / `tasks`). */ @@ -103,8 +87,6 @@ export interface ChatStore { wsMenuOpen: boolean; sending: { sessionId: string; text: string } | null; attachments: Attachment[]; - /** @deprecated see `PreviewTarget`. */ - preview: PreviewTarget | null; taskOutput: TaskItem | null; dispatchOpen: boolean; @@ -129,8 +111,6 @@ export interface ChatStore { addAttachment: (attachment: Attachment) => void; removeAttachment: (id: string) => void; clearAttachments: () => void; - /** @deprecated see `PreviewTarget`. */ - setPreview: (preview: PreviewTarget | null) => void; setTaskOutput: (task: TaskItem | null) => void; setDispatchOpen: (open: boolean) => void; @@ -144,7 +124,7 @@ export interface ChatStore { /** * Re-key every per-session slice after the plugin migrates `tmp-N` → the * real id: history (so an in-flight prompt and its page are not lost), - * the optimistic `sending` chip and the (deprecated) preview target. + * and the optimistic `sending` chip. */ migrateSession: (from: string, to: string) => void; } @@ -172,7 +152,6 @@ export const useChatStore = create((set) => ({ wsMenuOpen: false, sending: null, attachments: [], - preview: null, taskOutput: null, dispatchOpen: false, @@ -211,7 +190,6 @@ export const useChatStore = create((set) => ({ addAttachment: (attachment) => set((state) => ({ attachments: [...state.attachments, attachment] })), removeAttachment: (id) => set((state) => ({ attachments: state.attachments.filter((item) => item.id !== id) })), clearAttachments: () => set({ attachments: [] }), - setPreview: (preview) => set({ preview }), setTaskOutput: (taskOutput) => set({ taskOutput }), setDispatchOpen: (dispatchOpen) => set({ dispatchOpen }), @@ -281,7 +259,6 @@ export const useChatStore = create((set) => ({ return { history, sending: state.sending?.sessionId === from ? { ...state.sending, sessionId: to } : state.sending, - preview: state.preview?.sessionId === from ? { ...state.preview, sessionId: to } : state.preview, }; }), })); diff --git a/web/src/locales/en.json b/web/src/locales/en.json index d64a986..3c7cfec 100644 --- a/web/src/locales/en.json +++ b/web/src/locales/en.json @@ -39,7 +39,6 @@ "chat.composerAria": "Message input", "chat.composerPlaceholder": "Message pi2…", "chat.contextUsage": "Context usage {used} of {window}", - "chat.currentSubagents": "Subagents in this session · {n}", "chat.denied": "Request denied", "chat.deny": "Deny", "chat.details": "Arguments", @@ -172,8 +171,6 @@ "chat.plan.snapshot": "Snapshot {time}", "chat.plan.title": "Plan", "chat.planAria": "View the todo plan", - "chat.preview": "Read-only preview", - "chat.previewNote": "Read-only preview · subagent messages are not written to the parent session", "chat.previewRunning": "Running…", "chat.previewSubagent": "Preview subagent", "chat.progress": "Progress {done}/{total}", @@ -229,7 +226,6 @@ "chat.steer": "Steer", "chat.steerMode": "Steering mode: {mode}", "chat.steerPlaceholder": "Send a steer instruction to this subagent…", - "chat.steerRequired": "Enter a steer instruction", "chat.steerSent": "Steer sent: {text}", "chat.stopTask": "Stop task", "chat.stopTaskText": "Stop background task \"{command}\"?", @@ -261,7 +257,6 @@ "chat.subagentFilter": "Subagent filter", "chat.subagentName": "Subagent name", "chat.subagentNamePlaceholder": "e.g. ui-research", - "chat.subagentTitle": "Subagent · {name}", "chat.subview.back": "Parent", "chat.subview.backTo": "Back to {name}", "chat.subview.copyId": "Copy subagent ID", @@ -282,7 +277,6 @@ "chat.tabSubagents": "Subagents", "chat.tabTasks": "Tasks", "chat.tabTodo": "Todo", - "chat.task": "Task", "chat.taskExitCode": "Exit code", "chat.taskLabel": "Task *", "chat.taskOutput": "Task output · {id}", diff --git a/web/src/locales/zh.json b/web/src/locales/zh.json index e7c2a00..1462788 100644 --- a/web/src/locales/zh.json +++ b/web/src/locales/zh.json @@ -39,7 +39,6 @@ "chat.composerAria": "输入消息", "chat.composerPlaceholder": "给 pi2 发消息…", "chat.contextUsage": "上下文占用 {used} / {window}", - "chat.currentSubagents": "当前 session 的子代理 · {n}", "chat.denied": "已拒绝该请求", "chat.deny": "拒绝", "chat.details": "参数详情", @@ -172,8 +171,6 @@ "chat.plan.snapshot": "快照 {time}", "chat.plan.title": "计划", "chat.planAria": "查看待办计划", - "chat.preview": "只读预览", - "chat.previewNote": "只读预览 · 子代理对话不会写入父会话", "chat.previewRunning": "正在执行…", "chat.previewSubagent": "预览子代理", "chat.progress": "进度 {done}/{total}", @@ -229,7 +226,6 @@ "chat.steer": "Steer", "chat.steerMode": "转向模式:{mode}", "chat.steerPlaceholder": "发送 steer 指令给该子代理…", - "chat.steerRequired": "请输入 steer 指令", "chat.steerSent": "已发送 steer 指令:{text}", "chat.stopTask": "停止任务", "chat.stopTaskText": "确认停止后台任务「{command}」?", @@ -261,7 +257,6 @@ "chat.subagentFilter": "子代理筛选", "chat.subagentName": "子代理名称", "chat.subagentNamePlaceholder": "例如 ui-research", - "chat.subagentTitle": "子代理 · {name}", "chat.subview.back": "父级", "chat.subview.backTo": "返回 {name}", "chat.subview.copyId": "复制子代理 ID", @@ -282,7 +277,6 @@ "chat.tabSubagents": "子代理", "chat.tabTasks": "任务", "chat.tabTodo": "待办", - "chat.task": "任务", "chat.taskExitCode": "退出码", "chat.taskLabel": "任务 task *", "chat.taskOutput": "任务输出 · {id}", diff --git a/web/src/styles/pages/chat.css b/web/src/styles/pages/chat.css index af83e3d..22a9dad 100644 --- a/web/src/styles/pages/chat.css +++ b/web/src/styles/pages/chat.css @@ -935,33 +935,6 @@ color: var(--warn); } -/* ---------- right panel: removed in v0.1.1(tray 取代;仅保留子代理条目样式) ---------- */ -.sub-item { - display: flex; - align-items: center; - gap: var(--space-2); - padding: var(--space-2); - border-radius: var(--radius); - cursor: pointer; - transition: background 0.15s ease; -} -.sub-item:hover { - background: var(--accent); -} -.sub-item__main { - flex: 1; - min-width: 0; - display: flex; - flex-direction: column; -} -.sub-item__name { - font-size: 0.875rem; - font-weight: 550; -} -.sub-item__meta { - font-size: 0.6875rem; -} - /* ---------- drawers(仅 <1000:会话树是抽屉) ---------- */ .drawer-backdrop { position: fixed; @@ -1085,30 +1058,6 @@ } } -/* ---------- subagent preview modal ---------- */ -.sub-preview { - display: flex; - flex-direction: column; - gap: var(--space-3); -} -.sub-preview__feed { - display: flex; - flex-direction: column; - gap: var(--space-3); - max-height: 38dvh; - overflow-y: auto; - padding: var(--space-3); - border-radius: var(--radius); - background: var(--background); - border: 1px solid var(--border); -} -.sub-preview__note { - font-size: 0.6875rem; -} -.sub-steer { - gap: var(--space-2); -} - /* ---------- attachment / dispatch ---------- */ .drop-zone { display: flex; diff --git a/web/tests/chat.commands.test.tsx b/web/tests/chat.commands.test.tsx index 45c5224..ca85d21 100644 --- a/web/tests/chat.commands.test.tsx +++ b/web/tests/chat.commands.test.tsx @@ -121,11 +121,7 @@ describe("chat command payloads", () => { }); }); - it("reads sub-sessions and task output by id", () => { - expect(chatCommands.readSubagent("s1", "researcher")).toMatchObject({ - method: "subagent.read", - params: { target: "researcher" }, - }); + it("reads task output by id", () => { expect(chatCommands.stopTask("s1", "t1")).toMatchObject({ method: "task.stop", params: { taskId: "t1" }, diff --git a/web/tests/chat.migration.test.tsx b/web/tests/chat.migration.test.tsx index fbe676c..1c00bed 100644 --- a/web/tests/chat.migration.test.tsx +++ b/web/tests/chat.migration.test.tsx @@ -9,7 +9,7 @@ import { entryFixture, sessionFixture } from "./chat-fixtures"; beforeEach(() => { useSessionsStore.getState().reset(); - useChatStore.setState({ history: {}, sending: null, preview: null }); + useChatStore.setState({ history: {}, sending: null }); window.history.replaceState(null, "", "/chat"); }); @@ -21,7 +21,6 @@ describe("session id migration (`tmp-N` → real id)", () => { hasMore: true, }); useChatStore.getState().setSending({ sessionId: "tmp-1", text: "hello" }); - useChatStore.getState().setPreview({ sessionId: "tmp-1", subagentId: "sa1" }); window.history.replaceState(null, "", "/chat/tmp-1?workspace=w1"); const seen: string[] = []; @@ -41,7 +40,6 @@ describe("session id migration (`tmp-N` → real id)", () => { expect(useChatStore.getState().history["01a1-real"]?.entries).toHaveLength(1); expect(useChatStore.getState().history["01a1-real"]?.cursor).toEqual({ before: "u1", hasMore: true }); expect(useChatStore.getState().sending).toEqual({ sessionId: "01a1-real", text: "hello" }); - expect(useChatStore.getState().preview).toEqual({ sessionId: "01a1-real", subagentId: "sa1" }); expect(replaceChatUrl("tmp-1", "01a1-real", "w1")).toBe(true); expect(window.location.pathname + window.location.search).toBe("/chat/01a1-real?workspace=w1"); diff --git a/web/tests/chat.modals.test.tsx b/web/tests/chat.modals.test.tsx index c368574..b28e499 100644 --- a/web/tests/chat.modals.test.tsx +++ b/web/tests/chat.modals.test.tsx @@ -1,10 +1,10 @@ import { render, screen } from "@testing-library/react"; import { afterEach, beforeAll, describe, expect, it, vi } from "vitest"; -import { SubagentModal, TaskOutputModal } from "@/features/chat/modals"; +import { TaskOutputModal } from "@/features/chat/modals"; import { setLanguage } from "@/lib/i18n"; -import { sessionFixture, subagentFixture, taskFixture, taskOutputFixture } from "./chat-fixtures"; +import { sessionFixture, taskFixture, taskOutputFixture } from "./chat-fixtures"; import { mockApi } from "./helpers/api-mock"; beforeAll(async () => { @@ -78,57 +78,3 @@ describe("task output modal", () => { expect(screen.queryByText("(no output)")).not.toBeInTheDocument(); }); }); - -describe("subagent preview modal", () => { - it("renders the raw pi entries from subagent.read (sessionFile + lines)", async () => { - mockCommands({ - "subagent.read": { - status: 202, - body: { - sessionFile: "/tmp/pi2-subsessions/researcher.jsonl", - lines: ["[1] user: fix the auth flow", "[2] assistant: looking at it now", "[3] tool result: ok"], - }, - }, - }); - - render( - , - ); - - expect(await screen.findByText("fix the auth flow")).toBeInTheDocument(); - expect(screen.getByText("looking at it now")).toBeInTheDocument(); - expect(screen.getByText("/tmp/pi2-subsessions/researcher.jsonl")).toBeInTheDocument(); - expect(screen.getByText("fix the auth flow").closest("article")).toHaveAttribute("data-role", "user"); - expect(screen.getByText("looking at it now").closest("article")).toHaveAttribute("data-role", "assistant"); - // No synthetic "preview" copy. - expect(screen.queryByText(/Got it\. I'll run with/)).not.toBeInTheDocument(); - }); - - it("shows an error state when the sub-session cannot be read", async () => { - mockCommands({ - "subagent.read": { - status: 404, - body: { error: { code: "E_NOT_FOUND", message: "unknown sub-agent session file", retryable: false } }, - }, - }); - render( - , - ); - - expect(await screen.findByRole("alert")).toHaveTextContent("Not found"); - }); -}); diff --git a/web/tests/chat.tree.test.tsx b/web/tests/chat.tree.test.tsx index 5e2ef44..d3fe5cf 100644 --- a/web/tests/chat.tree.test.tsx +++ b/web/tests/chat.tree.test.tsx @@ -571,7 +571,7 @@ function requestedUrls(fetchMock: ReturnType): string[] { describe("chat session deep link", () => { beforeEach(() => { useSessionsStore.getState().reset(); - useChatStore.setState({ history: {}, sending: null, preview: null }); + useChatStore.setState({ history: {}, sending: null }); silentSocket(); });