Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(transcript): make automatic folding deterministic

vastsa6e6f86244e9c
diff --git a/apps/desktop/src/features/chat/transcript/ActivityGroup.tsx b/apps/desktop/src/features/chat/transcript/ActivityGroup.tsx
index b3a648673..59a5bc9f4 100644
--- a/apps/desktop/src/features/chat/transcript/ActivityGroup.tsx
+++ b/apps/desktop/src/features/chat/transcript/ActivityGroup.tsx
@@ -1,4 +1,5 @@
import { SubagentStopButton } from "./SubagentStopButton";
+import { activityGroupStartsOpen } from "../../../lib/activity-group-folding";
import { activityTimingInputs, cachedVisibleActivityItems } from "../../../lib/transcript-activity-summary";
import { reuseReferences } from "../../../lib/transcript-summary";
import { ActivityItems } from "./ActivityItems";
@@ -61,9 +62,6 @@ type Translate = (key: string, options?: Record<string, unknown>) => string;
type ActivityItem = AssistantActivityItem;
-const AUTOMATIC_OPEN_MAX_ITEMS = 4;
-
-
function waitingSubagentActionLabel(
agent: AgentActivityAgent,
t: Translate,
@@ -137,6 +135,8 @@ type ActivityGroupProps = {
items: ActivityItem[];
embedded?: boolean;
isActive: boolean;
+ /** The owning assistant turn is still running. */
+ turnActive: boolean;
endedAt?: string;
/** Current runtime wait phase, when the group owns the live turn tail. */
runtimeActivity?: AgentActivity;
@@ -171,6 +171,7 @@ function activityGroupPropsEqual(
if (
previous.embedded !== next.embedded ||
previous.isActive !== next.isActive ||
+ previous.turnActive !== next.turnActive ||
previous.endedAt !== next.endedAt ||
previous.runtimeActivity !== next.runtimeActivity ||
previous.items.length !== next.items.length
@@ -198,6 +199,7 @@ export const ActivityGroup = memo(function ActivityGroup({
items,
embedded: _embedded = false,
isActive,
+ turnActive,
endedAt,
runtimeActivity,
turnDelegationStatuses,
@@ -244,7 +246,13 @@ export const ActivityGroup = memo(function ActivityGroup({
const first = items[0];
// Groups frame their rows; each tool or search payload keeps its own
// disclosure, so leaving a small group open does not reveal tool details.
- const automaticallyOpen = hasSubagentTopology || live || visibleItems.length <= AUTOMATIC_OPEN_MAX_ITEMS;
+ // Work the turn still owns and reasoning the reader asked to see stay open;
+ // only a settled group of plain tool rows falls back to the size rule.
+ const automaticallyOpen = activityGroupStartsOpen(visibleItems, {
+ subagentTopology: hasSubagentTopology,
+ turnActive,
+ groupActive: live,
+ });
const disclosure = useAutomaticDisclosure(
automaticallyOpen,
revealRequest,
diff --git a/apps/desktop/src/features/chat/transcript/AssistantTurnParts.tsx b/apps/desktop/src/features/chat/transcript/AssistantTurnParts.tsx
index 9561ac226..cc773ce29 100644
--- a/apps/desktop/src/features/chat/transcript/AssistantTurnParts.tsx
+++ b/apps/desktop/src/features/chat/transcript/AssistantTurnParts.tsx
@@ -89,6 +89,7 @@ const TurnPartBlock = memo(function TurnPartBlock({
items={part.items}
endedAt={part.endedAt}
isActive={part === activePart}
+ turnActive={isActive}
runtimeActivity={part === activePart ? runtimeActivity : undefined}
turnDelegationStatuses={turnDelegationStatuses}
turnDelegationTimings={turnDelegationTimings}
diff --git a/apps/desktop/src/features/chat/transcript/ProcessActivityGroup.tsx b/apps/desktop/src/features/chat/transcript/ProcessActivityGroup.tsx
index aeefd72bd..4739eeb18 100644
--- a/apps/desktop/src/features/chat/transcript/ProcessActivityGroup.tsx
+++ b/apps/desktop/src/features/chat/transcript/ProcessActivityGroup.tsx
@@ -49,9 +49,9 @@ export function ProcessActivityGroup({
) : null}
{active ? <span className="tool-activity-count">{t("chat.running")}</span> : null}
{summary.issues > 0 ? (
- <span className="turn-process-error">
+ <span className="activity-issue-count">
<IconCircleAlert size={14} aria-hidden />
- {t("chat.activityFailures", { count: summary.issues })}
+ <span>{t("chat.activityFailures", { count: summary.issues })}</span>
</span>
) : null}
<span className="tool-activity-caret" aria-hidden><IconChevronRight size={12} /></span>
diff --git a/apps/desktop/src/features/chat/transcript/ToolRow.tsx b/apps/desktop/src/features/chat/transcript/ToolRow.tsx
index 963106e8a..9b16001b6 100644
--- a/apps/desktop/src/features/chat/transcript/ToolRow.tsx
+++ b/apps/desktop/src/features/chat/transcript/ToolRow.tsx
@@ -726,6 +726,7 @@ function SubagentRunFollow({
key={`thinking-${item.message.id}`}
message={item.message}
streaming={item.message.status === "streaming"}
+ autoOpen
/>
) : (
<div
diff --git a/apps/desktop/src/features/chat/transcript/TurnProcess.tsx b/apps/desktop/src/features/chat/transcript/TurnProcess.tsx
index 7b0d83bd9..95700dfc4 100644
--- a/apps/desktop/src/features/chat/transcript/TurnProcess.tsx
+++ b/apps/desktop/src/features/chat/transcript/TurnProcess.tsx
@@ -104,8 +104,8 @@ export function TurnProcess({
return () => window.clearInterval(timer);
}, [isActive]);
const scope = useMemo<DisclosureScopeValue>(
- () => ({ claim: disclosure.claim, visible: disclosure.open }),
- [disclosure.claim, disclosure.open],
+ () => ({ claim: disclosure.claim, reveal: disclosure.reveal, visible: disclosure.open }),
+ [disclosure.claim, disclosure.open, disclosure.reveal],
);
// With nothing to reveal there is no disclosure - but the rows still have to
// render. Hidden reasoning superseded by a separate answer is exactly this
diff --git a/apps/desktop/src/features/chat/transcript/disclosure-scope.ts b/apps/desktop/src/features/chat/transcript/disclosure-scope.ts
index 7e725c5dd..41f976fc2 100644
--- a/apps/desktop/src/features/chat/transcript/disclosure-scope.ts
+++ b/apps/desktop/src/features/chat/transcript/disclosure-scope.ts
@@ -9,8 +9,13 @@ import { createContext } from "react";
* the type.
*/
export type DisclosureScopeValue = {
- /** Claim interaction for this level and, through it, for every ancestor. */
+ /**
+ * Hold this level and its ancestors open while a reader is using the content.
+ * The hold is transient and never becomes a disclosure choice.
+ */
claim: () => void;
+ /** Reveal this level and its ancestors, and keep the revealed path open. */
+ reveal: () => void;
/** Whether this level's contents are currently shown at all. */
visible: boolean;
};
@@ -18,5 +23,6 @@ export type DisclosureScopeValue = {
/** The implicit root scope: nothing above the transcript owns it. */
export const ScopeContext = createContext<DisclosureScopeValue>({
claim: () => {},
+ reveal: () => {},
visible: true,
});
diff --git a/apps/desktop/src/features/chat/transcript/disclosure.tsx b/apps/desktop/src/features/chat/transcript/disclosure.tsx
index 8f30f50c0..4b26a9a05 100644
--- a/apps/desktop/src/features/chat/transcript/disclosure.tsx
+++ b/apps/desktop/src/features/chat/transcript/disclosure.tsx
@@ -2,6 +2,7 @@ import {
createContext,
useCallback,
useContext,
+ useEffect,
useId,
useLayoutEffect,
useMemo,
@@ -26,7 +27,6 @@ class DisclosureChoices {
}
get = (key: string) => this.choices.get(key);
-
set(key: string, choice: Choice) {
const previous = this.choices.get(key);
if (previous?.open === choice.open && previous.revealRequest === choice.revealRequest) return;
@@ -67,13 +67,39 @@ export function disclosureKey(kind: string, ...ids: string[]) {
return JSON.stringify([kind, ...ids]);
}
-function ownsReadingPosition(body: HTMLElement | null): boolean {
- if (!body) return false;
- if (body.contains(document.activeElement)) return true;
+/**
+ * Whether a reader is still inside these levels.
+ *
+ * Keyboard focus anywhere in the level - including the title of a row nested
+ * under it - and an active text selection both count: an automatic close must
+ * never hide content the reader is using.
+ */
+function ownsReadingPosition(...levels: Array<HTMLElement | null>): boolean {
+ const active = document.activeElement;
+ if (levels.some((level) => Boolean(level && active && level.contains(active)))) return true;
const selection = window.getSelection();
- return Boolean(selection && !selection.isCollapsed && (
- body.contains(selection.anchorNode) || body.contains(selection.focusNode)
- ));
+ return Boolean(selection && !selection.isCollapsed && levels.some((level) => Boolean(
+ level && (level.contains(selection.anchorNode) || level.contains(selection.focusNode)),
+ )));
+}
+
+/*
+ * One listener set for every disclosure in the transcript. Each level only
+ * re-reads its own DOM, so a focus or selection change costs a handful of
+ * `contains` checks instead of one listener pair per row, and a level can never
+ * miss the event that releases its hold because its effect had not run yet.
+ */
+const readingSyncs = new Set<() => void>();
+let readingHubInstalled = false;
+function installReadingHub() {
+ if (readingHubInstalled || typeof document === "undefined") return;
+ readingHubInstalled = true;
+ const syncAll = () => {
+ for (const sync of [...readingSyncs]) sync();
+ };
+ document.addEventListener("focusin", syncAll);
+ document.addEventListener("selectionchange", syncAll);
+ window.addEventListener("pointerup", syncAll);
}
export function useAutomaticDisclosure(
@@ -89,46 +115,80 @@ export function useAutomaticDisclosure(
const subscribe = useCallback((listener: () => void) => choices.subscribe(key, listener), [choices, key]);
const snapshot = useCallback(() => choices.get(key), [choices, key]);
const choice = useSyncExternalStore(subscribe, snapshot, snapshot);
- // A pending reveal is the derived default, so the first paint (and SSR)
- // already shows the row the transcript search asked to open.
- const requestedOpen = choice?.open ?? (
- revealRequest !== undefined && choice?.revealRequest !== revealRequest
- ? true
- : automaticOpen
- );
const scope = useContext(ScopeContext);
- // A level below a collapsed parent renders nothing, whatever its own choice
- // says. The choice is left untouched so reopening the parent restores it.
- const open = requestedOpen && scope.visible;
const titleRef = useRef<HTMLButtonElement | null>(null);
const bodyRef = useRef<HTMLDivElement | null>(null);
const notifyAnchor = useDisclosureAnchorNotifier();
+
+ /*
+ * Reading protection is transient state, never a disclosure choice. It is
+ * derived from the DOM: focus or a selection inside the level defers an
+ * automatic close, and leaving the level hands control straight back to the
+ * automatic default. Recording those moments as choices is what used to
+ * disable automatic folding for the rest of the pane's life.
+ */
+ const [reading, setReading] = useState(false);
+
+ // A pending reveal is the derived default, so the first paint (and SSR)
+ // already shows the row the transcript search asked to open.
+ const derivedOpen = revealRequest !== undefined && choice?.revealRequest !== revealRequest
+ ? true
+ : automaticOpen;
+ // An explicit choice is authoritative. Without one, a reader inside the level
+ // defers an automatic close without changing what the default would be.
+ const requestedOpen = choice ? choice.open : (derivedOpen || reading);
+ const open = requestedOpen && scope.visible;
+
const currentOpen = useRef(open);
currentOpen.current = open;
- // The claim goes to the level that owns this one, not to the root: opening a
+ const ownsReading = useCallback(
+ () => ownsReadingPosition(titleRef.current, bodyRef.current),
+ [],
+ );
+ const syncReading = useCallback(
+ () => setReading(ownsReadingPosition(titleRef.current, bodyRef.current)),
+ [],
+ );
+
+ useEffect(() => {
+ installReadingHub();
+ readingSyncs.add(syncReading);
+ return () => {
+ readingSyncs.delete(syncReading);
+ };
+ }, [syncReading]);
+
+ // The claim goes to the level that owns this one, not to the root: reading a
// row inside a process disclosure has to keep that process open too.
const claim = useCallback(() => {
- if (!choices.get(key)) choices.set(key, { open: currentOpen.current });
+ installReadingHub();
+ syncReading();
scope.claim();
- }, [choices, key, scope.claim]);
+ }, [scope.claim, syncReading]);
+
+ // A revealed path stays open: the reader asked for that content, and closing
+ // the search must not take it away again.
+ const reveal = useCallback(() => {
+ if (!choices.get(key)) choices.set(key, { open: true });
+ scope.reveal();
+ }, [choices, key, scope.reveal]);
useLayoutEffect(() => {
if (revealRequest === undefined || choices.get(key)?.revealRequest === revealRequest) return;
choices.set(key, { open: true, revealRequest });
- scope.claim();
- }, [choices, key, scope.claim, revealRequest]);
+ scope.reveal();
+ }, [choices, key, scope.reveal, revealRequest]);
- const previousOpen = useRef(open);
+ // Completion must not hide keyboard focus or an active text selection. The
+ // reader can arrive without the pointer/focus events above (find in page,
+ // restored selection), so the transition checks the DOM itself.
+ const previousDerived = useRef(derivedOpen);
useLayoutEffect(() => {
- // Completion must not hide keyboard focus or an active text selection.
- if (previousOpen.current && !open && !choice && ownsReadingPosition(bodyRef.current)) {
- choices.set(key, { open: true });
- scope.claim();
- }
- previousOpen.current = open;
- }, [choice, choices, key, open, scope.claim]);
+ if (!choice && previousDerived.current && !derivedOpen && ownsReading()) setReading(true);
+ previousDerived.current = derivedOpen;
+ }, [choice, derivedOpen, ownsReading]);
const setManualOpen = useCallback((next: boolean) => {
scope.claim();
@@ -146,13 +206,14 @@ export function useAutomaticDisclosure(
toggle,
collapse,
claim,
+ reveal,
titleRef,
bodyRef,
// Kept for callers that read the parent's visibility directly; the scope
// itself already folded it into `open`.
parentVisible: scope.visible,
- // Pointer selection and keyboard interaction establish ownership before
- // a streaming update can apply an automatic close.
+ // Pointer and keyboard interaction re-check the reading hold before a
+ // streaming update can apply an automatic close.
bodyEvents: { onPointerDownCapture: claim, onFocusCapture: claim },
};
}
@@ -176,7 +237,8 @@ export function DisclosureScope({
}) {
const value = useMemo<DisclosureScopeValue>(() => ({
claim: disclosure.claim,
+ reveal: disclosure.reveal,
visible: open,
- }), [disclosure.claim, open]);
+ }), [disclosure.claim, disclosure.reveal, open]);
return <ScopeContext.Provider value={value}>{children}</ScopeContext.Provider>;
}
diff --git a/apps/desktop/src/lib/activity-group-folding.ts b/apps/desktop/src/lib/activity-group-folding.ts
new file mode 100644
index 000000000..92350eff7
--- /dev/null
+++ b/apps/desktop/src/lib/activity-group-folding.ts
@@ -0,0 +1,36 @@
+import type { AssistantActivityItem } from "./assistant-turns";
+
+/** A settled ordinary group stays open up to this many visible rows. */
+export const ACTIVITY_GROUP_AUTO_OPEN_MAX_ITEMS = 4;
+
+/**
+ * Whether a rendered activity group starts open.
+ *
+ * Folding is decided once per state, not per row: work the turn still owns stays
+ * visible, reader-requested reasoning stays visible, and only a settled group of
+ * plain tool rows falls back to the small-group rule. Explicit user choices are
+ * applied on top of this default and are never derived from it.
+ */
+export function activityGroupStartsOpen(
+ visibleItems: readonly AssistantActivityItem[],
+ state: {
+ /** Task fan-out is its own topology and keeps its released open default. */
+ subagentTopology: boolean;
+ /** The assistant turn is still running. */
+ turnActive: boolean;
+ /** This group still owns live work, including running delegations. */
+ groupActive: boolean;
+ },
+): boolean {
+ // `visibleItems` already excludes reasoning hidden by the preference, so a
+ // remaining Thinking row is content the reader asked to see. Folding it away
+ // would make `Show thinking` look broken.
+ const visibleReasoning = visibleItems.some((item) => item.kind === "thinking");
+ return (
+ state.subagentTopology ||
+ state.turnActive ||
+ state.groupActive ||
+ visibleReasoning ||
+ visibleItems.length <= ACTIVITY_GROUP_AUTO_OPEN_MAX_ITEMS
+ );
+}
diff --git a/apps/desktop/src/styles/messages.css b/apps/desktop/src/styles/messages.css
index 61b3efe4e..2dc30dc58 100644
--- a/apps/desktop/src/styles/messages.css
+++ b/apps/desktop/src/styles/messages.css
@@ -2339,6 +2339,33 @@
white-space: nowrap;
}
+/*
+ * Issue counts are inline metadata in an activity-group header, never a second
+ * line of the row. The icon and its localized count stay on one centered line
+ * and truncate together when the band runs out of width.
+ */
+.activity-issue-count {
+ display: inline-flex;
+ flex: 0 1 auto;
+ align-items: center;
+ gap: 4px;
+ min-width: 0;
+ color: var(--ds-error);
+ font-size: var(--text-xs-plus);
+ white-space: nowrap;
+}
+
+.activity-issue-count > svg {
+ flex: none;
+}
+
+.activity-issue-count > span {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
/* The caret closes the row, so a short label keeps it at the trailing edge. */
.tool-activity-caret {
display: inline-flex;
diff --git a/apps/desktop/test/activity-group-folding.test.mjs b/apps/desktop/test/activity-group-folding.test.mjs
new file mode 100644
index 000000000..159f22507
--- /dev/null
+++ b/apps/desktop/test/activity-group-folding.test.mjs
@@ -0,0 +1,76 @@
+import assert from "node:assert/strict";
+import { register } from "node:module";
+import test from "node:test";
+import { loadStyles } from "./helpers/styles.mjs";
+import { readTranscriptModule } from "./helpers/source-contracts.mjs";
+
+register(new URL("./helpers/ts-import-hooks.mjs", import.meta.url));
+const { ACTIVITY_GROUP_AUTO_OPEN_MAX_ITEMS, activityGroupStartsOpen } = await import(
+ "../src/lib/activity-group-folding.ts"
+);
+
+const items = (count, kind = "tool") =>
+ Array.from({ length: count }, () => ({ kind }));
+const settled = {
+ subagentTopology: false,
+ turnActive: false,
+ groupActive: false,
+};
+
+test("a settled group of plain tool rows follows the small-group rule", () => {
+ assert.equal(ACTIVITY_GROUP_AUTO_OPEN_MAX_ITEMS, 4);
+ assert.equal(activityGroupStartsOpen(items(4), settled), true);
+ assert.equal(activityGroupStartsOpen(items(5), settled), false);
+});
+
+test("work the turn still owns stays open regardless of group size", () => {
+ assert.equal(
+ activityGroupStartsOpen(items(20), { ...settled, turnActive: true }),
+ true,
+ "an assistant turn that is still running keeps every group visible",
+ );
+ assert.equal(
+ activityGroupStartsOpen(items(20), { ...settled, groupActive: true }),
+ true,
+ "a group that still owns live work keeps its rows visible",
+ );
+ assert.equal(
+ activityGroupStartsOpen(items(20), { ...settled, subagentTopology: true }),
+ true,
+ "Task topology keeps its released open default",
+ );
+});
+
+test("reasoning the reader asked to see never folds away", () => {
+ assert.equal(
+ activityGroupStartsOpen([...items(20), { kind: "thinking" }], settled),
+ true,
+ "a visible Thinking row is reader-requested content",
+ );
+ // Reasoning hidden by `Show thinking` never reaches this list, so a group of
+ // plain tool rows is still allowed to fold.
+ assert.equal(activityGroupStartsOpen(items(20), settled), false);
+});
+
+test("issue counters stay on one inline line in the group header", async () => {
+ const [styles, groupSource] = await Promise.all([
+ loadStyles(),
+ readTranscriptModule("ProcessActivityGroup.tsx"),
+ ]);
+ assert.match(groupSource, /className="activity-issue-count"/);
+ assert.match(
+ groupSource,
+ /<IconCircleAlert size=\{14\} aria-hidden \/>\s*<span>\{t\("chat\.activityFailures"/,
+ );
+ const badge = styles.match(/\.activity-issue-count \{([^}]*)\}/)?.[1];
+ assert.ok(badge, "the activity issue counter has no layout rule");
+ assert.match(badge, /display:\s*inline-flex;/);
+ assert.match(badge, /align-items:\s*center;/);
+ assert.match(badge, /white-space:\s*nowrap;/);
+ assert.match(
+ styles,
+ /\.activity-issue-count > span \{[^}]*text-overflow:\s*ellipsis;/,
+ );
+ // The top-level turn header still carries no issue count at all.
+ assert.doesNotMatch(styles, /\.turn-process-error/);
+});
diff --git a/apps/desktop/test/thinking-ui.test.mjs b/apps/desktop/test/thinking-ui.test.mjs
index 7dbbbe038..b71a4b9b6 100644
--- a/apps/desktop/test/thinking-ui.test.mjs
+++ b/apps/desktop/test/thinking-ui.test.mjs
@@ -284,7 +284,7 @@ test("tool and search rows stay collapsed while thinking keeps its leaf default"
assert.match(transcriptDisclosureSource, /const setManualOpen = useCallback/);
assert.match(
transcriptSource,
- /const automaticallyOpen = hasSubagentTopology \|\| live \|\| visibleItems\.length <= AUTOMATIC_OPEN_MAX_ITEMS;/,
+ /const automaticallyOpen = activityGroupStartsOpen\(visibleItems, \{\s*subagentTopology: hasSubagentTopology,\s*turnActive,\s*groupActive: live,\s*\}\);/,
);
assert.match(
transcriptSource,
diff --git a/apps/desktop/test/transcript-disclosure-reading.test.mjs b/apps/desktop/test/transcript-disclosure-reading.test.mjs
index cc62a7d8b..3d4e2fafa 100644
--- a/apps/desktop/test/transcript-disclosure-reading.test.mjs
+++ b/apps/desktop/test/transcript-disclosure-reading.test.mjs
@@ -25,11 +25,21 @@ test("a manual disclosure hands over its title before the state changes", () =>
});
test("automatic disclosure does not claim a reading position", () => {
- // Automatic reveal/collapse may claim the parent hierarchy, but never calls
- // the scroll anchor notifier reserved for direct user interaction.
- assert.match(disclosure, /if \(previousOpen\.current && !open && !choice && ownsReadingPosition/);
+ // Automatic reveal and collapse never call the scroll anchor notifier
+ // reserved for direct user interaction. A reader inside the level is a
+ // transient hold, never a permanent disclosure choice - recording those
+ // moments is what used to disable automatic folding for the pane's life.
+ const claimBody = disclosure.match(
+ /const claim = useCallback\(\(\) => \{[\s\S]*?\n \}, \[scope\.claim, syncReading\]\);/,
+ )?.[0];
+ assert.ok(claimBody, "the transient reading hold is missing");
+ assert.doesNotMatch(claimBody, /choices\.set/);
+ assert.match(
+ disclosure,
+ /if \(!choice && previousDerived\.current && !derivedOpen && ownsReading\(\)\) setReading\(true\);/,
+ );
const revealEffect = disclosure.match(
- /useLayoutEffect\(\(\) => \{\s*if \(revealRequest === undefined[\s\S]*?\n \}, \[choices, key, scope\.claim, revealRequest\]\);/,
+ /useLayoutEffect\(\(\) => \{\s*if \(revealRequest === undefined[\s\S]*?\n \}, \[choices, key, scope\.reveal, revealRequest\]\);/,
)?.[0];
assert.ok(revealEffect, "the automatic reveal effect is missing");
assert.doesNotMatch(revealEffect, /notifyAnchor/);
diff --git a/docs/adr/turn-process-and-thinking-display.md b/docs/adr/turn-process-and-thinking-display.md
index 414fd6a4a..71613afcc 100644
--- a/docs/adr/turn-process-and-thinking-display.md
+++ b/docs/adr/turn-process-and-thinking-display.md
@@ -63,12 +63,14 @@ wrapper.
still load, is no longer exposed in Settings, and is not read for rendering; new
writes store `transcriptDisplayMode`.
-Group folding defaults are unified across modes and do not depend on the
-thinking preference. The active ordinary group stays open while its segment is
-active. After completion, ordinary groups with at most four visible items stay
-open, larger ordinary groups start closed, and Task topology groups stay open.
-Tool, search and run-row payloads keep their own closed defaults. Explicit user
-choices remain authoritative.
+Group folding defaults are unified across modes. Every ordinary group of a turn
+stays open while that turn is active, whether or not it still owns the live
+segment, so work never folds away mid-run. After the turn settles, ordinary
+groups with at most four visible items stay open, larger groups of plain tool
+rows start closed, and Task topology groups stay open. A group that still renders
+a Thinking row stays open too: with `Show thinking` on the reasoning is content
+the reader asked to see. Tool, search and run-row payloads keep their own closed
+defaults. Explicit user choices remain authoritative.
The turn's disclosure header states the turn's outcome and carries only its
bounded metadata: status, recorded duration and direct tool/search count. It
@@ -116,13 +118,15 @@ still exposes the retained item choices without opening all descendants.
Each header toggles only its own level. Parent and child states are independent:
closing a parent preserves descendant choices, reopening restores them, and
-sibling groups do not form an accordion. Manual interaction with an item claims
-its containing group as user-owned without toggling it; completion must not close
-a container around content the user opened, focused, or selected. Manual choices
-survive streaming, completion, preference changes, reparenting from singleton to
-group, and row remounts while the owning retained session pane remains alive.
-Pane eviction, session deletion, or renderer restart releases this presentation
-memory; it is not stored in messages or host settings.
+sibling groups do not form an accordion. An explicit choice belongs to its own
+level alone and never pins an ancestor. Reading protection is transient: while
+focus or a selection is inside a level, an automatic close is deferred for that
+level and its ancestors, and leaving the content hands control straight back to
+the automatic default. Manual choices survive streaming, completion, preference
+changes, reparenting from singleton to group, and row remounts while the owning
+retained session pane remains alive. Pane eviction, session deletion, or renderer
+restart releases this presentation memory; it is not stored in messages or host
+settings.
Search/navigation reveals the ancestor path its target needs: the turn process
and, where one exists, the activity group that own the named message. Item-level
@@ -229,3 +233,10 @@ text-only hover and the inline caret position, while `turn-process.test.mjs` and
`transcript-style.test.mjs` continue to cover phase precedence and the shared
header geometry. See E2E-CHAT-turn-process-and-thinking-display for the
synchronized scenario text.
+For the 2026-10-24 automatic-folding amendment,
+`apps/desktop/test/activity-group-folding.test.mjs` covers the settled group
+defaults, and `pnpm test:e2e:transcript` exercises the automatic turn and group
+folding, transient reading protection, manual-choice locality and `Show thinking`
+behavior in real Chromium. The same suite measures the activity issue counter's
+inline layout at 320/800px and 100%/150% zoom in English and Simplified Chinese.
+See E2E-CHAT-turn-process-and-thinking-display.
diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.md
index 0b18ac1b0..7ed3258bd 100644
--- a/docs/spec/04-ux/08-component-spec.md
+++ b/docs/spec/04-ux/08-component-spec.md
@@ -923,12 +923,18 @@ thinking never creates an empty wrapper. All three modes render exactly one
top-level process disclosure and change neither what a tool received nor what is
stored.
-The ordinary group owning the active execution segment stays open while its turn
-is active. Afterward, ordinary groups with at most four visible items remain open;
-larger groups start closed, while Task topology groups remain open. These defaults
-are unified across modes and do not depend on the thinking preference. Explicit
-user choices remain authoritative. Group headers summarize count, running state
-and issue count without treating a failed child as a failed turn.
+Every ordinary group of a turn stays open while that turn is active, whether or
+not it still owns the live execution segment, so work never folds away mid-run.
+After the turn settles, ordinary groups with at most four visible items remain
+open, larger groups start closed, and Task topology groups remain open. A group
+that still renders a Thinking row also remains open: with `Show thinking` on the
+reasoning is content the reader asked to see, and folding the group around it
+would make the setting look broken. These defaults are unified across modes and
+otherwise do not depend on the thinking preference. Explicit user choices remain
+authoritative. Group headers summarize count, running state and issue count
+without treating a failed child as a failed turn; the issue counter is one inline
+non-wrapping chip whose icon and localized count share a centred line and
+truncate together when the band runs out of width.
The turn disclosure header states the turn's outcome and carries only its bounded
metadata: status, recorded duration and direct tool/search count. It never echoes
@@ -952,22 +958,25 @@ extra hierarchy.
Except for the display mode's Thinking default, no item payload opens itself: a
tool, hosted-search or plan call stays a header row until the user opens its
disclosure, including a Bash row, whose detail stays closed until the user opens
-it. Active groups stay open; after completion, small groups (up to four visible
-items) and Task topology groups remain open, while larger ordinary groups start
-closed. With `Show thinking` on, Thinking rows expand by default in every display
-mode and collapse only on user action. An expanded Thinking row shows its full
-reasoning markdown; a collapsed one shows only the Thinking indicator, with no
-summary or excerpt. With `Show thinking` off, no completed reasoning row renders;
-only a live whole-run TextShimmer `Thinking` indicator remains while reasoning is
-actively streaming, and empty thinking-only containers are omitted. The stored
-reasoning is retained and reappears when the preference is turned back on.
+it. Groups stay open while their turn runs; after it settles, small groups (up to
+four visible items), Task topology groups and groups that still render a Thinking
+row remain open, while larger ordinary groups of plain tool rows start closed.
+With `Show thinking` on, Thinking rows expand by default in every display mode and
+collapse only on user action. An expanded Thinking row shows its full reasoning
+markdown; a collapsed one shows only the Thinking indicator, with no summary or
+excerpt. With `Show thinking` off, no completed reasoning row renders; only a live
+whole-run TextShimmer `Thinking` indicator remains while reasoning is actively
+streaming, and empty thinking-only containers are omitted. The stored reasoning is
+retained and reappears when the preference is turned back on.
Group, run row and item are independent controls. Closing an ancestor keeps
descendant choices and reopening restores them; closing the turn's disclosure hides
every row under it, and reopening restores the groups the user had opened. Opening
-a parent never expands all children. User interaction with a child claims its
-containing group without toggling it, so completion cannot close around opened,
-focused or selected content. Choices use stable turn/group/item identities and
+a parent never expands all children. An explicit choice belongs to its own level
+alone and never pins an ancestor; reading protection is transient instead: while
+focus or a selection is inside a level, an automatic close is deferred for that
+level and its ancestors, and leaving the content hands control straight back to
+the automatic default. Choices use stable turn/group/item identities and
remain while the retained session pane lives, including preference changes and row
remounts; pane eviction, deletion or renderer restart reapplies defaults rather
than persisting disclosure state to messages or settings.
diff --git a/docs/spec/04-ux/09-interaction-patterns.md b/docs/spec/04-ux/09-interaction-patterns.md
index 027ca8fd4..0cc6a2bb8 100644
--- a/docs/spec/04-ux/09-interaction-patterns.md
+++ b/docs/spec/04-ux/09-interaction-patterns.md
@@ -943,9 +943,11 @@ may be retained while exactly one workspace supplies the visible shell context.
hidden thinking does not create a redundant group, and existing Task topology
remains separate. No mode adds a second top-level disclosure or leaves a run
row outside the process.
-- The active ordinary group stays open while the turn runs. After completion,
- ordinary groups with at most four visible items and Task topology groups remain
- open; larger ordinary groups start closed. These defaults do not depend on the
+- Every ordinary group of a turn stays open while that turn runs, whether or not
+ it still owns the live segment. After the turn settles, ordinary groups with at
+ most four visible items, Task topology groups and groups that still render a
+ Thinking row remain open; larger ordinary groups of plain tool rows start
+ closed. Apart from visible reasoning these defaults do not depend on the
thinking preference. Closing the turn's disclosure hides every group and run
row under it without erasing their choices; reopening restores their defaults
and any explicit user choices.
@@ -967,9 +969,11 @@ may be retained while exactly one workspace supplies the visible shell context.
- Activating a group or item header toggles only that level. Closing a parent
preserves child state, reopening restores it, and sibling groups remain
independent. Opening a parent is never an expand-all action.
-- A manual item action claims its containing group as user-owned without toggling
- it. Streaming and completion cannot reopen a manual close or close around
- content the user opened, focused or selected. Choices survive preference
+- An explicit choice belongs to its own level alone: it never pins an ancestor
+ open or closed. Streaming and completion cannot reopen a manual close. Reading
+ protection is transient - while focus or a selection is inside a level, an
+ automatic close is deferred for that level and its ancestors, and leaving the
+ content hands control back to the automatic default. Choices survive preference
changes, singleton-to-group growth and remounts while the retained session pane
lives.
- Search/navigation opens the turn process and activity group that own the named
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 422678c89..37b6f89c4 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -17422,12 +17422,15 @@ plugin-form fixtures in an isolated temporary directory at runtime.
stay inside their groups and only ordinary assistant progress text splits a
group, so the middle progress paragraph ends the preceding group and the
following activity starts a new one. A group appears only with at least two
- visible items; a singleton has no group. Active groups stay open while the turn
- runs; after completion, groups with at most four visible items and Task topology
- groups remain open, while larger ordinary groups start closed. Thinking rows
- default expanded in every mode when `Show thinking` is on.
+ visible items; a singleton has no group. Every group stays open while its turn
+ runs; after completion, groups with at most four visible items, Task topology
+ groups and groups that still render a Thinking row remain open, while larger
+ ordinary groups of plain tool rows start closed. Thinking rows default
+ expanded in every mode when `Show thinking` is on.
Explicit user choices persist and are restored when the enclosing disclosure is
- reopened; group defaults do not depend on `Show thinking`. The header
+ reopened, and never pin an ancestor; an automatic close is deferred only while
+ focus or a selection remains inside. Apart from visible reasoning, group
+ defaults do not depend on `Show thinking`. The header
reports running, finished, stopped, or failed with failure and stop outranking
a normal finish, reads `Thinking` while the live step is reasoning, names
compaction and recovery while those stages are live, omits a duration the
@@ -17457,10 +17460,14 @@ plugin-form fixtures in an isolated temporary directory at runtime.
group presentation only; precise item-level transcript search targeting is out
of scope and keeps the existing message-level search behavior.
- **Automation:** `pnpm test:e2e:transcript` covers the command-first and
- fully-folded layouts and active-to-completed process disclosure behavior;
- `pnpm test:e2e:transcript-disclosure` verifies manual-open retention and
- viewport anchoring; `apps/desktop/test/turn-process.test.mjs` covers mode
- segmentation, `apps/desktop/test/transcript-display-modes-ui.test.mjs` covers
+ fully-folded layouts, active-to-completed process disclosure behavior, the
+ automatic folding and reading-hold transitions, and the activity issue
+ counter's inline layout at 320/800px and 100%/150% zoom in English and
+ Simplified Chinese; `pnpm test:e2e:transcript-disclosure` verifies manual-open
+ retention and viewport anchoring; `apps/desktop/test/turn-process.test.mjs`
+ covers mode segmentation, `apps/desktop/test/activity-group-folding.test.mjs`
+ covers the settled group defaults and the issue-counter contract,
+ `apps/desktop/test/transcript-display-modes-ui.test.mjs` covers
the renderer's mode wiring, Thinking defaults and TextShimmer,
`apps/desktop/test/turn-process-header.test.mjs` covers the top-level header's
status/duration/tool-count composition and the absence of issue counts,
diff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.md
index a7b84a613..e17fe616b 100644
--- a/docs/spec/08-meta/decisions-log.md
+++ b/docs/spec/08-meta/decisions-log.md
@@ -7967,3 +7967,30 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.
`packages/agent-runtime/src/provider-binding.test.ts`, and the official-wire
cases in `packages/agent-runtime/src/provider-reasoning-effort.test.ts`. See
`03-runtime/11-provider-model-system.md` and E2E-005E.
+
+## 2026-10-24 — Automatic transcript folding is deterministic (D673)
+
+- D673 amends the turn-process disclosure policy: every ordinary group of a turn
+ stays open while that turn is active, instead of folding as soon as it stops
+ owning the live segment. After the turn settles, groups with at most four
+ visible items, Task topology groups, and groups that still render a Thinking
+ row stay open; larger groups of plain tool rows start closed. Visible
+ reasoning is reader-requested content, so `Show thinking` is no longer
+ undermined by folding the group around it.
+- Disclosure ownership is split in two. An explicit header/rail choice belongs to
+ its own level and never pins an ancestor; a press, focus or selection is a
+ transient reading hold that defers an automatic close until the reader leaves.
+ Previously a pointer press or a nested toggle recorded the enclosing levels'
+ current state as permanent choices, which disabled automatic folding for the
+ rest of the pane's life and could pin a level closed. Search reveals still keep
+ their revealed ancestor path open.
+- The activity-group issue counter is one inline non-wrapping chip
+ (`activity-issue-count`), replacing the unstyled `turn-process-error` span that
+ wrapped its icon and localized count onto separate lines in narrow bands. The
+ top-level turn header still carries no issue count.
+- No persisted format or protocol change. Covered by
+ `apps/desktop/test/activity-group-folding.test.mjs` and the automatic-folding
+ scenario inside `pnpm test:e2e:transcript`. See ADR
+ `turn-process-and-thinking-display`, `04-ux/08-component-spec.md` §9,
+ `04-ux/09-interaction-patterns.md` §4.2, and
+ E2E-CHAT-turn-process-and-thinking-display.
diff --git a/scripts/e2e/transcript-auto-collapse.tsx b/scripts/e2e/transcript-auto-collapse.tsx
new file mode 100644
index 000000000..1d20b4920
--- /dev/null
+++ b/scripts/e2e/transcript-auto-collapse.tsx
@@ -0,0 +1,317 @@
+import { createRoot } from "react-dom/client";
+import { flushSync } from "react-dom";
+import { createInstance } from "i18next";
+import { I18nextProvider } from "react-i18next";
+import { catalogs } from "@pi-desktop/i18n";
+import type { AppSettings, UiMessage } from "@pi-desktop/shared";
+import { AssistantTurn } from "../../apps/desktop/src/features/chat/transcript/AssistantTurn";
+import { TranscriptDisclosureProvider } from "../../apps/desktop/src/features/chat/transcript/disclosure";
+import { buildTranscriptEntries } from "../../apps/desktop/src/lib/assistant-turns";
+import { useAppStore } from "../../apps/desktop/src/stores/app-store";
+
+/**
+ * Real nested-disclosure state transitions: automatic folding, manual choices,
+ * transient reading protection, `Show thinking`, and the activity issue counter.
+ * Only transcript inputs and settings are fixtures.
+ */
+export async function transcriptAutoCollapseProbe() {
+ const i18n = createInstance();
+ await i18n.init({
+ lng: "en",
+ resources: {
+ en: { translation: catalogs.en },
+ "zh-CN": { translation: catalogs["zh-CN"] },
+ },
+ interpolation: { escapeValue: false },
+ });
+ const host = document.createElement("div");
+ host.style.cssText = "width:800px;max-width:100%;padding:32px;box-sizing:border-box";
+ const outside = document.createElement("button");
+ outside.textContent = "Outside transcript";
+ const container = document.createElement("div");
+ host.append(container, outside);
+ document.body.append(host);
+ const errors: unknown[] = [];
+ const root = createRoot(container, { onUncaughtError: (error) => errors.push(error) });
+ const initialSettings = useAppStore.getState().settings;
+ const notes: string[] = [];
+ const failures: string[] = [];
+ const check = (value: unknown, name: string) => {
+ (value ? notes : failures).push(name);
+ };
+
+ const message = (
+ id: string,
+ role: UiMessage["role"],
+ content: string,
+ extra: Partial<UiMessage> = {},
+ ): UiMessage => ({ id, role, content, createdAt: "2026-09-17T00:00:00.000Z", ...extra });
+ const thoughtLive = message("thought", "assistant", "", {
+ thinking: "Reasoning stays available when Show thinking is enabled.",
+ status: "streaming",
+ });
+ const thoughtDone: UiMessage = { ...thoughtLive, status: "complete" };
+ const reads = Array.from({ length: 7 }, (_, index) =>
+ message(`read-${index}`, "tool", "", {
+ toolName: "Read",
+ toolCallId: `call-read-${index}`,
+ toolStatus: index === 0 ? "error" : "success",
+ toolArgs: { path: `src/example-${index}.ts` },
+ toolResult: { details: { stdout: "fixture output", exitCode: index === 0 ? 1 : 0 } },
+ }),
+ );
+ const answer = message("answer", "assistant", "Final answer stays visible.", {
+ status: "complete",
+ });
+ const settings: AppSettings = {
+ defaultMode: "agent",
+ theme: "light",
+ enterToSend: true,
+ onboardingDismissed: true,
+ showThinking: true,
+ transcriptDisplayMode: "fully-folded",
+ smoothStreaming: false,
+ };
+ const configure = (patch: Partial<AppSettings> = {}) =>
+ flushSync(() => useAppStore.setState({ settings: { ...settings, ...patch } }));
+ const render = (id: string, messages: UiMessage[], active: boolean) => {
+ const entry = buildTranscriptEntries(messages).entries.find(
+ (item) => item.kind === "assistant-turn",
+ );
+ if (entry?.kind !== "assistant-turn") throw new Error("Missing assistant turn fixture");
+ flushSync(() =>
+ root.render(
+ <I18nextProvider i18n={i18n}>
+ <TranscriptDisclosureProvider key={id}>
+ <AssistantTurn entry={entry} isActive={active} />
+ </TranscriptDisclosureProvider>
+ </I18nextProvider>,
+ ),
+ );
+ };
+ const header = () => container.querySelector<HTMLButtonElement>(".turn-process > button");
+ const thoughtHeader = () =>
+ container.querySelector<HTMLButtonElement>(".tool-row.thinking .tool-row-header");
+ const groupHeader = () =>
+ container.querySelector<HTMLButtonElement>(".process-activity-group > .tool-activity-header");
+ const expanded = (element: Element | null) =>
+ element?.getAttribute("aria-expanded") === "true";
+ const click = (element: HTMLElement | null) => {
+ if (!element) throw new Error("Missing disclosure click target");
+ flushSync(() => element.click());
+ };
+ const press = (element: HTMLElement) =>
+ flushSync(() => {
+ for (const type of ["pointerdown", "pointerup"] as const) {
+ element.dispatchEvent(
+ new PointerEvent(type, { bubbles: true, button: 0, pointerId: 1 }),
+ );
+ }
+ });
+ const focusOutside = () =>
+ flushSync(() => {
+ // Leaving the transcript is a click elsewhere: press, move focus, release.
+ outside.dispatchEvent(
+ new PointerEvent("pointerdown", { bubbles: true, button: 0, pointerId: 1 }),
+ );
+ outside.focus();
+ outside.dispatchEvent(
+ new PointerEvent("pointerup", { bubbles: true, button: 0, pointerId: 1 }),
+ );
+ });
+ const select = (element?: HTMLElement) =>
+ flushSync(() => {
+ const selection = window.getSelection();
+ selection?.removeAllRanges();
+ if (element) {
+ const range = document.createRange();
+ range.selectNodeContents(element);
+ selection?.addRange(range);
+ }
+ document.dispatchEvent(new Event("selectionchange"));
+ });
+
+ try {
+ configure();
+
+ // A mere press is not a disclosure choice: the automatic close at settle
+ // still applies, and the answer stays outside the folded process.
+ render("press", [thoughtLive], true);
+ const prose = container.querySelector<HTMLElement>(".thinking-prose");
+ if (!prose) throw new Error("Missing visible reasoning");
+ press(prose);
+ render("press", [thoughtDone, answer], false);
+ check(
+ !expanded(header()),
+ "a plain body press does not disable automatic turn collapse",
+ );
+ check(
+ Boolean(
+ container.querySelector('[data-message-id="answer"]')?.getBoundingClientRect().height,
+ ),
+ "the final answer remains visible outside the collapsed process",
+ );
+
+ // Keyboard focus inside the process is protected while it is there, and the
+ // automatic close resumes as soon as the reader leaves.
+ render("focus", [thoughtLive, ...reads], true);
+ const focusedRow = container.querySelector<HTMLButtonElement>(
+ '[data-message-id="read-0"] .tool-row-header',
+ );
+ if (!focusedRow) throw new Error("Missing focus target");
+ flushSync(() => focusedRow.focus());
+ render("focus", [thoughtDone, ...reads, answer], false);
+ check(
+ expanded(header()) && document.activeElement === focusedRow,
+ "completion does not hide keyboard focus inside the process",
+ );
+ focusOutside();
+ check(
+ !expanded(header()),
+ "leaving the process releases the reading hold and applies automatic collapse",
+ );
+
+ // The same rule protects an active text selection, and only that selection.
+ render("selection", [thoughtLive], true);
+ const selectedProse = container.querySelector<HTMLElement>(".thinking-prose");
+ if (!selectedProse) throw new Error("Missing selection target");
+ press(selectedProse);
+ select(selectedProse);
+ render("selection", [thoughtDone, answer], false);
+ check(
+ expanded(header()) && window.getSelection()?.isCollapsed === false,
+ "completion preserves an active reasoning selection",
+ );
+ select();
+ check(
+ !expanded(header()),
+ "clearing the selection releases automatic collapse protection",
+ );
+
+ // Child choices stay local: they are restored, never used to pin ancestors.
+ render("child", [thoughtLive], true);
+ click(thoughtHeader());
+ click(thoughtHeader());
+ render("child", [thoughtDone, answer], false);
+ focusOutside();
+ check(
+ !expanded(header()),
+ "a child toggle does not permanently force its enclosing turn open",
+ );
+ click(header());
+ check(
+ expanded(thoughtHeader()),
+ "reopening the turn restores the explicit reasoning choice",
+ );
+ click(thoughtHeader());
+ click(header());
+ click(header());
+ check(
+ !expanded(thoughtHeader()),
+ "closing and reopening a parent preserves a manually collapsed child",
+ );
+
+ for (const mode of ["flat", "command-first", "fully-folded"] as const) {
+ configure({ transcriptDisplayMode: mode });
+
+ // Work the turn still owns never folds mid-run, however large the group.
+ render(`live-${mode}`, [thoughtLive, ...reads], true);
+ check(expanded(header()), `${mode}: a running turn stays open`);
+ check(
+ mode === "flat" || expanded(groupHeader()),
+ `${mode}: the running activity group stays open beyond four items`,
+ );
+ check(
+ [...container.querySelectorAll(".tool-row.thinking .tool-row-header")].every(expanded),
+ `${mode}: Show thinking keeps reasoning expanded`,
+ );
+
+ // A manual close is authoritative while the turn keeps streaming.
+ click(header());
+ render(`live-${mode}`, [thoughtLive, ...reads, answer], true);
+ check(
+ !expanded(header()),
+ `${mode}: streaming does not undo a manual turn close`,
+ );
+ click(header());
+ focusOutside();
+
+ // Settled: plain tool rows fall back to the size rule, while reasoning the
+ // reader asked to see is never folded away.
+ render(`settled-${mode}`, [...reads, answer], false);
+ check(
+ mode === "flat" || !expanded(groupHeader()),
+ `${mode}: a settled group of plain tool rows folds when it is large`,
+ );
+ render(`reasoning-${mode}`, [thoughtDone, ...reads, answer], false);
+ click(header());
+ check(
+ (mode === "flat" || expanded(groupHeader())) && expanded(thoughtHeader()),
+ `${mode}: settled reasoning stays visible under Show thinking`,
+ );
+
+ configure({ transcriptDisplayMode: mode, showThinking: false });
+ check(
+ container.querySelector(".tool-row.thinking") === null,
+ `${mode}: hidden completed reasoning leaves no empty row`,
+ );
+ configure({ transcriptDisplayMode: mode });
+ check(
+ expanded(thoughtHeader()),
+ `${mode}: re-enabling Show thinking restores expanded reasoning`,
+ );
+ focusOutside();
+ }
+
+ configure();
+ // The issue counter is real header metadata with the app stylesheet: icon
+ // and localized count stay on one centered line at both locale widths.
+ for (const locale of ["en", "zh-CN"]) {
+ await i18n.changeLanguage(locale);
+ render(`issues-${locale}`, [thoughtLive, ...reads], true);
+ for (const width of [320, 800]) {
+ host.style.width = `${width}px`;
+ for (const zoom of [1, 1.5]) {
+ host.style.zoom = String(zoom);
+ const issue = container.querySelector<HTMLElement>(".activity-issue-count");
+ const icon = issue?.querySelector("svg");
+ if (!issue || !icon) throw new Error("Missing activity issue counter");
+ const text = document.createRange();
+ text.selectNodeContents(issue);
+ text.setStartAfter(icon);
+ const iconRect = icon.getBoundingClientRect();
+ const textRect = text.getBoundingClientRect();
+ const issueRect = issue.getBoundingClientRect();
+ const parentRect = issue.parentElement?.getBoundingClientRect();
+ check(
+ textRect.width > 0 &&
+ textRect.left >= iconRect.right &&
+ Math.abs(
+ (textRect.top + textRect.bottom - iconRect.top - iconRect.bottom) / 2,
+ ) < 3 * zoom,
+ `${locale}/${width}/${zoom}: issue icon and count share one centered line`,
+ );
+ check(
+ Boolean(parentRect) &&
+ issueRect.right <= (parentRect as DOMRect).right + 1 &&
+ issueRect.height <= (parentRect as DOMRect).height + 1,
+ `${locale}/${width}/${zoom}: the issue counter stays inside its header row`,
+ );
+ }
+ }
+ }
+ check(
+ errors.length === 0,
+ `React rendering has no errors: ${errors.map(String).join("; ")}`,
+ );
+ if (failures.length) {
+ throw new Error(`Automatic disclosure regressions: ${JSON.stringify(failures)}`);
+ }
+ return { ok: true, checks: notes.length, notes };
+ } finally {
+ select();
+ flushSync(() => root.unmount());
+ useAppStore.setState({ settings: initialSettings });
+ host.remove();
+ }
+}
diff --git a/scripts/e2e/transcript-render.tsx b/scripts/e2e/transcript-render.tsx
index 8f535942f..d1fb47a19 100644
--- a/scripts/e2e/transcript-render.tsx
+++ b/scripts/e2e/transcript-render.tsx
@@ -1,6 +1,7 @@
import { transcriptLongHistoryProbe as runLongHistoryProbe } from "./transcript-long-history";
import { transcriptEditProbe } from "./transcript-edit";
import { turnProcessProbe } from "./turn-process";
+import { transcriptAutoCollapseProbe } from "./transcript-auto-collapse";
import { transcriptStatusProbe } from "./transcript-status";
import { createRoot } from "react-dom/client";
import { flushSync } from "react-dom";
@@ -652,6 +653,7 @@ globalThis.transcriptRenderProbe = async () => {
const markdownLinks = await markdownLinkInteractionProbe(i18n);
const contextMenuSubmenu = await contextMenuSubmenuInteractionProbe();
const turnProcess = await turnProcessProbe();
+ const autoCollapse = await transcriptAutoCollapseProbe();
return {
ok: statusLifecycle.ok && markdownLinks.ok && contextMenuSubmenu.ok && turnProcess.ok,
statusLifecycle,
@@ -664,6 +666,7 @@ globalThis.transcriptRenderProbe = async () => {
taskLifecycleUpdated: true,
taskTimingUpdated: true,
turnProcess,
+ autoCollapse,
messageEditing: await transcriptEditProbe(),
textUpdateDurationMs,
};