hyperhive#4008, mara: 'add a setting to not display verbose output... like the grey colored debug stuff.' Same shape as the existing expand-tool-output preference (ExpandDetailsSetting.tsx): a new shared/src/prefs.ts key pair (getHideDebugPref/setHideDebugPref), a new settings-menu-row component owning its own state (HideDebugSetting.tsx, not a prop threaded through the shared SettingsMenu component — per mara's earlier review on the first one, more per-page options as props there is how that component accumulates cruft), mounted next to ExpandDetailsSetting in Root.tsx. Row.tsx skips (returns null for, not CSS display:none) any TermMsg whose level is 'debug' when the pref is set — matches the muted 'debug' row this issue is about (see docs/web-ui/terminal-rendering.md's Levels table). Read live per-row, same as expand-details, so toggling applies to newly streamed rows in an already-open tab without a reload; already -rendered rows are unaffected either way, same non-retroactive precedent the existing preference already sets.
56 lines
2.2 KiB
TypeScript
56 lines
2.2 KiB
TypeScript
// Tiny browser-local (localStorage) preference helper, in `@hive/shared`
|
|
// 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.
|
|
|
|
const EXPAND_DETAILS_KEY = "hive-agent-expand-details";
|
|
|
|
// Whether a per-agent terminal's otherwise-collapsed `<details>` panels
|
|
// (long tool-results, Write/Edit diffs, …) should default open. Pure
|
|
// client-side — no backend field, nothing round-trips through
|
|
// `/api/*`. Read live (not cached) by the shared terminal factory's
|
|
// `expandDetails` option — see docs/web-ui/shape.md::Shared terminal
|
|
// pane — so a preference change applies to the next rendered row in
|
|
// any already-open agent tab without a reload.
|
|
export function getExpandDetailsPref(): boolean {
|
|
try {
|
|
return localStorage.getItem(EXPAND_DETAILS_KEY) === "1";
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
export function setExpandDetailsPref(v: boolean): void {
|
|
try {
|
|
if (v) localStorage.setItem(EXPAND_DETAILS_KEY, "1");
|
|
else localStorage.removeItem(EXPAND_DETAILS_KEY);
|
|
} catch {
|
|
/* localStorage unavailable — preference is session-only */
|
|
}
|
|
}
|
|
|
|
const HIDE_DEBUG_KEY = "hive-agent-hide-debug";
|
|
|
|
// Whether a per-agent terminal's `debug`-level rows (thinking, coalesced
|
|
// ticks, ambient harness chatter — see docs/web-ui/terminal-rendering.md's
|
|
// Levels table) should be skipped entirely rather than rendered muted.
|
|
// Same shape as `getExpandDetailsPref` above: pure client-side, no
|
|
// backend field, read live (not cached) so a change applies to the next
|
|
// rendered row without a reload.
|
|
export function getHideDebugPref(): boolean {
|
|
try {
|
|
return localStorage.getItem(HIDE_DEBUG_KEY) === "1";
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
export function setHideDebugPref(v: boolean): void {
|
|
try {
|
|
if (v) localStorage.setItem(HIDE_DEBUG_KEY, "1");
|
|
else localStorage.removeItem(HIDE_DEBUG_KEY);
|
|
} catch {
|
|
/* localStorage unavailable — preference is session-only */
|
|
}
|
|
}
|