




















@@ -1380,6 +1380,78 @@ describe("handleSendChat", () => {
13801380expect(host.chatMessage).toBe("");
13811381});
138213821383+it.each([
1384+{
1385+input: "/reset soft please reload system prompt",
1386+expected: "/reset soft please reload system prompt",
1387+},
1388+{
1389+input: "/reset\tsoft please reload system prompt",
1390+expected: "/reset soft please reload system prompt",
1391+},
1392+{
1393+input: "/reset\nsoft please reload system prompt",
1394+expected: "/reset soft please reload system prompt",
1395+},
1396+{
1397+input: "/reset: soft please reload system prompt",
1398+expected: "/reset soft please reload system prompt",
1399+},
1400+])("preserves $input args and skips confirmation dialog", async ({ input, expected }) => {
1401+const confirm = vi.fn(() => false);
1402+vi.stubGlobal("confirm", confirm);
1403+const request = vi.fn(async (method: string) => {
1404+if (method === "chat.send") {
1405+return { status: "started" };
1406+}
1407+throw new Error(`Unexpected request: ${method}`);
1408+});
1409+const host = makeHost({
1410+client: { request } as unknown as ChatHost["client"],
1411+chatMessage: input,
1412+sessionKey: "agent:main",
1413+});
1414+1415+await handleSendChat(host);
1416+1417+expect(confirm).not.toHaveBeenCalled();
1418+const payload = findRequestPayload(
1419+request as unknown as MockCallSource,
1420+"chat.send",
1421+"chat send payload",
1422+);
1423+expect(payload.sessionKey).toBe("agent:main");
1424+expect(payload.message).toBe(expected);
1425+expect(host.chatMessage).toBe("");
1426+});
1427+1428+it.each([
1429+"/reset softish please archive",
1430+"/reset\tsoftish please archive",
1431+"/reset\nsoftish please archive",
1432+"/reset: softish please archive",
1433+])("keeps %s on the hard-reset confirmation path", async (message) => {
1434+const confirm = vi.fn(() => false);
1435+vi.stubGlobal("confirm", confirm);
1436+const request = vi.fn(async (method: string) => {
1437+throw new Error(`Unexpected request: ${method}`);
1438+});
1439+const host = makeHost({
1440+client: { request } as unknown as ChatHost["client"],
1441+chatMessage: "keep this draft",
1442+sessionKey: "agent:main",
1443+});
1444+1445+await handleSendChat(host, message, {
1446+confirmReset: true,
1447+restoreDraft: true,
1448+});
1449+1450+expect(confirm).toHaveBeenCalledTimes(1);
1451+expect(request).not.toHaveBeenCalled();
1452+expect(host.chatMessage).toBe("keep this draft");
1453+});
1454+13831455it("records visible send timing phases for a normal chat send", async () => {
13841456const request = vi.fn(async (method: string) => {
13851457if (method === "chat.send") {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。