fix(web): preview artifact images on primary click

This commit is contained in:
2026-10-21 12:26:27 +01:00
parent cc094fc06d
commit 93be42b06e
5 changed files with 75 additions and 13 deletions
+15 -7
View File
@@ -1235,10 +1235,12 @@ function renderArtifactListRow(artifact, viewable, viewerIndexOf) {
open.append(h("span", { class: "artifact-kind", text: artifactKindLabel(kind) }));
open.append(h("span", { class: "artifact-list-name", text: name }));
open.append(h("span", { class: "artifact-size", text: humanBytes(artifact.size_bytes) }));
open.addEventListener("click", () => openArtifactInBrowser(resolved));
const at = viewerIndexOf.get(artifact.url);
const previewImage = kind === ArtifactKind.Image && at != null;
open.addEventListener("click", () => previewImage
? openArtifactViewer(viewable, at, open) : openArtifactInBrowser(resolved));
wrap.append(open, renderTileActions(resolved, media, opensViewer && at != null
? (trigger) => openArtifactViewer(viewable, at, trigger) : null, name));
? (trigger) => openArtifactViewer(viewable, at, trigger) : null, name, previewImage));
return wrap;
}
@@ -1316,7 +1318,7 @@ function renderArtifactTile(artifact, viewable, viewerIndexOf) {
const img = h("img", { class: "artifact-thumb", alt: name, loading: "lazy" });
if (resolved) img.src = resolved;
tile.append(img);
tile.addEventListener("click", openTab);
tile.addEventListener("click", () => openViewer(tile));
} else if (kind === ArtifactKind.Video) {
tile.append(
h(
@@ -1339,18 +1341,22 @@ function renderArtifactTile(artifact, viewable, viewerIndexOf) {
);
tile.addEventListener("click", openTab);
}
wrap.append(tile, renderTileActions(resolved, media, opensViewer ? openViewer : null, name));
wrap.append(tile, renderTileActions(resolved, media, opensViewer ? openViewer : null, name, kind === ArtifactKind.Image));
return wrap;
}
/** The compact per-tile actions: icon-only link/share, shown on hover or focus. */
function renderTileActions(resolved, media, preview = null, name = "artifact") {
function renderTileActions(resolved, media, preview = null, name = "artifact", previewImage = false) {
const actions = h("div", { class: "artifact-actions" });
const stop = (fn) => (event) => {
event.stopPropagation();
fn(event.currentTarget);
};
if (preview) actions.append(artifactAction("preview", `Preview in app: ${name}`, !resolved, stop(preview)));
if (previewImage) {
actions.append(artifactAction("external", `Open in browser: ${name}`, !resolved, stop(() => openArtifactInBrowser(resolved))));
} else if (preview) {
actions.append(artifactAction("preview", `Preview in app: ${name}`, !resolved, stop(preview)));
}
if (!media) {
actions.append(
artifactAction("link", "Copy link", !resolved || !canCopyLink(), stop(() => copyArtifactLink(resolved))),
@@ -1379,7 +1385,9 @@ function artifactAction(kind, label, disabled, onclick) {
svg.setAttribute("aria-hidden", "true");
svg.setAttribute("focusable", "false");
const path = document.createElementNS(ARTIFACT_SVG_NS, "path");
path.setAttribute("d", kind === "preview"
path.setAttribute("d", kind === "external"
? "M14 3h7v7M21 3 10 14M10 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-5"
: kind === "preview"
? "M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12ZM15 12a3 3 0 1 1-6 0a3 3 0 0 1 6 0Z"
: kind === "link"
? "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"