Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apps/web/src/components/ManagedRunEvidence.browser.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,11 @@ it("shows the exact reviewed commit and reports a budget overrun separately from
await expect.element(review.getByText("Operator", { exact: true })).toBeVisible();
await expect.element(review.getByText("Token budget exceeded")).toBeVisible();
});

it("displays the Langfuse correlation ID alongside the managed run", async () => {
const runId = "aea004a0-2e19-483e-a001-390900df711a";
const traceId = runId.replaceAll("-", "");
await using screen = await render(<ManagedRunEvidence run={{ ...run, runId, traceId }} />);
await expect.element(screen.getByText("Langfuse correlation ID", { exact: true })).toBeVisible();
await expect.element(screen.getByText(traceId, { exact: true })).toBeVisible();
});
1 change: 1 addition & 0 deletions apps/web/src/components/ManagedRunEvidence.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export function ManagedRunEvidence({ run }: { run: ManagedRun }) {
const { brief, budget, qa } = run;
const fields = [
["Run ID", run.runId],
...(run.traceId ? [["Langfuse correlation ID", run.traceId]] : []),
["Status", run.status],
["Brief revision", run.revision],
["Workspace", brief.workspaceId],
Expand Down
6 changes: 6 additions & 0 deletions apps/web/src/lib/managedRunDelivery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ describe("managed-run Delivery", () => {
expect(parseManagedRun({ ...run, nextVersionField: null }, runId)).toMatchObject(run);
});

it("binds a trace correlation ID to the displayed run", () => {
const traceId = runId.replaceAll("-", "");
expect(parseManagedRun({ ...run, traceId }, runId)?.traceId).toBe(traceId);
expect(parseManagedRun({ ...run, traceId: otherId.replaceAll("-", "") }, runId)).toBeNull();
});

it("distinguishes an observed zero from missing tool usage", () => {
expect(parseManagedRun(run, runId)?.stages[0]?.toolCalls).toBeUndefined();
const withUsage = (toolCalls: number | null) => ({
Expand Down
6 changes: 5 additions & 1 deletion apps/web/src/lib/managedRunDelivery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const ManagedRun = Schema.Struct({
version: Schema.Literal(1),
runId: Schema.String.check(Schema.isPattern(uuid)),
ticket: Schema.String,
traceId: Schema.optionalKey(Schema.String.check(Schema.isPattern(/^[a-f0-9]{32}$/))),
revision: Schema.String.check(Schema.isPattern(/^[0-9a-f]{64}$/)),
status: Schema.String,
brief: Schema.Struct({
Expand Down Expand Up @@ -53,7 +54,10 @@ export function parseManagedRunId(input: unknown): string | undefined {
}

export function parseManagedRun(input: unknown, requestedRunId: string): ManagedRun | null {
return isManagedRun(input) && input.runId === requestedRunId ? input : null;
if (!isManagedRun(input) || input.runId !== requestedRunId) return null;
return input.traceId === undefined || input.traceId === input.runId.replaceAll("-", "")
? input
: null;
}

export async function readManagedRun(
Expand Down
Loading