Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
5678802
🤖 feat: fold routine tool runs and compact code execution cards
ammar-agent Nov 11, 2026
c243155
tests: keep code execution stories within the Pixel snapshot budget
ammar-agent Nov 11, 2026
0c5528d
perf: find the live tail once per routine projection
ammar-agent Nov 11, 2026
e4271cf
feat: Codex/Cursor-style summary lines and quieter tool rows
ammar-agent Nov 11, 2026
0848149
tests: match the folded reads row by its new copy
ammar-agent Nov 11, 2026
1b5426b
feat: one gutter, one chevron, one rail; quiet reasoning; collapsible…
ammar-agent Nov 11, 2026
c67addf
fix: keep background spawns and bash_output polls out of routine fold…
ammar-agent Nov 11, 2026
628e98f
fix: payload-aware routine test (migrated/nested background bash); ke…
ammar-agent Nov 11, 2026
dd356b9
feat: compact transcript by default: a turn is its prompt, one work l…
ammar-agent Nov 11, 2026
769a97a
docs: say why a background spawn folds with the turn at compact density
ammar-agent Nov 11, 2026
c13a925
fix: stop routine runs and output-poll groups at work-line boundaries
ammar-agent Nov 11, 2026
ff87ab6
fix: keep MCP App views out of the work fold; regenerate phone chrome…
ammar-agent Nov 11, 2026
e5a59b0
fix: a row that needs the user never folds; prompt actions back in th…
ammar-agent Nov 11, 2026
2813e74
feat: no hidden-messages markers on desktop; the mount window counts …
ammar-agent Nov 12, 2026
1724129
fix: earlier plans fold behind a real button; a script's earlier-call…
ammar-agent Nov 12, 2026
d975e79
refactor: split the functions the CRAP gate names in the transcript p…
ammar-agent Nov 12, 2026
3682a8c
refactor: split script, bash and file-read tool rows into named parts…
ammar-agent Nov 12, 2026
707b083
refactor: extract plan card parts, resume send options and the though…
ammar-agent Nov 12, 2026
feb2855
tests: script result, nested-call cut and attachment views; file-read…
ammar-agent Nov 12, 2026
38b4019
feat: one work line per turn that names its live step; machine prompt…
ammar-agent Nov 12, 2026
d50fd34
feat: prompt and step action rows float on hover; report rows read li…
ammar-agent Nov 12, 2026
d52a8eb
refactor: split the work line formatter (CRAP gate); class order
ammar-agent Nov 12, 2026
780226c
refactor: the store hands out the approval set; test
ammar-agent Nov 12, 2026
1dffe43
tests: typed array fills
ammar-agent Nov 12, 2026
b912d64
fix: hidden action rows keep taking clicks; wake chips sit left; webv…
ammar-agent Nov 12, 2026
25bf7d2
tests: the task_await UI test opens the work line
ammar-agent Nov 12, 2026
dd1bf17
tests: the TODO-nudge repro opens the work line
ammar-agent Nov 12, 2026
69c1f8d
fix: /refine apply approves only a proposal whose row is mounted
ammar-agent Nov 12, 2026
158fd16
Merge origin/main into transcript-succinct-tools
ammar-agent Nov 12, 2026
0c9d38c
feat: the layout turn-end nudge folds as a step; machine row tests
ammar-agent Nov 12, 2026
5fd10a3
tests: the tool-block repro opens the work line before it looks for t…
ammar-agent Nov 12, 2026
c8a3041
fix: /refine apply reads only the invoking workspace's laid-out trans…
ammar-agent Nov 12, 2026
7ae67b4
fix: /refine apply keeps the display cap's reach now that desktop sho…
ammar-agent Nov 12, 2026
8ea4126
feat: status updates stay in view; the steps between two updates fold…
ammar-agent Nov 12, 2026
8027dbb
refactor: run rows and step collection split for the CRAP gate; UI an…
ammar-agent Nov 12, 2026
2f36160
tests: typed expectation for the live stretch
ammar-agent Nov 12, 2026
3061bc2
fix: prompt navigation and ArrowUp edit skip the prompts the machine …
ammar-agent Nov 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ describe("AskUserQuestionDock", () => {
test("a question set that arrives after the user collapsed the form re-opens it", () => {
messages = [ROW_A];
const view = render(dock(workspaceId), { wrapper: Wrapper });
fireEvent.click(view.getByText("ask_user_question"));
fireEvent.click(view.getByText("Question"));
expect(view.queryByText(STORAGE.question)).toBeNull();

messages = [ROW_A, ROW_B];
Expand Down
66 changes: 41 additions & 25 deletions src/browser/components/ChatPane/ChatPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import { TRANSCRIPT_MAX_MOUNTED_ROWS } from "@/common/constants/ui";
import { useOpenInEditor } from "@/browser/hooks/useOpenInEditor";
import { useUserPreferences } from "@/browser/stores/AppConfigStore";
import {
useBashSandboxApprovalToolCallIds,
useWorkspaceAggregator,
useWorkspaceState,
useWorkspaceUsage,
Expand Down Expand Up @@ -121,11 +122,15 @@ import { useBackgroundBashError } from "@/browser/contexts/BackgroundBashContext
import { hasWorkspaceRepository } from "@/browser/utils/workspaceCapabilities";
import {
buildEditingStateFromDisplayed,
canEditDisplayedUserMessage,
findLastEditablePrompt,
normalizeQueuedMessage,
type EditingMessageState,
} from "@/browser/utils/chatEditing";
import { estimateTranscriptRowWeight } from "@/browser/utils/messages/transcriptRenderProjection";
import {
computeWindowRowIndices,
estimateTranscriptRowWeight,
selectTranscriptWindowRows,
} from "@/browser/utils/messages/transcriptRenderProjection";
import { isBlockedPreStreamTaskStatus } from "@/browser/utils/ui/workspaceFiltering";
import { PerfRenderMarker } from "@/browser/utils/perf/PerfRenderMarker";
import { markChatSwitchMilestoneOnNextFrame } from "@/browser/utils/perf/chatSwitchTiming";
Expand Down Expand Up @@ -666,18 +671,23 @@ export const ChatPaneContent: React.FC<ChatPaneContentProps> = (props) => {
[workspaceId, latestMessageId, onOpenTerminal]
);

const transcriptRowDerivations = useTranscriptRowDerivations({
const approvalToolCallIds = useBashSandboxApprovalToolCallIds(workspaceId);
const transcriptBundles = useTranscriptBundles({
workspaceId,
messages: deferredMessages,
transcriptDensity,
isTurnActive: isStreamStarting || canInterrupt,
approvalToolCallIds,
});
const { bashOutputGroupInfos, expandedBashGroups, expandBashGroup } = transcriptRowDerivations;

const transcriptBundles = useTranscriptBundles({
// After the bundles: bash_output poll groups stop at work-line boundaries.
const transcriptRowDerivations = useTranscriptRowDerivations({
workspaceId,
messages: deferredMessages,
transcriptDensity,
isTurnActive: isStreamStarting || canInterrupt,
workBundleInfos: transcriptBundles.workBundleInfos,
});
const { bashOutputGroupInfos, expandedBashGroups, expandBashGroup } = transcriptRowDerivations;

const {
workBundleInfos,
operationalBundleInfos,
Expand All @@ -694,7 +704,7 @@ export const ChatPaneContent: React.FC<ChatPaneContentProps> = (props) => {
const bashOutputGroup = bashOutputGroupInfos[index];
if (bashOutputGroup !== undefined && bashOutputGroup.position !== "first") return false;
const workBundle = workBundleInfos?.[index];
if (workBundle !== undefined && workBundle.position !== "head") return false;
if (workBundle !== undefined && workBundle.headIndex !== index) return false;
const operationalBundle = operationalBundleInfos?.[index];
return operationalBundle === undefined || operationalBundle.position === "head";
};
Expand Down Expand Up @@ -734,21 +744,28 @@ export const ChatPaneContent: React.FC<ChatPaneContentProps> = (props) => {
// While the skeleton owns the pane no row is mounted, so the reveal must not advance behind
// it: it would otherwise mount the whole transcript in the one commit that replaces the
// skeleton. Handing it no rows keeps it idle; the real transcript then starts tail-first.
// The window budgets the rows that mount. In compact density the steps behind a closed work
// line mount nothing, so it is given the rows that do (computeWindowRowIndices), and its
// indices are translated back to the transcript's below.
const windowRows = showTranscriptHydrationPlaceholder
? selectTranscriptWindowRows(EMPTY_TRANSCRIPT, undefined)
: selectTranscriptWindowRows(deferredMessages, computeWindowRowIndices(workBundleInfos));
const {
fromIndex: revealFromIndex,
toIndex: revealToIndex,
fromIndex: windowFromIndex,
toIndex: windowToIndex,
isDetached: isTranscriptDetached,
isFullyRevealed,
isRevealPaused,
revealMore,
revealThrough,
revealThrough: revealThroughWindowRow,
revealNewer,
resetToLatest,
} = useBoundedTranscriptReveal({
workspaceId,
messages: showTranscriptHydrationPlaceholder ? EMPTY_TRANSCRIPT : deferredMessages,
isSafeCut: isSafeRevealCut,
rowWeight: (index) => estimateTranscriptRowWeight(deferredMessages[index]),
messages: windowRows.rows,
isSafeCut: (index) => isSafeRevealCut(windowRows.toTranscriptIndex(index)),
rowWeight: (index) =>
estimateTranscriptRowWeight(deferredMessages[windowRows.toTranscriptIndex(index)]),
// Bounds renderer heap on long read-backs (#4961 F20): past the cap the newest rows unmount
// ("detached") until Show newer or Jump to bottom brings them back.
maxMountedRows: TRANSCRIPT_MAX_MOUNTED_ROWS,
Expand All @@ -761,6 +778,8 @@ export const ChatPaneContent: React.FC<ChatPaneContentProps> = (props) => {
useLayoutEffect(() => {
setTranscriptDetached(isTranscriptDetached);
}, [isTranscriptDetached, setTranscriptDetached]);
const revealFromIndex = windowRows.toTranscriptIndex(windowFromIndex);
const revealToIndex = windowRows.toTranscriptIndex(windowToIndex);
const revealedMessages = mountedSlice(deferredMessages, revealFromIndex, revealToIndex);
// An accepted non-blocking answer closes its question without any transcript change.
useAcceptedAnswersVersion();
Expand Down Expand Up @@ -897,7 +916,8 @@ export const ChatPaneContent: React.FC<ChatPaneContentProps> = (props) => {
// The automatic reveal may have paused above the target, so ask it to reach the target. A
// target below a detached slice re-centers the slice on it.
if (!isInSlice(targetIndex, revealFromIndex, revealToIndex)) {
revealThrough(targetIndex);
// A target folded behind a work line is mounted with the line it sits behind.
revealThroughWindowRow(windowRows.toWindowIndex(targetIndex));
return;
}

Expand Down Expand Up @@ -928,7 +948,8 @@ export const ChatPaneContent: React.FC<ChatPaneContentProps> = (props) => {
operationalBundleInfos,
pendingTimelineReveal,
revealFromIndex,
revealThrough,
revealThroughWindowRow,
windowRows,
revealToIndex,
setOperationalBundleExpanded,
setWorkBundleExpanded,
Expand Down Expand Up @@ -1022,14 +1043,15 @@ export const ChatPaneContent: React.FC<ChatPaneContentProps> = (props) => {
setPendingScrollTarget(null);
return;
}
revealThrough(targetIndex);
revealThroughWindowRow(windowRows.toWindowIndex(targetIndex));
}, [
autoScroll,
contentRef,
deferredMessages,
pendingScrollTarget,
revealFromIndex,
revealThrough,
revealThroughWindowRow,
windowRows,
revealToIndex,
workspaceId,
]);
Expand Down Expand Up @@ -1232,13 +1254,7 @@ export const ChatPaneContent: React.FC<ChatPaneContentProps> = (props) => {
// Otherwise, edit last user message. `current.messages` may be a cached/provisional view
// while the replay is still running, so ArrowUp must not enter edit mode until caught up.
if (!isTranscriptMutationAllowed(workspaceId)) return;
const transformedMessages = mergeConsecutiveStreamErrors(current.messages);
const lastUserMessage = [...transformedMessages]
.reverse()
.find(
(msg): msg is Extract<DisplayedMessage, { type: "user" }> =>
msg.type === "user" && canEditDisplayedUserMessage(msg)
);
const lastUserMessage = findLastEditablePrompt(mergeConsecutiveStreamErrors(current.messages));

if (!lastUserMessage) {
return;
Expand Down
189 changes: 187 additions & 2 deletions src/browser/components/ChatPane/TranscriptBundles.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
import { act, cleanup, renderHook } from "@testing-library/react";
import { act, cleanup, fireEvent, render, renderHook } from "@testing-library/react";
import { GlobalWindow } from "happy-dom";
import type { DisplayedMessage } from "@/common/types/message";
import { useTranscriptBundles } from "./TranscriptBundles";
import { TranscriptBundleRows, useTranscriptBundles } from "./TranscriptBundles";

const NO_MESSAGES: DisplayedMessage[] = [];

Expand Down Expand Up @@ -75,3 +75,188 @@ describe("useTranscriptBundles", () => {
expect(rendersWithOverride).toEqual([]);
});
});

// The rows a host mounts for a turn at compact density, with the real projection behind them.
describe("TranscriptBundleRows", () => {
let originalWindow: typeof globalThis.window;
let originalDocument: typeof globalThis.document;

beforeEach(() => {
originalWindow = globalThis.window;
originalDocument = globalThis.document;
const domWindow = new GlobalWindow() as unknown as Window & typeof globalThis;
globalThis.window = domWindow;
globalThis.document = domWindow.document;
});

afterEach(() => {
cleanup();
globalThis.window = originalWindow;
globalThis.document = originalDocument;
});

const HISTORY_ID = "history-turn";

function read(id: string, status: "completed" | "executing" = "completed"): DisplayedMessage {
return {
type: "tool",
id,
historyId: HISTORY_ID,
toolCallId: id,
toolName: "file_read",
args: {},
status,
isPartial: false,
historySequence: 1,
};
}

function say(id: string): DisplayedMessage {
return {
type: "assistant",
id,
historyId: HISTORY_ID,
content: id,
historySequence: 1,
isStreaming: false,
isPartial: false,
isCompacted: false,
isIdleCompacted: false,
};
}

function Transcript(props: {
messages: DisplayedMessage[];
isTurnActive: boolean;
approvalToolCallIds?: ReadonlySet<string>;
}) {
const bundles = useTranscriptBundles({
workspaceId: "ws",
messages: props.messages,
transcriptDensity: "hyper",
isTurnActive: props.isTurnActive,
approvalToolCallIds: props.approvalToolCallIds,
});
return (
<TranscriptBundleRows
workspaceId="ws"
messages={props.messages}
indexOffset={0}
bundles={bundles}
renderMessageAtIndex={(message, _index, options) => (
<div key={options.key} data-row={message.id} />
)}
/>
);
}

function shownRows(container: HTMLElement): string[] {
return [...container.querySelectorAll("[data-row]")].map(
(row) => row.getAttribute("data-row") ?? ""
);
}

test("what the agent wrote stays in view, and the steps between open in place", () => {
const messages = [say("update"), read("read-1"), read("read-2"), say("reply"), read("read-3")];
const view = render(<Transcript messages={messages} isTurnActive={false} />);

expect(shownRows(view.container)).toEqual(["update", "reply"]);
const [first, second] = view.getAllByTestId("work-bundle");
expect(first.textContent).toContain("Read 2 files");

fireEvent.click(first);

// The opened steps are listed one by one on a rail, between the two texts. Compact density
// has no second fold inside an opened line.
expect(shownRows(view.container)).toEqual(["update", "read-1", "read-2", "reply"]);
expect(view.queryByTestId("operational-bundle")).toBeNull();
const steps = view.getByTestId("work-bundle-steps");
expect(shownRows(steps)).toEqual(["read-1", "read-2"]);
// The other line is its own block and stays closed.
expect(second.getAttribute("aria-expanded")).toBe("false");
// The line and its steps share one block, which bounds where the opened line sticks.
const block = first.closest('[data-testid="work-bundle-block"]');
expect(block?.contains(steps)).toBe(true);
expect(block?.contains(second)).toBe(false);

fireEvent.click(view.getAllByTestId("work-bundle")[0]);
expect(shownRows(view.container)).toEqual(["update", "reply"]);
});

test("a range that starts below a closed line mounts nothing for that stretch", () => {
const messages = [read("read-1"), read("read-2"), say("reply")];
function Tail() {
const bundles = useTranscriptBundles({
workspaceId: "ws",
messages,
transcriptDensity: "hyper",
isTurnActive: false,
});
return (
<TranscriptBundleRows
workspaceId="ws"
messages={messages.slice(1)}
indexOffset={1}
bundles={bundles}
renderMessageAtIndex={(message, _index, options) => (
<div key={options.key} data-row={message.id} />
)}
/>
);
}
const view = render(<Tail />);

expect(shownRows(view.container)).toEqual(["reply"]);
expect(view.queryByTestId("work-bundle-block")).toBeNull();
});

test("a live stretch mounts no step under its closed line, which names the step instead", () => {
const messages = [say("update"), read("read-1"), read("read-2", "executing")];
const view = render(<Transcript messages={messages} isTurnActive />);

expect(shownRows(view.container)).toEqual(["update"]);
const line = view.getByTestId("work-bundle");
expect(line.getAttribute("aria-expanded")).toBe("false");
expect(line.textContent).toContain("Reading a file");
});

test("a call that waits for approval shows under its closed line", () => {
const messages = [say("update"), read("read-1"), read("read-2", "executing")];
const view = render(
<Transcript messages={messages} isTurnActive approvalToolCallIds={new Set(["read-2"])} />
);

expect(shownRows(view.container)).toEqual(["update", "read-2"]);
expect(view.getByTestId("work-bundle").getAttribute("aria-expanded")).toBe("false");
expect(view.queryByTestId("work-bundle-steps")).toBeNull();
});

test("detailed density folds runs of routine calls and has no work lines", () => {
const messages = [say("update"), read("read-1"), read("read-2"), say("reply")];
function Detailed() {
const bundles = useTranscriptBundles({
workspaceId: "ws",
messages,
transcriptDensity: "normal",
isTurnActive: false,
});
return (
<TranscriptBundleRows
workspaceId="ws"
messages={messages}
indexOffset={0}
bundles={bundles}
renderMessageAtIndex={(message, _index, options) => (
<div key={options.key} data-row={message.id} />
)}
/>
);
}
const view = render(<Detailed />);

expect(view.queryByTestId("work-bundle")).toBeNull();
expect(shownRows(view.container)).toEqual(["update", "reply"]);
fireEvent.click(view.getByTestId("operational-bundle"));
expect(shownRows(view.container)).toEqual(["update", "read-1", "read-2", "reply"]);
});
});
Loading
Loading