Files
tutti/packages/agent/gui/shared/workspaceAgentTimelineMessageHelpers.spec.ts
agent-radar 2ed3415fb7
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:17:27 +08:00

48 lines
1.3 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { messageBody } from "./workspaceAgentTimelineMessageHelpers";
import type { WorkspaceAgentActivityTimelineItem } from "./workspaceAgentTimelineTypes";
describe("messageBody", () => {
it.each([
["payload content", { payload: { content: "\nHello\n" } }],
["top-level content", { content: "\nHello\n" }],
["payload text", { payload: { text: "\nHello\n" } }]
])("preserves whitespace from %s", (_label, fields) => {
expect(messageBody(item(fields))).toBe("\nHello\n");
});
it("uses trimming only to reject whitespace-only content", () => {
expect(
messageBody(
item({
content: "fallback",
payload: { content: " \n\t", text: "unused" }
})
)
).toBe("fallback");
expect(messageBody(item({ payload: { text: " \n\t" } }))).toBe("");
});
it("still suppresses synthetic control messages surrounded by whitespace", () => {
expect(
messageBody(
item({ payload: { content: "\n[Request interrupted by user]\n" } })
)
).toBe("");
});
});
function item(
fields: Partial<WorkspaceAgentActivityTimelineItem>
): WorkspaceAgentActivityTimelineItem {
return {
actorId: "agent",
actorType: "agent",
agentSessionId: "session-1",
eventId: "event-1",
id: 1,
itemType: "message",
...fields
};
}