count in-process preview pages in the ai evals active-preview resolver (#11725)

* fix: count in-process preview pages in the ai evals active-preview resolver

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor: share the page-slot predicate between the session and eval resolvers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-10-13 13:09:45 +00:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 3d67d3ac6b
commit f2b9c6d33c
3 changed files with 17 additions and 12 deletions
@@ -17,6 +17,7 @@ import {
previewLocationLabel,
promptSafe,
resolvePreviewTab,
slotShowsPage,
} from "../../../../../frontend/src/lib/components/sessions/previewRouter";
import type { ArtifactVersionTarget } from "../../../../../frontend/src/lib/components/sessions/previewRouter";
import type { SessionTarget } from "../../../../../frontend/src/lib/components/sessions/sessionState.svelte";
@@ -136,9 +137,8 @@ export function createEvalPreviewPanel(input: {
activePreview: () => {
const tab = owner.displayedTab;
if (!tab) return undefined;
// Artifact and editor tabs are not iframes: they carry no page location, and an
// artifact's pinned version reaches the chat only through get_preview_status.
if (resolvePreviewTab(tab.url).kind !== "iframe") return undefined;
// An artifact's pinned version reaches the chat only through get_preview_status.
if (!slotShowsPage(resolvePreviewTab(tab.url).kind)) return undefined;
return previewLocationContext(whereIs(tab));
},
dispose: () => {
@@ -613,6 +613,18 @@ export type PreviewSlot =
| { kind: 'run'; jobId: string; workspace?: string }
| { kind: 'iframe' }
/** Whether a tab on this slot shows a page, framed or mounted in process, and so has a
* location to stamp as the chat's ACTIVE PREVIEW. Editors register as the ACTIVE EDITOR. */
export function slotShowsPage(kind: PreviewSlot['kind']): boolean {
return (
kind === 'iframe' ||
kind === 'pageitem' ||
kind === 'pagelist' ||
kind === 'run' ||
kind === 'viewer'
)
}
export function resolvePreviewTab(url: string): PreviewSlot {
const artifact = parseArtifactRoute(url)
if (artifact) return { kind: 'artifact', id: artifact.id, version: artifact.version }
@@ -72,6 +72,7 @@ import {
promptSafe,
parseRunFormRoute,
resolvePreviewTab,
slotShowsPage,
type PreviewSlot
} from './previewRouter'
import { normalizePipelineFolder } from '$lib/utils/pipelineFolder'
@@ -466,15 +467,7 @@ function createRuntime(session: Session): SessionRuntime {
// point those at a page the user cannot see.
const tab = owner?.displayedTab
if (!tab) return undefined
const slotKind = resolvePreviewTab(tab.url).kind
if (
slotKind !== 'iframe' &&
slotKind !== 'pageitem' &&
slotKind !== 'pagelist' &&
slotKind !== 'run' &&
slotKind !== 'viewer'
)
return undefined
if (!slotShowsPage(resolvePreviewTab(tab.url).kind)) return undefined
return previewLocationContext(whereIs(tab))
}
// Pre-flight: materialise the (still-transient) session, then commit