fix(web): open artifacts outside the installed app context

This commit is contained in:
2026-10-20 20:03:41 +01:00
parent 5014c9e61f
commit 06dddb002a
13 changed files with 388 additions and 92 deletions
+5 -22
View File
@@ -2,10 +2,10 @@
// routing. Debounce/staleness/ordering/empty-state decisions are pure in
// search.js; this module owns the DOM and the route hand-off.
import { h } from "../dom.js";
import { h, openArtifactInBrowser } from "../dom.js";
import { describeError } from "../format.js";
import { resolveArtifactUrl } from "../serverUrl.js";
import { ArtifactKind, artifactKind, isViewerArtifact } from "../artifacts.js";
import { ArtifactKind, artifactKind } from "../artifacts.js";
import {
DEFAULT_SEARCH_KIND,
DEFAULT_SEARCH_SORT,
@@ -623,31 +623,14 @@ function renderSearchResultRow(hit) {
async function routeSearchResult(hit) {
const target = searchTarget(hit);
if (!target) return;
// An artifact hit opens the artifact, not the run/visit that recorded it: media
// in the viewer, anything else in a tab. Nothing to show means no navigation.
// All artifact types open in the browser. In-app preview is an explicit
// gallery action, never an unexpected navigation away from the installed app.
if (hit?.kind === "artifact" && hit.artifact?.url) {
const artifact = hit.artifact;
const resolved = resolveArtifactUrl(state.url, artifact.url);
if (!resolved) return;
closeSearch();
// Media, markdown and text all belong in the viewer, which now renders the
// document and offers the trip back to the run; anything else opens raw.
if (isViewerArtifact(artifact.content_type, artifact.name)) {
rt.views.dialogs.openArtifactViewer(
[
{
url: artifact.url,
name: artifact.name,
content_type: artifact.content_type,
size_bytes: artifact.size_bytes,
run_id: artifact.run_id,
},
],
0,
);
} else {
window.open(resolved, "_blank", "noopener,noreferrer");
}
openArtifactInBrowser(resolved);
return;
}
closeSearch();