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:
@@ -304,6 +304,42 @@
|
||||
.search-row.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
|
||||
.search-row.readonly { opacity: 0.85; }
|
||||
.search-kind { flex: 0 0 auto; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; padding-top: 2px; }
|
||||
/* An artifact result shows the artifact: a real thumbnail for an image, a type
|
||||
tile for everything else, so "artifact" never stands in for the content. */
|
||||
.search-row-artifact { align-items: center; }
|
||||
.search-thumb {
|
||||
flex: 0 0 auto;
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
object-fit: cover;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
background: var(--surface-2);
|
||||
}
|
||||
.search-type {
|
||||
flex: 0 0 auto;
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
background: var(--surface-2);
|
||||
color: var(--muted);
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
.search-open-run {
|
||||
margin-top: 4px;
|
||||
padding: 2px 8px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 999px;
|
||||
background: transparent;
|
||||
color: var(--color-muted);
|
||||
font-size: 11px;
|
||||
}
|
||||
.search-open-run:hover { border-color: var(--color-border-strong); color: var(--color-text); }
|
||||
.search-row-main { flex: 1 1 auto; min-width: 0; }
|
||||
.search-row-title { font-weight: 600; }
|
||||
.search-row-secondary, .search-row-snippet {
|
||||
|
||||
@@ -192,6 +192,20 @@
|
||||
.change-path { overflow-wrap: anywhere; }
|
||||
.change-meta { font-size: 12px; }
|
||||
.change-stat { display: flex; gap: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
|
||||
/* The run Summary's Pipeline value opens the definition that produced it. */
|
||||
.kv-pipeline-link {
|
||||
border: 0;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
color: var(--accent);
|
||||
font: inherit;
|
||||
text-align: left;
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 2px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.kv-pipeline-link:hover { color: var(--color-text); }
|
||||
|
||||
.stat-add { color: var(--ok); }
|
||||
.stat-del { color: var(--bad); }
|
||||
|
||||
|
||||
+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 {
|
||||
|
||||
@@ -183,6 +183,16 @@ test("summaryRows is the Android order, omitting blank values", () => {
|
||||
assert.equal(rows[9].kind, "block");
|
||||
});
|
||||
|
||||
test("the Pipeline summary row carries the pipeline and version for navigation", () => {
|
||||
const rows = summaryRows({ pipeline_id: 24, version: 6, status: "succeeded" }, 0, TIME_OPTS);
|
||||
const row = rows.find((entry) => entry.kind === "pipeline");
|
||||
assert.ok(row, "a pipeline row rather than plain text");
|
||||
assert.equal(row.key, "Pipeline");
|
||||
assert.equal(row.value, "id 24 · v6");
|
||||
assert.equal(row.pipelineId, 24);
|
||||
assert.equal(row.version, 6);
|
||||
});
|
||||
|
||||
test("summaryRows omits blank values and the wait line when there is none", () => {
|
||||
const rows = summaryRows(
|
||||
{ id: 1, pipeline_id: 2, version: 1, status: "running", executing: false, steps: [], completed_steps: 0 },
|
||||
|
||||
Reference in New Issue
Block a user