The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { assert } from "@effect/vitest"; |
| 2 | import type { ProviderReplayTranscript } from "@t3tools/contracts"; |
| 3 | |
| 4 | import type { OrchestratorV2ScenarioResult } from "../../OrchestratorScenario.ts"; |
| 5 | import { |
| 6 | assertAssistantTextIncludes, |
| 7 | assertBaseProjection, |
| 8 | assertSemanticProjectionIntegrity, |
| 9 | assertUserMessageInputIntents, |
| 10 | assertUserMessagesInclude, |
| 11 | assertVisibleTurnItemsMirrorLocalTurnItems, |
| 12 | OPENCODE2_CANCELLED_PROMPT, |
| 13 | OPENCODE2_QUEUED_PROMPT, |
| 14 | OPENCODE2_STEER_PROMPT, |
| 15 | OPENCODE2_STEER_TEXT, |
| 16 | projectionFor, |
| 17 | } from "../shared.ts"; |
| 18 | |
| 19 | export function assertOpenCode2InboxOutput( |
| 20 | result: OrchestratorV2ScenarioResult, |
| 21 | transcript: ProviderReplayTranscript, |
| 22 | ) { |
| 23 | assertBaseProjection({ |
| 24 | result, |
| 25 | transcript, |
| 26 | runCount: 3, |
| 27 | providerTurnCountAtLeast: 2, |
| 28 | runStatuses: ["completed", "completed", "cancelled"], |
| 29 | }); |
| 30 | const projection = projectionFor(result, transcript.scenario); |
| 31 | assertSemanticProjectionIntegrity(projection); |
| 32 | assertVisibleTurnItemsMirrorLocalTurnItems(projection); |
| 33 | assertUserMessagesInclude(projection, [ |
| 34 | OPENCODE2_STEER_PROMPT, |
| 35 | OPENCODE2_STEER_TEXT, |
| 36 | OPENCODE2_QUEUED_PROMPT, |
| 37 | ]); |
| 38 | assertUserMessageInputIntents(projection, ["turn_start", "steer", "queued_turn"]); |
| 39 | assertAssistantTextIncludes(projection, "STEERED"); |
| 40 | assertAssistantTextIncludes(projection, "QUEUED_B"); |
| 41 | assert.notInclude( |
| 42 | projection.turnItems.flatMap((item) => (item.type === "user_message" ? [item.text] : [])), |
| 43 | OPENCODE2_CANCELLED_PROMPT, |
| 44 | ); |
| 45 | |
| 46 | const [first, queued] = projection.runs.toSorted((left, right) => left.ordinal - right.ordinal); |
| 47 | const turnOf = (run: typeof first) => |
| 48 | projection.providerTurns.filter((turn) => turn.runAttemptId === run?.activeAttemptId); |
| 49 | assert.deepEqual( |
| 50 | [turnOf(first).map((turn) => turn.status), turnOf(queued).map((turn) => turn.status)], |
| 51 | [["completed"], ["completed"]], |
| 52 | ); |
| 53 | const steered = projection.turnItems.find( |
| 54 | (item) => item.type === "assistant_message" && item.text.includes("STEERED"), |
| 55 | ); |
| 56 | assert.equal(steered?.runId, first?.id); |
| 57 | const shell = projection.turnItems.find((item) => item.type === "command_execution"); |
| 58 | assert.deepEqual([shell?.status, shell?.runId], ["completed", first?.id]); |
| 59 | |
| 60 | for (const turn of [...turnOf(first), ...turnOf(queued)]) { |
| 61 | assert.match(turn.nativeTurnRef?.nativeId ?? "", /^msg_t3_turn_/); |
| 62 | } |
| 63 | } |