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
+41
-9
@@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test";
|
||||
import type { OrchestrationV2ShellSnapshot } from "@t3tools/contracts";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
|
||||
import { findThread, relativeTime, threadRows } from "../src/model/threads.ts";
|
||||
import { findThread, relativeTime, statusLabel, threadRows } from "../src/model/threads.ts";
|
||||
|
||||
const at = (ms: number) => DateTime.makeUnsafe(ms);
|
||||
const thread = (id: string, title: string, updated: number, extra: Record<string, unknown> = {}) => ({
|
||||
@@ -11,7 +11,23 @@ const thread = (id: string, title: string, updated: number, extra: Record<string
|
||||
projectId: "p1",
|
||||
status: "completed",
|
||||
activeRunId: null,
|
||||
latestRunId: "run-1",
|
||||
latestRunRequestedAt: at(updated - 100),
|
||||
latestRunStartedAt: at(updated - 90),
|
||||
latestRunCompletedAt: at(updated),
|
||||
pendingRuntimeRequest: null,
|
||||
latestUserMessageAt: null,
|
||||
lineage: { relationshipToParent: null, parentThreadId: null },
|
||||
modelSelection: { instanceId: "codex", model: "gpt" },
|
||||
archivedAt: null,
|
||||
deletedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
pinnedAt: null,
|
||||
lastVisitedAt: at(updated + 1),
|
||||
hasActionableProposedPlan: false,
|
||||
interactionMode: "default",
|
||||
createdAt: at(0),
|
||||
updatedAt: at(updated),
|
||||
...extra,
|
||||
});
|
||||
@@ -19,21 +35,36 @@ const snapshot = {
|
||||
projects: [{ id: "p1", title: "tasknotes", workspaceRoot: "/home/me/tasknotes" }],
|
||||
threads: [
|
||||
thread("mcp:launch:aaaa1111", "old finished", 1_000),
|
||||
thread("t-running", "busy one", 2_000, { status: "running", activeRunId: "r1" }),
|
||||
thread("t-waiting", "wants approval", 500, { status: "running", activeRunId: "r2", pendingRuntimeRequest: { id: "q", kind: "command", createdAt: at(0) } }),
|
||||
thread("t-new", "newest finished", 3_000),
|
||||
thread("t-running", "busy one", 2_000, { status: "running", activeRunId: "run-1", latestRunCompletedAt: null }),
|
||||
thread("t-waiting", "wants approval", 500, { status: "running", activeRunId: "run-1", latestRunCompletedAt: null, pendingRuntimeRequest: { id: "q", kind: "command", createdAt: at(0) } }),
|
||||
thread("t-new", "newest finished", 3_000, { lastVisitedAt: at(10) }),
|
||||
thread("t-settled", "put away", 4_000, { settledOverride: "settled", settledAt: at(4_000) }),
|
||||
thread("t-child", "a subagent", 5_000, { lineage: { relationshipToParent: "subagent", parentThreadId: "t-new" } }),
|
||||
],
|
||||
} as unknown as OrchestrationV2ShellSnapshot;
|
||||
|
||||
describe("threadRows", () => {
|
||||
test("orders needs-you, then running, then recent by activity", () => {
|
||||
expect(threadRows(snapshot).map((row) => row.thread.id as string)).toEqual(["t-waiting", "t-running", "t-new", "mcp:launch:aaaa1111"]);
|
||||
test("uses the web sidebar's sections and leaves subagents under their parent", () => {
|
||||
expect(threadRows(snapshot).map((row) => [row.thread.id as string, row.section])).toEqual([
|
||||
["t-new", "active"],
|
||||
["mcp:launch:aaaa1111", "active"],
|
||||
["t-waiting", "active"],
|
||||
["t-running", "working"],
|
||||
["t-settled", "settled"],
|
||||
]);
|
||||
});
|
||||
|
||||
test("filters by title or project and caps recent rows", () => {
|
||||
test("shows the sidebar's status words", () => {
|
||||
const byId = new Map(threadRows(snapshot).map((row) => [row.thread.id as string, row]));
|
||||
expect(statusLabel(byId.get("t-waiting")!)?.text).toBe("Approval");
|
||||
expect(statusLabel(byId.get("t-new")!)?.text).toBe("Done");
|
||||
expect(statusLabel(byId.get("mcp:launch:aaaa1111")!)).toBeNull();
|
||||
expect(statusLabel(byId.get("t-running")!, 2_000 + 75_000)?.text).toBe("Working 1m");
|
||||
});
|
||||
|
||||
test("filters by title or project", () => {
|
||||
expect(threadRows(snapshot, { query: "BUSY" }).map((row) => row.thread.id as string)).toEqual(["t-running"]);
|
||||
expect(threadRows(snapshot, { query: "tasknotes" })).toHaveLength(4);
|
||||
expect(threadRows(snapshot, { recentLimit: 1 }).map((row) => row.group)).toEqual(["needs-you", "running", "recent"]);
|
||||
expect(threadRows(snapshot, { query: "tasknotes" })).toHaveLength(5);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -46,6 +77,7 @@ describe("findThread", () => {
|
||||
});
|
||||
|
||||
test("relativeTime", () => {
|
||||
expect(relativeTime(0, 2_000)).toBe("now");
|
||||
expect(relativeTime(0, 45_000)).toBe("45s");
|
||||
expect(relativeTime(0, 3 * 3600_000)).toBe("3h");
|
||||
});
|
||||
Reference in new issue
Block a user