Changed files under each reply, with a turn footer
This commit is contained in:
1 parent
b70099f23f
commit
49b04f9012
6 files changed
+215
-9
No files matched your search
+26
-1
@@ -1,6 +1,6 @@
|
||||
import { afterEach, describe, expect, test } from "bun:test";
|
||||
|
||||
import { omittedCommand, withApproval, withOmittedOutput, withQuestion } from "./fixtures.ts";
|
||||
import { omittedCommand, withApproval, withCompletedTurn, withOmittedOutput, withQuestion } from "./fixtures.ts";
|
||||
import { loadLayout } from "../../src/layout.ts";
|
||||
import { fakeSession, renderApp, v2ThreadId } from "./harness.tsx";
|
||||
|
||||
@@ -138,6 +138,31 @@ describe("palette and pickers", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("a finished turn", () => {
|
||||
test("its changed files fold out under the reply, and a file opens the turn's diff", async () => {
|
||||
const patch = "diff --git a/src/index.ts b/src/index.ts\n--- a/src/index.ts\n+++ b/src/index.ts\n@@ -1 +1 @@\n-old\n+new\n";
|
||||
const app = await open({ session: fakeSession({ projection: withCompletedTurn(), results: { turnDiff: { diff: patch } } }) });
|
||||
expect(app.frame()).toContain("✎ 3 files +42 −7 ›");
|
||||
expect(app.frame()).not.toContain("src/util.ts");
|
||||
const line = app.find("3 files");
|
||||
await app.click(line.x, line.y);
|
||||
expect(app.frame()).toContain("src/index.ts");
|
||||
expect(app.frame()).toContain("src/util.ts");
|
||||
expect(app.frame()).toContain("+30 −5");
|
||||
const file = app.find("src/util.ts");
|
||||
await app.click(file.x, file.y);
|
||||
await app.settle(50);
|
||||
expect(app.calls("turnDiff").map((call) => call.args[0])).toEqual([{ threadId: v2ThreadId, toTurnCount: 1, ignoreWhitespace: true, fromTurnCount: 0 }]);
|
||||
expect(app.frame()).toContain("Turn 1");
|
||||
});
|
||||
|
||||
test("its footer names the model, the duration and the time", async () => {
|
||||
const app = await open({ session: fakeSession({ projection: withCompletedTurn() }) });
|
||||
// The date half is locale- and timezone-shaped; the model and duration are not.
|
||||
expect(app.frame()).toMatch(/gpt-5\.4 · 3m 12s · /);
|
||||
});
|
||||
});
|
||||
|
||||
describe("approvals", () => {
|
||||
test("y, Y and n answer the request", async () => {
|
||||
const app = await open({ session: fakeSession({ projection: withApproval() }) });
|
||||
|
||||
@@ -4,6 +4,8 @@ import * as DateTime from "effect/DateTime";
|
||||
import { v2Projection } from "../../vendor/t3code/packages/client-runtime/src/state/orchestrationV2TestFixtures.ts";
|
||||
|
||||
const at = DateTime.makeUnsafe("2026-06-20T00:00:00.000Z");
|
||||
/** `seconds` after the fixture's start. */
|
||||
const after = (seconds: number) => DateTime.makeUnsafe(DateTime.toEpochMillis(at) + seconds * 1_000);
|
||||
|
||||
/** The thread with a command waiting for approval. */
|
||||
export function withApproval(supportsFeedback = false): OrchestrationV2ThreadProjection {
|
||||
@@ -54,6 +56,57 @@ export const omittedCommand = {
|
||||
exitCode: 0,
|
||||
} as const;
|
||||
|
||||
/** A finished turn: one prompt, one reply 3m 12s later, and a checkpoint of three changed files. */
|
||||
export function withCompletedTurn(): OrchestrationV2ThreadProjection {
|
||||
const base = {
|
||||
threadId: v2Projection.thread.id,
|
||||
runId: "run-1",
|
||||
nodeId: null,
|
||||
providerThreadId: null,
|
||||
providerTurnId: null,
|
||||
nativeItemRef: null,
|
||||
parentItemId: null,
|
||||
title: null,
|
||||
};
|
||||
const turnItems = [
|
||||
{ ...base, id: "item-user", ordinal: 0, status: "completed", startedAt: at, completedAt: at, updatedAt: at, type: "user_message", createdBy: "user", creationSource: "web", messageId: "msg-user-1", inputIntent: "turn_start", text: "Do the thing", attachments: [] },
|
||||
{ ...base, id: "item-edit", ordinal: 1, status: "completed", startedAt: after(60), completedAt: after(65), updatedAt: after(65), type: "file_change", fileName: "src/index.ts", additions: 30, deletions: 5 },
|
||||
{ ...base, id: "item-assistant", ordinal: 2, status: "completed", startedAt: after(192), completedAt: after(192), updatedAt: after(192), type: "assistant_message", messageId: "msg-assistant-1", text: "Done — the thing is done.", streaming: false },
|
||||
];
|
||||
return {
|
||||
...v2Projection,
|
||||
runs: [
|
||||
{ id: "run-1", threadId: v2Projection.thread.id, ordinal: 1, providerInstanceId: "codex", modelSelection: { instanceId: "codex", model: "gpt-5.4" }, providerThreadId: null, userMessageId: "msg-user-1", rootNodeId: null, activeAttemptId: null, status: "completed", requestedAt: at, startedAt: at, completedAt: after(192), checkpointId: "checkpoint-1", contextHandoffId: null },
|
||||
],
|
||||
messages: [
|
||||
{ createdBy: "user", creationSource: "web", id: "msg-user-1", threadId: v2Projection.thread.id, runId: "run-1", nodeId: null, role: "user", text: "Do the thing", attachments: [], streaming: false, createdAt: at, updatedAt: at },
|
||||
{ createdBy: "user", creationSource: "web", id: "msg-assistant-1", threadId: v2Projection.thread.id, runId: "run-1", nodeId: null, role: "assistant", text: "Done — the thing is done.", attachments: [], streaming: false, createdAt: after(192), updatedAt: after(192) },
|
||||
],
|
||||
checkpoints: [
|
||||
{
|
||||
id: "checkpoint-1",
|
||||
threadId: v2Projection.thread.id,
|
||||
scopeId: "scope-1",
|
||||
runId: "run-1",
|
||||
nodeId: null,
|
||||
parentCheckpointId: null,
|
||||
ordinalWithinScope: 0,
|
||||
appRunOrdinal: 1,
|
||||
ref: "refs/t3/checkpoint-1",
|
||||
status: "ready",
|
||||
files: [
|
||||
{ path: "src/index.ts", kind: "modified", additions: 30, deletions: 5 },
|
||||
{ path: "src/util.ts", kind: "modified", additions: 10, deletions: 2 },
|
||||
{ path: "README.md", kind: "modified", additions: 2, deletions: 0 },
|
||||
],
|
||||
capturedAt: after(192),
|
||||
},
|
||||
],
|
||||
turnItems,
|
||||
visibleTurnItems: turnItems.map((item, position) => ({ position, visibility: "local", sourceThreadId: v2Projection.thread.id, sourceItemId: item.id, item })),
|
||||
} as unknown as OrchestrationV2ThreadProjection;
|
||||
}
|
||||
|
||||
export function withOmittedOutput(): OrchestrationV2ThreadProjection {
|
||||
return {
|
||||
...v2Projection,
|
||||
|
||||
Reference in new issue
Block a user