Open History to see the last commit
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<Pick<OrchestrationV2ThreadShell, "status" | "pendingRuntimeRequest">> = {},
24 ) => ({
25 id: "thread-2" as ThreadId,
26 title: "Integrate orchestration",
27 modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.4" },
28 status: "running" as const,
29 pendingRuntimeRequest: null,
30 updatedAt,
31 ...overrides,
32 });
33
34 it("projects V2 run state", () => {
35 expect(
36 projectThreadAwarenessV2({
37 environmentId: "env-1" as EnvironmentId,
38 project,
39 thread: v2Thread(),
40 }),
41 ).toMatchObject({ phase: "running", headline: "Agent is working" });
42 });
43
44 it("prioritizes V2 user-input requests", () => {
45 expect(
46 projectThreadAwarenessV2({
47 environmentId: "env-1" as EnvironmentId,
48 project,
49 thread: v2Thread({
50 pendingRuntimeRequest: {
51 id: RuntimeRequestId.make("request-1"),
52 kind: "user_input",
53 createdAt: updatedAt,
54 },
55 }),
56 }),
57 ).toMatchObject({ phase: "waiting_for_input", headline: "Waiting for input" });
58 });
59
60 it("does not present authentication refreshes as user approvals", () => {
61 expect(
62 projectThreadAwarenessV2({
63 environmentId: "env-1" as EnvironmentId,
64 project,
65 thread: v2Thread({
66 pendingRuntimeRequest: {
67 id: RuntimeRequestId.make("request-auth-refresh"),
68 kind: "auth_refresh",
69 createdAt: updatedAt,
70 },
71 }),
72 }),
73 ).toMatchObject({ phase: "running", headline: "Agent is working" });
74 });
75});