Match T3 Code's sidebar, timeline and composer
Reuse the web app's timeline derivation (turn folds, work groups, live work), its sidebar sections and status words, steer-by-default sending, the question panel, decline-with-feedback, and visit/read marking.
This commit is contained in:
1 parent
4f42407099
commit
2dac4763d2
17 files changed
+988
-430
No files matched your search
@@ -27,52 +27,3 @@ describe("blockFor", () => {
|
||||
expect(blockFor(item({ type: "checkpoint" }), new Set())).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
import type { OrchestrationV2ThreadProjection } from "@t3tools/contracts";
|
||||
import { buildTranscript, summarizeWork } from "../src/model/transcript.ts";
|
||||
|
||||
const projectionOf = (items: OrchestrationV2TurnItem[], pendingIds: string[] = []) =>
|
||||
({
|
||||
runtimeRequests: pendingIds.map((id) => ({ id, status: "pending" })),
|
||||
visibleTurnItems: items.map((entry, position) => ({ position, item: entry })),
|
||||
}) as unknown as OrchestrationV2ThreadProjection;
|
||||
|
||||
let counter = 0;
|
||||
const turn = (fields: Record<string, unknown>) => item({ id: `i${counter++}`, ...fields });
|
||||
|
||||
describe("buildTranscript", () => {
|
||||
test("folds runs of work between messages into one segment", () => {
|
||||
const transcript = buildTranscript(
|
||||
projectionOf([
|
||||
turn({ type: "user_message", text: "fix it" }),
|
||||
turn({ type: "command_execution", input: "ls" }),
|
||||
turn({ type: "reasoning", text: "thinking", streaming: false }),
|
||||
turn({ type: "file_change", fileName: "a.ts" }),
|
||||
turn({ type: "assistant_message", text: "done", streaming: false }),
|
||||
]),
|
||||
);
|
||||
expect(transcript.segments.map((segment) => segment.kind)).toEqual(["user", "work", "assistant"]);
|
||||
const work = transcript.segments[1];
|
||||
expect(work?.kind === "work" && summarizeWork(work.steps)).toBe("1 command · 1 edit");
|
||||
});
|
||||
|
||||
test("marks trailing work active while the thread runs", () => {
|
||||
const transcript = buildTranscript(projectionOf([turn({ type: "command_execution", input: "make" })]), { running: true });
|
||||
expect(transcript.segments[0]).toMatchObject({ kind: "work", active: true });
|
||||
});
|
||||
|
||||
test("errors break out of folded work", () => {
|
||||
const transcript = buildTranscript(projectionOf([turn({ type: "command_execution", input: "a" }), turn({ type: "error", failure: { message: "boom" } }), turn({ type: "command_execution", input: "b" })]));
|
||||
expect(transcript.segments.map((segment) => segment.kind)).toEqual(["work", "alert", "work"]);
|
||||
});
|
||||
|
||||
test("reuses unchanged segments so the view can skip them", () => {
|
||||
const user = turn({ type: "user_message", text: "hi" });
|
||||
const command = turn({ type: "command_execution", input: "ls" });
|
||||
const first = buildTranscript(projectionOf([user, command, turn({ type: "assistant_message", text: "He", streaming: true })]));
|
||||
const second = buildTranscript(projectionOf([user, command, turn({ type: "assistant_message", text: "Hello", streaming: true })]), { previous: first });
|
||||
expect(second.segments[0]).toBe(first.segments[0]!);
|
||||
expect(second.segments[1]).toBe(first.segments[1]!);
|
||||
expect(second.segments[2]).not.toBe(first.segments[2]!);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user