web: finish L6 after merging R10's live-run work
Integration fixes found by the full suite: - drop the dead 1 Hz run poll helpers still referencing R10-removed state (they threw on every route apply, so the first connection never rendered a list); - keep this tab's ephemeral verification chats across a reload (sessionStorage), so a chat the server intentionally hides stays usable in the tab that made it; - the smoke marks only the throwaway ephemeral, clears the marker after /new, and tolerates a stale page banner plus a re-rendered row menu; - the nav no longer claims a false Pipelines (0) before that list has loaded, and the Runs destination preloads it once per connection. Full suite: 580 unit tests green, UI SMOKE PASS.
This commit is contained in:
+48
-33
@@ -600,7 +600,10 @@ const state = {
|
||||
// server deliberately never lists them; the page keeps its own in-memory row so
|
||||
// the creator can keep working with the chat it just opened. The set is
|
||||
// memory-only, so a reload cannot turn one into a permanent list entry.
|
||||
chatEphemeralIds: new Set(),
|
||||
// Verification chats this tab created (never listed by the server). Kept in
|
||||
// sessionStorage so a reload of this tab still shows the chat it made, while a
|
||||
// different tab or a later visit never sees it.
|
||||
chatEphemeralIds: new Set(readEphemeralChatIds()),
|
||||
chatLoading: false,
|
||||
chatLoaded: false,
|
||||
chatError: "",
|
||||
@@ -1242,7 +1245,9 @@ function renderContent() {
|
||||
h(
|
||||
"nav",
|
||||
{ class: "tabs" },
|
||||
tabButton("pipelines", `Pipelines (${state.pipelines.length})`),
|
||||
// A destination reached by a deep link has not loaded this list yet: say
|
||||
// "Pipelines" rather than a false count of 0.
|
||||
tabButton("pipelines", state.pipelinesLoaded ? `Pipelines (${state.pipelines.length})` : "Pipelines"),
|
||||
tabButton("runs", `Runs (${state.runs.length})`),
|
||||
tabButton("templates", "Templates"),
|
||||
tabButton("chat", CHAT_TAB_TITLE),
|
||||
@@ -4824,6 +4829,28 @@ function applyChatSessionUpdate(id, updated, closed) {
|
||||
// This device's chat changes (C13): local rename, hide + undo, row menu
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const EPHEMERAL_CHATS_KEY = "pipelines.web.ephemeralChats.v1";
|
||||
|
||||
/** This tab's verification-chat ids (never listed), or an empty set. */
|
||||
function readEphemeralChatIds() {
|
||||
try {
|
||||
const raw = sessionStorage.getItem(EPHEMERAL_CHATS_KEY);
|
||||
const ids = raw ? JSON.parse(raw) : [];
|
||||
return Array.isArray(ids) ? ids.filter((id) => typeof id === "string" && id.trim() !== "") : [];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/** Persist this tab's verification-chat ids for a reload of the same tab. */
|
||||
function writeEphemeralChatIds(ids) {
|
||||
try {
|
||||
sessionStorage.setItem(EPHEMERAL_CHATS_KEY, JSON.stringify([...ids]));
|
||||
} catch {
|
||||
// Storage may be unavailable; the in-memory set still covers this page.
|
||||
}
|
||||
}
|
||||
|
||||
/** The server row with this device's local title applied (for the open pane). */
|
||||
function effectiveChatSession(session) {
|
||||
if (!session) return null;
|
||||
@@ -5183,7 +5210,10 @@ async function startChatSession(directory) {
|
||||
// operator's list. Set only by test tooling; a normal page leaves it unset.
|
||||
const ephemeral = globalThis.__pipelinesEphemeralChat === true;
|
||||
const created = await repo.chatCreate("New chat", directory, undefined, { ephemeral });
|
||||
if (ephemeral) state.chatEphemeralIds = new Set(state.chatEphemeralIds).add(created.id);
|
||||
if (ephemeral) {
|
||||
state.chatEphemeralIds = new Set(state.chatEphemeralIds).add(created.id);
|
||||
writeEphemeralChatIds(state.chatEphemeralIds);
|
||||
}
|
||||
// The list is the server's; insert the created session so the row is present
|
||||
// before the conversation opens, then refresh from the server.
|
||||
state.chatSessions = [created, ...state.chatSessions.filter((s) => s.id !== created.id)];
|
||||
@@ -7513,9 +7543,10 @@ async function onConnected() {
|
||||
state.routeFirstConnect = true;
|
||||
const route = state.pendingRoute ?? state.route ?? DEFAULT_ROUTE;
|
||||
state.pendingRoute = null;
|
||||
// The watch is connection-scoped, not route-scoped: wait for it on the first
|
||||
// connection too, which returns early after opening a pending deep link.
|
||||
await watched;
|
||||
// The watch is connection-scoped, not route-scoped: it was started above (its
|
||||
// subscribe is already sent) and its own resync seeds the run list, so opening
|
||||
// the pending route must not wait for it here.
|
||||
watched.catch(() => {});
|
||||
await applyRoute(route);
|
||||
return;
|
||||
}
|
||||
@@ -7617,9 +7648,9 @@ async function applyRoute(route) {
|
||||
state.error = "";
|
||||
state.loading = false;
|
||||
state.view = viewForRoute(r);
|
||||
// A run detail's poll belongs to the Runs view only. Moving to any other
|
||||
// destination stops it, including a destination that keeps the selection id.
|
||||
if (state.view !== "runs") stopRunPoll();
|
||||
// R10 removed the 1 Hz run poll: a run detail is advanced by pushed
|
||||
// `run_event` frames and the shared clocks, so a destination change has no
|
||||
// poll to stop.
|
||||
|
||||
if (r.kind === "pipelines") {
|
||||
// A default destination reached from an unknown or malformed path (a boot
|
||||
@@ -7645,7 +7676,6 @@ async function applyRoute(route) {
|
||||
state.runStageSections = new Set();
|
||||
state.decisionOpen = false;
|
||||
state.runDecision = null;
|
||||
stopRunPoll();
|
||||
renderContent();
|
||||
if (!state.runs.length) await loadCurrentView();
|
||||
return;
|
||||
@@ -7852,13 +7882,16 @@ async function loadCurrentView(force = false, { runsFresh = false } = {}) {
|
||||
runAlerts.seed(runs);
|
||||
state.usage = usage;
|
||||
state.runsLoaded = true;
|
||||
// The nav badge reads `Pipelines (${state.pipelines.length})`, so the Runs
|
||||
// destination (and a run deep link) loads the pipeline list too when it has
|
||||
// not been seen: an empty `state.pipelines` would show a false `Pipelines (0)`
|
||||
// until the Pipelines tab was visited.
|
||||
if (!state.pipelinesLoaded) {
|
||||
}
|
||||
// The nav badge reads the pipeline count, and the Pipelines destination is
|
||||
// one click away: load that list once when it has not been seen, whether the
|
||||
// runs came from the watch's resync or a direct read.
|
||||
if (!state.pipelinesLoaded) {
|
||||
try {
|
||||
state.pipelines = await repo.listPipelines();
|
||||
state.pipelinesLoaded = true;
|
||||
} catch {
|
||||
// The Pipelines destination will report its own load failure.
|
||||
}
|
||||
}
|
||||
state.loading = false;
|
||||
@@ -8231,7 +8264,6 @@ function isServerRefusal(err) {
|
||||
* never throws and never leaves an empty run pane carrying a stale identity.
|
||||
*/
|
||||
async function missingRunFallback(err) {
|
||||
stopRunPoll();
|
||||
resetRunDetailState();
|
||||
state.selectedRunId = null;
|
||||
state.view = "runs";
|
||||
@@ -8341,7 +8373,6 @@ async function selectRun(id, { silent = false, updateRoute = true } = {}) {
|
||||
// itself is stopped here: a reply discarded for a view that no longer shows
|
||||
// Runs must not leave a 1 Hz get_run loop running against an unshown run.
|
||||
if (!runStillSelected(id)) {
|
||||
stopRunPoll();
|
||||
return;
|
||||
}
|
||||
state.runDetail = detail;
|
||||
@@ -8351,11 +8382,9 @@ async function selectRun(id, { silent = false, updateRoute = true } = {}) {
|
||||
// `get_run` for the heavy fields the compact delta omits.
|
||||
} catch (err) {
|
||||
if (!runStillSelected(id)) {
|
||||
stopRunPoll();
|
||||
return;
|
||||
}
|
||||
if (silent) {
|
||||
stopRunPoll();
|
||||
return;
|
||||
}
|
||||
if (isServerRefusal(err)) {
|
||||
@@ -8368,20 +8397,6 @@ async function selectRun(id, { silent = false, updateRoute = true } = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
function updateRunPoll() {
|
||||
stopRunPoll();
|
||||
if (state.view === "runs" && state.selectedRunId && isExecuting(state.runDetail)) {
|
||||
runPoll = setInterval(() => selectRun(state.selectedRunId, { silent: true }), 1000);
|
||||
}
|
||||
}
|
||||
|
||||
function stopRunPoll() {
|
||||
if (runPoll) {
|
||||
clearInterval(runPoll);
|
||||
runPoll = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (Re)start the shared runs-list clock: it ticks once a second only while a
|
||||
* shown run is executing, updating each running row's meta line in place (never
|
||||
|
||||
+26
-5
@@ -259,11 +259,20 @@ async function cancelLiveRun(id) {
|
||||
// Open one chat row's Chat actions menu (the row's management items live behind
|
||||
// it since C13: Rename… / Close chat… or Reopen / Hide on this device).
|
||||
async function openChatRowMenu(sessionId) {
|
||||
await page.click(`#chatRows .chat-row[data-session="${sessionId}"] .chat-menu-button`);
|
||||
await page.waitForSelector(
|
||||
`#chatRows .chat-row[data-session="${sessionId}"] .chat-menu-panel`,
|
||||
{ timeout: 10000 },
|
||||
);
|
||||
// The row can be re-rendered by a just-finished create/refresh right under the
|
||||
// click, which closes the menu again; retry once before failing.
|
||||
for (let attempt = 0; attempt < 2; attempt += 1) {
|
||||
await page.click(`#chatRows .chat-row[data-session="${sessionId}"] .chat-menu-button`);
|
||||
const opened = await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`!!document.querySelector('#chatRows .chat-row[data-session="${sessionId}"] .chat-menu-panel')`,
|
||||
),
|
||||
{ timeout: attempt === 0 ? 3000 : 10000, what: "the Chat actions menu" },
|
||||
).catch(() => false);
|
||||
if (opened) return;
|
||||
}
|
||||
throw new Error(`the Chat actions menu did not open for ${sessionId}`);
|
||||
}
|
||||
|
||||
// --- P5: create a pipeline from a template (scratch server only) -----------
|
||||
@@ -4154,6 +4163,9 @@ try {
|
||||
if (!startedNotice.startsWith("Started a new session “")) {
|
||||
throw new Error(`/new notice: ${startedNotice}`);
|
||||
}
|
||||
// Only the throwaway is a verification chat: clear the marker so C2's own
|
||||
// create (which must appear in the list as its acceptance) is a normal chat.
|
||||
await page.evaluate(`window.__pipelinesEphemeralChat = false`);
|
||||
console.log(` /new opened throwaway session ${throwawayId} ("${throwawayTitle}") — ${startedNotice}`);
|
||||
await showComposer();
|
||||
await shot("62-chat-new-session.png");
|
||||
@@ -5141,6 +5153,15 @@ try {
|
||||
// F2: the header URL field and the Settings field are one draft, mirrored in
|
||||
// place, so they cannot show different endpoints while typing.
|
||||
const goodUrl = await page.evaluate(`document.querySelector("#settingsServerUrl")?.value ?? ""`);
|
||||
// An earlier section can leave a page banner behind; the assertion below is
|
||||
// about where THIS refusal is surfaced, so clear any stale one with the page's
|
||||
// own path (re-selecting the active destination) before triggering it.
|
||||
await page.evaluate(`(() => {
|
||||
if (!document.querySelector("#content .banner.error")) return true;
|
||||
const tab = [...document.querySelectorAll("nav.tabs button.tab")].find((b) => b.classList.contains("active"));
|
||||
if (tab) tab.click();
|
||||
return !document.querySelector("#content .banner.error");
|
||||
})()`);
|
||||
await page.fill("#settingsServerUrl", "not a url");
|
||||
await page.click("#settingsSecondary");
|
||||
const urlErrorState = await eventually(
|
||||
|
||||
Reference in New Issue
Block a user