From b85c6fd03a26552f05b29299606fd6cfcd1109e2 Mon Sep 17 00:00:00 2001 From: InTheta <17220028+InTheta@users.noreply.github.com> Date: Tue, 17 Nov 2026 12:20:02 +0000 Subject: [PATCH] Link Delivery evidence to the known local worker thread --- .../ManagedRunEvidence.browser.test.tsx | 59 +++++++++++++++++++ .../web/src/components/ManagedRunEvidence.tsx | 24 +++++++- 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 apps/web/src/components/ManagedRunEvidence.browser.test.tsx diff --git a/apps/web/src/components/ManagedRunEvidence.browser.test.tsx b/apps/web/src/components/ManagedRunEvidence.browser.test.tsx new file mode 100644 index 0000000000000..7f7ed6f9c4ae5 --- /dev/null +++ b/apps/web/src/components/ManagedRunEvidence.browser.test.tsx @@ -0,0 +1,59 @@ +import { EnvironmentId } from "@t3tools/contracts"; +import { expect, it, vi } from "vite-plus/test"; + +import { render } from "../../test/render"; +import type { ManagedRun } from "~/lib/managedRunDelivery"; +import { ManagedRunEvidence } from "./ManagedRunEvidence"; + +vi.mock(import("~/state/environments"), async (original) => ({ + ...(await original()), + usePrimaryEnvironmentId: () => EnvironmentId.make("windows-fixture"), +})); +vi.mock(import("~/state/entities"), async (original) => ({ + ...(await original()), + useQuietThreadShell: (ref) => + ref?.threadId === "mcp:launch:known" ? ({ threadId: ref.threadId } as never) : null, +})); + +it("links an operator wait to the locally known worker and preserves unknown evidence", async () => { + const run: ManagedRun = { + version: 1, + runId: "00000000-0000-0000-0000-000000000000", + ticket: "fixture", + revision: "a".repeat(64), + status: "approved", + brief: { + workspaceId: "fixture", + repository: "lab/fixture", + baseSha: "b".repeat(40), + scope: "Fixture", + tokens: 100, + }, + budget: { reserved: 100, used: null, remaining: null }, + stages: [ + { + stageId: "known", + role: "implementation", + status: "waiting_for_operator", + threadId: "mcp:launch:known", + providerInstanceId: "codex", + toolCalls: 0, + }, + { + stageId: "unknown", + role: "qa", + status: "queued", + threadId: "mcp:launch:unknown", + providerInstanceId: null, + }, + ], + }; + await using screen = await render(); + await expect.element(screen.getByText("implementation · Waiting for operator")).toBeVisible(); + await expect + .element(screen.getByRole("link", { name: "Open worker thread" })) + .toHaveAttribute("href", "/windows-fixture/mcp%3Alaunch%3Aknown"); + await expect.element(screen.getByText("Thread mcp:launch:unknown")).toBeVisible(); + await expect.element(screen.getByText("Tool calls 0")).toBeVisible(); + await expect.element(screen.getByText("Tool calls Unknown")).toBeVisible(); +}); diff --git a/apps/web/src/components/ManagedRunEvidence.tsx b/apps/web/src/components/ManagedRunEvidence.tsx index da2c84ac81f3d..34ac3b809b64f 100644 --- a/apps/web/src/components/ManagedRunEvidence.tsx +++ b/apps/web/src/components/ManagedRunEvidence.tsx @@ -1,6 +1,28 @@ +import { ThreadId } from "@t3tools/contracts"; import { Link } from "@tanstack/react-router"; import type { ManagedRun } from "~/lib/managedRunDelivery"; +import { useQuietThreadShell } from "~/state/entities"; +import { usePrimaryEnvironmentId } from "~/state/environments"; + +function WorkerThread({ id }: { id: string | null }) { + const environmentId = usePrimaryEnvironmentId(); + const ref = environmentId && id ? { environmentId, threadId: ThreadId.make(id) } : null; + const thread = useQuietThreadShell(ref); + return ( +

+ Thread {id ?? "Unknown"} + {ref && thread && ( + <> + {" · "} + + Open worker thread + + + )} +

+ ); +} function formatCount(value: number | null): string { return value === null ? "Unknown" : value.toLocaleString(); @@ -49,7 +71,7 @@ export function ManagedRunEvidence({ run }: { run: ManagedRun }) {

Stage ID {stage.stageId}

Provider instance {stage.providerInstanceId ?? "Unknown"}

-

Thread {stage.threadId ?? "Unknown"}

+

Tool calls {formatCount(stage.toolCalls ?? null)}

{stage.status === "waiting_for_operator" && (