Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

agentAwareness.test.ts

87 lines2.5 KB

1import { describe, expect, it } from "@effect/vitest";
2​
3import type {
4 EnvironmentId,
5 OrchestrationV2ThreadShell,
6 Project,
7 ThreadId,
8} from "@t3tools/contracts";
9import { ProviderInstanceId, RuntimeRequestId } from "@t3tools/contracts";
10import * as DateTime from "effect/DateTime";
11​
12import { projectThreadAwarenessV2 } from "./agentAwareness.ts";
13​
14const NOW = "2026-05-22T12:00:00.000Z";
15​
16const project = {
17 title: "t3code",
18} satisfies Pick<Project, "title">;
19​
20describe("projectThreadAwarenessV2", () => {
21 const updatedAt = DateTime.makeUnsafe(NOW);
22 const v2Thread = (
23 overrides: Partial<
24 Pick<OrchestrationV2ThreadShell, "activityRunStatus" | "status" | "pendingRuntimeRequest">
25 > = {},
26 ) => ({
27 id: "thread-2" as ThreadId,
28 title: "Integrate orchestration",
29 modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.4" },
30 status: "running" as const,
31 pendingRuntimeRequest: null,
32 updatedAt,
33 ...overrides,
34 });
35​
36 it("projects V2 run state", () => {
37 expect(
38 projectThreadAwarenessV2({
39 environmentId: "env-1" as EnvironmentId,
40 project,
41 thread: v2Thread(),
42 }),
43 ).toMatchObject({ phase: "running", headline: "Agent is working" });
44 });
45​
46 it("keeps an older activity run visible over a newer cancelled run", () => {
47 expect(
48 projectThreadAwarenessV2({
49 environmentId: "env-1" as EnvironmentId,
50 project,
51 thread: v2Thread({ status: "cancelled", activityRunStatus: "running" }),
52 }),
53 ).toMatchObject({ phase: "running", headline: "Agent is working" });
54 });
55​
56 it("prioritizes V2 user-input requests", () => {
57 expect(
58 projectThreadAwarenessV2({
59 environmentId: "env-1" as EnvironmentId,
60 project,
61 thread: v2Thread({
62 pendingRuntimeRequest: {
63 id: RuntimeRequestId.make("request-1"),
64 kind: "user_input",
65 createdAt: updatedAt,
66 },
67 }),
68 }),
69 ).toMatchObject({ phase: "waiting_for_input", headline: "Waiting for input" });
70 });
71​
72 it("does not present authentication refreshes as user approvals", () => {
73 expect(
74 projectThreadAwarenessV2({
75 environmentId: "env-1" as EnvironmentId,
76 project,
77 thread: v2Thread({
78 pendingRuntimeRequest: {
79 id: RuntimeRequestId.make("request-auth-refresh"),
80 kind: "auth_refresh",
81 createdAt: updatedAt,
82 },
83 }),
84 }),
85 ).toMatchObject({ phase: "running", headline: "Agent is working" });
86 });
87});