mirror of
https://github.com/murashit/codex-panel.git
synced 2026-07-22 17:30:31 +00:00
61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import type { MessageStreamItem } from "../../../../src/features/chat/domain/message-stream/items";
|
|
import { forkCandidatesFromItems } from "../../../../src/features/chat/domain/message-stream/selectors";
|
|
|
|
describe("message stream item selectors", () => {
|
|
it("selects final assistant messages as fork candidates", () => {
|
|
const streamItems = messageStreamItems();
|
|
|
|
const candidates = forkCandidatesFromItems(streamItems);
|
|
|
|
expect(candidates).toEqual([
|
|
{ itemId: "a1", turnId: "turn-1" },
|
|
{ itemId: "a2", turnId: "turn-2" },
|
|
{ itemId: "a3", turnId: "turn-3" },
|
|
]);
|
|
});
|
|
});
|
|
|
|
function messageStreamItems(): MessageStreamItem[] {
|
|
return [
|
|
{ id: "u1", kind: "message", messageKind: "user", role: "user", text: "first", turnId: "turn-1" },
|
|
{
|
|
id: "a1",
|
|
kind: "message",
|
|
role: "assistant",
|
|
text: "first answer",
|
|
turnId: "turn-1",
|
|
messageKind: "assistantResponse",
|
|
messageState: "completed",
|
|
},
|
|
{ id: "tool-1", kind: "tool", role: "tool", text: "work", turnId: "turn-2" },
|
|
{
|
|
id: "a2-delta",
|
|
kind: "message",
|
|
role: "assistant",
|
|
text: "draft",
|
|
turnId: "turn-2",
|
|
messageKind: "proposedPlan",
|
|
messageState: "streaming",
|
|
},
|
|
{
|
|
id: "a2",
|
|
kind: "message",
|
|
role: "assistant",
|
|
text: "second answer",
|
|
turnId: "turn-2",
|
|
messageKind: "assistantResponse",
|
|
messageState: "completed",
|
|
},
|
|
{ id: "u3", kind: "message", messageKind: "user", role: "user", text: "third", turnId: "turn-3" },
|
|
{
|
|
id: "a3",
|
|
kind: "message",
|
|
role: "assistant",
|
|
text: "third answer",
|
|
turnId: "turn-3",
|
|
messageKind: "assistantResponse",
|
|
messageState: "completed",
|
|
},
|
|
];
|
|
}
|