Watch
0
0
Fork
You've already forked hyperhive
0

swarm ui: show thinking is a toggle of its own, apart from the developer details

This commit is contained in:
iris 2026-11-16 20:35:03 +01:00 • committed by mara
commit 857b175a74

View file

@ -17,8 +17,11 @@ import { renderMarkdown } from "./markdown.js";
import {
getExpandDetailsPref,
getHideDebugPref,
getShowThinkingPref,
subscribeHideDebugPref,
subscribeShowThinkingPref,
} from "../prefs.js";
import { rowHidden, rowIsFilterable } from "./row-visibility.js";
function MarkdownBody({ text }: { text: string }) {
const ref = useRef<HTMLDivElement>(null);
@ -58,24 +61,33 @@ function DiffBody({ text }: { text: string }) {
);
}
// A `debug` row, which follows the "hide developer details" preference as it
// changes. Only debug rows subscribe, so a long terminal does not hold a
// listener per row.
function DebugRow({ row }: { row: TermRow }) {
const [hidden, setHidden] = useState(() => getHideDebugPref());
// A row that a preference can hide: a `debug` row ("hide developer details")
// or a thinking row ("show thinking"). It follows them as they change. Only
// these rows subscribe, so a long terminal does not hold a listener per row.
function FilterableRow({ row }: { row: TermRow }) {
const [hideDebug, setHideDebug] = useState(() => getHideDebugPref());
const [showThinking, setShowThinking] = useState(() => getShowThinkingPref());
useEffect(
() => subscribeHideDebugPref(() => setHidden(getHideDebugPref())),
() => subscribeHideDebugPref(() => setHideDebug(getHideDebugPref())),
[],
);
// "hide developer details" is a skip, not a dimmer — a hidden debug row
// still occupies no DOM node at all, same as it never streamed, rather
// than a CSS `display: none` that would keep it in the layout/DOM for
// no benefit.
return hidden ? null : <RowBody row={row} />;
useEffect(
() =>
subscribeShowThinkingPref(() => setShowThinking(getShowThinkingPref())),
[],
);
// A hidden row is a skip, not a dimmer — it occupies no DOM node at all, same
// as it never streamed, rather than a CSS `display: none` that would keep it
// in the layout/DOM for no benefit.
return rowHidden(row, hideDebug, showThinking) ? null : <RowBody row={row} />;
}
export function Row({ row }: { row: TermRow }) {
return row.level === "debug" ? <DebugRow row={row} /> : <RowBody row={row} />;
return rowIsFilterable(row) ? (
<FilterableRow row={row} />
) : (
<RowBody row={row} />
);
}
function RowBody({ row }: { row: TermRow }) {