Skip to content

Commit 7b2e83e

Browse files
committed
Fix tool group spacing by detecting subsequent renderable blocks
Add logic to check for renderable blocks after tool groups to conditionally apply bottom margin. This prevents unnecessary spacing at the end of messages while maintaining proper separation between tool groups and other content.
1 parent 5afb92e commit 7b2e83e

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

cli/src/components/message-block.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,14 +637,33 @@ export const MessageBlock = ({
637637
Boolean,
638638
) as React.ReactNode[]
639639
if (nonNullGroupNodes.length > 0) {
640+
// Check for any subsequent renderable blocks without allocating a slice
641+
let hasRenderableAfter = false
642+
for (let j = i; j < sourceBlocks.length; j++) {
643+
const b = sourceBlocks[j] as any
644+
if (b.type === 'tool') {
645+
if ((b as any).toolName !== 'end_turn') {
646+
hasRenderableAfter = true
647+
break
648+
}
649+
} else if (
650+
b.type === 'text' ||
651+
b.type === 'html' ||
652+
b.type === 'agent' ||
653+
b.type === 'agent-list'
654+
) {
655+
hasRenderableAfter = true
656+
break
657+
}
658+
}
640659
nodes.push(
641660
<box
642661
key={`${messageId}-tool-group-${start}`}
643662
style={{
644663
flexDirection: 'column',
645664
gap: 0,
646665
marginTop: 1,
647-
marginBottom: 1,
666+
marginBottom: hasRenderableAfter ? 1 : 0,
648667
}}
649668
>
650669
{nonNullGroupNodes}

0 commit comments

Comments
 (0)