





















@@ -45,62 +45,60 @@ const loadSessionsMock = vi.hoisted(() =>
4545}),
4646);
4747const buildChatItemsMock = vi.hoisted(() =>
48-vi.fn(
49-(props: { messages: unknown[]; stream: string | null; streamStartedAt: number | null }) => {
50-if (
51-props.messages.some(
52-(message) =>
53-typeof message === "object" &&
54-message !== null &&
55-(message as { __testDivider?: unknown })["__testDivider"] === true,
56-)
57-) {
58-return [
59-{
60-kind: "divider",
61-key: "divider:compaction:test",
62-label: "Compacted history",
63-description:
64-"The compacted transcript is preserved as a checkpoint. Open session checkpoints to branch or restore from that compacted view.",
65-action: {
66-kind: "session-checkpoints",
67-label: "Open checkpoints",
68-},
69-timestamp: 1,
70-},
71-];
72-}
73-if (props.messages.length > 0) {
74-return [
75-{
76-kind: "group",
77-key: "group:assistant:test",
78-role: "assistant",
79-messages: props.messages.map((message, index) => ({
80-key: `message:${index}`,
81- message,
82-})),
83-timestamp: 1,
84-isStreaming: false,
48+vi.fn((props: { messages: unknown[]; stream: string | null; streamStartedAt: number | null }) => {
49+if (
50+props.messages.some(
51+(message) =>
52+typeof message === "object" &&
53+message !== null &&
54+(message as { __testDivider?: unknown })["__testDivider"] === true,
55+)
56+) {
57+return [
58+{
59+kind: "divider",
60+key: "divider:compaction:test",
61+label: "Compacted history",
62+description:
63+"The compacted transcript is preserved as a checkpoint. Open session checkpoints to branch or restore from that compacted view.",
64+action: {
65+kind: "session-checkpoints",
66+label: "Open checkpoints",
8567},
86-];
87-}
88-if (props.stream !== null) {
89-return props.stream
90- ? [
91-{
92-kind: "stream",
93-key: "stream:test",
94-text: props.stream,
95-startedAt: props.streamStartedAt ?? 1,
96-isStreaming: true,
97-},
98-]
99- : [{ kind: "reading-indicator", key: "reading:test" }];
100-}
101-return [];
102-},
103-),
68+timestamp: 1,
69+},
70+];
71+}
72+if (props.messages.length > 0) {
73+return [
74+{
75+kind: "group",
76+key: "group:assistant:test",
77+role: "assistant",
78+messages: props.messages.map((message, index) => ({
79+key: `message:${index}`,
80+ message,
81+})),
82+timestamp: 1,
83+isStreaming: false,
84+},
85+];
86+}
87+if (props.stream !== null) {
88+return props.stream
89+ ? [
90+{
91+kind: "stream",
92+key: "stream:test",
93+text: props.stream,
94+startedAt: props.streamStartedAt ?? 1,
95+isStreaming: true,
96+},
97+]
98+ : [{ kind: "reading-indicator", key: "reading:test" }];
99+}
100+return [];
101+}),
104102);
105103106104function requireFirstAttachmentsChange(
@@ -1074,6 +1072,17 @@ describe("chat slash menu accessibility", () => {
10741072textarea!.dispatchEvent(new KeyboardEvent("keydown", { key, bubbles: true }));
10751073}
107610741075+it("does not request a slash-menu rerender for plain draft input when suggestions are closed", () => {
1076+const onDraftChange = vi.fn();
1077+const onRequestUpdate = vi.fn();
1078+const container = renderChatView({ onDraftChange, onRequestUpdate });
1079+1080+inputDraft(container, "plain first message");
1081+1082+expect(onDraftChange).toHaveBeenCalledWith("plain first message");
1083+expect(onRequestUpdate).not.toHaveBeenCalled();
1084+});
1085+10771086it("wires command suggestions to the composer with stable active option ids", () => {
10781087let draft = "";
10791088const onDraftChange = vi.fn((next: string) => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。