Files
sanderling/inspect-ui/src/api.ts
T
pj 8e9ac938f3 feat(inspect-ui): hierarchy + html panels in run detail
HierarchyPanel renders the captured DOM/AX tree with a filter input.
HtmlPanel renders the per-step HTML in an iframe (sandboxed) with a
toggle to view source. HTML tab only shows when the step actually has
HTML captured.
2026-04-27 18:54:02 +07:00

30 lines
1.0 KiB
TypeScript

import type { Run, RunSummary, Step } from "./types";
async function getJson<T>(path: string): Promise<T> {
const response = await fetch(path, { headers: { Accept: "application/json" } });
if (!response.ok) {
throw new Error(`request failed: ${response.status} ${response.statusText} (${path})`);
}
return (await response.json()) as T;
}
export function listRuns(): Promise<RunSummary[]> {
return getJson<RunSummary[]>("/api/runs");
}
export function getRun(runId: string): Promise<Run> {
return getJson<Run>(`/api/runs/${encodeURIComponent(runId)}`);
}
export function getStep(runId: string, index: number): Promise<Step> {
return getJson<Step>(`/api/runs/${encodeURIComponent(runId)}/steps/${index}`);
}
export function screenshotUrl(runId: string, name: string): string {
return `/api/runs/${encodeURIComponent(runId)}/screenshots/${encodeURIComponent(name)}`;
}
export function htmlUrl(runId: string, name: string): string {
return `/api/runs/${encodeURIComponent(runId)}/html/${encodeURIComponent(name)}`;
}