web: installable app, diff viewer history, calmer chat
- The diff viewer is a centered panel over a dim scrim (clicking outside closes), and the browser Back button closes the open viewer/audit/artifact viewer via a modal history entry. Transient sheets opt out (they must never undo an in-app navigation on close). - The page is installable: web app manifest, 192/512/maskable icons, apple meta, and a shell service worker that never caches the socket or artifacts. - Chat: operator bubbles are accent-tinted, agent bubbles neutral with an accent edge; the tool summary is a quiet line outside the message; the star and more controls are compact 20px corner icons inside the row. - The Refresh button's tooltip shows the last data arrival (manual or socket), per destination.
This commit is contained in:
@@ -77,6 +77,22 @@ function defaultServerUrl() {
|
||||
const client = new PipelinesClient();
|
||||
const repo = new PipelinesRepository(client);
|
||||
|
||||
// Register the app's shell service worker where the browser allows it (a secure
|
||||
// context: https, localhost, or the desktop app). On a plain-LAN http origin the
|
||||
// page still works; only installation/offline caching is unavailable there.
|
||||
if (typeof navigator !== "undefined" && "serviceWorker" in navigator) {
|
||||
const secure =
|
||||
typeof location !== "undefined" &&
|
||||
(location.protocol === "https:" ||
|
||||
location.hostname === "localhost" ||
|
||||
location.hostname === "127.0.0.1");
|
||||
if (secure) {
|
||||
window.addEventListener("load", () => {
|
||||
navigator.serviceWorker.register("/sw.js").catch(() => undefined);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Read the persisted settings once: the server URL falls back to the page's own
|
||||
// proxy endpoint when unset, and the workspace starts blank when unset. Both the
|
||||
// configured value and the draft start from storage.
|
||||
@@ -166,6 +182,9 @@ const state = {
|
||||
chatStars: readChatStars(),
|
||||
// Whether the CLOSED chats group is expanded (the chevron beside its name).
|
||||
chatClosedOpen: false,
|
||||
// The last time each destination's data arrived (manual refresh or a socket
|
||||
// push); the list's Refresh button shows it on hover.
|
||||
lastUpdated: {},
|
||||
// The mounted run-mode graph (R5) on the run detail's Graph tab. Dropped on
|
||||
// every re-render and on a run change, so its wheel/pointer/resize listeners
|
||||
// and its elapsed timer can never leak.
|
||||
@@ -1102,11 +1121,32 @@ function renderContent() {
|
||||
}
|
||||
}
|
||||
|
||||
/** The last-updated words for a view, local time, or the not-yet-loaded note. */
|
||||
function lastUpdatedTitle(view) {
|
||||
const at = Number(state.lastUpdated?.[view] ?? 0);
|
||||
if (!(at > 0)) return "Not refreshed yet";
|
||||
return `Last updated ${new Date(at).toLocaleTimeString([], {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
})}`;
|
||||
}
|
||||
|
||||
/** Record that a view's data just arrived, and refresh the hover title in place. */
|
||||
function touchView(view = state.view) {
|
||||
state.lastUpdated = { ...(state.lastUpdated ?? {}), [view]: Date.now() };
|
||||
if (view !== state.view) return;
|
||||
const button = document.querySelector('.list-pane [data-refresh="true"]');
|
||||
if (button) button.title = lastUpdatedTitle(view);
|
||||
}
|
||||
|
||||
function refreshButton() {
|
||||
return h("button", {
|
||||
class: "ghost",
|
||||
type: "button",
|
||||
text: "Refresh",
|
||||
title: lastUpdatedTitle(state.view),
|
||||
"data-refresh": "true",
|
||||
onclick: () => loadCurrentView(true),
|
||||
});
|
||||
}
|
||||
@@ -1554,6 +1594,7 @@ async function loadCurrentView(force = false, { runsFresh = false } = {}) {
|
||||
state.usage = usage;
|
||||
state.runsLoaded = true;
|
||||
}
|
||||
touchView(state.view);
|
||||
// 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.
|
||||
@@ -1830,6 +1871,8 @@ function applyRunEvent(frame) {
|
||||
} else if (fold.runs !== state.runs) {
|
||||
state.runs = fold.runs;
|
||||
listChanged = true;
|
||||
touchView("runs");
|
||||
if (state.view === "pipelines") touchView("pipelines");
|
||||
renderRunState();
|
||||
// A terminal transition also settles the usage aggregate (the active
|
||||
// count), which the delta does not carry; one server read refreshes it. A
|
||||
@@ -1844,6 +1887,7 @@ function applyRunEvent(frame) {
|
||||
const detailChanged = folded !== detail;
|
||||
if (detailChanged) {
|
||||
state.runDetail = folded;
|
||||
touchView("runs");
|
||||
renderRunState();
|
||||
}
|
||||
if (runDetailNeedsFullSync(frame) && (detailChanged || listChanged)) {
|
||||
@@ -2106,6 +2150,7 @@ const runtime = {
|
||||
render,
|
||||
renderContent,
|
||||
renderHeader,
|
||||
touchView,
|
||||
focusDetailHeading,
|
||||
focusListHeading,
|
||||
endpointConfigured,
|
||||
|
||||
Reference in New Issue
Block a user