Skip to content

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

fix(web,server): removable exited processes, icon-only copy feedback, single-line trace file row (#327)

Yaowei Zhengc01e1e949993
diff --git a/changelog/unreleased/2026-08-18-session-details-and-copy-ux.md b/changelog/unreleased/2026-08-18-session-details-and-copy-ux.md
new file mode 100644
index 00000000..2d996eb1
--- /dev/null
+++ b/changelog/unreleased/2026-08-18-session-details-and-copy-ux.md
@@ -0,0 +1,30 @@
+# Removable exited processes, icon-only copy feedback, single-line Trace file row
+
+- **Date:** 2026-08-18
+- **Type:** fix
+- **Scope:** `web`, `server`, `docs`
+- **PR:** [#327](https://github.com/Prism-Shadow/penguin-harness/pull/327)
+- **Issue:** [#312](https://github.com/Prism-Shadow/penguin-harness/issues/312)
+
+[中文版](2026-08-18-session-details-and-copy-ux.zh.md)
+
+Three fixes to the chat session's details card and the copy affordances around it: exited background processes became removable from the process list, copy buttons confirm with their icon alone, and the Trace file row shows a single-line file name.
+
+## Removable exited processes
+
+The details card's process list keeps entries whose command has already exited. Those rows gained a **Remove** button that deletes the entry; running rows kept their **Stop** button, which kills and removes as before, and were deliberately left non-removable.
+
+- Added `DELETE /api/sessions/:sessionId/processes/:processId`: 204 removes an exited entry, 409 `process_running` while the process is still running (stop it instead), 404 `process_not_found` when the id is unknown or the runtime is gone. The removal reuses the kill path on the dead entry, like `input_command`'s post-exit reap.
+- Removal is immediate and final: the entry leaves the runtime registry together with the output captured from that process, so `input_command` on that `process_id` afterwards reports an unknown `process_id`. No confirmation step was added — the button's tooltip and the Web App docs state what the row takes with it.
+- The docs' session endpoint table gained rows for all three `/processes` routes; the GET and the kill POST had been undocumented.
+
+## Copy buttons confirm with the check icon alone
+
+After a successful copy, every copy button swaps its copy icon to a check mark for a moment and flips its tooltip to "Copied". The transient "Copied" **text label** was dropped everywhere — it had sat next to the check on the Session id and Agent State path rows. The memory tab's and the skill import dialog's "Copy prompt" buttons moved off toast feedback and onto that shared convention, flipping their glyph while their visible label stays put; the toast strings they had used were removed.
+
+- An icon swap is silent, so every copy control also renders a visually hidden polite live region that announces the confirmation to screen readers. The accessible name stays the copy action.
+- Repeated clicks each get the full flash window: the pending reset is restarted rather than left over from the previous click. A control that unmounts inside that window — the Trace row closes the details card itself — no longer leaves a timer behind.
+
+## Trace file row shows the single-line file name
+
+The details card's Trace file row stopped wrapping the full absolute path over several lines and shows just the file name on one line. The full path moved into the tooltip and into a new copy-full-path button beside the name; clicking the name still deep-links into the Trace browser focused on the session.
diff --git a/changelog/unreleased/2026-08-18-session-details-and-copy-ux.zh.md b/changelog/unreleased/2026-08-18-session-details-and-copy-ux.zh.md
new file mode 100644
index 00000000..1ec889cd
--- /dev/null
+++ b/changelog/unreleased/2026-08-18-session-details-and-copy-ux.zh.md
@@ -0,0 +1,30 @@
+# 已退出的进程可移除、复制只用图标反馈、轨迹文件行改为单行
+
+- **Date:** 2026-08-18
+- **Type:** fix
+- **Scope:** `web`, `server`, `docs`
+- **PR:** [#327](https://github.com/Prism-Shadow/penguin-harness/pull/327)
+- **Issue:** [#312](https://github.com/Prism-Shadow/penguin-harness/issues/312)
+
+[English](2026-08-18-session-details-and-copy-ux.md)
+
+对话会话详情卡及其周边复制控件的三处修复:已退出的后台进程可以从进程列表移除,复制按钮只以图标确认,轨迹文件行改为单行显示文件名。
+
+## 已退出的进程可移除
+
+详情卡的会话进程列表会保留命令已经退出的条目。这些行新增了「移除」按钮,点击即把条目从列表删掉;运行中的行保留原有的「停止」按钮(照旧是先杀停再移除),并有意不提供移除。
+
+- 新增 `DELETE /api/sessions/:sessionId/processes/:processId`:204 表示已退出的条目已移除,进程仍在运行时返回 409 `process_running`(应改用停止),id 未知或运行时已不在时返回 404 `process_not_found`。移除复用了作用在已死条目上的 kill 路径,与 `input_command` 在进程退出后的回收一致。
+- 移除立即生效且不可撤销:条目会连同该进程已捕获的输出一起离开运行时注册表,此后对该 `process_id` 调用 `input_command` 会报告 `process_id` 未知。没有加确认步骤——按钮的 tooltip 与 Web App 文档会说明这一行会带走什么。
+- 文档中的 session 端点表补上了全部三条 `/processes` 路由;此前 GET 与 kill 的 POST 都没有写进文档。
+
+## 复制按钮只用对勾图标确认
+
+复制成功后,每个复制按钮都会把复制图标短暂换成对勾,并把 tooltip 翻成「已复制」。那个一闪而过的「已复制」**文字标签**在各处都去掉了——它此前出现在 Session id 行和 Agent State 路径行的对勾旁边。记忆标签页与技能导入对话框的「复制 Prompt」按钮从 toast 反馈改到同一套约定上:只翻转图标,可见的文字标签保持不动;它们原先用的 toast 文案也一并删除。
+
+- 图标切换是无声的,因此每个复制控件旁边还会渲染一个视觉隐藏的 polite live region,把这次确认播报给屏幕阅读器。可访问名称仍是复制这个动作本身。
+- 连续点击时每次都能拿到完整的闪现窗口:待执行的复位定时器会被重启,而不是沿用上一次点击留下的那个。在这个窗口内被卸载的控件——轨迹文件那一行点下去会把详情卡本身关掉——也不会再遗留定时器。
+
+## 轨迹文件行只显示单行文件名
+
+详情卡的轨迹文件行不再把完整绝对路径折成好几行,而是只用一行显示文件名。完整路径移到了 tooltip,以及文件名旁边新增的复制完整路径按钮上;点击文件名仍然跳转到聚焦本会话的轨迹观测页。
diff --git a/packages/docs/content/server-api.en.md b/packages/docs/content/server-api.en.md
index 1a5a2f05..073f7dd4 100644
--- a/packages/docs/content/server-api.en.md
+++ b/packages/docs/content/server-api.en.md
@@ -189,6 +189,9 @@ The paths below omit the `/api/sessions/:sessionId` prefix. For the storage mode
| POST | /abort | Interrupt the current Task: 202 when triggered, 204 when idle |
| POST | /retry-now | "Retry now" on the reconnect countdown: skips the in-progress backoff wait, firing the next retry immediately (attempt counter unchanged) → 200 `{skipped}` — `skipped:false` is the benign "no wait in progress" case, never an error |
| POST | /compact | Trigger context compaction: 202; 409 `nothing_to_compact` when there is nothing to compact |
+| GET | /processes | Background processes the conversation started (`exec_command`s promoted past their yield window). Served from the active runtime only — an evicted or never-loaded session truthfully reports an empty list |
+| POST | /processes/:processId/kill | Stop one background process (SIGTERM to the whole process group, SIGKILL after a grace period); the entry drops from the list. 404 `process_not_found` when it is gone |
+| DELETE | /processes/:processId | Remove one **exited** process entry from the list: 409 `process_running` while it still runs (stop it instead), 404 `process_not_found` when it is already gone. The entry leaves the runtime registry with the output captured from it, so `input_command` on that `process_id` fails afterwards |
| GET | /files?path= | Browse the Workspace directory |
| GET | /files/content?path=&download=&preview= | Read a Workspace file (`download=1` serves it as an attachment, `preview=1` renders it in a sandbox — see below) |
| GET | /files/preview-redirect?path= | "Open in a new tab" for html: mints a signed token and 302s to the separate preview origin |
diff --git a/packages/docs/content/server-api.zh.md b/packages/docs/content/server-api.zh.md
index f6b5868b..1c1aa2f3 100644
--- a/packages/docs/content/server-api.zh.md
+++ b/packages/docs/content/server-api.zh.md
@@ -189,6 +189,9 @@ Trace 下载对任意成员开放;导入仅限 owner(同 Agent 快照导入
| POST | /abort | 中断当前 Task:已触发返回 202,无任务返回 204 |
| POST | /retry-now | 重连倒计时上的「立即重试」:跳过进行中的退避等待、立刻发起下一次重试(重试计数不变)→ 200 `{skipped}`——`skipped:false` 表示当前没有等待可跳过(良性空操作,非错误) |
| POST | /compact | 触发上下文压缩:202;无可压缩内容返回 409 `nothing_to_compact` |
+| GET | /processes | 对话启动的后台进程(超过 yield 窗口转入后台的 `exec_command`)。仅来自活跃运行时——被回收或从未装载的会话如实返回空列表 |
+| POST | /processes/:processId/kill | 停止一个后台进程(对整个进程组先 SIGTERM、宽限期后 SIGKILL),条目随之从列表消失;已不存在时 404 `process_not_found` |
+| DELETE | /processes/:processId | 从列表移除一个**已退出**的进程条目:仍在运行时 409 `process_running`(应改用停止),已不存在时 404 `process_not_found`。条目连同该进程已捕获的输出一起离开运行时注册表,此后对该 `process_id` 调用 `input_command` 会失败 |
| GET | /files?path= | 浏览 Workspace 目录 |
| GET | /files/content?path=&download=&preview= | 读取 Workspace 文件(`download=1` 时作为附件下载,`preview=1` 以沙箱方式预览 —— 见下) |
| GET | /files/preview-redirect?path= | html 的“新页面打开”:签发令牌并 302 跳转到独立预览源 |
diff --git a/packages/docs/content/web-app.en.md b/packages/docs/content/web-app.en.md
index 1d293ef2..2a75781c 100644
--- a/packages/docs/content/web-app.en.md
+++ b/packages/docs/content/web-app.en.md
@@ -44,6 +44,15 @@ There are four approval modes: `allow-all`, `deny-all`, `read-only` (only read-o
- Subagents leave a full-width row in the stream, styled like the other collapsed step rows (agent avatar, name, short session id, running spinner, and an amber dot while one of their tool calls awaits approval); clicking it opens the agents side panel — a call graph of that row's Task on top (each node shows its elapsed time; click a node to switch) and the selected child's live conversation below — the child's own user prompts included — where nested tool cards and approvals work exactly as in the main chat. Panel visibility is task-scoped: sending a message that starts a new task closes it by default (entering a session starts closed too), and it comes back when you open it yourself or — on desktop — when the current task spawns a subagent (one auto-open per task; a manual close holds until the next task; never over an open files panel). Opening the panel from the toolbar, or switching sessions, shows the latest Task's graph; a row on an older turn brings back that turn's graph. The agents panel and the Workspace files panel never show together — opening one closes the other. Context compaction and the first-run MCP connect show a unified step row (the work-group header shell, sticky title bar included — running/success/failure only swap the icon and the one-line detail, with the wall time on the result; the MCP row leads with the discovered-tool count and names unavailable servers, and expands into one group per server — status, tool count and that server's connect time — each opening into its tool list or the failure detail);
- After each Task, a stats line shows tokens, TPS, elapsed time, and cost.
+### Header Stats and the Details Card
+
+The toolbar's right edge shows the Session's cumulative stats (tokens, cost, elapsed time); clicking them opens the details card — model, Session id (with a copy button beside it), Workspace, creation time and per-line statistics. Below those:
+
+- **Processes** — background processes the conversation started (`exec_command`s promoted past their yield window), one row each with the command, start time and pid. Running rows carry a **Stop** button (kills the whole process group and drops the row); exited rows keep their "exited" label and carry a **Remove** button that deletes the entry from the list. Removal is immediate and final: the entry leaves the runtime registry together with the output captured from that process, so afterwards the model can no longer be asked to read it — keep the row until you are done with its output.
+- **Trace file** — the Session's current Trace file, shown as its file name on a single line: clicking the name opens the Trace Browser focused on this session, and the button beside it copies the full path.
+
+Copy buttons across the app confirm at the button itself: the copy icon flips to a check mark for a moment (no "Copied" text label).
+
### Input and Shortcuts
- Enter sends, Shift+Enter inserts a newline, and images can be pasted;
diff --git a/packages/docs/content/web-app.zh.md b/packages/docs/content/web-app.zh.md
index 086c2870..e30b1cac 100644
--- a/packages/docs/content/web-app.zh.md
+++ b/packages/docs/content/web-app.zh.md
@@ -44,6 +44,15 @@ penguin web
- 子 Agent 在消息流中只留下一条通栏行,样式与其他折叠步骤行一致(头像、名称、短会话号、运行中转圈,子会话内有待审批时带琥珀色圆点);点击打开右侧智能体面板——上方是该行所属 Task 派生关系的调用图(节点上显示运行时长,点节点切换),下方是所选子会话的实时对话(含子会话自己的用户消息),嵌套工具卡片与审批与主对话完全一致;面板的显示以任务为界:发送消息开启新任务时默认关闭(进入会话时同样默认关闭),仅在手动打开、或(桌面端)当前任务派生子智能体时重新显示(每个任务自动打开一次,任务内手动关闭后保持关闭到下个任务,且不抢占已打开的工作区面板);从工具条打开面板或切换 Session 时默认展示最新 Task 的调用图,点旧轮次的行则回看那一轮的调用图;智能体面板与工作区面板不会同时显示,打开一个即关闭另一个;上下文压缩与首次 MCP 连接以统一样式的步骤行提示(与运行分组头同款外壳,含吸顶标题栏,连接中/成功/失败仅切换图标与单行详情,结果行含耗时;MCP 行主显发现的工具数并点名不可用的 Server,展开后按 Server 分组——每组一行状态、工具数与该 Server 的连接耗时,点开组内是工具列表或失败原因);
- 每个 Task 结束后显示统计行:Token 用量、TPS、耗时与费用。
+### 头部统计与详情卡
+
+工具行最右侧显示会话累计统计(Token、费用、用时),点击即打开详情卡——模型、Session id(旁附复制按钮)、Workspace、创建时间与逐行统计。其下还有两节:
+
+- **会话进程**——对话启动的后台进程(超过 yield 窗口转入后台的 `exec_command`),逐行显示命令、启动时间与 pid。运行中的行带「停止」按钮(杀停整个进程组并把该行从列表移除);已退出的行保留「已退出」标注,并带「移除」按钮,可把该条目从列表删除。移除立即生效且不可撤销:条目连同该进程已捕获的输出一起离开运行时注册表,之后无法再让模型读取那段输出——输出还有用时请先留着这一行。
+- **轨迹文件**——会话当前的 Trace 文件,单行仅显示文件名:点击文件名跳转到聚焦本会话的轨迹观测页,旁边的按钮复制完整路径。
+
+全站的复制按钮在按钮自身给出反馈:复制成功后图标短暂切换为对勾(不再显示「已复制」文字)。
+
### 输入与快捷操作
- Enter 发送,Shift+Enter 换行,支持粘贴图片;
diff --git a/packages/server/src/http/routes/sessions.ts b/packages/server/src/http/routes/sessions.ts
index 94694bd4..caa622c2 100644
--- a/packages/server/src/http/routes/sessions.ts
+++ b/packages/server/src/http/routes/sessions.ts
@@ -851,6 +851,30 @@ export function sessionsRoutes(deps: AppDeps): Hono<AppEnv> {
return c.body(null, 204);
});
+ // Remove one EXITED process entry from the list (the per-row delete on "exited" rows).
+ // A running process is 409 — stopping it is the kill route's job, so a removal never
+ // surprise-signals a live process group; 404 when the id is unknown or the runtime is
+ // gone (nothing left to remove either way — the UI just refreshes its list).
+ app.delete("/:sessionId/processes/:processId", (c) => {
+ const row = resolveSession(c);
+ const result = deps.manager.removeProcess(row.sessionId, pathParam(c, "processId"));
+ if (result === "running") {
+ throw new HttpError(
+ 409,
+ "process_running",
+ "Process is still running; stop it instead of removing it.",
+ );
+ }
+ if (result === "not_found") {
+ throw new HttpError(
+ 404,
+ "process_not_found",
+ "Process does not exist or has already been removed.",
+ );
+ }
+ return c.body(null, 204);
+ });
+
// "Retry now" on the reconnect countdown: skip the remaining backoff wait and fire the
// next retry immediately (attempt counter unchanged). Benign either way — 200 with
// skipped:false when no reconnect wait is in progress, so a timing race (the wait
diff --git a/packages/server/src/runtime/session-manager.ts b/packages/server/src/runtime/session-manager.ts
index 264200cf..a4ec4e90 100644
--- a/packages/server/src/runtime/session-manager.ts
+++ b/packages/server/src/runtime/session-manager.ts
@@ -947,6 +947,33 @@ export class SessionManager {
return killed;
}
+ /**
+ * Removes one EXITED background command entry from a loaded session's process list.
+ * A running process is refused ("running") — stopping is killProcess's job, and a
+ * bare removal must never surprise-signal a live process group. "not_found" covers
+ * an unloaded session and an unknown id alike: the entry is gone either way. The
+ * removal itself reuses the kill path — core's registry removal signals the (dead)
+ * group defensively and drops the row, exactly like input_command's post-exit reap.
+ * The only race, an entry observed running that exits before a retry, is benign:
+ * the caller gets "running", refreshes, and sees the row exited on the next look.
+ *
+ * Note what leaves with the row: the registry entry owns the ManagedSession holding
+ * that process's captured output, so after a removal input_command on the same
+ * process_id answers "unknown process_id". Removal is a deliberate discard, not just
+ * a list tidy-up — the Web App says so at the button and in the docs.
+ */
+ removeProcess(sessionId: string, processId: string): "removed" | "running" | "not_found" {
+ const entry = this.entries.get(sessionId);
+ if (!entry) return "not_found";
+ const info = entry.session.listBackgroundCommands?.().find((p) => p.processId === processId);
+ if (!info) return "not_found";
+ if (info.running) return "running";
+ const removed = entry.session.killBackgroundCommand?.(processId) ?? false;
+ if (!removed) return "not_found";
+ entry.lastActivityMs = Date.now();
+ return "removed";
+ }
+
/**
* Disposes a just-removed entry's runtime — after its in-flight drive (if any)
* settles, so interrupt cleanup never races a dying environment. Deleting a Session /
diff --git a/packages/server/test/session-processes.test.ts b/packages/server/test/session-processes.test.ts
new file mode 100644
index 00000000..88957d68
--- /dev/null
+++ b/packages/server/test/session-processes.test.ts
@@ -0,0 +1,197 @@
+/**
+ * Integration tests for the session background-process endpoints:
+ * - GET /api/sessions/:id/processes — list (ISO startedAt, running flag);
+ * - POST /api/sessions/:id/processes/:pid/kill — stop a running process (drops the row);
+ * - DELETE /api/sessions/:id/processes/:pid — remove an EXITED entry from the list:
+ * 204 removes it, 409 process_running while it still runs (stop is the kill route's
+ * job — removal never signals a live process group), 404 for unknown ids and for
+ * sessions whose runtime is gone (nothing left to remove either way);
+ * - 404 for foreign/unknown sessions (the shared resolveSession semantics).
+ */
+import { afterEach, beforeEach, describe, expect, it } from "vitest";
+import type { BackgroundCommandInfo, OmniMessage } from "@prismshadow/penguin-core";
+import type { ApproveFn } from "@prismshadow/penguin-core";
+import type { SessionProcessesResponse } from "../src/api/types.js";
+import type { SessionRow } from "../src/db/repos/sessions.js";
+import type { RuntimeSession } from "../src/runtime/session-manager.js";
+import { apiClient, createTestApp, provisionUser } from "./helpers.js";
+import type { TestApp } from "./helpers.js";
+
+const SID = "session-2026-08-18-10-00-00-ccdd0031";
+const SID_UNLOADED = "session-2026-08-18-10-00-00-ccdd0032";
+const STARTED_AT = Date.UTC(2026, 7, 18, 12, 4, 0);
+
+/** Fake Session backed by a mutable process array; kill removes the entry like core's registry. */
+function processesFakeSession(
+ sessionId: string,
+ procs: BackgroundCommandInfo[],
+ kills: string[],
+): RuntimeSession {
+ return {
+ sessionId,
+ toolPermission: () => "rw",
+ generateTitle: async () => ({ title: null, usage: null }),
+ compactability: () => "ok" as const,
+ steer: () => false,
+ skipReconnectWait: () => false,
+ async *run(_input: OmniMessage[], _opts: { approve: ApproveFn; signal: AbortSignal }) {},
+ async *compact() {},
+ listBackgroundCommands: () => [...procs],
+ killBackgroundCommand: (processId: string) => {
+ const i = procs.findIndex((p) => p.processId === processId);
+ if (i === -1) return false;
+ kills.push(processId);
+ procs.splice(i, 1);
+ return true;
+ },
+ };
+}
+
+describe("session processes routes", () => {
+ let t: TestApp;
+ let api: ReturnType<typeof apiClient>;
+ let outsider: ReturnType<typeof apiClient>;
+ let procs: BackgroundCommandInfo[];
+ let kills: string[];
+
+ const sessionRow = (sessionId: string): SessionRow => ({
+ sessionId,
+ projectId: "procuser-default_project",
+ agentId: "default_agent",
+ modelId: "m1",
+ provider: "custom",
+ workspace: "/tmp/w",
+ approvalMode: "always-ask",
+ title: null,
+ createdAt: new Date().toISOString(),
+ lastActiveAt: new Date().toISOString(),
+ });
+
+ beforeEach(async () => {
+ t = await createTestApp();
+ const { cookie } = await provisionUser(t.app, "procuser");
+ const other = await provisionUser(t.app, "outsider_p");
+ api = apiClient(t.app, cookie);
+ outsider = apiClient(t.app, other.cookie);
+ procs = [
+ {
+ processId: "proc-11111111",
+ pid: 4242,
+ cmd: "pnpm dev",
+ cwd: "/tmp/w",
+ startedAt: STARTED_AT,
+ running: true,
+ },
+ {
+ processId: "proc-22222222",
+ pid: 4243,
+ cmd: "sleep 1",
+ cwd: "/tmp/w",
+ startedAt: STARTED_AT,
+ running: false,
+ },
+ ];
+ kills = [];
+ t.deps.sessionsRepo.insert(sessionRow(SID));
+ t.deps.manager.adopt(sessionRow(SID), processesFakeSession(SID, procs, kills));
+ // A second session with no runtime entry: truthfully reports no processes.
+ t.deps.sessionsRepo.insert(sessionRow(SID_UNLOADED));
+ });
+ afterEach(async () => {
+ await t.cleanup();
+ });
+
+ it("GET lists the runtime's processes with ISO start times; an unloaded session reports none", async () => {
+ const res = await api.get(`/api/sessions/${SID}/processes`);
+ expect(res.status).toBe(200);
+ const body = (await res.json()) as SessionProcessesResponse;
+ expect(body.processes).toEqual([
+ {
+ processId: "proc-11111111",
+ pid: 4242,
+ cmd: "pnpm dev",
+ cwd: "/tmp/w",
+ startedAt: new Date(STARTED_AT).toISOString(),
+ running: true,
+ },
+ {
+ processId: "proc-22222222",
+ pid: 4243,
+ cmd: "sleep 1",
+ cwd: "/tmp/w",
+ startedAt: new Date(STARTED_AT).toISOString(),
+ running: false,
+ },
+ ]);
+
+ const unloaded = await api.get(`/api/sessions/${SID_UNLOADED}/processes`);
+ expect(unloaded.status).toBe(200);
+ expect(((await unloaded.json()) as SessionProcessesResponse).processes).toEqual([]);
+ });
+
+ it("DELETE removes an exited entry (204) and the follow-up list no longer carries it", async () => {
+ const res = await api.delete(`/api/sessions/${SID}/processes/proc-22222222`);
+ expect(res.status).toBe(204);
+ expect(kills).toEqual(["proc-22222222"]);
+
+ const body = (await (
+ await api.get(`/api/sessions/${SID}/processes`)
+ ).json()) as SessionProcessesResponse;
+ expect(body.processes.map((p) => p.processId)).toEqual(["proc-11111111"]);
+
+ // Removing it again: already gone → 404, nothing re-killed.
+ const again = await api.delete(`/api/sessions/${SID}/processes/proc-22222222`);
+ expect(again.status).toBe(404);
+ expect(((await again.json()) as { error: { code: string } }).error.code).toBe(
+ "process_not_found",
+ );
+ expect(kills).toEqual(["proc-22222222"]);
+ });
+
+ it("DELETE on a running process → 409 process_running, entry untouched", async () => {
+ const res = await api.delete(`/api/sessions/${SID}/processes/proc-11111111`);
+ expect(res.status).toBe(409);
+ expect(((await res.json()) as { error: { code: string } }).error.code).toBe("process_running");
+ expect(kills).toEqual([]);
+
+ const body = (await (
+ await api.get(`/api/sessions/${SID}/processes`)
+ ).json()) as SessionProcessesResponse;
+ expect(body.processes).toHaveLength(2);
+ });
+
+ it("DELETE with an unknown id or an unloaded runtime → 404 process_not_found", async () => {
+ const ghost = await api.delete(`/api/sessions/${SID}/processes/proc-99999999`);
+ expect(ghost.status).toBe(404);
+ expect(((await ghost.json()) as { error: { code: string } }).error.code).toBe(
+ "process_not_found",
+ );
+
+ const unloaded = await api.delete(`/api/sessions/${SID_UNLOADED}/processes/proc-11111111`);
+ expect(unloaded.status).toBe(404);
+ expect(((await unloaded.json()) as { error: { code: string } }).error.code).toBe(
+ "process_not_found",
+ );
+ expect(kills).toEqual([]);
+ });
+
+ it("POST kill stops a RUNNING process and drops its row (the stop path is untouched)", async () => {
+ const res = await api.post(`/api/sessions/${SID}/processes/proc-11111111/kill`, {});
+ expect(res.status).toBe(204);
+ expect(kills).toEqual(["proc-11111111"]);
+
+ const body = (await (
+ await api.get(`/api/sessions/${SID}/processes`)
+ ).json()) as SessionProcessesResponse;
+ expect(body.processes.map((p) => p.processId)).toEqual(["proc-22222222"]);
+ });
+
+ it("foreign and unknown sessions → 404 (same auth semantics as the other session routes)", async () => {
+ expect((await outsider.get(`/api/sessions/${SID}/processes`)).status).toBe(404);
+ expect((await outsider.delete(`/api/sessions/${SID}/processes/proc-22222222`)).status).toBe(
+ 404,
+ );
+ expect((await api.delete(`/api/sessions/session-ghost/processes/proc-1`)).status).toBe(404);
+ expect(kills).toEqual([]);
+ });
+});
diff --git a/packages/web/e2e/chat-tweaks.spec.mjs b/packages/web/e2e/chat-tweaks.spec.mjs
index 883d3183..7c7017be 100644
--- a/packages/web/e2e/chat-tweaks.spec.mjs
+++ b/packages/web/e2e/chat-tweaks.spec.mjs
@@ -3,8 +3,9 @@
* - the schedule create form's model/workspace use the same form-style pickers as the
* Project defaults dialog, and its bind-Session field is a searchable dropdown (not a
* raw id text input);
- * - the chat details card shows the Session id as a click-to-copy row (label flips to
- * "已复制").
+ * - the chat details card shows the Session id as a click-to-copy row (the button's icon
+ * flips to the check and its tooltip to "已复制", with the same confirmation in a
+ * visually hidden live region for screen readers — no visible text label, #312).
*
* (The Project-defaults "已保存" toast is a one-line success path exercised manually; it is
* left out here — dirtying the defaults block through its custom pickers is too sensitive
@@ -88,14 +89,26 @@ test("schedule form pickers and details Session-id copy", async ({ page }) => {
// --- Details card Session id + copy ---
// The id is selectable mono text with the copy button beside it (not inside it); the
- // "已复制" feedback appears AT the button (text), and the "Session id" label is untouched.
+ // copied feedback is the button's own icon flipping to the check + its tooltip flipping
+ // to "已复制" — NO "已复制" text is rendered (#312), and the "Session id" label is untouched.
await page.goto(`${BASE}/chat/${sessionId}`);
await page.getByPlaceholder(/输入消息/).waitFor();
await page.locator('button[title="Session 信息"]').click();
await expect(page.getByText(sessionId, { exact: true }).first()).toBeVisible();
const copyBtn = page.getByRole("button", { name: "复制 Session id" });
await copyBtn.click();
- await expect(copyBtn).toContainText("已复制");
+ expect(await page.evaluate(() => navigator.clipboard.readText())).toBe(sessionId);
+ // Feedback at the button: tooltip flips while copied; the accessible name (aria-label)
+ // and the icon-only content stay — no transient text label anywhere.
+ await expect(copyBtn).toHaveAttribute("title", "已复制");
+ await expect(copyBtn).toHaveText("");
+ // An icon swap is silent, so the confirmation ALSO lands in a visually hidden live
+ // region beside the button — present in the DOM (that is what a screen reader reads)
+ // while the button itself stays icon-only, as asserted right above.
+ await expect(page.getByText("已复制", { exact: true })).toHaveCount(1);
+ // …and both halves clear once the copied flash ends (1.5s).
+ await expect(copyBtn).toHaveAttribute("title", "复制 Session id", { timeout: 5_000 });
+ await expect(page.getByText("已复制", { exact: true })).toHaveCount(0);
// The section label above the id is not the feedback target — it stays "Session id".
await expect(page.getByText("Session id", { exact: true })).toBeVisible();
});
diff --git a/packages/web/e2e/mock-llm.mjs b/packages/web/e2e/mock-llm.mjs
index ea36b200..9ff4774e 100644
--- a/packages/web/e2e/mock-llm.mjs
+++ b/packages/web/e2e/mock-llm.mjs
@@ -13,6 +13,9 @@
* - "background server test" -> tool_use(exec_command) whose command outlives its yield
* window (processes.spec: the promoted background process shows in the session's
* process list and can be stopped from there)
+ * - "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)
* - "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
@@ -312,6 +315,19 @@ const server = http.createServer((req, res) => {
return;
}
+ // Background process that EXITS on its own (processes.spec: the exited row keeps its
+ // "已退出" label and gains a remove button that deletes the entry from the list). The
+ // command outlives the 300ms yield window — so it is promoted to background — and
+ // exits ~200ms later, leaving an exited entry behind.
+ if (flat.includes("background exit test") && !hasToolResult) {
+ block(res, 0, { type: "tool_use", id: "toolu_bgexit_1", name: "exec_command", input: {} }, [
+ { type: "input_json_delta", partial_json: '{"cmd": "sleep 0.5",' },
+ { type: "input_json_delta", partial_json: ' "yield_time_ms": 300}' },
+ ]);
+ messageStop(res, "tool_use", 14);
+ 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 e54c9d27..8b7ccbc2 100644
--- a/packages/web/e2e/processes.spec.mjs
+++ b/packages/web/e2e/processes.spec.mjs
@@ -66,9 +66,14 @@ test("background process appears in the details card and can be stopped", async
// rate in parens (from the recorded usage row).
await expect(page.getByText(/总 Token/).first()).toBeVisible();
await expect(page.getByText(/缓存命中率 \d+%/).first()).toBeVisible();
- // Trace file row names the actual .jsonl path.
+ // Trace file row shows just the FILE NAME on one line (#312) — anchored match, a full
+ // path would not match — with the copy-full-path button beside it (its own coverage
+ // lives in the exited-process test below).
await expect(page.getByText("轨迹文件")).toBeVisible();
- await expect(page.getByText(/\.jsonl/).first()).toBeVisible();
+ await expect(
+ page.getByRole("button", { name: new RegExp(`^${sessionId}_\\d{3}\\.jsonl$`) }),
+ ).toBeVisible();
+ await expect(page.getByRole("button", { name: "复制完整路径" })).toBeVisible();
// The process list row: the command, its pid line, and a working stop button.
await expect(page.getByText("会话进程")).toBeVisible();
@@ -88,3 +93,82 @@ test("background process appears in the details card and can be stopped", async
).json();
expect(procs.processes).toEqual([]);
});
+
+test("an exited process can be removed from the list; the trace row copies the full path and deep-links", 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 first test, 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 exit branch: `sleep 0.5` with a 300ms yield — promoted to background,
+ // exits on its own ~200ms later, leaving an EXITED entry in the list.
+ await ta.fill("background exit test");
+ await page.getByRole("button", { name: "发送" }).click();
+ await expect(page.getByText(/Command finished/).first()).toBeVisible({ timeout: 30_000 });
+
+ // Open the details card. The exited row keeps its 已退出 label and gains a remove
+ // button (#312); running rows are the only ones with 停止. The generous timeout rides
+ // out one 15s poll interval in case the idle refresh still saw the process alive.
+ await page.locator('button[title="Session 信息"]').click();
+ await expect(page.getByText("会话进程")).toBeVisible();
+ const row = page.locator("li", { hasText: "sleep 0.5" }).first();
+ await expect(row.getByText("已退出")).toBeVisible({ timeout: 30_000 });
+ await expect(row.getByRole("button", { name: "停止" })).toHaveCount(0);
+ await row.getByRole("button", { name: "移除" }).click();
+
+ // The removal deletes the entry: the whole section hides (no entries left) and the
+ // server-side list agrees.
+ await expect(page.getByText("会话进程")).toHaveCount(0, { timeout: 10_000 });
+ const procs = await (
+ await page.request.get(`${BASE}/api/sessions/${sessionId}/processes`)
+ ).json();
+ expect(procs.processes).toEqual([]);
+
+ // --- Trace file row actions (#312) ---
+ // Copy puts the FULL absolute path on the clipboard while the row shows only the name…
+ const traceName = page.getByRole("button", {
+ name: new RegExp(`^${sessionId}_\\d{3}\\.jsonl$`),
+ });
+ await expect(traceName).toBeVisible();
+ await page.getByRole("button", { name: "复制完整路径" }).click();
+ const copied = await page.evaluate(() => navigator.clipboard.readText());
+ expect(copied).toMatch(/\.jsonl$/);
+ expect(copied).toContain(`${sessionId}_`);
+ expect(copied.length).toBeGreaterThan((await traceName.textContent()).length);
+ expect(copied.endsWith(await traceName.textContent())).toBe(true);
+ // …and clicking the name deep-links into the Trace page focused on this session.
+ await traceName.click();
+ await expect(page).toHaveURL(new RegExp(`/traces\\?agentId=.*sessionId=`));
+ await expect(page.locator("main").getByText("轨迹观测").first()).toBeVisible({
+ timeout: 15_000,
+ });
+});
diff --git a/packages/web/src/api/endpoints.ts b/packages/web/src/api/endpoints.ts
index ff24994b..8d09238e 100644
--- a/packages/web/src/api/endpoints.ts
+++ b/packages/web/src/api/endpoints.ts
@@ -469,6 +469,13 @@ export const killSessionProcess = (sessionId: string, processId: string) =>
{ method: "POST", body: {} },
);
+/** Removes one EXITED background process entry from the list (409 process_running while it still runs — stopping is the kill route's job; 404 when it is already gone — callers just refresh). */
+export const removeSessionProcess = (sessionId: string, processId: string) =>
+ apiFetch<void>(
+ `/api/sessions/${encodeURIComponent(sessionId)}/processes/${encodeURIComponent(processId)}`,
+ { method: "DELETE" },
+ );
+
/** Mid-run steering: queues a message for the running Task (delivered between turns as a standalone `[user_steering]` user message); 409 not_running when no Task is in progress. */
export const postSteer = (sessionId: string, body: SteerRequest) =>
apiFetch<void>(`/api/sessions/${encodeURIComponent(sessionId)}/steer`, {
diff --git a/packages/web/src/components/ui/copy-button.tsx b/packages/web/src/components/ui/copy-button.tsx
index 3ea5a4bc..4d4a9ef9 100644
--- a/packages/web/src/components/ui/copy-button.tsx
+++ b/packages/web/src/components/ui/copy-button.tsx
@@ -4,21 +4,20 @@
*
* - the write is optimistic (an insecure context or denied permission must not leave the
* control stuck), matching the clipboard convention used across the chat views;
- * - the feedback is ALWAYS shown AT THE BUTTON — the icon swaps copy → check for
- * COPIED_MS and the tooltip flips to "已复制"; a control with room can also show the
- * "已复制" text next to the check (showCopiedText). The feedback never replaces an
- * unrelated label/title elsewhere.
- *
- * Icon-only callers (message footer, code block, reply stats) pass their own compact
- * className and omit showCopiedText, keeping their existing look; wider affordances (the
- * details card's Session id row) opt into the text.
+ * - the feedback is ALWAYS shown AT THE BUTTON, and it is the icon alone: copy swaps to
+ * the check for COPIED_MS and the tooltip flips to "已复制" (#312 — no transient
+ * "已复制" text is rendered, and the feedback never replaces an unrelated label/title
+ * elsewhere). A control that keeps a visible text label (e.g. "复制 Prompt") keeps it
+ * unchanged and swaps only its glyph — see CopyCheckGlyph + useCopied;
+ * - the icon swap is silent, so every copy affordance also renders a CopiedStatus live
+ * region beside itself — that is the screen-reader half of the same feedback.
*/
-import { useState } from "react";
+import { useEffect, useRef, useState } from "react";
import { S } from "../../lib/strings";
import { STAT_ICONS } from "../../lib/stat-icons";
import { GlyphIcon } from "./glyph-icon";
-/** How long the copied state (check icon + "已复制") stays after a click. */
+/** How long the copied state (check icon + flipped tooltip) stays after a click. */
const COPIED_MS = 1500;
/** Best-effort clipboard write (never throws; no-op where the API is unavailable). */
@@ -28,28 +27,78 @@ export function writeClipboard(text: string): void {
/**
* Transient "just copied" flag: `flash()` writes the text and turns `copied` on for
- * COPIED_MS. Exposed for the rare caller whose copy trigger is not a plain CopyButton
- * (e.g. a whole row); most callers should use CopyButton directly.
+ * COPIED_MS. Exposed for the caller whose copy trigger is not a plain CopyButton
+ * (e.g. a text button rendering CopyCheckGlyph next to its label); most callers
+ * should use CopyButton directly.
*/
export function useCopied(): { copied: boolean; flash: (text: string) => void } {
const [copied, setCopied] = useState(false);
+ // The pending reset is held so it can be restarted and cancelled. Restarted: a second
+ // click must get its own full COPIED_MS, or the first click's timer clears the check
+ // right after the second copy — and the check is now the only feedback, so a check that
+ // vanishes on click reads as "the copy didn't take". Cancelled: the control can unmount
+ // inside the window (the Trace row closes the details popover itself; the memory and
+ // skill-import modals close the same way), and the timeout must not outlive it.
+ const resetTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
+ useEffect(
+ () => () => {
+ if (resetTimer.current !== null) clearTimeout(resetTimer.current);
+ },
+ [],
+ );
const flash = (text: string) => {
writeClipboard(text);
setCopied(true);
- setTimeout(() => setCopied(false), COPIED_MS);
+ if (resetTimer.current !== null) clearTimeout(resetTimer.current);
+ resetTimer.current = setTimeout(() => {
+ resetTimer.current = null;
+ setCopied(false);
+ }, COPIED_MS);
};
return { copied, flash };
}
+/** The glyph pair every copy affordance shows: the copy icon, swapping to the check while copied. */
+export function CopyCheckGlyph({ copied, size }: { copied: boolean; size?: number }) {
+ return <GlyphIcon d={copied ? STAT_ICONS.check : STAT_ICONS.copy} size={size} />;
+}
+
+/**
+ * Screen-reader half of the copy feedback, rendered NEXT TO the control (never inside it,
+ * so it joins neither the visible label nor the accessible name). The check glyph is
+ * `aria-hidden` and the tooltip flip is never announced — a `title` only contributes when
+ * there is no `aria-label` — so without this region the confirmation is silent. The region
+ * is always rendered and merely filled on copy: a live region announces changes to its
+ * content, so it has to exist before the text appears.
+ *
+ * Deliberately a bare `aria-live` region rather than `role="status"` (which would mean the
+ * same to a screen reader): `role="status"` is this app's RUNNING-SPINNER marker — see
+ * status-icon.tsx — and copy buttons sit on pages that assert no spinner is left over.
+ */
+export function CopiedStatus({ copied }: { copied: boolean }) {
+ return (
+ <span className="sr-only" aria-live="polite" aria-atomic="true">
+ {copied ? S.common.copied : ""}
+ </span>
+ );
+}
+
/** Default compact icon-button look (message footer / code block). */
const DEFAULT_CLASS =
"rounded p-0.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300";
+/**
+ * The copy button beside a mono value row (details card Session id / Trace file, Agent
+ * State path): the default look plus what a flex row needs — never shrink, and an
+ * explicit dark-mode idle tone.
+ */
+export const ROW_COPY_CLASS =
+ "shrink-0 rounded p-0.5 text-gray-400 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-600 dark:text-gray-500 dark:hover:bg-gray-800 dark:hover:text-gray-300";
+
export function CopyButton({
text,
label,
className = DEFAULT_CLASS,
- showCopiedText = false,
}: {
/** The string to copy, or a getter for content computed at click time (e.g. a formatted stats line). */
text: string | (() => string);
@@ -57,26 +106,22 @@ export function CopyButton({
label: string;
/** Overrides the compact default look (e.g. the reply row's fixed-size button). */
className?: string;
- /** Render the "已复制" text beside the check while copied (for wide affordances with room). */
- showCopiedText?: boolean;
}) {
const { copied, flash } = useCopied();
return (
- <button
- type="button"
- title={copied ? S.common.copied : label}
- aria-label={label}
- onClick={() => flash(typeof text === "function" ? text() : text)}
- className={className}
- >
- {showCopiedText && copied ? (
- <span className="flex items-center gap-1">
- <GlyphIcon d={STAT_ICONS.check} />
- {S.common.copied}
- </span>
- ) : (
- <GlyphIcon d={copied ? STAT_ICONS.check : STAT_ICONS.copy} />
- )}
- </button>
+ <>
+ <button
+ type="button"
+ title={copied ? S.common.copied : label}
+ aria-label={label}
+ onClick={() => flash(typeof text === "function" ? text() : text)}
+ className={className}
+ >
+ <CopyCheckGlyph copied={copied} />
+ </button>
+ {/* Sibling, not a child: the button's accessible name stays `label`, and `sr-only`
+ is position:absolute, so it is not a flex item and disturbs no caller's layout. */}
+ <CopiedStatus copied={copied} />
+ </>
);
}
diff --git a/packages/web/src/features/agents/agent-settings-page.tsx b/packages/web/src/features/agents/agent-settings-page.tsx
index 37416e09..80a674ab 100644
--- a/packages/web/src/features/agents/agent-settings-page.tsx
+++ b/packages/web/src/features/agents/agent-settings-page.tsx
@@ -35,7 +35,7 @@ import { Input, Textarea } from "../../components/ui/input";
import { OptionMenu, type OptionMenuChoice } from "../../components/ui/option-menu";
import { Switch } from "../../components/ui/switch";
import { ConfirmModal, useSaveConfirm } from "../../components/ui/confirm-modal";
-import { CopyButton } from "../../components/ui/copy-button";
+import { CopyButton, ROW_COPY_CLASS } from "../../components/ui/copy-button";
import { Skeleton } from "../../components/ui/skeleton";
import { GlyphIcon } from "../../components/ui/glyph-icon";
import { SkillsTab } from "./skills-tab";
@@ -487,8 +487,7 @@ function OverviewTab({
<CopyButton
text={data.stateDir}
label={S.agent.copyStateDir}
- showCopiedText
- className="flex shrink-0 items-center gap-1 rounded p-0.5 text-xs text-gray-400 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-600 dark:text-gray-500 dark:hover:bg-gray-800 dark:hover:text-gray-300"
+ className={ROW_COPY_CLASS}
/>
</div>
</div>
diff --git a/packages/web/src/features/agents/memory-tab.tsx b/packages/web/src/features/agents/memory-tab.tsx
index 421e299d..d1f26645 100644
--- a/packages/web/src/features/agents/memory-tab.tsx
+++ b/packages/web/src/features/agents/memory-tab.tsx
@@ -28,6 +28,7 @@ import { useAuth } from "../../state/auth";
import { useLocale } from "../../state/locale";
import { useProject } from "../../state/project";
import { Button } from "../../components/ui/button";
+import { CopiedStatus, CopyCheckGlyph, useCopied } from "../../components/ui/copy-button";
import { GlyphIcon } from "../../components/ui/glyph-icon";
import { Modal } from "../../components/ui/modal";
import { Textarea } from "../../components/ui/input";
@@ -306,13 +307,9 @@ export function MemoryTab({
};
const editPrompt = editing ? buildMemoryEditPrompt(editing.file.title, editRequirement) : "";
-
- const copyEditPrompt = () => {
- void navigator.clipboard
- .writeText(editPrompt)
- .then(() => toastSuccess(S.memory.editCopied))
- .catch(() => toastError(S.common.unknownError));
- };
+ // Copy feedback lives at the button (the shared copy convention): its glyph flips to
+ // the check while copied — no toast, and the button label never changes.
+ const editCopy = useCopied();
/**
* The bridge-to-chat jump shared by edit and add: prefill the draft (merging over what is
@@ -351,13 +348,7 @@ export function MemoryTab({
};
const addPrompt = adding ? buildMemoryAddPrompt(adding.kind, addContent) : "";
-
- const copyAddPrompt = () => {
- void navigator.clipboard
- .writeText(addPrompt)
- .then(() => toastSuccess(S.memory.editCopied))
- .catch(() => toastError(S.common.unknownError));
- };
+ const addCopy = useCopied();
const openAddChat = () => {
if (adding) openChatWithDraft(addPrompt, adding.workspacePath);
@@ -684,9 +675,11 @@ export function MemoryTab({
className="text-gray-600 dark:text-gray-300"
/>
<div className="flex gap-2">
- <Button size="sm" onClick={copyEditPrompt}>
+ <Button size="sm" onClick={() => editCopy.flash(editPrompt)}>
+ <CopyCheckGlyph copied={editCopy.copied} size={12} />
{S.memory.editCopyPrompt}
</Button>
+ <CopiedStatus copied={editCopy.copied} />
<Button size="sm" variant="primary" onClick={openEditChat}>
{S.memory.editOpenChat}
</Button>
@@ -726,9 +719,15 @@ export function MemoryTab({
className="text-gray-600 dark:text-gray-300"
/>
<div className="flex gap-2">
- <Button size="sm" disabled={addContent.trim() === ""} onClick={copyAddPrompt}>
+ <Button
+ size="sm"
+ disabled={addContent.trim() === ""}
+ onClick={() => addCopy.flash(addPrompt)}
+ >
+ <CopyCheckGlyph copied={addCopy.copied} size={12} />
{S.memory.editCopyPrompt}
</Button>
+ <CopiedStatus copied={addCopy.copied} />
<Button
size="sm"
variant="primary"
diff --git a/packages/web/src/features/agents/skills-tab.tsx b/packages/web/src/features/agents/skills-tab.tsx
index 449737cc..c8edda4a 100644
--- a/packages/web/src/features/agents/skills-tab.tsx
+++ b/packages/web/src/features/agents/skills-tab.tsx
@@ -29,6 +29,7 @@ import { useAuth } from "../../state/auth";
import { useLocale } from "../../state/locale";
import { agentDisplayName, useProject } from "../../state/project";
import { Button } from "../../components/ui/button";
+import { CopiedStatus, CopyCheckGlyph, useCopied } from "../../components/ui/copy-button";
import { GlyphIcon } from "../../components/ui/glyph-icon";
import { Input, Textarea } from "../../components/ui/input";
import { Modal } from "../../components/ui/modal";
@@ -197,12 +198,9 @@ export function SkillsTab({
const trimmedSource = source.trim();
const chatPrompt = buildImportPrompt(trimmedSource || S.skills.importSourceToken);
- const copyPrompt = () => {
- void navigator.clipboard
- .writeText(buildImportPrompt(trimmedSource))
- .then(() => toastSuccess(S.skills.importCopied))
- .catch(() => toastError(S.common.unknownError));
- };
+ // Copy feedback lives at the button (the shared copy convention): its glyph flips to
+ // the check while copied — no toast, and the button label never changes.
+ const promptCopy = useCopied();
/**
* "Open a new chat" with this Agent: the same draft-state entry as the agents page
@@ -404,9 +402,15 @@ export function SkillsTab({
className="text-gray-600 dark:text-gray-300"
/>
<div className="flex gap-2">
- <Button size="sm" disabled={trimmedSource === ""} onClick={copyPrompt}>
+ <Button
+ size="sm"
+ disabled={trimmedSource === ""}
+ onClick={() => promptCopy.flash(buildImportPrompt(trimmedSource))}
+ >
+ <CopyCheckGlyph copied={promptCopy.copied} size={12} />
{S.skills.importCopyPrompt}
</Button>
+ <CopiedStatus copied={promptCopy.copied} />
<Button size="sm" variant="primary" onClick={openChat}>
{S.skills.importOpenChat}
</Button>
diff --git a/packages/web/src/features/chat/chat-page.tsx b/packages/web/src/features/chat/chat-page.tsx
index b805933f..7f1be305 100644
--- a/packages/web/src/features/chat/chat-page.tsx
+++ b/packages/web/src/features/chat/chat-page.tsx
@@ -32,6 +32,7 @@ import * as api from "../../api/endpoints";
import { ApiError } from "../../api/client";
import { S } from "../../lib/strings";
import { apiErrorText } from "../../lib/api-error";
+import { pathFileName } from "../../lib/file-path";
import { useDocumentTitle } from "../../lib/use-document-title";
import {
formatDateTime,
@@ -53,7 +54,7 @@ import { Button } from "../../components/ui/button";
import { Skeleton } from "../../components/ui/skeleton";
import { Truncated } from "../../components/ui/truncated";
import { Dropdown } from "../../components/ui/dropdown";
-import { CopyButton } from "../../components/ui/copy-button";
+import { CopyButton, ROW_COPY_CLASS } from "../../components/ui/copy-button";
import { EmptyState } from "../../components/ui/empty-state";
import { toastError } from "../../components/ui/toast";
import { MessageStream } from "./message-stream";
@@ -138,8 +139,9 @@ function StatChip({ icon, value, label }: { icon: string; value: ReactNode; labe
/**
* Session id row in the details card: the id is selectable mono text (styled like the other
- * sections' values) with the shared CopyButton beside it. The copy feedback shows the check
- * + "已复制" text at the button (showCopiedText) — the "Session id" label above never changes.
+ * sections' values) with the shared CopyButton beside it. The copy feedback is the button's
+ * icon swapping to the check (#312, no "已复制" text) — the "Session id" label above never
+ * changes.
*/
function SessionIdRow({ sessionId }: { sessionId: string }) {
return (
@@ -149,12 +151,7 @@ function SessionIdRow({ sessionId }: { sessionId: string }) {
</p>
<div className="flex items-start gap-1.5">
<span className="min-w-0 flex-1 break-all font-mono text-xs leading-5">{sessionId}</span>
- <CopyButton
- text={sessionId}
- label={S.chat.copySessionId}
- showCopiedText
- className="flex shrink-0 items-center gap-1 rounded p-0.5 text-xs text-gray-400 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-600 dark:text-gray-500 dark:hover:bg-gray-800 dark:hover:text-gray-300"
- />
+ <CopyButton text={sessionId} label={S.chat.copySessionId} className={ROW_COPY_CLASS} />
</div>
</div>
);
@@ -704,6 +701,14 @@ export function ChatPage() {
};
}, [projectId, selected, stream.taskState, infoOpen]);
+ // The currently selected Session, readable from an async callback that captured an older
+ // one (the process actions below): a state value read through a closure would be the value
+ // at click time, which is exactly what must not decide where a late response lands.
+ const selectedSessionIdRef = useRef<string | null>(selectedSessionId);
+ useEffect(() => {
+ selectedSessionIdRef.current = selectedSessionId;
+ }, [selectedSessionId]);
+
// Background-process list: fetched on session entry, then kept fresh while it can still
// change — during a run (a foreground command may promote to background at any moment),
// while any listed process is still running (it can exit on its own), and while the
@@ -736,28 +741,59 @@ export function ChatPage() {
};
}, [selectedSessionId, stream.taskState, processesCanChange]);
- // Stop one background process: the kill also removes it from the server-side registry,
- // 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(
- async (processId: string) => {
+ /**
+ * 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.
+ */
+ const runProcessAction = useCallback(
+ async (
+ processId: string,
+ request: (sessionId: string, processId: string) => Promise<void>,
+ staleStatuses: readonly number[],
+ ) => {
if (!selected || procBusy !== null) return;
+ const sessionId = selected.sessionId;
setProcBusy(processId);
try {
- await api.killSessionProcess(selected.sessionId, processId);
+ await request(sessionId, processId);
} catch (e) {
- if (!(e instanceof ApiError && e.status === 404)) toastError(apiErrorText(e));
+ if (!(e instanceof ApiError && staleStatuses.includes(e.status))) {
+ toastError(apiErrorText(e));
+ }
} finally {
setProcBusy(null);
api
- .getSessionProcesses(selected.sessionId)
- .then((res) => setProcesses(res.processes))
+ .getSessionProcesses(sessionId)
+ .then((res) => {
+ if (selectedSessionIdRef.current === sessionId) setProcesses(res.processes);
+ })
.catch(() => undefined);
}
},
[selected, procBusy],
);
+ // Stop one background process: the kill also removes it from the server-side registry,
+ // 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]),
+ [runProcessAction],
+ );
+
+ // Remove one EXITED process entry from the list (#312; running rows offer Stop instead).
+ // 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]),
+ [runProcessAction],
+ );
+
// Trace file path for the popover's trace row: the single-session GET is the only
// surface carrying it, so fetch lazily on open (and once per session — the path only
// ever moves forward when a new trace file starts, which a reopen picks up).
@@ -1497,8 +1533,9 @@ export function ChatPage() {
</div>
{/* Background processes the conversation started (e.g. a dev server on
localhost:3000): live rows carry a stop button — the kill signals the whole
- process group and the row drops on the follow-up refresh. Hidden entirely
- while there are none. */}
+ 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. */}
{processes.length > 0 && (
<div>
<p className="text-xs font-medium text-gray-500 dark:text-gray-400">
@@ -1534,9 +1571,26 @@ export function ChatPage() {
{procBusy === p.processId ? S.common.loading : S.chat.processStop}
</button>
) : (
- <span className="shrink-0 text-[11px] text-gray-400 dark:text-gray-500">
- {S.chat.processExited}
- </span>
+ <>
+ <span className="shrink-0 text-[11px] text-gray-400 dark:text-gray-500">
+ {S.chat.processExited}
+ </span>
+ {/* The row is the only handle on that process's captured
+ output — removing the entry drops it from the runtime
+ registry, so the model can no longer be asked to read it
+ (input_command answers "unknown process_id"). No confirm
+ step for a one-click tidy-up of a dead row, but the title
+ says what leaves with it. */}
+ <button
+ type="button"
+ title={S.chat.processRemoveHint}
+ disabled={procBusy !== null}
+ 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}
+ </button>
+ </>
)}
</li>
))}
@@ -1544,30 +1598,46 @@ export function ChatPage() {
</div>
)}
{/* Trace file, same section anatomy as the rows above (label + mono value):
- the path itself is the click target and SPA-navigates to the Trace page
- deep-linked to the owning Agent AND this Session (?agentId= focuses/expands
- the Agent group, ?sessionId= auto-selects — a Session beyond the first
- loaded page resolves via the Trace page's full-fetch fallback). Hidden
- until a trace exists (a brand-new session has no file to open); only
- reachable for a real Session — this whole header renders behind the
- `selected` guard, so a draft never shows it. */}
+ the value is the file NAME on a single line (#312 — the full path wrapped
+ over several lines; it now lives in the tooltip and the copy button, which
+ copies the FULL path). The name itself is the click target and
+ SPA-navigates to the Trace page deep-linked to the owning Agent AND this
+ Session (?agentId= focuses/expands the Agent group, ?sessionId=
+ auto-selects — a Session beyond the first loaded page resolves via the
+ Trace page's full-fetch fallback). Hidden until a trace exists (a
+ brand-new session has no file to open); only reachable for a real
+ Session — this whole header renders behind the `selected` guard, so a
+ draft never shows it. */}
{tracePath !== null && (
<div>
<p className="text-xs font-medium text-gray-500 dark:text-gray-400">
{S.chat.traceFile}
</p>
- <button
- type="button"
- onClick={() => {
- setInfoOpen(false);
- navigate(
- `/traces?agentId=${encodeURIComponent(selected.agentId)}&sessionId=${encodeURIComponent(selected.sessionId)}`,
- );
- }}
- className="break-all text-left font-mono text-xs leading-5 text-gray-600 underline decoration-gray-300 underline-offset-2 transition-colors duration-150 hover:text-gray-900 dark:text-gray-300 dark:decoration-gray-600 dark:hover:text-gray-100"
- >
- {tracePath}
- </button>
+ <div className="flex items-center gap-1.5">
+ {/* Wrapper (not flex-1 on the button itself) keeps the click target no
+ wider than the name while the copy button still sits at the row's
+ right edge, mirroring the Session id row. */}
+ <div className="min-w-0 flex-1">
+ <button
+ type="button"
+ title={tracePath}
+ onClick={() => {
+ setInfoOpen(false);
+ navigate(
+ `/traces?agentId=${encodeURIComponent(selected.agentId)}&sessionId=${encodeURIComponent(selected.sessionId)}`,
+ );
+ }}
+ className="max-w-full truncate text-left font-mono text-xs leading-5 text-gray-600 underline decoration-gray-300 underline-offset-2 transition-colors duration-150 hover:text-gray-900 dark:text-gray-300 dark:decoration-gray-600 dark:hover:text-gray-100"
+ >
+ {pathFileName(tracePath)}
+ </button>
+ </div>
+ <CopyButton
+ text={tracePath}
+ label={S.chat.copyTracePath}
+ className={ROW_COPY_CLASS}
+ />
+ </div>
</div>
)}
</div>
diff --git a/packages/web/src/lib/file-path.ts b/packages/web/src/lib/file-path.ts
index 909fb37c..e885d07f 100644
--- a/packages/web/src/lib/file-path.ts
+++ b/packages/web/src/lib/file-path.ts
@@ -95,6 +95,22 @@ export function joinWorkspacePath(base: string, name: string): string {
return base === "" ? name : `${base}/${name}`;
}
+/**
+ * Final path segment, for showing a file's NAME where the full path would wrap (the
+ * details card's Trace file row keeps the path in the tooltip / copy action instead).
+ * Cuts at the last separator of EITHER kind: a Windows deployment reports `\`
+ * (server-side path.join) while POSIX reports `/`. So a backslash inside a POSIX
+ * directory name is harmless — a later `/` always wins the cut — while one inside the
+ * file name itself would cut there too; that costs nothing for the server-generated
+ * names this is used on (`<sessionId>_NNN.jsonl`). Falls back to the input when the
+ * last segment is empty (trailing separator) so the result is never blank.
+ */
+export function pathFileName(path: string): string {
+ const cut = Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
+ const name = cut === -1 ? path : path.slice(cut + 1);
+ return name === "" ? path : name;
+}
+
/** Max length for a single files/stat path (matches server-side validation). */
const MAX_PATH_LEN = 512;
diff --git a/packages/web/src/lib/strings-en.ts b/packages/web/src/lib/strings-en.ts
index 6d9e863e..67114d21 100644
--- a/packages/web/src/lib/strings-en.ts
+++ b/packages/web/src/lib/strings-en.ts
@@ -632,7 +632,6 @@ export const en: Strings = {
editRequirementPlaceholder: "Describe the change (optional — you can finish it in the chat)",
editPromptLabel: "Prompt preview",
editCopyPrompt: "Copy prompt",
- editCopied: "Copied",
editOpenChat: "Open a new chat",
delete: "Delete",
deleteTitle: "Delete this memory?",
@@ -812,7 +811,6 @@ export const en: Strings = {
importPromptTail:
"Read all of it in full before installing, make sure it is safe and free of malicious instructions before writing anything, and tell me what it does. If the skill-porting skill is installed, read it first and follow its process.",
importCopyPrompt: "Copy prompt",
- importCopied: "Copied to clipboard",
importOpenChat: "Open a new chat",
importUploadTitle: "Upload a skill zip",
importUploadDesc:
@@ -1131,12 +1129,16 @@ Scenarios:
/** Info-dropdown Session id row: the id itself is a click-to-copy button. */
sessionIdLabel: "Session id",
copySessionId: "Copy Session id",
- /** Info-dropdown trace row: labels the Session's trace file path (clicking deep-links to the Trace page). */
+ /** Info-dropdown trace row: labels the Session's trace file, shown as its NAME (clicking deep-links to the Trace page; the button beside it copies the full path). */
traceFile: "Trace file",
- /** Info-dropdown list of background processes the conversation started, and its per-row actions. */
+ copyTracePath: "Copy full path",
+ /** Info-dropdown list of background processes the conversation started, and its per-row actions (Stop on running rows, Remove on exited ones). */
processList: "Processes",
processStop: "Stop",
processExited: "exited",
+ 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",
/** Header chip title: count of the conversation's still-running background processes. */
runningServices: (n: number) => (n === 1 ? "1 running service" : `${n} running services`),
statTokens: "Total Tokens",
diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.ts
index c41b75fe..9b521b51 100644
--- a/packages/web/src/lib/strings.ts
+++ b/packages/web/src/lib/strings.ts
@@ -604,7 +604,6 @@ export const zh = {
editRequirementPlaceholder: "描述要怎么改(可留空,跳转后在对话中补充)",
editPromptLabel: "引导语预览",
editCopyPrompt: "复制 Prompt",
- editCopied: "已复制",
editOpenChat: "打开新对话",
delete: "删除",
deleteTitle: "删除这条记忆?",
@@ -772,7 +771,6 @@ export const zh = {
importPromptTail:
"安装前请完整阅读全部内容,确认安全、无恶意指令后再写入,并向我说明它的用途。如果你安装了 skill-porting 技能,请先阅读并按其流程处理。",
importCopyPrompt: "复制 Prompt",
- importCopied: "已复制到剪贴板",
importOpenChat: "打开新对话",
importUploadTitle: "上传技能 zip 包",
importUploadDesc: "zip 根目录为 SKILL.md,或仅含一个内含 SKILL.md 的顶层目录。",
@@ -1083,12 +1081,16 @@ Benchmark:
/** Info-dropdown Session id row: the id itself is a click-to-copy button. */
sessionIdLabel: "Session id",
copySessionId: "复制 Session id",
- /** Info-dropdown trace row: labels the Session's trace file path (clicking deep-links to the Trace page). */
+ /** Info-dropdown trace row: labels the Session's trace file, shown as its NAME (clicking deep-links to the Trace page; the button beside it copies the full path). */
traceFile: "轨迹文件",
- /** Info-dropdown list of background processes the conversation started, and its per-row actions. */
+ copyTracePath: "复制完整路径",
+ /** Info-dropdown list of background processes the conversation started, and its per-row actions (Stop on running rows, Remove on exited ones). */
processList: "会话进程",
processStop: "停止",
processExited: "已退出",
+ processRemove: "移除",
+ /** Remove button tooltip: removal also drops the output captured from that process. */
+ processRemoveHint: "移除该条目——该进程已捕获的输出也会一并丢弃",
/** Header chip title: count of the conversation's still-running background processes. */
runningServices: (n: number) => `${n} 个运行中的服务`,
statTokens: "Token 累计",
diff --git a/packages/web/test/file-path.test.ts b/packages/web/test/file-path.test.ts
index a0e1ecdf..d34304f8 100644
--- a/packages/web/test/file-path.test.ts
+++ b/packages/web/test/file-path.test.ts
@@ -1,10 +1,16 @@
/**
* file-path.ts unit tests: whether inline code in message text looks like a file path,
* all branches of normalizing body paths to a Workspace-relative path (toWorkspaceRelative),
- * and the directory-browser navigation join (joinWorkspacePath).
+ * the directory-browser navigation join (joinWorkspacePath), and the display name of a
+ * file path (pathFileName — the details card's Trace file row).
*/
import { describe, expect, it } from "vitest";
-import { isFilePathLike, joinWorkspacePath, toWorkspaceRelative } from "../src/lib/file-path";
+import {
+ isFilePathLike,
+ joinWorkspacePath,
+ pathFileName,
+ toWorkspaceRelative,
+} from "../src/lib/file-path";
describe("isFilePathLike", () => {
it("relative path + image extension → match", () => {
@@ -158,3 +164,35 @@ describe("joinWorkspacePath", () => {
expect(joinWorkspacePath(pathStateAfterFirstClick, "home")).toBe("home/home");
});
});
+
+describe("pathFileName", () => {
+ it("POSIX absolute path → final segment", () => {
+ expect(pathFileName("/home/user/PenguinHarness/traces/2026-08-18/s-1/001.jsonl")).toBe(
+ "001.jsonl",
+ );
+ });
+
+ it("Windows path (backslashes) → final segment", () => {
+ expect(pathFileName("C:\\Users\\u\\PenguinHarness\\traces\\001.jsonl")).toBe("001.jsonl");
+ });
+
+ it("mixed separators → the last of either kind cuts", () => {
+ expect(pathFileName("C:/Users/u\\traces\\001.jsonl")).toBe("001.jsonl");
+ });
+
+ it("bare filename → unchanged", () => {
+ expect(pathFileName("001.jsonl")).toBe("001.jsonl");
+ });
+
+ it("a backslash inside a POSIX directory name is harmless — the later '/' wins the cut", () => {
+ expect(pathFileName("/data/weird\\dir/traces/001.jsonl")).toBe("001.jsonl");
+ });
+
+ it("the cut is the last separator of either kind, so a backslash in the file name cuts too (no such trace name exists — pinning the rule, not endorsing it)", () => {
+ expect(pathFileName("/data/traces/weird\\001.jsonl")).toBe("001.jsonl");
+ });
+
+ it("degenerate trailing separator falls back to the input (never blank)", () => {
+ expect(pathFileName("/home/user/")).toBe("/home/user/");
+ });
+});