Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

feat(web): the process list clears every exited process in one click, and a long command reads whole on hover (#782)

Yaowei Zheng8a9a7f192b98
diff --git a/changelog/unreleased/2026-09-17-process-list-clear-exited.md b/changelog/unreleased/2026-09-17-process-list-clear-exited.md
new file mode 100644
index 00000000..2656e611
--- /dev/null
+++ b/changelog/unreleased/2026-09-17-process-list-clear-exited.md
@@ -0,0 +1,28 @@
+# The process list clears every exited process in one click, and shows a long command whole on hover
+
+- **Date:** 2026-09-17
+- **Type:** feature
+- **Scope:** `web`
+- **PR:** [#782](https://github.com/Prism-Shadow/penguin-harness/pull/782)
+
+[中文版](2026-09-17-process-list-clear-exited.zh.md)
+
+The **Processes** list in a conversation's details card gained a one-click action that removes
+every exited process, and a command too long for its row became readable by hovering it.
+
+## Details
+
+- While at least one listed process has exited, the list heading shows a text action, **Clear
+ exited**: small gray text that darkens on hover, with no background or border. Its hover hint
+ notes that the output captured from those processes is discarded too. One click removes every
+ exited entry, with no confirmation step. It sends each entry's own
+ Remove request, the same route as a row's **Remove** button, so running processes are never
+ touched. An entry that has already gone, or turns out to be still running, is not reported as an
+ error. Any other failure produces one toast for the whole batch, and the list refreshes
+ afterwards.
+- A command cut off by its row now shows whole in a styled tooltip when hovered: monospace, wrapping
+ inside the panel, and kept within the screen. A command that fits its row opens no tooltip. The
+ row no longer carries a native `title`.
+- The shared `Tooltip` gained a `code` content kind for such text, and caps every panel's width at
+ the room left on screen on the side it grows toward. `Truncated` gained a `codeTooltip` option
+ that discloses a clipped tail through that panel instead of a native `title`.
diff --git a/changelog/unreleased/2026-09-17-process-list-clear-exited.zh.md b/changelog/unreleased/2026-09-17-process-list-clear-exited.zh.md
new file mode 100644
index 00000000..c563ae25
--- /dev/null
+++ b/changelog/unreleased/2026-09-17-process-list-clear-exited.zh.md
@@ -0,0 +1,21 @@
+# 会话进程列表一键清除已退出的进程,悬停显示完整的长命令
+
+- **Date:** 2026-09-17
+- **Type:** feature
+- **Scope:** `web`
+- **PR:** [#782](https://github.com/Prism-Shadow/penguin-harness/pull/782)
+
+[English](2026-09-17-process-list-clear-exited.md)
+
+对话详情卡中的**会话进程**列表新增一键移除所有已退出进程的操作;超出行宽的命令,悬停即可读到全文。
+
+## 细节
+
+- 列表中至少有一个进程已退出时,列表标题右侧显示文字操作「清除已退出」:灰色小字,悬停时加深,无背景、
+ 无边框;其悬停提示注明这些进程已捕获的输出也会一并丢弃。点击一次即移除全部已退出条目,无确认步骤。它为每个条目各发一次移除请求,与逐行
+ 「移除」按钮走同一接口,因此运行中的进程不受影响。条目已不存在或实际仍在运行时不作为错误提示;其他失败
+ 整批只弹出一条提示,之后列表随即刷新。
+- 被行宽截断的命令,悬停时以样式化浮层显示全文:等宽字、在浮层内折行、不超出屏幕。行内放得下的命令不弹出
+ 浮层。该行不再带原生 `title`。
+- 共享的 `Tooltip` 为这类文本新增 `code` 内容类型,并按面板伸展方向上剩余的屏幕空间限制所有浮层的宽度。
+ `Truncated` 新增 `codeTooltip` 选项,以该浮层而非原生 `title` 显示被截断的尾部。
diff --git a/packages/web/e2e/background-notify.spec.mjs b/packages/web/e2e/background-notify.spec.mjs
index ac760f37..b53b7a9e 100644
--- a/packages/web/e2e/background-notify.spec.mjs
+++ b/packages/web/e2e/background-notify.spec.mjs
@@ -56,10 +56,10 @@ test("a run_in_background completion reaches the open chat page unprompted", asy
timeout: 30_000,
});
- // The launched command is a normal background process: the header stats show a running
- // service (same registry as the promoted-past-yield path).
+ // The launched command is a normal background process: the header stats show a background
+ // task (same registry as the promoted-past-yield path).
const detailsBtn = page.locator('button[title="Session 信息"]');
- await expect(detailsBtn.locator('span[title="1 个运行中的服务"]')).toBeVisible({
+ await expect(detailsBtn.locator('span[title="1 个后台任务"]')).toBeVisible({
timeout: 10_000,
});
diff --git a/packages/web/e2e/mock-llm.mjs b/packages/web/e2e/mock-llm.mjs
index 0507debd..5798713d 100644
--- a/packages/web/e2e/mock-llm.mjs
+++ b/packages/web/e2e/mock-llm.mjs
@@ -16,6 +16,9 @@
* - "background exit test" -> tool_use(exec_command) whose command outlives the yield
* window but exits on its own shortly after (processes.spec: the exited row can be
* removed from the process list)
+ * - "background pair test" -> two tool_use(exec_command) in one turn: one that stays up and
+ * one with a long command line that exits shortly after its yield window (processes.spec:
+ * "clear exited" removes only the exited row; hovering the long command shows it whole)
* - "slow stream test" -> tool_use(exec_command) with a command that prints one line
* every 200ms for ~8s (reload-midstream.spec reloads while its output streams)
* - "slow text test" -> a long text streamed one delta every 200ms for ~8s
@@ -27,6 +30,9 @@ import http from "node:http";
/** The run_subagent prompt; also the marker the mock uses to detect "this is the child session's own request". */
const SUBAGENT_PROMPT = "Count the TODO items in the repository";
+/** The long tail of the "background pair test" exited command (processes.spec hovers the row and expects this whole line in the tooltip). */
+const PAIR_LONG_ECHO =
+ "the-exited-process-whose-command-line-runs-far-past-the-width-of-its-row-in-the-details-card";
/** Background-subagent FAILURE prompt: the child session's every request is rejected 400, so its run fails after the retry ladder. */
const SUBAGENT_FAIL_PROMPT = "Fail the TODO count on purpose";
@@ -425,6 +431,27 @@ const server = http.createServer((req, res) => {
return;
}
+ // A running and an exited background process side by side (processes.spec: the list's
+ // "clear exited" action removes the exited row and leaves the running one). Two calls in
+ // one turn, both past their 300ms yield window: a long sleep that stays up, and a short
+ // one that exits ~200ms later — with a command line too long for its row, so the same
+ // spec can hover it and read the whole command in the tooltip.
+ if (flat.includes("background pair test") && !hasToolResult) {
+ block(res, 0, { type: "tool_use", id: "toolu_bgpair_1", name: "exec_command", input: {} }, [
+ { type: "input_json_delta", partial_json: '{"cmd": "sleep 600",' },
+ { type: "input_json_delta", partial_json: ' "yield_time_ms": 300}' },
+ ]);
+ block(res, 1, { type: "tool_use", id: "toolu_bgpair_2", name: "exec_command", input: {} }, [
+ {
+ type: "input_json_delta",
+ partial_json: `{"cmd": "sleep 0.5 && echo ${PAIR_LONG_ECHO}",`,
+ },
+ { type: "input_json_delta", partial_json: ' "yield_time_ms": 300}' },
+ ]);
+ messageStop(res, "tool_use", 28);
+ return;
+ }
+
// Slow tool-output test case (reload-midstream.spec): a real exec_command whose output
// streams one line every 200ms for ~8s — long enough to reload the page mid-stream and
// watch the output keep growing afterwards.
diff --git a/packages/web/e2e/processes.spec.mjs b/packages/web/e2e/processes.spec.mjs
index 4c111c61..eb3a9906 100644
--- a/packages/web/e2e/processes.spec.mjs
+++ b/packages/web/e2e/processes.spec.mjs
@@ -1,11 +1,13 @@
/**
* Session background-process list (details popover):
* a task whose exec_command outlives its yield window becomes a background process —
- * the header's stats trigger gains a running-services count, the details card lists the
+ * the header's stats trigger gains a background-task count, the details card lists the
* process (cmd + pid + start time) with a stop button, stopping it clears both, and the
* card's other rows (model / workspace / created / per-line stats) render in their
* new layout. The mock's "background server test" branch drives it
- * (`sleep 600` with a 300ms yield — see mock-llm.mjs).
+ * (`sleep 600` with a 300ms yield — see mock-llm.mjs). An exited row can be removed on its
+ * own, or together with every other exited row from the list heading, and a command too long
+ * for its row reads whole in the hover tooltip.
*/
import { test, expect } from "@playwright/test";
import { provisionAndLogin } from "./auth.mjs";
@@ -52,9 +54,9 @@ test("background process appears in the details card and can be stopped", async
await page.getByRole("button", { name: "发送" }).click();
// The turn finishes with the command promoted to background: the stats trigger (far
- // right; it doubles as the "Session 信息" details button) gains the services count.
+ // right; it doubles as the "Session 信息" details button) gains the background-task count.
const detailsBtn = page.locator('button[title="Session 信息"]');
- await expect(detailsBtn.locator('span[title="1 个运行中的服务"]')).toBeVisible({
+ await expect(detailsBtn.locator('span[title="1 个后台任务"]')).toBeVisible({
timeout: 30_000,
});
@@ -80,7 +82,7 @@ test("background process appears in the details card and can be stopped", async
// The kill drops the process from the registry: the row disappears on the follow-up
// refresh and the header count goes with it.
await expect(page.getByText("会话进程")).toHaveCount(0, { timeout: 10_000 });
- await expect(detailsBtn.locator('span[title="1 个运行中的服务"]')).toHaveCount(0);
+ await expect(detailsBtn.locator('span[title="1 个后台任务"]')).toHaveCount(0);
// The server-side list agrees (the registry entry is gone, not merely marked exited).
const procs = await (
@@ -146,3 +148,78 @@ test("an exited process can be removed from the list", async ({ page }) => {
).json();
expect(procs.processes).toEqual([]);
});
+
+test("clear exited removes every exited process and leaves the running one", async ({ page }) => {
+ await provisionAndLogin(page.request, U, P);
+
+ const projects = await (await page.request.get(`${BASE}/api/projects`)).json();
+ const projectId = projects.projects[0].projectId;
+ // Same idempotent model setup as the tests above, so this test can be rerun on its own.
+ const put = await page.request.put(`${BASE}/api/projects/${projectId}/models`, {
+ data: {
+ defaultModel: { provider: "custom", modelId: "claude-4-8" },
+ models: [
+ {
+ provider: "custom",
+ modelId: "claude-4-8",
+ apiKey: "sk-mock",
+ baseUrl: MOCK,
+ contextWindow: 200000,
+ pricing: { cacheRead: 1, cacheWrite: 5, output: 10 },
+ },
+ ],
+ },
+ });
+ expect(put.ok(), "put models").toBeTruthy();
+
+ const sess = await (
+ await page.request.post(`${BASE}/api/projects/${projectId}/agents/default_agent/sessions`, {
+ data: { provider: "custom", modelId: "claude-4-8", approvalMode: "allow-all" },
+ })
+ ).json();
+ const sessionId = sess.session.sessionId;
+
+ await page.goto(`${BASE}/chat/${sessionId}`);
+ const ta = page.getByPlaceholder(/输入消息/);
+ await ta.waitFor();
+ // The mock's pair branch: `sleep 600` stays up, and a `sleep 0.5 && echo …` with a long
+ // command line exits shortly after its yield window.
+ await ta.fill("background pair test");
+ await page.getByRole("button", { name: "发送" }).click();
+ await expect(page.getByText(/Command finished/).first()).toBeVisible({ timeout: 30_000 });
+
+ await page.locator('button[title="Session 信息"]').click();
+ await expect(page.getByText("会话进程")).toBeVisible();
+ const running = page.locator("li", { hasText: "sleep 600" }).first();
+ const exited = page.locator("li", { hasText: "sleep 0.5" }).first();
+ await expect(running.getByRole("button", { name: "停止" })).toBeVisible();
+ // Rides out one 15s poll interval in case the idle refresh still saw the process alive.
+ await expect(exited.getByText("已退出")).toBeVisible({ timeout: 30_000 });
+
+ // The exited command is too long for its row: hovering it shows the whole line in the
+ // styled tooltip (mock-llm.mjs PAIR_LONG_ECHO).
+ const longCommand =
+ "sleep 0.5 && echo the-exited-process-whose-command-line-runs-far-past-the-width-of-its-row-in-the-details-card";
+ await exited.getByText(longCommand).hover();
+ await expect(page.getByTestId("tooltip")).toHaveText(longCommand);
+
+ // One click on the list heading's text action removes the exited entry; the running row
+ // stays, and with nothing exited left the action itself goes away. Its hint names what
+ // leaves with the rows.
+ const clearExited = page.getByRole("button", { name: "清除已退出", exact: true });
+ await expect(clearExited).toHaveAttribute("title", /已捕获的输出也会一并丢弃/);
+ await clearExited.click();
+ await expect(page.locator("li", { hasText: "sleep 0.5" })).toHaveCount(0, { timeout: 10_000 });
+ await expect(running).toBeVisible();
+ await expect(clearExited).toHaveCount(0);
+
+ // The server-side list agrees: only the running process is left.
+ const procs = await (
+ await page.request.get(`${BASE}/api/sessions/${sessionId}/processes`)
+ ).json();
+ expect(procs.processes.map((p) => p.cmd)).toEqual(["sleep 600"]);
+
+ // Leave nothing running behind.
+ await running.getByRole("button", { name: "停止" }).click();
+ await expect(page.getByText("会话进程")).toHaveCount(0, { timeout: 10_000 });
+});
diff --git a/packages/web/src/components/ui/tooltip.tsx b/packages/web/src/components/ui/tooltip.tsx
index 6de9e164..ce190535 100644
--- a/packages/web/src/components/ui/tooltip.tsx
+++ b/packages/web/src/components/ui/tooltip.tsx
@@ -1,5 +1,6 @@
/**
- * Hover/focus tooltip for a control whose visible form is an icon alone.
+ * Hover/focus tooltip for a control whose visible form is an icon alone — and for a line of
+ * code a row truncates, whose full text has nowhere else to show (`content="code"`).
*
* What it replaces is the native `title` attribute: that one waits about a second before it
* appears, cannot be styled, and never shows on keyboard focus — so an icon rail labeled
@@ -19,7 +20,8 @@
* Deliberately NOT `role="tooltip"` + `aria-describedby`: its callers label their triggers
* with the same words it shows, and a description repeating the accessible name makes a
* screen reader say the entry twice. The panel is decorative here and hidden from the
- * accessibility tree; the trigger's own `aria-label` stays the one name.
+ * accessibility tree; the trigger's own `aria-label` stays the one name. A truncated line
+ * keeps its whole text in the DOM, so the same holds there.
*
* Dismissal mirrors the portal panel's, minus the parts a hover-driven panel has no use for
* (no outside click, no Esc layer): it closes on pointer leave, on blur, on Escape, on any
@@ -43,16 +45,50 @@ const VIEWPORT_MARGIN = 8;
/** Which side of its trigger the panel hangs off. */
export type TooltipPlacement = "right" | "bottom";
+/**
+ * What the panel holds, which decides how it sets its text and how wide it may grow.
+ *
+ * - `label`: a control's name — a few words, capped narrow.
+ * - `code`: a line of code its row truncated (a background process's command). Monospace like
+ * the row it stands for, and wider, because it is read rather than glanced at. It breaks
+ * anywhere — a path or a run of flags has no space to wrap at — and keeps its own line
+ * breaks, so a multi-line command reads the way it was written.
+ */
+export type TooltipContent = "label" | "code";
+
+const contentClass: Record<TooltipContent, string> = {
+ label: "",
+ code: "whitespace-pre-wrap wrap-anywhere font-mono",
+};
+
+/** The width each kind wraps at, before the room left on screen caps it further. */
+const contentMaxWidth: Record<TooltipContent, string> = {
+ label: "16rem",
+ code: "24rem",
+};
+
+/** The trigger's viewport box — the part of a DOMRect the geometry reads. */
+export type TriggerRect = Pick<DOMRect, "top" | "bottom" | "left" | "right" | "width" | "height">;
+
+/** The viewport the panel must stay inside, in CSS pixels. */
+export interface Viewport {
+ width: number;
+ height: number;
+}
+
/**
* The viewport point the panel is pinned at. Exactly one horizontal edge is given: `left`
* grows the panel rightward from that point, `right` leftward. Anchoring by the far edge is
* what keeps a panel on screen without anyone measuring a width that does not exist until
- * after it renders.
+ * after it renders — and `room` is the other half of that: how far the panel may grow from
+ * its edge before it would cross the margin on the opposite side, the width a long text has
+ * to wrap at instead of running off screen.
*/
-interface PanelPosition {
+export interface PanelPosition {
top: number;
left?: number;
right?: number;
+ room: number;
}
/**
@@ -60,13 +96,15 @@ interface PanelPosition {
* centred on the trigger and clamped so a rail entry scrolled to the very top or bottom still
* gets a panel on screen.
*/
-function besideTrigger(rect: DOMRect): PanelPosition {
+export function besideTrigger(rect: TriggerRect, viewport: Viewport): PanelPosition {
+ const left = rect.right + PANEL_GAP;
return {
top: Math.min(
Math.max(rect.top + rect.height / 2, VIEWPORT_MARGIN),
- window.innerHeight - VIEWPORT_MARGIN,
+ viewport.height - VIEWPORT_MARGIN,
),
- left: rect.right + PANEL_GAP,
+ left,
+ room: Math.max(viewport.width - left - VIEWPORT_MARGIN, 0),
};
}
@@ -75,16 +113,20 @@ function besideTrigger(rect: DOMRect): PanelPosition {
* window, so the panel always grows inward. A toolbar button near the right edge of a docked
* panel is the case this exists for: left-aligned there, the panel would run off screen.
*/
-function belowTrigger(rect: DOMRect): PanelPosition {
+export function belowTrigger(rect: TriggerRect, viewport: Viewport): PanelPosition {
const top = rect.bottom + PANEL_GAP;
- return rect.left + rect.width / 2 > window.innerWidth / 2
- ? { top, right: Math.max(window.innerWidth - rect.right, VIEWPORT_MARGIN) }
- : { top, left: Math.max(rect.left, VIEWPORT_MARGIN) };
+ if (rect.left + rect.width / 2 > viewport.width / 2) {
+ const right = Math.max(viewport.width - rect.right, VIEWPORT_MARGIN);
+ return { top, right, room: Math.max(viewport.width - right - VIEWPORT_MARGIN, 0) };
+ }
+ const left = Math.max(rect.left, VIEWPORT_MARGIN);
+ return { top, left, room: Math.max(viewport.width - left - VIEWPORT_MARGIN, 0) };
}
export function Tooltip({
label,
placement = "right",
+ content = "label",
suppressed,
className,
children,
@@ -93,6 +135,8 @@ export function Tooltip({
label: string;
/** Which side of the trigger the panel hangs off; `right` suits a vertical rail, `bottom` a horizontal toolbar. */
placement?: TooltipPlacement;
+ /** What `label` is: a control's name (the default), or a truncated line of code shown whole. */
+ content?: TooltipContent;
/**
* Hold the panel closed and refuse to open it. For a trigger that owns something else on
* screen while it is active: the rail avatar's open user menu hangs off the same corner,
@@ -122,7 +166,10 @@ export function Tooltip({
timerRef.current = null;
const rect = anchorRef.current?.getBoundingClientRect();
if (!rect) return;
- setPosition(placement === "bottom" ? belowTrigger(rect) : besideTrigger(rect));
+ const viewport = { width: window.innerWidth, height: window.innerHeight };
+ setPosition(
+ placement === "bottom" ? belowTrigger(rect, viewport) : besideTrigger(rect, viewport),
+ );
}, OPEN_DELAY_MS);
};
@@ -174,8 +221,9 @@ export function Tooltip({
top: position.top,
left: position.left,
right: position.right,
+ maxWidth: `min(${contentMaxWidth[content]}, ${position.room}px)`,
}}
- className={`anim-fade pointer-events-none z-[60] w-max max-w-64 rounded-md border border-gray-200 bg-white px-2 py-1 text-xs text-gray-700 shadow-lg dark:border-gray-700 dark:bg-gray-900 dark:text-gray-200 ${placement === "right" ? "-translate-y-1/2" : ""}`}
+ className={`anim-fade pointer-events-none z-[60] w-max rounded-md border border-gray-200 bg-white px-2 py-1 text-xs text-gray-700 shadow-lg dark:border-gray-700 dark:bg-gray-900 dark:text-gray-200 ${contentClass[content]} ${placement === "right" ? "-translate-y-1/2" : ""}`}
>
{label}
</div>,
diff --git a/packages/web/src/components/ui/truncated.tsx b/packages/web/src/components/ui/truncated.tsx
index e002c356..3aef2251 100644
--- a/packages/web/src/components/ui/truncated.tsx
+++ b/packages/web/src/components/ui/truncated.tsx
@@ -26,21 +26,31 @@
* `title` is attached: having both put a tooltip over the very text sliding past
* underneath it (#570). The full text always stays in the DOM either way, so the
* accessible name carries it whole no matter how much of it is visually clipped.
+ *
+ * `codeTooltip` swaps the native `title` for the styled Tooltip panel, set as code, for a
+ * line that is a command rather than a name. A command runs long, and the native tooltip —
+ * slow to appear, unstyled, and laid out however the browser or the desktop shell sees fit —
+ * is no dependable way to read one whole. The same rule decides whether the panel may open:
+ * it is held shut while the text fits, exactly where no `title` would have been attached.
*/
import { useLayoutEffect, useRef, useState } from "react";
import type { CSSProperties } from "react";
import { revealDistancePx, revealDurationMs, titleDisclosure } from "../../lib/title-reveal";
+import { Tooltip } from "./tooltip";
import { usePrefersReducedMotion } from "./use-reduced-motion";
export function Truncated({
text,
className = "",
scrollReveal = false,
+ codeTooltip = false,
}: {
text: string;
className?: string;
/** Scroll the clipped tail into view while a `data-title-reveal` ancestor is hovered / keyboard-focused (sidebar conversation rows). */
scrollReveal?: boolean;
+ /** Disclose a clipped tail in the styled Tooltip below the text, set as code, instead of a native `title` (a background process's command). */
+ codeTooltip?: boolean;
}) {
const ref = useRef<HTMLSpanElement>(null);
/** Measured overflow in px (0 = fits): > 0 drives both the `title` tooltip and the scroll distance. */
@@ -77,7 +87,7 @@ export function Truncated({
scrollReveal,
reducedMotion,
});
- return (
+ const line = (
<span
ref={ref}
className={`truncate ${className}${disclosure === "scroll" ? " title-scroll" : ""}`}
@@ -89,7 +99,7 @@ export function Truncated({
} as CSSProperties,
}
: {})}
- {...(disclosure === "tooltip" ? { title: text } : {})}
+ {...(disclosure === "tooltip" && !codeTooltip ? { title: text } : {})}
>
{/* The scroll needs a child the keyframes can turn into an inline-block and
transform; at rest it renders inline, i.e. exactly like the bare text node
@@ -97,4 +107,18 @@ export function Truncated({
{scrollReveal ? <span className="title-scroll-text">{text}</span> : text}
</span>
);
+ if (!codeTooltip) return line;
+ // The wrapper is what the panel measures and hangs below. It is a flex box, so it needs
+ // min-w-0 to let the line inside shrink and truncate rather than widen its column.
+ return (
+ <Tooltip
+ label={text}
+ placement="bottom"
+ content="code"
+ suppressed={disclosure !== "tooltip"}
+ className="min-w-0"
+ >
+ {line}
+ </Tooltip>
+ );
}
diff --git a/packages/web/src/features/chat/chat-page.tsx b/packages/web/src/features/chat/chat-page.tsx
index 52c128e0..e401360d 100644
--- a/packages/web/src/features/chat/chat-page.tsx
+++ b/packages/web/src/features/chat/chat-page.tsx
@@ -143,6 +143,7 @@ import { GlyphIcon } from "../../components/ui/glyph-icon";
import { STAT_ICONS } from "../../lib/stat-icons";
import { BACKGROUND_TASKS_ICON, INFO_ICON } from "../../components/ui/icons";
import { ICON_GAP, ICON_SIZE } from "../../lib/icon-scale";
+import { exitedProcessIds, reportableProcessFailure } from "./process-list";
/** How often the background-process list refreshes while it can still change (a run may promote a command at any time; a running process can exit on its own). */
const PROCESS_POLL_MS = 15_000;
@@ -324,9 +325,10 @@ export function ChatPage() {
const [modeSaving, setModeSaving] = useState(false);
const [models, setModels] = useState<ModelsResponse | null>(null);
// Background processes the conversation started (the details popover list), refreshed by
- // the polling effect below; procBusy marks the row whose stop request is in flight.
+ // the polling effect below; procBusy marks the rows whose Stop / Remove requests are in
+ // flight (every exited row at once while "clear exited" runs).
const [processes, setProcesses] = useState<SessionProcessInfo[]>([]);
- const [procBusy, setProcBusy] = useState<string | null>(null);
+ const [procBusy, setProcBusy] = useState<readonly string[] | null>(null);
// Session Token buckets from the last usage fetch (the popover's tokens-line breakdown):
// server-recorded values — they can trail the live chip mid-run and reconcile on idle.
const [usageBuckets, setUsageBuckets] = useState<{
@@ -976,29 +978,31 @@ export function ChatPage() {
}, [selectedSessionId, stream.taskState, processesCanChange, backgroundProcessCount]);
/**
- * Shared body of the per-row process actions (Stop / Remove): one request at a time
- * (procBusy), the statuses that only mean "the list was stale" swallowed instead of
- * toasted, and the list refreshed however the request ended — the truth comes from the
- * refresh, not from the response. The refresh is applied ONLY while its own session is
- * still selected: switching sessions mid-request would otherwise paint the previous
- * session's processes into the new session's card, and with the popover closed and
- * nothing running there is no poll to correct it.
+ * Shared body of the process actions (a row's Stop / Remove, the list's "clear exited"):
+ * one action at a time (procBusy), one request per entry through the per-entry route, the
+ * statuses that only mean "the list was stale" swallowed instead of toasted (at most one
+ * toast for the whole batch — see reportableProcessFailure), and the list refreshed
+ * however the requests ended — the truth comes from the refresh, not from the responses.
+ * The refresh is applied ONLY while its own session is still selected: switching sessions
+ * mid-request would otherwise paint the previous session's processes into the new
+ * session's card, and with the popover closed and nothing running there is no poll to
+ * correct it.
*/
const runProcessAction = useCallback(
async (
- processId: string,
+ processIds: readonly string[],
request: (sessionId: string, processId: string) => Promise<void>,
staleStatuses: readonly number[],
) => {
if (!selected || procBusy !== null) return;
const sessionId = selected.sessionId;
- setProcBusy(processId);
+ setProcBusy(processIds);
try {
- await request(sessionId, processId);
- } catch (e) {
- if (!(e instanceof ApiError && staleStatuses.includes(e.status))) {
- toastError(apiErrorText(e));
- }
+ const results = await Promise.allSettled(
+ processIds.map((processId) => request(sessionId, processId)),
+ );
+ const failure = reportableProcessFailure(results, staleStatuses);
+ if (failure !== null) toastError(apiErrorText(failure.error));
} finally {
setProcBusy(null);
api
@@ -1016,7 +1020,7 @@ export function ChatPage() {
// so the follow-up refresh drops the row (a 404 means it already exited/was reaped —
// same outcome, not an error worth surfacing).
const onKillProcess = useCallback(
- (processId: string) => runProcessAction(processId, api.killSessionProcess, [404]),
+ (processId: string) => runProcessAction([processId], api.killSessionProcess, [404]),
[runProcessAction],
);
@@ -1024,10 +1028,19 @@ export function ChatPage() {
// A 404 means the entry is already gone, a 409 that it is in fact (still) running —
// either way the follow-up refresh shows the truth, so neither is surfaced as an error.
const onRemoveProcess = useCallback(
- (processId: string) => runProcessAction(processId, api.removeSessionProcess, [404, 409]),
+ (processId: string) => runProcessAction([processId], api.removeSessionProcess, [404, 409]),
[runProcessAction],
);
+ // Clear every EXITED entry at once: the rows' own Remove, sent for each of them through the
+ // same route, so every entry meets the same checks (an entry that turns out to be running
+ // stays, one already gone is no error) and running rows are never touched.
+ const exitedIds = useMemo(() => exitedProcessIds(processes), [processes]);
+ const onClearExitedProcesses = useCallback(
+ () => runProcessAction(exitedIds, api.removeSessionProcess, [404, 409]),
+ [runProcessAction, exitedIds],
+ );
+
// Model config (context window + credential guide): fetched once per Project.
//
// The credential guide **only ever nags once per lifetime** (first entry after registration):
@@ -2044,12 +2057,33 @@ export function ChatPage() {
localhost:3000): live rows carry a stop button — the kill signals the whole
process group and the row drops on the follow-up refresh; exited rows keep
their "exited" label and carry a remove button that deletes the entry from
- the list (#312). Hidden entirely while there are none. */}
+ the list (#312), and the heading carries one action removing every exited
+ row at once. A command too long for its row shows whole in a tooltip. Hidden
+ entirely while there are none. */}
{processes.length > 0 && (
<div>
- <p className="text-xs font-medium text-gray-500 dark:text-gray-400">
- {S.chat.processList}
- </p>
+ <div className="flex items-center justify-between gap-2">
+ <p className="text-xs font-medium text-gray-500 dark:text-gray-400">
+ {S.chat.processList}
+ </p>
+ {/* Only while something has exited. Words rather than a glyph, in the quiet
+ text-action style of the memory card's "Open memory list": the same
+ text size as the heading beside it, so the heading row keeps its height
+ when the first process exits. The same no-confirm tidy-up as a single
+ row's Remove, and its hint, like that button's, says what leaves with
+ the rows. */}
+ {exitedIds.length > 0 && (
+ <button
+ type="button"
+ title={S.chat.processClearExitedHint}
+ disabled={procBusy !== null}
+ onClick={() => void onClearExitedProcesses()}
+ className="shrink-0 cursor-pointer text-xs text-gray-400 transition-colors duration-150 hover:text-gray-600 disabled:cursor-default disabled:opacity-60 dark:text-gray-500 dark:hover:text-gray-300"
+ >
+ {S.chat.processClearExited}
+ </button>
+ )}
+ </div>
<ul className="mt-1 space-y-1.5">
{processes.map((p) => (
<li key={p.processId} className="flex items-center gap-2">
@@ -2062,9 +2096,7 @@ export function ChatPage() {
}`}
/>
<span className="min-w-0 flex-1">
- <span className="block truncate font-mono text-xs" title={p.cmd}>
- {p.cmd}
- </span>
+ <Truncated text={p.cmd} className="font-mono text-xs" codeTooltip />
<span className="block truncate text-[11px] text-gray-400 dark:text-gray-500">
{formatDateTime(p.startedAt)}
{p.pid !== null && ` · pid ${p.pid}`}
@@ -2094,7 +2126,9 @@ export function ChatPage() {
onClick={() => void onKillProcess(p.processId)}
className="shrink-0 rounded-md border border-gray-200 px-2 py-0.5 text-xs text-gray-600 transition-colors duration-150 hover:border-red-200 hover:bg-red-50 hover:text-red-600 disabled:cursor-default disabled:opacity-60 dark:border-gray-700 dark:text-gray-300 dark:hover:border-red-900 dark:hover:bg-red-950/40 dark:hover:text-red-400"
>
- {procBusy === p.processId ? S.common.loading : S.chat.processStop}
+ {procBusy?.includes(p.processId)
+ ? S.common.loading
+ : S.chat.processStop}
</button>
) : (
<>
@@ -2114,7 +2148,9 @@ export function ChatPage() {
onClick={() => void onRemoveProcess(p.processId)}
className="shrink-0 rounded-md border border-gray-200 px-2 py-0.5 text-xs text-gray-600 transition-colors duration-150 hover:border-red-200 hover:bg-red-50 hover:text-red-600 disabled:cursor-default disabled:opacity-60 dark:border-gray-700 dark:text-gray-300 dark:hover:border-red-900 dark:hover:bg-red-950/40 dark:hover:text-red-400"
>
- {procBusy === p.processId ? S.common.loading : S.chat.processRemove}
+ {procBusy?.includes(p.processId)
+ ? S.common.loading
+ : S.chat.processRemove}
</button>
</>
)}
diff --git a/packages/web/src/features/chat/process-list.ts b/packages/web/src/features/chat/process-list.ts
new file mode 100644
index 00000000..c25f6584
--- /dev/null
+++ b/packages/web/src/features/chat/process-list.ts
@@ -0,0 +1,41 @@
+/**
+ * Pure rules of the details card's background-process list (chat-page.tsx): which entries
+ * the list's "clear exited" action removes, and which failure out of a batch of per-entry
+ * requests is worth telling the user about. Kept out of the page so they are unit-testable
+ * (vitest runs node-only, no DOM).
+ */
+import type { SessionProcessInfo } from "@prismshadow/penguin-server/api";
+import { ApiError } from "../../api/client";
+
+/**
+ * The entries "clear exited" removes, in list order: every row that is no longer running.
+ * A running row is never among them — stopping one is its own Stop button's job, and the
+ * server refuses to remove a live entry anyway.
+ */
+export function exitedProcessIds(
+ processes: readonly Pick<SessionProcessInfo, "processId" | "running">[],
+): string[] {
+ return processes.filter((p) => !p.running).map((p) => p.processId);
+}
+
+/**
+ * The one failure worth a toast out of a batch of per-entry requests (a row's own Stop or
+ * Remove is a batch of one): the first rejection whose status is not in `staleStatuses`.
+ * Those only mean the list was stale — an entry already gone, or one that turned out to be
+ * running — and the refresh that follows every action already shows the truth. One toast
+ * for the batch rather than one per entry, because what fails one request of a batch (a
+ * lost login, an unreachable server) fails the rest the same way. Null when nothing else
+ * failed.
+ */
+export function reportableProcessFailure(
+ results: readonly PromiseSettledResult<unknown>[],
+ staleStatuses: readonly number[],
+): { error: unknown } | null {
+ for (const result of results) {
+ if (result.status !== "rejected") continue;
+ const error: unknown = result.reason;
+ if (error instanceof ApiError && staleStatuses.includes(error.status)) continue;
+ return { error };
+ }
+ return null;
+}
diff --git a/packages/web/src/lib/strings-en.ts b/packages/web/src/lib/strings-en.ts
index 2776e7f8..6e07af71 100644
--- a/packages/web/src/lib/strings-en.ts
+++ b/packages/web/src/lib/strings-en.ts
@@ -2257,6 +2257,10 @@ Scenarios:
processRemove: "Remove",
/** Remove button tooltip: removal also drops the output captured from that process. */
processRemoveHint: "Remove this entry — the output captured from it is discarded too",
+ /** The list heading's text action: removes every exited entry at once; its hint says the captured output goes too. */
+ processClearExited: "Clear exited",
+ processClearExitedHint:
+ "Clear every exited process — the output captured from them is discarded too",
statTokens: "Total Tokens",
/** Info-dropdown stats list: the tokens bullet's label and its cache-hit-rate parenthetical (rate = cacheRead ÷ all input, e.g. "68%"). */
statTotalTokens: "Total Tokens",
diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.ts
index 8326712b..202e8964 100644
--- a/packages/web/src/lib/strings.ts
+++ b/packages/web/src/lib/strings.ts
@@ -2248,6 +2248,9 @@ Benchmark:
processRemove: "移除",
/** Remove button tooltip: removal also drops the output captured from that process. */
processRemoveHint: "移除该条目——该进程已捕获的输出也会一并丢弃",
+ /** The list heading's text action: removes every exited entry at once; its hint says the captured output goes too. */
+ processClearExited: "清除已退出",
+ processClearExitedHint: "清除所有已退出的进程——它们已捕获的输出也会一并丢弃",
statTokens: "Token 累计",
/** Info-dropdown stats list: the tokens bullet's label and its cache-hit-rate parenthetical (rate = cacheRead ÷ all input, e.g. "68%"). */
statTotalTokens: "总 Token",
diff --git a/packages/web/test/process-list.test.ts b/packages/web/test/process-list.test.ts
new file mode 100644
index 00000000..a20deff0
--- /dev/null
+++ b/packages/web/test/process-list.test.ts
@@ -0,0 +1,102 @@
+/**
+ * The details card's background-process list (src/features/chat/process-list.ts and its use in
+ * chat-page.tsx): which entries "clear exited" removes, which failure of a batch of per-entry
+ * requests reaches the user, and how a command too long for its row is read whole.
+ *
+ * The last part is a source scan, as in title-reveal.test.ts: vitest runs node-only here
+ * (`environment: "node"`, no jsdom), and a native `title` creeping back onto the command line —
+ * two tooltips over each other — is not something a rendered-markup assertion would see.
+ */
+import { readFileSync } from "node:fs";
+import { dirname, resolve } from "node:path";
+import { fileURLToPath } from "node:url";
+import { describe, expect, it } from "vitest";
+import { ApiError } from "../src/api/client";
+import { exitedProcessIds, reportableProcessFailure } from "../src/features/chat/process-list";
+
+const row = (processId: string, running: boolean) => ({ processId, running });
+
+const rejected = (reason: unknown): PromiseSettledResult<unknown> => ({
+ status: "rejected",
+ reason,
+});
+const fulfilled: PromiseSettledResult<unknown> = { status: "fulfilled", value: undefined };
+
+describe("exitedProcessIds", () => {
+ it("picks every exited entry, in list order", () => {
+ expect(
+ exitedProcessIds([row("p1", false), row("p2", true), row("p3", false), row("p4", true)]),
+ ).toEqual(["p1", "p3"]);
+ });
+
+ it("never picks a running entry, so a list with nothing exited offers nothing to clear", () => {
+ expect(exitedProcessIds([row("p1", true), row("p2", true)])).toEqual([]);
+ expect(exitedProcessIds([])).toEqual([]);
+ });
+});
+
+describe("reportableProcessFailure", () => {
+ const REMOVE_STALE = [404, 409];
+
+ it("reports nothing when every request succeeded", () => {
+ expect(reportableProcessFailure([fulfilled, fulfilled], REMOVE_STALE)).toBeNull();
+ });
+
+ it("swallows the statuses that only mean the list was stale", () => {
+ // An entry already gone (404) or one that turned out to be running (409): the refresh
+ // after the batch shows the truth, so neither is an error.
+ const gone = new ApiError(404, "process_not_found", "gone");
+ const running = new ApiError(409, "process_running", "running");
+ expect(
+ reportableProcessFailure([rejected(gone), fulfilled, rejected(running)], REMOVE_STALE),
+ ).toBeNull();
+ });
+
+ it("reports the first other failure once, however many requests it failed", () => {
+ const denied = new ApiError(401, "unauthorized", "first");
+ const deniedAgain = new ApiError(401, "unauthorized", "second");
+ const failure = reportableProcessFailure(
+ [
+ rejected(new ApiError(404, "process_not_found", "gone")),
+ rejected(denied),
+ rejected(deniedAgain),
+ ],
+ REMOVE_STALE,
+ );
+ expect(failure).toEqual({ error: denied });
+ });
+
+ it("reports a failure that never reached the server", () => {
+ const network = new TypeError("Failed to fetch");
+ expect(reportableProcessFailure([rejected(network)], REMOVE_STALE)).toEqual({
+ error: network,
+ });
+ });
+
+ it("judges staleness by the action's own statuses", () => {
+ // Stop treats only 404 as stale: a 409 there is a real refusal worth saying.
+ const conflict = new ApiError(409, "process_running", "running");
+ expect(reportableProcessFailure([rejected(conflict)], [404])).toEqual({ error: conflict });
+ });
+});
+
+describe("the process row's command line", () => {
+ const src = resolve(dirname(fileURLToPath(import.meta.url)), "../src");
+ const chatPage = readFileSync(resolve(src, "features/chat/chat-page.tsx"), "utf8");
+
+ it("shows a truncated command whole in the code tooltip, never in a native title", () => {
+ expect(chatPage).toContain(
+ '<Truncated text={p.cmd} className="font-mono text-xs" codeTooltip />',
+ );
+ expect(chatPage).not.toContain("title={p.cmd}");
+ });
+
+ it("clears exited entries through the same per-entry route a row's Remove uses", () => {
+ expect(chatPage).toMatch(
+ /runProcessAction\(exitedIds, api\.removeSessionProcess, \[404, 409\]\)/,
+ );
+ expect(chatPage).toMatch(
+ /runProcessAction\(\[processId\], api\.removeSessionProcess, \[404, 409\]\)/,
+ );
+ });
+});
diff --git a/packages/web/test/tooltip-geometry.test.ts b/packages/web/test/tooltip-geometry.test.ts
new file mode 100644
index 00000000..a8d26f4c
--- /dev/null
+++ b/packages/web/test/tooltip-geometry.test.ts
@@ -0,0 +1,60 @@
+/**
+ * Where the styled Tooltip (src/components/ui/tooltip.tsx) hangs its panel, and how wide the
+ * panel may grow before it would leave the screen.
+ *
+ * The panel is pinned by one horizontal edge and grows away from it, so the only width it can
+ * safely take is the room between that edge and the viewport margin on the far side. A long
+ * text — a background process's command, shown whole — wraps at that room instead of running
+ * off a phone's screen; a short label never reaches it.
+ */
+import { describe, expect, it } from "vitest";
+import { belowTrigger, besideTrigger } from "../src/components/ui/tooltip";
+
+const VIEWPORT = { width: 1000, height: 800 };
+
+/** A trigger box from its left/top corner and size. */
+const box = (left: number, top: number, width: number, height: number) => ({
+ left,
+ top,
+ width,
+ height,
+ right: left + width,
+ bottom: top + height,
+});
+
+describe("belowTrigger", () => {
+ it("anchors by the right edge in the right half, with the room reaching back to the left margin", () => {
+ // A command line near the right of the window: the panel grows leftward from its right edge.
+ expect(belowTrigger(box(700, 100, 200, 20), VIEWPORT)).toEqual({
+ top: 128,
+ right: 100,
+ room: 892,
+ });
+ });
+
+ it("anchors by the left edge in the left half, with the room reaching to the right margin", () => {
+ // A phone-width card: the room, not the panel's own cap, is what keeps the text on screen.
+ expect(belowTrigger(box(40, 100, 200, 20), { width: 390, height: 800 })).toEqual({
+ top: 128,
+ left: 40,
+ room: 342,
+ });
+ });
+
+ it("keeps the anchored edge inside the viewport margin", () => {
+ expect(belowTrigger(box(900, 0, 100, 20), VIEWPORT).right).toBe(8);
+ expect(belowTrigger(box(-20, 0, 100, 20), VIEWPORT).left).toBe(8);
+ });
+});
+
+describe("besideTrigger", () => {
+ it("hangs to the right of a rail entry, centred on it, with the room to the right margin", () => {
+ expect(besideTrigger(box(8, 200, 32, 32), VIEWPORT)).toEqual({ top: 216, left: 48, room: 944 });
+ });
+
+ it("clamps the centre into the viewport and never reports negative room", () => {
+ const offscreen = besideTrigger(box(990, 900, 32, 32), VIEWPORT);
+ expect(offscreen.top).toBe(792);
+ expect(offscreen.room).toBe(0);
+ });
+});