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:
2026-10-19 20:45:39 +01:00
parent a7991077d2
commit ff45c0ec86
6 changed files with 261 additions and 35 deletions
+69 -19
View File
@@ -765,6 +765,9 @@ async function openRunDetail(runId) {
await page.waitForSelector(row, { timeout: 20000 });
await page.click(row);
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
// 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
@@ -3662,6 +3665,8 @@ try {
step("routing a pipeline hit to its detail (S2)");
const pipelineTarget = await routeSearchKind(SEARCH_QUERY, "pipeline", async () => {
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 });
return true;
});
@@ -3758,28 +3763,49 @@ try {
what: "the step stage pane to close",
});
step("routing an artifact hit to the same visit pane (S2)");
const artifactTarget = await routeSearchKind(SEARCH_QUERY, "artifact", async () => {
await eventually(() => page.evaluate(`!!document.querySelector(".stage-pane")`), {
timeout: 20000,
what: "the routed artifact visit pane",
});
step("routing an artifact hit opens the artifact itself (S2)");
// Query a known image artifact: "plan" also matches non-image files, which open
// in a tab by design and could not be asserted here.
const artifactTarget = await routeSearchKind("background-viewer", "artifact", async () => {
// 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;
});
if (artifactTarget) {
const artifactPane = await page.evaluate(
`document.querySelector(".stage-pane-title")?.textContent ?? ""`,
// The image element exists when the viewer mounts; wait for it to decode.
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}"`);
await page.rect(".stage-pane-sheet");
const artifactOpen = await page.evaluate(`({
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 page.click(".stage-pane-back");
await eventually(() => page.evaluate(`!document.querySelector(".stage-pane")`), {
await page.evaluate(`document.querySelector(".artifact-viewer")?.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }))`);
await eventually(() => page.evaluate(`!document.querySelector(".artifact-viewer")`), {
timeout: 5000,
what: "the artifact stage pane to close",
what: "the artifact viewer to close",
});
} 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)");
@@ -3803,10 +3829,10 @@ try {
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
// 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");
const beforeClose = await viewSnapshot();
await page.click("#searchClose");
@@ -3818,10 +3844,25 @@ try {
if (afterClose.tab !== beforeClose.tab || afterClose.detail !== beforeClose.detail) {
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.waitForSelector("#searchInput", { timeout: 15000 });
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(
`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.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.toolChips.length < 1) {
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
// the rendered <pre> block; the sample is removed again straight after.
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 mod = await import("/src/app.js");
const node = mod.renderMarkdown(${JSON.stringify(codeSample)});
@@ -4522,12 +4568,16 @@ try {
label: node.querySelector(".md-code-label")?.textContent ?? "",
hasPre: !!node.querySelector("pre.md-pre code"),
text: node.querySelector("pre.md-pre code")?.textContent ?? "",
tableRows: node.querySelectorAll("table tr").length,
};
})()`);
if (!codeBlock || !codeBlock.hasPre) {
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.tableRows < 3) {
throw new Error(`the markdown renderer drew no table from the sample: ${codeBlock.tableRows} rows`);
}
console.log(
` markdown code block (page renderer sample): label "${codeBlock.label}", text ${JSON.stringify(codeBlock.text)}`,
);