web: link artifacts and runs back to their sources
- The run Summary's Pipeline value is a button that opens that pipeline version. - The artifact viewer carries an Open run button (the search viewer passes the artifact's run id), so the evidence always leads back to the run. - Search artifact rows show the image itself as a thumbnail; other artifacts get a type tile (MD/TXT/JSON/CSV/GO/PDF/...), and every artifact row offers an Open run action next to its own navigation.
This commit is contained in:
+11
-1
@@ -137,7 +137,17 @@ export function summaryRows(run, nowMillis, options = {}) {
|
||||
if (text.trim() === "") return;
|
||||
rows.push({ kind: "kv", key, value: text, monospace });
|
||||
};
|
||||
kv("Pipeline", `id ${run.pipeline_id ?? 0} · v${run.version ?? 0}`);
|
||||
if (Number(run.pipeline_id) > 0) {
|
||||
rows.push({
|
||||
kind: "pipeline",
|
||||
key: "Pipeline",
|
||||
value: `id ${run.pipeline_id} · v${run.version ?? 0}`,
|
||||
pipelineId: Number(run.pipeline_id),
|
||||
version: Number(run.version) || 0,
|
||||
});
|
||||
} else {
|
||||
kv("Pipeline", `id ${run.pipeline_id ?? 0} · v${run.version ?? 0}`);
|
||||
}
|
||||
kv("Stage", run.current_stage);
|
||||
const wait = resourceWaitLine(run);
|
||||
if (wait) rows.push({ kind: "wait", value: wait });
|
||||
|
||||
@@ -722,6 +722,23 @@ function openArtifactViewer(viewable, startIndex, trigger = null) {
|
||||
);
|
||||
|
||||
const actions = h("div", { class: "viewer-actions" });
|
||||
// Where this file came from: a run's evidence is only interpretable next to
|
||||
// the run, so the viewer offers the trip back without closing on a guess.
|
||||
const runId = Number(artifact.run_id ?? state.selectedRunId ?? 0);
|
||||
if (Number.isFinite(runId) && runId > 0) {
|
||||
actions.append(
|
||||
h("button", {
|
||||
class: "viewer-action",
|
||||
type: "button",
|
||||
"data-viewer-focus": "run",
|
||||
text: `Open run ${runId}`,
|
||||
onclick: () => {
|
||||
closeArtifactViewer();
|
||||
selectRun(runId);
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (resolved) {
|
||||
actions.append(
|
||||
h("button", {
|
||||
|
||||
@@ -105,6 +105,7 @@ export function createRunDetailView(rt) {
|
||||
const renderConfirmDialog = (...args) => rt.views.dialogs.renderConfirmDialog(...args);
|
||||
const renderActionFailedDialog = (...args) => rt.views.dialogs.renderActionFailedDialog(...args);
|
||||
const openArtifactViewer = (...args) => rt.views.dialogs.openArtifactViewer(...args);
|
||||
const selectPipeline = (...args) => rt.selectPipeline(...args);
|
||||
|
||||
/**
|
||||
* The run detail: a tab strip (Summary / Graph / Input / Output / Timeline) over
|
||||
@@ -212,6 +213,7 @@ function renderRunSummaryTab(d, now) {
|
||||
if (row.kind === "wait") rows.append(h("div", { class: "run-wait", text: row.value }));
|
||||
else if (row.kind === "duration") rows.append(renderDurationRow(d, row));
|
||||
else if (row.kind === "block") rows.append(renderCodeBlock(row.key, row.value));
|
||||
else if (row.kind === "pipeline") rows.append(renderPipelineRow(row));
|
||||
else rows.append(renderKvRow(row));
|
||||
}
|
||||
wrap.append(rows);
|
||||
@@ -237,6 +239,30 @@ function renderRunSummaryTab(d, now) {
|
||||
return wrap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Pipeline row: the same "id N · vM" text, but a button that opens that
|
||||
* pipeline version. A run is only legible next to the definition it executed, so
|
||||
* this is the shortest path from the evidence to the pipeline.
|
||||
*/
|
||||
function renderPipelineRow(row) {
|
||||
const wrap = h("div", { class: "kv-row" });
|
||||
wrap.append(h("span", { class: "kv-key", text: row.key }));
|
||||
const link = h("button", {
|
||||
class: "kv-val kv-pipeline-link",
|
||||
type: "button",
|
||||
text: row.value,
|
||||
title: `Open pipeline ${row.pipelineId}`,
|
||||
"aria-label": `Open pipeline ${row.pipelineId}, version ${row.version}`,
|
||||
});
|
||||
link.addEventListener("click", async () => {
|
||||
state.view = "pipelines";
|
||||
state.selectedRunId = null;
|
||||
await selectPipeline({ id: row.pipelineId, version: row.version });
|
||||
});
|
||||
wrap.append(link);
|
||||
return wrap;
|
||||
}
|
||||
|
||||
/** The Duration row, tagged so the detail clock can update it in place. */
|
||||
function renderDurationRow(d, row) {
|
||||
return h(
|
||||
|
||||
+104
-6
@@ -397,18 +397,70 @@ function fillSearchResults(area) {
|
||||
area.replaceChildren(...nodes);
|
||||
}
|
||||
|
||||
/** The short caption on a non-image artifact's type tile. */
|
||||
function artifactTypeBadge(kind, artifact) {
|
||||
const name = String(artifact?.name ?? "").toLowerCase();
|
||||
const mime = String(artifact?.content_type ?? "").split(";")[0].trim().toLowerCase();
|
||||
const ext = name.includes(".") ? name.slice(name.lastIndexOf(".") + 1) : "";
|
||||
if (kind === ArtifactKind.Document) {
|
||||
if (mime === "text/markdown" || ext === "md" || ext === "markdown") return "MD";
|
||||
if (mime === "text/plain" || ext === "txt") return "TXT";
|
||||
return "DOC";
|
||||
}
|
||||
if (kind === ArtifactKind.Spreadsheet) {
|
||||
if (ext === "csv") return "CSV";
|
||||
if (ext === "tsv") return "TSV";
|
||||
if (ext === "xlsx" || ext === "xls") return "XLSX";
|
||||
return "SHEET";
|
||||
}
|
||||
if (kind === ArtifactKind.Code) return ext ? ext.toUpperCase().slice(0, 5) : "CODE";
|
||||
switch (kind) {
|
||||
case ArtifactKind.Image:
|
||||
return "IMG";
|
||||
case ArtifactKind.Video:
|
||||
return "VID";
|
||||
case ArtifactKind.Audio:
|
||||
return "AUD";
|
||||
case ArtifactKind.Pdf:
|
||||
return "PDF";
|
||||
case ArtifactKind.Json:
|
||||
return "JSON";
|
||||
case ArtifactKind.Archive:
|
||||
return "ZIP";
|
||||
case ArtifactKind.Spreadsheet:
|
||||
return "SHEET";
|
||||
case ArtifactKind.Log:
|
||||
return "LOG";
|
||||
case ArtifactKind.Code:
|
||||
return "CODE";
|
||||
case ArtifactKind.Document:
|
||||
return "DOC";
|
||||
default:
|
||||
return "FILE";
|
||||
}
|
||||
}
|
||||
|
||||
/** Leave the search panel and open a run, for an artifact row's own action. */
|
||||
async function openRunFromSearch(runId) {
|
||||
closeSearch();
|
||||
state.error = "";
|
||||
state.view = "runs";
|
||||
await selectRun(runId);
|
||||
}
|
||||
|
||||
/**
|
||||
* One result row: a compact kind label (the accessibility counterpart of the
|
||||
* app's type glyph), the title and — for a text match — the server snippet with
|
||||
* the first case-insensitive query occurrence emphasised. A known payload is
|
||||
* One result row: the artifact itself when it is an image (a thumbnail), a type
|
||||
* tile otherwise, the title and — for a text match — the server snippet with the
|
||||
* first case-insensitive query occurrence emphasised. A known payload is
|
||||
* clickable and routes to its destination; an unknown/absent payload is rendered
|
||||
* read-only and is never clickable. Every server string is set as text.
|
||||
*/
|
||||
function renderSearchResultRow(hit) {
|
||||
const row = searchRow(hit, state.searchQuery);
|
||||
const target = searchTarget(hit);
|
||||
const artifactHit = hit?.kind === "artifact" && hit.artifact ? hit.artifact : null;
|
||||
const element = h("div", {
|
||||
class: `search-row${target ? " clickable" : " readonly"}`,
|
||||
class: `search-row${target ? " clickable" : " readonly"}${artifactHit ? " search-row-artifact" : ""}`,
|
||||
"data-kind": String(hit?.kind ?? ""),
|
||||
});
|
||||
if (target) {
|
||||
@@ -430,7 +482,32 @@ function renderSearchResultRow(hit) {
|
||||
}
|
||||
});
|
||||
}
|
||||
element.append(h("span", { class: "search-kind muted", text: searchResultKindLabel(hit) }));
|
||||
if (artifactHit) {
|
||||
const kind = artifactKind(artifactHit.content_type, artifactHit.name);
|
||||
const resolved = artifactHit.url ? resolveArtifactUrl(state.url, artifactHit.url) : "";
|
||||
if (kind === ArtifactKind.Image && resolved) {
|
||||
const thumb = h("img", {
|
||||
class: "search-thumb",
|
||||
src: resolved,
|
||||
alt: "",
|
||||
loading: "lazy",
|
||||
"aria-hidden": "true",
|
||||
});
|
||||
element.append(thumb);
|
||||
element.setAttribute("aria-label", `Image artifact ${searchRow(hit, state.searchQuery).title}`);
|
||||
} else {
|
||||
element.append(
|
||||
h("span", {
|
||||
class: "search-type",
|
||||
text: artifactTypeBadge(kind, artifactHit),
|
||||
title: searchResultKindLabel(hit),
|
||||
"aria-label": searchResultKindLabel(hit),
|
||||
}),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
element.append(h("span", { class: "search-kind muted", text: searchResultKindLabel(hit) }));
|
||||
}
|
||||
const main = h("div", { class: "search-row-main" });
|
||||
main.append(h("div", { class: "search-row-title", text: row.title }));
|
||||
if (row.snippet != null) {
|
||||
@@ -446,6 +523,20 @@ function renderSearchResultRow(hit) {
|
||||
} else if (row.secondary) {
|
||||
main.append(h("div", { class: "search-row-secondary muted", text: row.secondary }));
|
||||
}
|
||||
if (artifactHit && Number(artifactHit.run_id) > 0) {
|
||||
const runButton = h("button", {
|
||||
class: "search-open-run",
|
||||
type: "button",
|
||||
text: `Open run #${Number(artifactHit.run_id)}`,
|
||||
});
|
||||
// A row action must not also trigger the row's own artifact navigation.
|
||||
runButton.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
openRunFromSearch(Number(artifactHit.run_id));
|
||||
});
|
||||
runButton.addEventListener("keydown", (event) => event.stopPropagation());
|
||||
main.append(runButton);
|
||||
}
|
||||
element.append(main);
|
||||
return element;
|
||||
}
|
||||
@@ -472,7 +563,14 @@ async function routeSearchResult(hit) {
|
||||
const kind = artifactKind(artifact.content_type, artifact.name);
|
||||
if (kind === ArtifactKind.Image || kind === ArtifactKind.Video) {
|
||||
rt.views.dialogs.openArtifactViewer(
|
||||
[{ url: artifact.url, name: artifact.name, content_type: artifact.content_type }],
|
||||
[
|
||||
{
|
||||
url: artifact.url,
|
||||
name: artifact.name,
|
||||
content_type: artifact.content_type,
|
||||
run_id: artifact.run_id,
|
||||
},
|
||||
],
|
||||
0,
|
||||
);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user