Skip to content

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

fix(web): 子会话的输入框发不出去消息时,原因留在框上方,不再只活六秒

lmlihengc6ae24d338b6
diff --git a/changelog/unreleased/2026-11-05-subagent-send-refusal.md b/changelog/unreleased/2026-11-05-subagent-send-refusal.md
new file mode 100644
index 00000000..8b8f2e9d
--- /dev/null
+++ b/changelog/unreleased/2026-11-05-subagent-send-refusal.md
@@ -0,0 +1,50 @@
+# A message the subagent panel could not deliver says why above its composer, not in a six-second toast
+
+- **Date:** 2026-11-05
+- **Type:** fix
+- **Scope:** `web`
+- **Breaking:** no
+
+[中文](2026-11-05-subagent-send-refusal.zh.md)
+
+The agents dock has a composer of its own, so a child session can be answered from the panel. When
+that message did not reach the child — the child had been released and could not be revived, the
+server refused it, the connection dropped — the composer deliberately kept what was typed (`onSend`
+answers `false` for exactly that reason) while the reason went to a notification: six seconds later
+it was gone, leaving a box that still held the message, with the same button to retry it, and
+nothing saying what had happened.
+
+That sentence now sits right above the box it belongs to (`role="alert"`, danger colour,
+`NoticeStrip`'s danger tone) and stays there until the next attempt clears it. A released child
+keeps its own wording ("the subagent session no longer exists and could not be revived") because
+there the child is what is missing, not the message; every other failure is named for the action and
+carries the server's own words, read through the app-wide refusal rule (a request that never reached
+the route says what its code means, not its wire message).
+
+## Details
+
+- `packages/web/src/features/chat/subagent-send-refusal.ts` (new): `subagentSendRefused(err)` — the
+ pure decision, so which sentence appears is in one place and testable without the panel.
+- `packages/web/src/features/chat/subagents-view.tsx`: the panel's `SubagentComposer` gains a
+ `sendRefusal` state, written by `sendFailure` (which used to `toastError`) and cleared by the send
+ and steer paths before their requests leave; the strip renders above `ChatInput`, inside the same
+ reading column. The composer is keyed by child, so switching nodes never carries a stale line over.
+- `packages/web/src/lib/strings{,-en}.ts`: one new pair, `subagentPanel.sendRefused(reason)`.
+
+## Tests
+
+- `packages/web/test/subagent-send-refusal.test.ts` (new, 5 cases): the released child keeps its own
+ sentence; a server answer is named for the action and carries its words; a request that failed on
+ the way out reads through `refusalText`; nothing to say falls back to the generic sentence; the
+ active language is the one used.
+- `packages/web/e2e/subagent-send-refusal.spec.mjs` (new, real server, real browser): spawn a child,
+ stub the child-message `POST` to 500, press send in the panel's composer. The line appears above
+ the box with the server's words, the notification region never carries them, the draft stays in the
+ box, and **seven seconds later** (past the six an error notification lives) it is still there; once
+ the route is allowed through again the next send leaves nothing behind.
+
+## Compatibility
+
+No interface change, no new dependency, no Project config change. The panel's `pinChildLevel`
+failure (a thinking-level pick in the toolbar) keeps its toast: what the reader has to change there
+is the picker itself, not the composer.
diff --git a/changelog/unreleased/2026-11-05-subagent-send-refusal.zh.md b/changelog/unreleased/2026-11-05-subagent-send-refusal.zh.md
new file mode 100644
index 00000000..f583c257
--- /dev/null
+++ b/changelog/unreleased/2026-11-05-subagent-send-refusal.zh.md
@@ -0,0 +1,41 @@
+# 子智能体面板发不出去的消息,原因留在输入框上方,不再只活六秒
+
+- **日期:** 2026-11-05
+- **类型:** fix
+- **范围:** `web`
+- **破坏性:** 否
+
+[English](2026-11-05-subagent-send-refusal.md)
+
+智能体停靠栏有自己的输入框,因此子会话可以直接在面板里回话。那条消息没能送到子会话时 —— 子会话已经被
+释放、恢复不了,服务端拒绝了,或者连接断了 —— 输入框是有意留着用户打的字的(`onSend` 返回 `false` 正是
+为了这个),而原因只落进一条通知:六秒后它自己消失,屏上留下一个仍然装着那条消息的框、同一颗重试的按钮,
+以及什么都没有发生的样子。
+
+那句话现在贴在它所属的框上方(`role="alert"`、危险色、`NoticeStrip` 的危险色调),一直留到下一次尝试
+把它清掉。子会话已被释放时仍念它自己的那句(「该子会话已不存在,无法恢复」)—— 那里缺的是子会话,不是
+消息;其余失败一律先点名这件事,再接服务端原话,走全应用拒绝位的规则(请求没到服务端时念错误码自己的
+本地化句子,而不是它的线上原文)。
+
+## 明细
+
+- `packages/web/src/features/chat/subagent-send-refusal.ts`(新):`subagentSendRefused(err)` —— 纯判断,
+ 念哪句话只在这一处,不依赖面板就能测。
+- `packages/web/src/features/chat/subagents-view.tsx`:面板的 `SubagentComposer` 多一个 `sendRefusal`
+ 状态 —— `sendFailure` 写上(原来走 `toastError`),发送与转向两条路在请求发出之前清掉;那条提示条画在
+ `ChatInput` 上方、同一个阅读栏里。输入框按子会话设了 key,切换节点不会把上一次的话带过去。
+- `packages/web/src/lib/strings{,-en}.ts`:一对新文案 `subagentPanel.sendRefused(reason)`。
+
+## 测试
+
+- `packages/web/test/subagent-send-refusal.test.ts`(新,5 条):被释放的子会话念它自己那句;服务端的
+ 答复先点名这件事并带上原话;没到服务端的请求按 `refusalText` 读;无话可说时退回通用句;用的是当前语言。
+- `packages/web/e2e/subagent-send-refusal.spec.mjs`(新,真服务端 + 真浏览器):派生子会话,把子会话
+ 消息那一笔 `POST` 在 `page.route` 上桩成 500,在面板的输入框里按发送。那句话画在框上方、带服务端原话,
+ 通知区里没有它,草稿仍在框里;**7 秒后**(超过错误通知活着的 6 秒)它仍在;把这条路由放行之后再发一次,
+ 屏上什么都不留。
+
+## 兼容性
+
+不碰接口、不引入新依赖、不改 Project 配置。面板里另一处 `pinChildLevel` 失败(工具栏那次思考等级的下发)
+仍走通知:那里要改的是选择器本身,不是输入框。
diff --git a/packages/web/e2e/subagent-send-refusal.spec.mjs b/packages/web/e2e/subagent-send-refusal.spec.mjs
new file mode 100644
index 00000000..7de8b316
--- /dev/null
+++ b/packages/web/e2e/subagent-send-refusal.spec.mjs
@@ -0,0 +1,115 @@
+/**
+ * Regression: a message the subagent panel could not deliver leaves its reason above the box that
+ * still holds the text, instead of in a six-second toast.
+ *
+ * The child composer deliberately keeps what was typed when `onSend` answers `false` — so after a
+ * refusal the reader is still looking at the message they meant to send, with the same button to
+ * retry it. The reason used to be a notification: it floated over the panel, dismissed itself after
+ * six seconds, and left a composer that read exactly as it did before the press.
+ *
+ * The message POST is stubbed at `page.route` for the refusal half, so the child's own run is not
+ * what is being measured; the second half lets the same route through again and watches the line
+ * go, because it belongs to the attempt that produced it.
+ */
+import { test, expect } from "@playwright/test";
+import { provisionAndLogin } from "./auth.mjs";
+
+const BASE = process.env.BASE_URL;
+const MOCK = process.env.MOCK_URL;
+const P = "password123";
+
+/** The child's route: one message into one subagent child of one session. */
+const MESSAGE_ROUTE = /\/api\/sessions\/[^/]+\/subagents\/[^/]+\/message$/;
+
+/** The refusal the stub answers with: a 500 whose words must come back into the panel. */
+const REFUSAL = { code: "subagent_busy", message: "the subagent is mid-rewrite" };
+
+/** Register a user, wire the mock model into their auto-provisioned Project, create one session. */
+async function provisionSession(page, username) {
+ await provisionAndLogin(page.request, username, P);
+ const projects = await (await page.request.get(`${BASE}/api/projects`)).json();
+ const projectId = projects.projects[0].projectId;
+ 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,
+ },
+ ],
+ },
+ });
+ expect(put.ok(), "put models").toBeTruthy();
+ const sessRes = await page.request.post(
+ `${BASE}/api/projects/${projectId}/agents/default_agent/sessions`,
+ { data: { provider: "custom", modelId: "claude-4-8" } },
+ );
+ expect(sessRes.ok(), `create session: ${await sessRes.text()}`).toBeTruthy();
+ return (await sessRes.json()).session.sessionId;
+}
+
+test("a message the child composer cannot deliver says why above the box, and keeps saying it", async ({
+ page,
+}) => {
+ const sessionId = await provisionSession(page, "subsendfail");
+
+ await page.goto(`${BASE}/chat/${sessionId}`);
+ // The MAIN composer: the panel brings a second ChatInput once the agents tab is up.
+ const main = page.locator('textarea:not([data-testid="dock"] textarea)');
+ await main.waitFor();
+ await main.fill("run a subagent");
+ await page.locator('button[aria-label="发送"]:not([data-testid="dock"] *)').click();
+
+ // The panel opens itself on the live spawn; this spec needs the child composer, not the chip.
+ await expect(
+ page.locator('[data-testid="dock"] [data-tab-id="agents"][data-active="true"]'),
+ ).toBeVisible();
+ // The parent's turn ends, so the child is idle and the send below is an ordinary send.
+ await expect(page.getByText("Command finished; the result looks as expected.")).toBeVisible();
+ const child = page.locator('[data-testid="dock"] textarea').first();
+ await child.waitFor();
+
+ await page.route(MESSAGE_ROUTE, (route) =>
+ route.fulfill({
+ status: 500,
+ contentType: "application/json",
+ body: JSON.stringify({ error: REFUSAL }),
+ }),
+ );
+
+ const refusal = page.getByTestId("subagent-send-refusal");
+ await child.fill("one more thing");
+ await child.press("Enter");
+
+ // The sentence names the action and carries the server's own words, right where the retry is.
+ await expect(refusal).toBeVisible();
+ await expect(refusal).toContainText("消息没有送到子会话");
+ await expect(refusal).toContainText(REFUSAL.message);
+ // It is not a toast: the notification region never carries that sentence, and the draft is
+ // still in the box.
+ const notifications = page.getByRole("region", { name: "通知" });
+ await expect(notifications.getByText(REFUSAL.message)).toHaveCount(0);
+ await expect(child).toHaveValue("one more thing");
+
+ // Past the six seconds an error notification lives: the line is still there.
+ await page.waitForTimeout(7000);
+ await expect(refusal).toBeVisible();
+ await expect(refusal).toContainText(REFUSAL.message);
+ await expect(child).toHaveValue("one more thing");
+
+ // The next attempt clears it before it leaves — and a delivery that lands leaves nothing behind.
+ await page.unroute(MESSAGE_ROUTE);
+ await page.route(MESSAGE_ROUTE, (route) =>
+ route.fulfill({
+ status: 200,
+ contentType: "application/json",
+ body: JSON.stringify({ outcome: "started" }),
+ }),
+ );
+ await child.press("Enter");
+ await expect(refusal).toHaveCount(0);
+});
diff --git a/packages/web/src/features/chat/subagent-send-refusal.ts b/packages/web/src/features/chat/subagent-send-refusal.ts
new file mode 100644
index 00000000..f5245503
--- /dev/null
+++ b/packages/web/src/features/chat/subagent-send-refusal.ts
@@ -0,0 +1,29 @@
+/**
+ * The sentence a message that never reached a subagent leaves above the panel's composer, and why
+ * it is a line there rather than a toast.
+ *
+ * The child composer keeps what was typed when the send comes back refused — that is the whole
+ * point of `onSend` answering `false` — so after the failure the reader is still looking at the
+ * message they meant to send, with the same button to retry it. The reason used to be a
+ * notification: it floated over the panel, dismissed itself after six seconds, and left a composer
+ * that read exactly as it did before the press. Whatever has to change (the child was released, the
+ * server refused it mid-turn, the connection dropped) is a sentence the reader needs while looking
+ * at that draft, so it is drawn right above the box.
+ *
+ * `subagent_gone` keeps its own sentence (`S.subagentPanel.subagentGone`, "该子会话已不存在,无法
+ * 恢复"): there the child is what is missing, not the message, and it is the one answer that also
+ * decides what the panel should do next. Everything else reads through `refusalText` — 7.19's rule,
+ * so a request that never reached the route says what its own code means rather than the code's
+ * wire message.
+ */
+import { ApiError } from "../../api/client";
+import { refusalText } from "../../lib/api-error";
+import { S } from "../../lib/strings";
+
+/** The line under the child composer, naming what failed before the server's own words. */
+export function subagentSendRefused(err: unknown): string {
+ if (err instanceof ApiError && err.code === "subagent_gone") {
+ return S.subagentPanel.subagentGone;
+ }
+ return S.subagentPanel.sendRefused(refusalText(err));
+}
diff --git a/packages/web/src/features/chat/subagents-view.tsx b/packages/web/src/features/chat/subagents-view.tsx
index 3fe4f12d..a18e3231 100644
--- a/packages/web/src/features/chat/subagents-view.tsx
+++ b/packages/web/src/features/chat/subagents-view.tsx
@@ -38,11 +38,11 @@ import {
EmptyState,
GlyphIcon,
ICON_SIZE,
+ NoticeStrip,
StatusIcon,
Text,
toastError,
} from "@adelie/ui";
-import { ApiError } from "../../api/client";
import { abortSubagent, getAgentSkills, messageSubagent, patchSession } from "../../api/endpoints";
import { apiErrorText } from "../../lib/api-error";
import { S } from "../../lib/strings";
@@ -64,6 +64,7 @@ import type { TopologyNode } from "./agent-topology";
import { AgentTopologyView } from "./agent-topology-view";
import { MessageStream } from "./message-stream";
import type { StreamRenderContext } from "./message-stream";
+import { subagentSendRefused } from "./subagent-send-refusal";
import type { ComposerReference } from "../../lib/workspace-tree";
interface Selection {
@@ -413,14 +414,14 @@ function SubagentComposer({
: undefined;
const send = (text: string) => messageSubagent(sessionId, childSessionId, text);
+ /**
+ * The server's answer to a message that never reached the child, kept above the composer that
+ * still holds the text (subagent-send-refusal.ts): the retry is that same button, and a toast
+ * would have dismissed itself over it after six seconds.
+ */
+ const [sendRefusal, setSendRefusal] = useState<string | null>(null);
const sendFailure = (err: unknown): void => {
- toastError(
- err instanceof ApiError && err.code === "subagent_gone"
- ? S.subagentPanel.subagentGone
- : err instanceof Error
- ? err.message
- : String(err),
- );
+ setSendRefusal(subagentSendRefused(err));
};
return (
@@ -430,6 +431,19 @@ function SubagentComposer({
or wider, and the composer must line up with the messages above it rather than span
the surface. A docked panel is narrower than the cap, so there it changes nothing. */}
<div className="mx-auto max-w-3xl">
+ {sendRefusal !== null && (
+ // Right above the box it belongs to: the draft is still in there, and pressing send
+ // again is the whole retry. Cleared by the next attempt (both send and steer), so the
+ // line always describes the press that produced it.
+ <NoticeStrip
+ tone="danger"
+ role="alert"
+ data-testid="subagent-send-refusal"
+ className="mb-2 rounded-md border px-2.5 py-2 text-xs"
+ >
+ <span data-slot="body">{sendRefusal}</span>
+ </NoticeStrip>
+ )}
<ChatInput
variant="subagent"
controlRef={controlRef}
@@ -441,6 +455,7 @@ function SubagentComposer({
.join("\n\n")
.trim();
if (!text) return false;
+ setSendRefusal(null);
try {
await send(text);
return true;
@@ -450,6 +465,7 @@ function SubagentComposer({
}
}}
onSteer={async (text: string) => {
+ setSendRefusal(null);
try {
await send(text);
// steered/started/resumed alike: the message reached the child (the race where
diff --git a/packages/web/src/lib/strings-en.ts b/packages/web/src/lib/strings-en.ts
index 1923ddb1..07fcdfe1 100644
--- a/packages/web/src/lib/strings-en.ts
+++ b/packages/web/src/lib/strings-en.ts
@@ -4313,6 +4313,8 @@ export const en: Strings = {
nodeDone: "done",
openAsSession: "Jump to this session",
subagentGone: "This subagent session no longer exists and could not be revived",
+ /** A message the panel could not deliver to the child (subagent-send-refusal.ts). */
+ sendRefused: (reason: string) => `The message did not reach the subagent: ${reason}`,
},
files: {
diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.ts
index cb68d9b9..8e4ff73b 100644
--- a/packages/web/src/lib/strings.ts
+++ b/packages/web/src/lib/strings.ts
@@ -4380,6 +4380,11 @@ export const zh = {
openAsSession: "跳转到该会话",
/** The child's session record no longer exists and could not be revived. */
subagentGone: "该子会话已不存在,无法恢复",
+ /**
+ * A message the panel could not deliver to the child (subagent-send-refusal.ts), drawn above
+ * the composer that still holds the text: the action, then the server's own words.
+ */
+ sendRefused: (reason: string) => `消息没有送到子会话:${reason}`,
},
files: {
diff --git a/packages/web/test/subagent-send-refusal.test.ts b/packages/web/test/subagent-send-refusal.test.ts
new file mode 100644
index 00000000..ae5b69fb
--- /dev/null
+++ b/packages/web/test/subagent-send-refusal.test.ts
@@ -0,0 +1,54 @@
+/**
+ * The subagent panel's composer: what a message that never reached the child leaves above the box
+ * (src/features/chat/subagent-send-refusal.ts).
+ *
+ * The composer keeps what was typed when `onSend` answers `false`, so after a refusal the reader
+ * is still looking at the draft they meant to send. The line has to name the action, take the
+ * server's own words for the reason, and keep the one answer that is about the child rather than
+ * the message.
+ */
+import { afterEach, describe, expect, it } from "vitest";
+import { ApiError } from "../src/api/client";
+import { en as EN } from "../src/lib/strings-en";
+import { S, setActiveStrings, zh as ZH } from "../src/lib/strings";
+import { subagentSendRefused } from "../src/features/chat/subagent-send-refusal";
+
+afterEach(() => {
+ setActiveStrings(ZH);
+});
+
+describe("subagentSendRefused", () => {
+ it("names the action and relays the server's words", () => {
+ const line = subagentSendRefused(
+ new ApiError(500, "subagent_busy", "RAW ENGLISH SERVER MESSAGE"),
+ );
+ expect(line).toContain("RAW ENGLISH SERVER MESSAGE");
+ expect(line).toBe(S.subagentPanel.sendRefused("RAW ENGLISH SERVER MESSAGE"));
+ });
+
+ it("draws a released child as the child's sentence, not the message's", () => {
+ // `subagent_gone` is about the child: nothing was sent, and the panel is what has to change.
+ expect(subagentSendRefused(new ApiError(404, "subagent_gone", "no such subagent"))).toBe(
+ S.subagentPanel.subagentGone,
+ );
+ });
+
+ it("reads a request that failed on the way out through refusalText's rule", () => {
+ // A connection that never reached the route raises a plain Error whose message is the only
+ // thing known; 7.19 keeps it rather than flattening it to the generic text.
+ expect(subagentSendRefused(new Error("Failed to fetch"))).toBe(
+ S.subagentPanel.sendRefused("Failed to fetch"),
+ );
+ });
+
+ it("falls back to the generic sentence when the value has nothing to say", () => {
+ expect(subagentSendRefused(undefined)).toBe(S.subagentPanel.sendRefused(S.common.unknownError));
+ });
+
+ it("speaks the active language", () => {
+ setActiveStrings(EN);
+ expect(subagentSendRefused(new ApiError(409, "subagent_busy", "busy"))).toBe(
+ EN.subagentPanel.sendRefused("busy"),
+ );
+ });
+});