Per mara: 'i wanted you to put this in .../settings.html' — the toggle belongs with the other operator-local browser preferences, not buried in each agent's own overflow menu. Extracted the get/set + localStorage key into @hive/shared/prefs.js so settings.html (writer) and every per-agent app.js (reader, via HiveTerminal.create's expandDetails option) agree on the exact same key without two independently-typed copies that could drift. Removed the now-unused overflow-menu toggle + its agent.css rules from the agent page. Docs moved from docs/web-ui/agent.md's overflow-button section to docs/web-ui/dashboard.md's S3TT1NGS section, next to the existing browser-notifications preference.
27 lines
1.4 KiB
JavaScript
27 lines
1.4 KiB
JavaScript
// Tiny browser-local (localStorage) preference helpers shared by the
|
|
// dashboard's /settings.html and the per-agent page — both need the
|
|
// exact same key name to actually talk to each other via the browser's
|
|
// shared per-origin storage (settings.html is where the operator sets
|
|
// the preference; every per-agent page's terminal reads it), so the
|
|
// get/set pair — and the key itself — live here once rather than as
|
|
// independent copies in each package that could drift out of sync.
|
|
|
|
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 on /settings.html applies to the next
|
|
// rendered row in any already-open agent tab without a reload.
|
|
export function getExpandDetailsPref() {
|
|
try { return localStorage.getItem(EXPAND_DETAILS_KEY) === '1'; }
|
|
catch { return false; }
|
|
}
|
|
export function setExpandDetailsPref(v) {
|
|
try {
|
|
if (v) localStorage.setItem(EXPAND_DETAILS_KEY, '1');
|
|
else localStorage.removeItem(EXPAND_DETAILS_KEY);
|
|
} catch { /* localStorage unavailable — preference is session-only */ }
|
|
}
|