web: sticky sections, spotlight search, and live sync for other clients' prompts
- Sticky sections: a run/pipeline/template keeps the section you chose when you open another one, and the choice persists across reloads (localStorage per destination). A stage deep link still opens the Graph. - Search is a Spotlight: a modal overlay opened with Ctrl+/ (Cmd+/ too), arrow keys move the selected result, Enter opens it, the query/kind/sort/selection resume on the next open, and an artifact result opens the artifact itself (media in the viewer, anything else in a tab) instead of the run's visit pane. - Live sync: the server only emits a user frame for prompts sent through it, so a message typed in the OpenCode UI appeared only after a refresh. When a frame for an unknown turn arrives, the open conversation now reads the newest history once, which brings the user message in live.
This commit is contained in:
+27
-1
@@ -120,7 +120,33 @@
|
|||||||
.search-host { background: var(--surface); border-bottom: 1px solid var(--border); }
|
.search-host { background: var(--surface); border-bottom: 1px solid var(--border); }
|
||||||
.search-host:empty { display: none; }
|
.search-host:empty { display: none; }
|
||||||
|
|
||||||
.search-panel { padding: 10px 16px 12px; display: grid; gap: 8px; }
|
/* Spotlight: the search is a modal over the page, not a strip in the header. */
|
||||||
|
#searchPanel {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 70;
|
||||||
|
display: grid;
|
||||||
|
place-items: start center;
|
||||||
|
padding: min(12vh, 110px) 16px 16px;
|
||||||
|
background: color-mix(in srgb, #000 55%, transparent);
|
||||||
|
}
|
||||||
|
.search-modal {
|
||||||
|
width: min(760px, 100%);
|
||||||
|
max-height: 70vh;
|
||||||
|
display: grid;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 12px;
|
||||||
|
background: var(--surface-2);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 14px;
|
||||||
|
box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
|
||||||
|
}
|
||||||
|
.search-results { max-height: 46vh; overflow-y: auto; }
|
||||||
|
.search-row.active {
|
||||||
|
background: var(--surface);
|
||||||
|
outline: 2px solid var(--accent);
|
||||||
|
outline-offset: -2px;
|
||||||
|
}
|
||||||
|
|
||||||
.search-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
|
.search-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
|
||||||
.search-field { display: flex; gap: 6px; align-items: center; }
|
.search-field { display: flex; gap: 6px; align-items: center; }
|
||||||
|
|||||||
+32
-6
@@ -78,6 +78,29 @@ const repo = new PipelinesRepository(client);
|
|||||||
// configured value and the draft start from storage.
|
// configured value and the draft start from storage.
|
||||||
const initialWorkspace = readWorkspace(localStorage);
|
const initialWorkspace = readWorkspace(localStorage);
|
||||||
|
|
||||||
|
/** The three detail section choices are sticky and survive a reload. */
|
||||||
|
const SECTION_STORAGE_KEYS = {
|
||||||
|
pipelines: "pipelines.web.pipelineTab.v1",
|
||||||
|
runs: "pipelines.web.runTab.v1",
|
||||||
|
templates: "pipelines.web.templateTab.v1",
|
||||||
|
};
|
||||||
|
|
||||||
|
function readSection(key, fallback) {
|
||||||
|
try {
|
||||||
|
return localStorage.getItem(SECTION_STORAGE_KEYS[key]) || fallback;
|
||||||
|
} catch {
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function writeSection(key, value) {
|
||||||
|
try {
|
||||||
|
localStorage.setItem(SECTION_STORAGE_KEYS[key], value);
|
||||||
|
} catch {
|
||||||
|
// Storage may be unavailable; the in-memory choice still applies.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
view: "pipelines",
|
view: "pipelines",
|
||||||
url: readServerUrl(localStorage) || defaultServerUrl(),
|
url: readServerUrl(localStorage) || defaultServerUrl(),
|
||||||
@@ -127,7 +150,7 @@ const state = {
|
|||||||
pipelineFilters: { ...EMPTY_PIPELINE_FILTERS },
|
pipelineFilters: { ...EMPTY_PIPELINE_FILTERS },
|
||||||
pipelineSort: "server_order",
|
pipelineSort: "server_order",
|
||||||
pipelineMenu: null,
|
pipelineMenu: null,
|
||||||
pipelineTab: "summary",
|
pipelineTab: readSection("pipelines", "summary"),
|
||||||
// The mounted workflow graph (P6) and whether its panel is expanded. The
|
// The mounted workflow graph (P6) and whether its panel is expanded. The
|
||||||
// handle is dropped on every re-render so its listeners can never leak.
|
// handle is dropped on every re-render so its listeners can never leak.
|
||||||
pipelineGraph: null,
|
pipelineGraph: null,
|
||||||
@@ -145,7 +168,7 @@ const state = {
|
|||||||
// failed/absent validate stores null so the card/detail say "unavailable".
|
// failed/absent validate stores null so the card/detail say "unavailable".
|
||||||
templateGraphs: new Map(),
|
templateGraphs: new Map(),
|
||||||
selectedTemplateKey: null,
|
selectedTemplateKey: null,
|
||||||
templateTab: "summary",
|
templateTab: readSection("templates", "summary"),
|
||||||
// The create-from-template dialog (P5): whether it is open, the name being
|
// The create-from-template dialog (P5): whether it is open, the name being
|
||||||
// typed, whether a validate+submit is in flight, the server's refusal text and
|
// typed, whether a validate+submit is in flight, the server's refusal text and
|
||||||
// the created pipeline's name (null until a success, which is also what makes
|
// the created pipeline's name (null until a success, which is also what makes
|
||||||
@@ -165,7 +188,7 @@ const state = {
|
|||||||
// expand/collapse choices for the input/output field sections and the summary
|
// expand/collapse choices for the input/output field sections and the summary
|
||||||
// artifacts section. The stage pane is the timeline's per-visit panel; its
|
// artifacts section. The stage pane is the timeline's per-visit panel; its
|
||||||
// section expansion is reseeded each time a pane is opened.
|
// section expansion is reseeded each time a pane is opened.
|
||||||
runTab: "summary",
|
runTab: readSection("runs", "summary"),
|
||||||
runSections: new Set(),
|
runSections: new Set(),
|
||||||
runStagePane: null,
|
runStagePane: null,
|
||||||
runStageSections: new Set(),
|
runStageSections: new Set(),
|
||||||
@@ -185,6 +208,8 @@ const state = {
|
|||||||
// changes, plus the pure debounce/stale-token sequencer. Opening or closing the
|
// changes, plus the pure debounce/stale-token sequencer. Opening or closing the
|
||||||
// search leaves state.view, the selection and the loaded data untouched.
|
// search leaves state.view, the selection and the loaded data untouched.
|
||||||
searchOpen: false,
|
searchOpen: false,
|
||||||
|
// The keyboard-selected result (ArrowUp/Down) and the row Enter opens.
|
||||||
|
searchActiveIndex: 0,
|
||||||
searchQuery: "",
|
searchQuery: "",
|
||||||
searchKind: DEFAULT_SEARCH_KIND,
|
searchKind: DEFAULT_SEARCH_KIND,
|
||||||
searchSort: DEFAULT_SEARCH_SORT,
|
searchSort: DEFAULT_SEARCH_SORT,
|
||||||
@@ -683,6 +708,7 @@ function selectSection(key) {
|
|||||||
if (state.view === "pipelines") state.pipelineTab = key;
|
if (state.view === "pipelines") state.pipelineTab = key;
|
||||||
else if (state.view === "runs") state.runTab = key;
|
else if (state.view === "runs") state.runTab = key;
|
||||||
else if (state.view === "templates") state.templateTab = key;
|
else if (state.view === "templates") state.templateTab = key;
|
||||||
|
writeSection(state.view, key);
|
||||||
renderContent();
|
renderContent();
|
||||||
focusSectionTab(key);
|
focusSectionTab(key);
|
||||||
}
|
}
|
||||||
@@ -1315,7 +1341,7 @@ async function applyRoute(route) {
|
|||||||
state.selectedPipelineId = r.id;
|
state.selectedPipelineId = r.id;
|
||||||
state.pipelineRequestedVersion = version;
|
state.pipelineRequestedVersion = version;
|
||||||
state.pipelineDetail = null;
|
state.pipelineDetail = null;
|
||||||
state.pipelineTab = r.kind === "pipelineStage" ? "graph" : "summary";
|
if (r.kind === "pipelineStage") state.pipelineTab = "graph";
|
||||||
state.pipelineGraphSelection = r.kind === "pipelineStage" ? r.stageKey : null;
|
state.pipelineGraphSelection = r.kind === "pipelineStage" ? r.stageKey : null;
|
||||||
renderContent();
|
renderContent();
|
||||||
if (!connected()) return;
|
if (!connected()) return;
|
||||||
@@ -1798,7 +1824,7 @@ function resetRunDetailState() {
|
|||||||
state.runGraph?.unmount();
|
state.runGraph?.unmount();
|
||||||
state.runGraph = null;
|
state.runGraph = null;
|
||||||
state.runDetail = null;
|
state.runDetail = null;
|
||||||
state.runTab = "summary";
|
// The section stays put when the operator opens another run (sticky, persisted).
|
||||||
state.runSections = new Set();
|
state.runSections = new Set();
|
||||||
state.runStagePane = null;
|
state.runStagePane = null;
|
||||||
state.runStageSections = new Set();
|
state.runStageSections = new Set();
|
||||||
@@ -1846,7 +1872,7 @@ async function missingRunFallback(err) {
|
|||||||
*/
|
*/
|
||||||
function resetPipelineDetailState() {
|
function resetPipelineDetailState() {
|
||||||
state.pipelineDetail = null;
|
state.pipelineDetail = null;
|
||||||
state.pipelineTab = "summary";
|
// The section stays put when the operator opens another pipeline.
|
||||||
state.pipelineGraphSelection = null;
|
state.pipelineGraphSelection = null;
|
||||||
state.versionsExpanded = false;
|
state.versionsExpanded = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -576,8 +576,31 @@ function onChatEvent(frame) {
|
|||||||
if (!sessionId || !state.chatThreads.has(sessionId)) return;
|
if (!sessionId || !state.chatThreads.has(sessionId)) return;
|
||||||
markBackgroundChatUnseen(sessionId);
|
markBackgroundChatUnseen(sessionId);
|
||||||
const thread = state.chatThreads.get(sessionId);
|
const thread = state.chatThreads.get(sessionId);
|
||||||
|
const messageId = String(frame?.message_id ?? "");
|
||||||
|
// The user turn of a prompt sent from another client (the OpenCode UI, not this
|
||||||
|
// page) never reaches the broker, so no `user` frame exists for it: only the
|
||||||
|
// assistant's frames arrive. When the first frame of an unknown turn arrives,
|
||||||
|
// read the newest history once so the user message (and anything else the page
|
||||||
|
// missed) appears without a manual refresh.
|
||||||
|
const knownTurn = messageId !== "" && (thread.messages ?? []).some((m) => m?.id === messageId);
|
||||||
state.chatThreads.set(sessionId, applyChatEvent(thread, frame, Date.now()));
|
state.chatThreads.set(sessionId, applyChatEvent(thread, frame, Date.now()));
|
||||||
renderContent();
|
renderContent();
|
||||||
|
if (!knownTurn) scheduleHistorySync(sessionId, messageId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** At most one history read per unseen turn, and only for the open conversation. */
|
||||||
|
const historySyncTimers = new Map();
|
||||||
|
const historySyncedFor = new Map();
|
||||||
|
function scheduleHistorySync(sessionId, messageId) {
|
||||||
|
if (!messageId || sessionId !== state.chatActiveId) return;
|
||||||
|
if (historySyncedFor.get(sessionId) === messageId) return;
|
||||||
|
historySyncedFor.set(sessionId, messageId);
|
||||||
|
if (historySyncTimers.has(sessionId)) return;
|
||||||
|
const timer = setTimeout(() => {
|
||||||
|
historySyncTimers.delete(sessionId);
|
||||||
|
loadChatHistory(sessionId).catch(() => {});
|
||||||
|
}, 250);
|
||||||
|
historySyncTimers.set(sessionId, timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+109
-8
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
import { h } from "../dom.js";
|
import { h } from "../dom.js";
|
||||||
import { describeError } from "../format.js";
|
import { describeError } from "../format.js";
|
||||||
|
import { resolveArtifactUrl } from "../serverUrl.js";
|
||||||
|
import { ArtifactKind, artifactKind } from "../artifacts.js";
|
||||||
import {
|
import {
|
||||||
DEFAULT_SEARCH_KIND,
|
DEFAULT_SEARCH_KIND,
|
||||||
DEFAULT_SEARCH_SORT,
|
DEFAULT_SEARCH_SORT,
|
||||||
@@ -28,6 +30,37 @@ export function createSearchView(rt) {
|
|||||||
const { state, repo, searchHost } = rt;
|
const { state, repo, searchHost } = rt;
|
||||||
let searchTimer = null;
|
let searchTimer = null;
|
||||||
let searchEdit = null;
|
let searchEdit = null;
|
||||||
|
// The last search is resumed on the next open (the field, kind, sort and the
|
||||||
|
// selected row). Persisted so it also survives a reload.
|
||||||
|
const SEARCH_STORAGE_KEY = "pipelines.web.search.v1";
|
||||||
|
function saveSearchState() {
|
||||||
|
try {
|
||||||
|
localStorage.setItem(
|
||||||
|
SEARCH_STORAGE_KEY,
|
||||||
|
JSON.stringify({
|
||||||
|
query: state.searchQuery,
|
||||||
|
kind: state.searchKind,
|
||||||
|
sort: state.searchSort,
|
||||||
|
activeIndex: state.searchActiveIndex,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
} catch {
|
||||||
|
// Storage may be unavailable; the in-memory state still resumes in this page.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function restoreSearchState() {
|
||||||
|
if (state.searchQuery !== "") return;
|
||||||
|
try {
|
||||||
|
const saved = JSON.parse(localStorage.getItem(SEARCH_STORAGE_KEY) || "null");
|
||||||
|
if (!saved || typeof saved.query !== "string") return;
|
||||||
|
state.searchQuery = saved.query;
|
||||||
|
if (SEARCH_KINDS.some((k) => k.value === saved.kind)) state.searchKind = saved.kind;
|
||||||
|
if (SEARCH_SORTS.some((k) => k.value === saved.sort)) state.searchSort = saved.sort;
|
||||||
|
state.searchActiveIndex = Number.isInteger(saved.activeIndex) ? Math.max(0, saved.activeIndex) : 0;
|
||||||
|
} catch {
|
||||||
|
// A corrupt value simply starts empty.
|
||||||
|
}
|
||||||
|
}
|
||||||
// Where focus goes when the panel closes: the rail or dock Search control that
|
// Where focus goes when the panel closes: the rail or dock Search control that
|
||||||
// opened it, so Escape/Close never drops the operator on <body>.
|
// opened it, so Escape/Close never drops the operator on <body>.
|
||||||
let searchTriggerId = null;
|
let searchTriggerId = null;
|
||||||
@@ -45,11 +78,20 @@ function openSearch() {
|
|||||||
if (state.searchOpen) return;
|
if (state.searchOpen) return;
|
||||||
const trigger = document.activeElement;
|
const trigger = document.activeElement;
|
||||||
searchTriggerId = trigger && trigger.id ? trigger.id : null;
|
searchTriggerId = trigger && trigger.id ? trigger.id : null;
|
||||||
|
restoreSearchState();
|
||||||
state.searchOpen = true;
|
state.searchOpen = true;
|
||||||
state.searchError = "";
|
state.searchError = "";
|
||||||
state.searchFocusPending = true;
|
state.searchFocusPending = true;
|
||||||
renderHeader();
|
renderHeader();
|
||||||
renderSearch();
|
renderSearch();
|
||||||
|
// Resume: the previous results show immediately, and a non-blank query is
|
||||||
|
// refreshed so the list is not stale.
|
||||||
|
if (searchQuerySendable(state.searchQuery)) {
|
||||||
|
state.searchLoading = true;
|
||||||
|
const sent = state.searchSequencer.begin(state.searchSequencer.edit(state.searchQuery));
|
||||||
|
if (sent) runSearch(sent);
|
||||||
|
refreshSearch();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,15 +103,12 @@ function openSearch() {
|
|||||||
*/
|
*/
|
||||||
function closeSearch() {
|
function closeSearch() {
|
||||||
cancelSearchDebounce();
|
cancelSearchDebounce();
|
||||||
|
saveSearchState();
|
||||||
// Recording an empty edit advances the sequencer, so a reply for a request
|
// Recording an empty edit advances the sequencer, so a reply for a request
|
||||||
// still in flight can no longer be accepted.
|
// still in flight can no longer be accepted.
|
||||||
state.searchSequencer.edit("");
|
state.searchSequencer.edit("");
|
||||||
state.searchOpen = false;
|
state.searchOpen = false;
|
||||||
state.searchQuery = "";
|
|
||||||
state.searchResults = [];
|
|
||||||
state.searchLoading = false;
|
state.searchLoading = false;
|
||||||
state.searchError = "";
|
|
||||||
state.searchLoaded = false;
|
|
||||||
state.searchFocusPending = false;
|
state.searchFocusPending = false;
|
||||||
renderHeader();
|
renderHeader();
|
||||||
renderSearch();
|
renderSearch();
|
||||||
@@ -78,6 +117,11 @@ function closeSearch() {
|
|||||||
if (trigger && trigger.getClientRects().length > 0) trigger.focus();
|
if (trigger && trigger.getClientRects().length > 0) trigger.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Keep the keyboard-selected row visible in the results list. */
|
||||||
|
function scrollActiveSearchRow() {
|
||||||
|
document.querySelector("#searchResults .search-row.active")?.scrollIntoView({ block: "nearest" });
|
||||||
|
}
|
||||||
|
|
||||||
function cancelSearchDebounce() {
|
function cancelSearchDebounce() {
|
||||||
if (searchTimer) {
|
if (searchTimer) {
|
||||||
clearTimeout(searchTimer);
|
clearTimeout(searchTimer);
|
||||||
@@ -165,6 +209,7 @@ async function runSearch(sent) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state.searchResults = Array.isArray(reply.results) ? reply.results : [];
|
state.searchResults = Array.isArray(reply.results) ? reply.results : [];
|
||||||
|
state.searchActiveIndex = 0;
|
||||||
state.searchLoading = false;
|
state.searchLoading = false;
|
||||||
state.searchError = "";
|
state.searchError = "";
|
||||||
state.searchLoaded = true;
|
state.searchLoaded = true;
|
||||||
@@ -242,9 +287,23 @@ function renderSearch() {
|
|||||||
"aria-label": "Search",
|
"aria-label": "Search",
|
||||||
oninput: (event) => onSearchInput(event.target.value),
|
oninput: (event) => onSearchInput(event.target.value),
|
||||||
onkeydown: (event) => {
|
onkeydown: (event) => {
|
||||||
|
const shown = sortSearchResults(
|
||||||
|
filterSearchResults(state.searchResults, state.searchKind),
|
||||||
|
state.searchSort,
|
||||||
|
);
|
||||||
|
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
||||||
|
event.preventDefault();
|
||||||
|
if (!shown.length) return;
|
||||||
|
const delta = event.key === "ArrowDown" ? 1 : -1;
|
||||||
|
state.searchActiveIndex = (state.searchActiveIndex + delta + shown.length) % shown.length;
|
||||||
|
refreshSearch();
|
||||||
|
scrollActiveSearchRow();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (event.key === "Enter") {
|
if (event.key === "Enter") {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
sendSearchNow();
|
if (shown.length) routeSearchResult(shown[state.searchActiveIndex] ?? shown[0]);
|
||||||
|
else sendSearchNow();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
@@ -278,9 +337,17 @@ function renderSearch() {
|
|||||||
|
|
||||||
const area = h("div", { id: "searchResults", class: "search-results", "aria-live": "polite" });
|
const area = h("div", { id: "searchResults", class: "search-results", "aria-live": "polite" });
|
||||||
fillSearchResults(area);
|
fillSearchResults(area);
|
||||||
searchHost.replaceChildren(
|
const panel = h(
|
||||||
h("div", { id: "searchPanel", class: "search-panel", role: "search", "aria-label": "Search" }, fieldRow, controls, area),
|
"div",
|
||||||
|
{ id: "searchPanel", class: "search-panel", role: "dialog", "aria-modal": "true", "aria-label": "Search" },
|
||||||
|
h("div", { class: "search-modal", role: "search" }, fieldRow, controls, area),
|
||||||
);
|
);
|
||||||
|
// A spotlight: clicking the dimmed backdrop closes it (the modal itself stops).
|
||||||
|
panel.addEventListener("click", (event) => {
|
||||||
|
if (event.target === panel) closeSearch();
|
||||||
|
});
|
||||||
|
panel.querySelector(".search-modal")?.addEventListener("click", (event) => event.stopPropagation());
|
||||||
|
searchHost.replaceChildren(panel);
|
||||||
if (state.searchFocusPending) {
|
if (state.searchFocusPending) {
|
||||||
document.getElementById("searchInput")?.focus();
|
document.getElementById("searchInput")?.focus();
|
||||||
state.searchFocusPending = false;
|
state.searchFocusPending = false;
|
||||||
@@ -306,7 +373,15 @@ function fillSearchResults(area) {
|
|||||||
if (body.kind === "error") {
|
if (body.kind === "error") {
|
||||||
nodes.push(h("div", { class: "search-error", text: body.message }));
|
nodes.push(h("div", { class: "search-error", text: body.message }));
|
||||||
} else if (body.kind === "results") {
|
} else if (body.kind === "results") {
|
||||||
for (const hit of shown) nodes.push(renderSearchResultRow(hit));
|
state.searchActiveIndex = Math.min(Math.max(0, state.searchActiveIndex), shown.length - 1);
|
||||||
|
shown.forEach((hit, index) => {
|
||||||
|
const row = renderSearchResultRow(hit);
|
||||||
|
if (index === state.searchActiveIndex) {
|
||||||
|
row.classList.add("active");
|
||||||
|
row.setAttribute("aria-selected", "true");
|
||||||
|
}
|
||||||
|
nodes.push(row);
|
||||||
|
});
|
||||||
} else if (body.kind === "searching") {
|
} else if (body.kind === "searching") {
|
||||||
nodes.push(
|
nodes.push(
|
||||||
h(
|
h(
|
||||||
@@ -387,6 +462,24 @@ function renderSearchResultRow(hit) {
|
|||||||
async function routeSearchResult(hit) {
|
async function routeSearchResult(hit) {
|
||||||
const target = searchTarget(hit);
|
const target = searchTarget(hit);
|
||||||
if (!target) return;
|
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.
|
||||||
|
if (hit?.kind === "artifact" && hit.artifact?.url) {
|
||||||
|
const artifact = hit.artifact;
|
||||||
|
const resolved = resolveArtifactUrl(state.url, artifact.url);
|
||||||
|
if (!resolved) return;
|
||||||
|
closeSearch();
|
||||||
|
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 }],
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
window.open(resolved, "_blank", "noopener,noreferrer");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
closeSearch();
|
closeSearch();
|
||||||
state.error = "";
|
state.error = "";
|
||||||
if (target.kind === "pipeline") {
|
if (target.kind === "pipeline") {
|
||||||
@@ -407,6 +500,14 @@ async function routeSearchResult(hit) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ctrl+/ (Cmd+/ on macOS) is the Spotlight shortcut: toggle from anywhere.
|
||||||
|
document.addEventListener("keydown", (event) => {
|
||||||
|
if (!(event.ctrlKey || event.metaKey) || event.key !== "/") return;
|
||||||
|
event.preventDefault();
|
||||||
|
if (state.searchOpen) closeSearch();
|
||||||
|
else openSearch();
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
openSearch,
|
openSearch,
|
||||||
closeSearch,
|
closeSearch,
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export function createTemplatesView(rt) {
|
|||||||
* fields can never drift.
|
* fields can never drift.
|
||||||
*/
|
*/
|
||||||
function resetTemplateCreateState() {
|
function resetTemplateCreateState() {
|
||||||
state.templateTab = "summary";
|
// The section is sticky across template selections (it is persisted by the shell).
|
||||||
// A different template reseeds the create dialog, so a name typed for one
|
// A different template reseeds the create dialog, so a name typed for one
|
||||||
// template can never be submitted against another.
|
// template can never be submitted against another.
|
||||||
state.templateCreateOpen = false;
|
state.templateCreateOpen = false;
|
||||||
|
|||||||
+69
-19
@@ -765,6 +765,9 @@ async function openRunDetail(runId) {
|
|||||||
await page.waitForSelector(row, { timeout: 20000 });
|
await page.waitForSelector(row, { timeout: 20000 });
|
||||||
await page.click(row);
|
await page.click(row);
|
||||||
await page.waitForSelector("#detailTitle", { timeout: 20000 });
|
await page.waitForSelector("#detailTitle", { timeout: 20000 });
|
||||||
|
// The section is sticky across runs now, so a run can open on whatever tab
|
||||||
|
// the previous one showed. This helper's callers expect the Summary.
|
||||||
|
await clickDetailTab("Summary");
|
||||||
// The tabstrip already exists from the previously opened run, so it is not
|
// The tabstrip already exists from the previously opened run, so it is not
|
||||||
// proof this run's detail loaded. Wait for this run's own identity line
|
// proof this run's detail loaded. Wait for this run's own identity line
|
||||||
// (`run {id} · …`) before returning, or the next assertion can read the
|
// (`run {id} · …`) before returning, or the next assertion can read the
|
||||||
@@ -3662,6 +3665,8 @@ try {
|
|||||||
step("routing a pipeline hit to its detail (S2)");
|
step("routing a pipeline hit to its detail (S2)");
|
||||||
const pipelineTarget = await routeSearchKind(SEARCH_QUERY, "pipeline", async () => {
|
const pipelineTarget = await routeSearchKind(SEARCH_QUERY, "pipeline", async () => {
|
||||||
await page.waitForSelector("#detailTitle", { timeout: 25000 });
|
await page.waitForSelector("#detailTitle", { timeout: 25000 });
|
||||||
|
// The section is sticky across pipelines now; this step checks the Summary.
|
||||||
|
await clickDetailTab("Summary");
|
||||||
await page.waitForSelector("#content .detail .monospace", { timeout: 25000 });
|
await page.waitForSelector("#content .detail .monospace", { timeout: 25000 });
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
@@ -3758,28 +3763,49 @@ try {
|
|||||||
what: "the step stage pane to close",
|
what: "the step stage pane to close",
|
||||||
});
|
});
|
||||||
|
|
||||||
step("routing an artifact hit to the same visit pane (S2)");
|
step("routing an artifact hit opens the artifact itself (S2)");
|
||||||
const artifactTarget = await routeSearchKind(SEARCH_QUERY, "artifact", async () => {
|
// Query a known image artifact: "plan" also matches non-image files, which open
|
||||||
await eventually(() => page.evaluate(`!!document.querySelector(".stage-pane")`), {
|
// in a tab by design and could not be asserted here.
|
||||||
timeout: 20000,
|
const artifactTarget = await routeSearchKind("background-viewer", "artifact", async () => {
|
||||||
what: "the routed artifact visit pane",
|
// An artifact hit opens the file, not the run/visit that recorded it: media in
|
||||||
});
|
// the viewer, everything else in a new tab.
|
||||||
|
await eventually(
|
||||||
|
() =>
|
||||||
|
page.evaluate(
|
||||||
|
`!!document.querySelector(".artifact-viewer") || !!document.querySelector(".stage-pane")`,
|
||||||
|
),
|
||||||
|
{ timeout: 20000, what: "the routed artifact to open" },
|
||||||
|
);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
if (artifactTarget) {
|
if (artifactTarget) {
|
||||||
const artifactPane = await page.evaluate(
|
// The image element exists when the viewer mounts; wait for it to decode.
|
||||||
`document.querySelector(".stage-pane-title")?.textContent ?? ""`,
|
await eventually(
|
||||||
|
() =>
|
||||||
|
page.evaluate(`(() => {
|
||||||
|
const i = document.querySelector(".artifact-viewer img");
|
||||||
|
return !!i && i.complete && i.naturalWidth > 0;
|
||||||
|
})()`),
|
||||||
|
{ timeout: 15000, what: "the artifact viewer image to load" },
|
||||||
);
|
);
|
||||||
console.log(` ${artifactTarget} -> run stage pane "${artifactPane}"`);
|
const artifactOpen = await page.evaluate(`({
|
||||||
await page.rect(".stage-pane-sheet");
|
viewer: !!document.querySelector(".artifact-viewer"),
|
||||||
|
stagePane: !!document.querySelector(".stage-pane"),
|
||||||
|
imageLoaded: (() => { const i = document.querySelector(".artifact-viewer img"); return !!i && i.complete && i.naturalWidth > 0; })(),
|
||||||
|
})`);
|
||||||
|
if (artifactOpen.stagePane || !artifactOpen.viewer || !artifactOpen.imageLoaded) {
|
||||||
|
throw new Error(`an artifact hit did not open the artifact: ${JSON.stringify(artifactOpen)}`);
|
||||||
|
}
|
||||||
|
console.log(` ${artifactTarget} -> artifact viewer (image loaded)`);
|
||||||
|
await page.rect(".artifact-viewer");
|
||||||
await shot("07-search-route-artifact.png");
|
await shot("07-search-route-artifact.png");
|
||||||
await page.click(".stage-pane-back");
|
await page.evaluate(`document.querySelector(".artifact-viewer")?.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }))`);
|
||||||
await eventually(() => page.evaluate(`!document.querySelector(".stage-pane")`), {
|
await eventually(() => page.evaluate(`!document.querySelector(".artifact-viewer")`), {
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
what: "the artifact stage pane to close",
|
what: "the artifact viewer to close",
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log(" -- no artifact hit routed to a visit pane; skipped the artifact capture");
|
console.log(" -- no artifact hit routed; skipped the artifact capture");
|
||||||
}
|
}
|
||||||
|
|
||||||
step("routing a version hit to its pipeline detail (S2)");
|
step("routing a version hit to its pipeline detail (S2)");
|
||||||
@@ -3803,10 +3829,10 @@ try {
|
|||||||
console.log(" -- no version hit routed; skipped the version capture");
|
console.log(" -- no version hit routed; skipped the version capture");
|
||||||
}
|
}
|
||||||
|
|
||||||
step("Closing search clears the query and leaves the view intact (S1)");
|
step("Closing search keeps the view and resumes the query (S1)");
|
||||||
// Use the same query whose field hits this run already proved; a live server's
|
// Use the same query whose field hits this run already proved; a live server's
|
||||||
// data changes, and "release" may simply have no field hit today (nothing about
|
// data changes, and "release" may simply have no field hit today (nothing about
|
||||||
// the close/clear path depends on the word).
|
// the close/resume path depends on the word).
|
||||||
await searchTargets(SEARCH_QUERY, "field");
|
await searchTargets(SEARCH_QUERY, "field");
|
||||||
const beforeClose = await viewSnapshot();
|
const beforeClose = await viewSnapshot();
|
||||||
await page.click("#searchClose");
|
await page.click("#searchClose");
|
||||||
@@ -3818,10 +3844,25 @@ try {
|
|||||||
if (afterClose.tab !== beforeClose.tab || afterClose.detail !== beforeClose.detail) {
|
if (afterClose.tab !== beforeClose.tab || afterClose.detail !== beforeClose.detail) {
|
||||||
throw new Error(`closing search changed the view: ${JSON.stringify({ beforeClose, afterClose })}`);
|
throw new Error(`closing search changed the view: ${JSON.stringify({ beforeClose, afterClose })}`);
|
||||||
}
|
}
|
||||||
|
// The spotlight resumes where it was left: same query, results shown again.
|
||||||
await page.click("#searchToggle");
|
await page.click("#searchToggle");
|
||||||
await page.waitForSelector("#searchInput", { timeout: 15000 });
|
await page.waitForSelector("#searchInput", { timeout: 15000 });
|
||||||
const reopenedQuery = await page.evaluate(`document.querySelector("#searchInput")?.value ?? ""`);
|
const reopenedQuery = await page.evaluate(`document.querySelector("#searchInput")?.value ?? ""`);
|
||||||
if (reopenedQuery !== "") throw new Error(`closing search did not clear the query: "${reopenedQuery}"`);
|
if (reopenedQuery !== SEARCH_QUERY) {
|
||||||
|
throw new Error(`reopening did not resume the query: "${reopenedQuery}"`);
|
||||||
|
}
|
||||||
|
await eventually(() => page.evaluate(`document.querySelectorAll("#searchResults .search-row").length > 0`), {
|
||||||
|
timeout: 20000,
|
||||||
|
what: "the resumed results",
|
||||||
|
});
|
||||||
|
console.log(` the spotlight resumed "${SEARCH_QUERY}" with its results`);
|
||||||
|
// Ctrl+/ toggles it closed again for the following steps.
|
||||||
|
await page.evaluate(`document.dispatchEvent(new KeyboardEvent("keydown", { key: "/", ctrlKey: true, bubbles: true, cancelable: true }))`);
|
||||||
|
await eventually(() => page.evaluate(`!document.querySelector("#searchInput")`), {
|
||||||
|
timeout: 10000,
|
||||||
|
what: "Ctrl+/ to close the spotlight",
|
||||||
|
});
|
||||||
|
console.log(" Ctrl+/ closed the spotlight");
|
||||||
await page.evaluate(
|
await page.evaluate(
|
||||||
`document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }))`,
|
`document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }))`,
|
||||||
);
|
);
|
||||||
@@ -4429,7 +4470,12 @@ try {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (transcript.markdown === 0) throw new Error("the agent turn rendered no markdown");
|
if (transcript.markdown === 0) throw new Error("the agent turn rendered no markdown");
|
||||||
if (transcript.tables === 0) throw new Error("the agent answer rendered no markdown table");
|
if (transcript.tables === 0) {
|
||||||
|
// The live transcript's first page is whatever the operator session holds; a
|
||||||
|
// table may legitimately be absent. The table path is proven below on the
|
||||||
|
// page's own renderer with a fixed sample.
|
||||||
|
console.log(" -- the loaded live turn carries no table; the renderer sample covers tables");
|
||||||
|
}
|
||||||
if (transcript.inlineCode === 0) throw new Error("the agent answer rendered no inline code");
|
if (transcript.inlineCode === 0) throw new Error("the agent answer rendered no inline code");
|
||||||
if (transcript.toolChips.length < 1) {
|
if (transcript.toolChips.length < 1) {
|
||||||
throw new Error(`expected at least one tool-call chip, got ${transcript.toolChips.length}`);
|
throw new Error(`expected at least one tool-call chip, got ${transcript.toolChips.length}`);
|
||||||
@@ -4510,7 +4556,7 @@ try {
|
|||||||
// so exercise the page's own markdown renderer on a labelled sample and capture
|
// so exercise the page's own markdown renderer on a labelled sample and capture
|
||||||
// the rendered <pre> block; the sample is removed again straight after.
|
// the rendered <pre> block; the sample is removed again straight after.
|
||||||
const fence = String.fromCharCode(96).repeat(3);
|
const fence = String.fromCharCode(96).repeat(3);
|
||||||
const codeSample = `${fence}js\nconst answer = 42;\n${fence}`;
|
const codeSample = `${fence}js\nconst answer = 42;\n${fence}\n\n| name | value |\n| --- | --- |\n| alpha | 1 |\n| beta | 2 |`;
|
||||||
const codeBlock = await page.evaluate(`(async () => {
|
const codeBlock = await page.evaluate(`(async () => {
|
||||||
const mod = await import("/src/app.js");
|
const mod = await import("/src/app.js");
|
||||||
const node = mod.renderMarkdown(${JSON.stringify(codeSample)});
|
const node = mod.renderMarkdown(${JSON.stringify(codeSample)});
|
||||||
@@ -4522,12 +4568,16 @@ try {
|
|||||||
label: node.querySelector(".md-code-label")?.textContent ?? "",
|
label: node.querySelector(".md-code-label")?.textContent ?? "",
|
||||||
hasPre: !!node.querySelector("pre.md-pre code"),
|
hasPre: !!node.querySelector("pre.md-pre code"),
|
||||||
text: node.querySelector("pre.md-pre code")?.textContent ?? "",
|
text: node.querySelector("pre.md-pre code")?.textContent ?? "",
|
||||||
|
tableRows: node.querySelectorAll("table tr").length,
|
||||||
};
|
};
|
||||||
})()`);
|
})()`);
|
||||||
if (!codeBlock || !codeBlock.hasPre) {
|
if (!codeBlock || !codeBlock.hasPre) {
|
||||||
throw new Error("the page's markdown renderer drew no fenced code block");
|
throw new Error("the page's markdown renderer drew no fenced code block");
|
||||||
}
|
}
|
||||||
if (codeBlock.label !== "js") throw new Error(`code block label: ${codeBlock.label}`);
|
if (codeBlock.label !== "js") throw new Error(`code block label: ${codeBlock.label}`);
|
||||||
|
if (codeBlock.tableRows < 3) {
|
||||||
|
throw new Error(`the markdown renderer drew no table from the sample: ${codeBlock.tableRows} rows`);
|
||||||
|
}
|
||||||
console.log(
|
console.log(
|
||||||
` markdown code block (page renderer sample): label "${codeBlock.label}", text ${JSON.stringify(codeBlock.text)}`,
|
` markdown code block (page renderer sample): label "${codeBlock.label}", text ${JSON.stringify(codeBlock.text)}`,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user