Skip to content

Commit d99f86b

Browse files
authored
fix(tui): separate subagent tool rows (anomalyco#33158)
1 parent 22cc758 commit d99f86b

3 files changed

Lines changed: 17 additions & 6 deletions

File tree

packages/tui/src/routes/session/index.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1838,6 +1838,7 @@ function InlineTool(props: {
18381838
pending: string
18391839
failure?: string
18401840
spinner?: boolean
1841+
separate?: boolean
18411842
children: JSX.Element
18421843
part: ToolPart
18431844
onClick?: () => void
@@ -1890,6 +1891,7 @@ function InlineTool(props: {
18901891
pending={props.pending}
18911892
failure={props.failure}
18921893
spinner={props.spinner}
1894+
separate={props.separate}
18931895
onMouseOver={() => clickable() && setHover(true)}
18941896
onMouseOut={() => setHover(false)}
18951897
onMouseUp={() => {
@@ -1919,6 +1921,7 @@ export function InlineToolRow(props: {
19191921
pending: string
19201922
failure?: string
19211923
spinner?: boolean
1924+
separate?: boolean
19221925
children: JSX.Element
19231926
onMouseOver?: () => void
19241927
onMouseOut?: () => void
@@ -1931,8 +1934,12 @@ export function InlineToolRow(props: {
19311934
onMouseOut={props.onMouseOut}
19321935
onMouseUp={props.onMouseUp}
19331936
ref={(el: BoxRenderable) => {
1937+
if (props.separate) alwaysSeparate.add(el)
19341938
setPreLayoutSiblingMargin(el, (previous) => {
1935-
return previous instanceof BoxRenderable && (previous.height > 1 || alwaysSeparate.has(previous)) ? 1 : 0
1939+
return props.separate ||
1940+
(previous instanceof BoxRenderable && (previous.height > 1 || alwaysSeparate.has(previous)))
1941+
? 1
1942+
: 0
19361943
})
19371944
}}
19381945
>
@@ -2281,6 +2288,7 @@ function Task(props: ToolProps) {
22812288
return (
22822289
<InlineTool
22832290
icon={props.part.state.status === "completed" ? "✓" : "│"}
2291+
separate={true}
22842292
color={retry() ? theme.error : undefined}
22852293
spinner={isRunning()}
22862294
complete={stringValue(props.input.description)}

packages/tui/test/cli/tui/__snapshots__/inline-tool-wrap-snapshot.test.tsx.snap

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,19 @@ exports[`TUI inline tool wrapping keeps separation after a padded user message 1
6060

6161
exports[`TUI inline tool wrapping separates after a multi-line task row 1`] = `
6262
" ✱ Grep "Task" (2 matches)
63+
6364
⠙ Explore Task — Inspect active task spacing
65+
6466
✓ General Task — Confirm completed task spacing
6567
↳ 1 toolcall · 501ms
6668
6769
→ Read src/cli/cmd/tui/routes/session/index.tsx"
6870
`;
6971

70-
exports[`TUI inline tool wrapping does not treat task rows differently from other inline rows 1`] = `
72+
exports[`TUI inline tool wrapping separates a task row from a preceding inline detail 1`] = `
7173
" → Read src/cli/cmd/tui/routes/session/index.tsx
7274
↳ Loaded src/cli/cmd/tui/routes/session/tools.tsx
75+
7376
✓ Explore Task — Inspect active task spacing
7477
↳ 1 toolcall · 501ms"
7578
`;

packages/tui/test/cli/tui/inline-tool-wrap-snapshot.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ function TaskRowsFixture() {
112112
<InlineToolRow icon="✱" complete={true} pending="">
113113
Grep "Task" (2 matches)
114114
</InlineToolRow>
115-
<InlineToolRow icon="⠙" complete={true} pending="">
115+
<InlineToolRow icon="⠙" complete={true} pending="" separate={true}>
116116
Explore Task — Inspect active task spacing
117117
</InlineToolRow>
118-
<InlineToolRow icon="✓" complete={true} pending="">
118+
<InlineToolRow icon="✓" complete={true} pending="" separate={true}>
119119
{"General Task — Confirm completed task spacing\n↳ 1 toolcall · 501ms"}
120120
</InlineToolRow>
121121
<InlineToolRow icon="→" complete={true} pending="">
@@ -134,7 +134,7 @@ function LoadedReadBeforeTaskFixture() {
134134
<box paddingLeft={3}>
135135
<text paddingLeft={3}>↳ Loaded src/cli/cmd/tui/routes/session/tools.tsx</text>
136136
</box>
137-
<InlineToolRow icon="✓" complete={true} pending="">
137+
<InlineToolRow icon="✓" complete={true} pending="" separate={true}>
138138
{"Explore Task — Inspect active task spacing\n↳ 1 toolcall · 501ms"}
139139
</InlineToolRow>
140140
</box>
@@ -312,7 +312,7 @@ describe("TUI inline tool wrapping", () => {
312312
expect(await renderFrame(() => <TaskRowsFixture />, { width: 72, height: 10 })).toMatchSnapshot()
313313
})
314314

315-
test("does not treat task rows differently from other inline rows", async () => {
315+
test("separates a task row from a preceding inline detail", async () => {
316316
expect(await renderFrame(() => <LoadedReadBeforeTaskFixture />, { width: 72, height: 8 })).toMatchSnapshot()
317317
})
318318

0 commit comments

Comments
 (0)