agent term: move expand-tool-output setting into its own settings popup
mara, #3778: the toggle lived on the separate hive-dashboard's /settings.html even though it's agent-terminal-only. Moved it into SettingsMenu (shared with swarm-ui) behind an opt-in showExpandDetails prop — only the agent page passes it, matching her caution that the component is shared but this setting isn't. Also found and fixed a real regression while touching this: the Preact rewrite's classifyEvent.ts hardcodes defaultOpen: true only for the always-open markdown-bearing rows (send/ask/answer/recv) and never reads the preference at all for the rows it's actually meant to control (diffs, plain tool output, long errors) — so the toggle currently has zero effect on the live page. Wired getExpandDetailsPref() into those four sites; the always-open rows are untouched, matching the documented pre-rewrite behavior. Converted prefs.js to prefs.ts (TS couldn't resolve types for a plain .js import) — same public @hive/shared/prefs.js export path, matching how badge.js/icons.js etc. already map a .js export name to a .tsx/.ts source file.
This commit is contained in:
parent
22db09ec66
commit
385d4b6fd7
7 changed files with 70 additions and 43 deletions
32
frontend/packages/shared/src/prefs.ts
Normal file
32
frontend/packages/shared/src/prefs.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// 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 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 */
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue