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:
@@ -164,6 +164,7 @@ function focusElement(element) {
|
||||
*/
|
||||
export function createModalController(options = {}) {
|
||||
const document_ = options.document ?? globalThis.document;
|
||||
const window_ = options.window ?? globalThis.window;
|
||||
const getLayer =
|
||||
typeof options.layer === "function"
|
||||
? options.layer
|
||||
@@ -196,6 +197,50 @@ export function createModalController(options = {}) {
|
||||
let keydownBound = false;
|
||||
let focusinBound = false;
|
||||
let fallbackMode = false;
|
||||
// One history entry per open modal, so the browser Back button closes it the
|
||||
// same way Escape and the backdrop do. A modal that closes through the UI
|
||||
// pops its own entry instead of leaving a dead one behind.
|
||||
let historyPushed = false;
|
||||
let historyClosing = false;
|
||||
|
||||
function pushModalHistory(id) {
|
||||
if (historyPushed || !window_?.history) return;
|
||||
try {
|
||||
window_.history.pushState(
|
||||
{ ...(window_.history.state ?? {}), pipelinesModal: id },
|
||||
"",
|
||||
);
|
||||
historyPushed = true;
|
||||
} catch {
|
||||
// A history-refusing environment simply keeps the UI close paths.
|
||||
}
|
||||
}
|
||||
|
||||
function popModalHistory() {
|
||||
if (!historyPushed || historyClosing) return;
|
||||
historyPushed = false;
|
||||
try {
|
||||
// Only pop our own entry. If the app navigated while the dialog was open,
|
||||
// its route entry is on top now; calling back() here would undo that
|
||||
// navigation (the dialog's own entry is buried under it).
|
||||
if (window_.history?.state?.pipelinesModal == null) return;
|
||||
window_.history.back();
|
||||
} catch {
|
||||
// Nothing to pop.
|
||||
}
|
||||
}
|
||||
|
||||
if (window_?.addEventListener) {
|
||||
window_.addEventListener("popstate", () => {
|
||||
if (!historyPushed) return;
|
||||
historyPushed = false;
|
||||
const entry = top();
|
||||
if (!entry) return;
|
||||
historyClosing = true;
|
||||
closeEntry(entry, { restore: true });
|
||||
historyClosing = false;
|
||||
});
|
||||
}
|
||||
|
||||
function layer() {
|
||||
return getLayer() ?? document_?.body ?? null;
|
||||
@@ -471,6 +516,7 @@ export function createModalController(options = {}) {
|
||||
releaseIfEmpty();
|
||||
}
|
||||
if (restore && wasTop) restoreFocus(entry);
|
||||
if (!stack.length) popModalHistory();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -559,6 +605,10 @@ export function createModalController(options = {}) {
|
||||
entryOptions.renderManaged !== false,
|
||||
);
|
||||
applyStackState();
|
||||
// Only overlays that act as their own view carry a history entry (the
|
||||
// viewers). A transient sheet must not, or closing it while the app
|
||||
// navigates would undo that navigation with history.back().
|
||||
if (entryOptions.history !== false) pushModalHistory(id);
|
||||
if (entryOptions.focus !== false) focusInside(entry.panel);
|
||||
return entry.panel;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user