Watch
0
0
Fork
You've already forked hyperhive
0

swarm-ui: a hide debug output toggle in the header's settings menu

The row moves from the per-agent page into @hive/shared so both pages mount
the same one. The terminal's debug rows now follow the preference as it
changes, so rows already on screen hide or show at once instead of only the
rows that arrive after the toggle.
This commit is contained in:
iris 2026-10-12 20:15:56 +02:00 • committed by mara
commit be6036b216
9 changed files with 88 additions and 36 deletions

View file

@ -2,9 +2,9 @@
// so a future second consumer (e.g. swarm-ui's own terminal) gets the
// exact same key name for free via the browser's shared per-origin
// storage, rather than an independent copy that could drift.
// `ExpandDetailsSetting` / `HideDebugSetting` (the per-agent page's own
// settings popover rows) are the only writers today; `Row.tsx` is the
// only reader of either.
// `ExpandDetailsSetting` / `HideDebugSetting` (the settings popover rows
// of the per-agent page and of the swarm UI) are the only writers today;
// `Row.tsx` is the only reader of either.
const EXPAND_DETAILS_KEY = "hive-agent-expand-details";
@ -53,4 +53,24 @@ export function setHideDebugPref(v: boolean): void {
} catch {
/* localStorage unavailable — preference is session-only */
}
for (const listener of hideDebugListeners) listener();
}
const hideDebugListeners = new Set<() => void>();
// Calls `listener` whenever the preference changes: in this tab through
// `setHideDebugPref`, in another tab of the same origin through the
// browser's `storage` event. Returns the unsubscribe. This is what lets a
// terminal that is already showing rows follow the toggle, instead of only
// the rows that arrive after it.
export function subscribeHideDebugPref(listener: () => void): () => void {
hideDebugListeners.add(listener);
const onStorage = (e: StorageEvent) => {
if (e.key === HIDE_DEBUG_KEY || e.key === null) listener();
};
window.addEventListener("storage", onStorage);
return () => {
hideDebugListeners.delete(listener);
window.removeEventListener("storage", onStorage);
};
}