Skip to content

Commit 9409c30

Browse files
committed
Add spacing between text and tool groups
1 parent f4ec499 commit 9409c30

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

cli/src/components/message-block.tsx

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,26 @@ export const MessageBlock = memo(
426426
)
427427
}
428428

429+
const isRenderableTimelineBlock = (
430+
block: ContentBlock | null | undefined,
431+
): boolean => {
432+
if (!block) return false
433+
if (block.type === 'tool') {
434+
return (block as any).toolName !== 'end_turn'
435+
}
436+
switch (block.type) {
437+
case 'text':
438+
case 'html':
439+
case 'agent':
440+
case 'agent-list':
441+
case 'plan':
442+
case 'mode-divider':
443+
return true
444+
default:
445+
return false
446+
}
447+
}
448+
429449
function renderAgentListBranch(
430450
agentListBlock: Extract<ContentBlock, { type: 'agent-list' }>,
431451
keyPrefix: string,
@@ -613,25 +633,12 @@ export const MessageBlock = memo(
613633
Boolean,
614634
) as React.ReactNode[]
615635
if (nonNullGroupNodes.length > 0) {
616-
const isRenderableBlock = (b: ContentBlock): boolean => {
617-
if (b.type === 'tool') {
618-
return (b as any).toolName !== 'end_turn'
619-
}
620-
switch (b.type) {
621-
case 'text':
622-
case 'html':
623-
case 'agent':
624-
case 'agent-list':
625-
return true
626-
default:
627-
return false
628-
}
629-
}
630-
631-
// Check for any subsequent renderable blocks without allocating a slice
636+
const hasRenderableBefore =
637+
start > 0 &&
638+
isRenderableTimelineBlock(nestedBlocks[start - 1] as any)
632639
let hasRenderableAfter = false
633640
for (let i = nestedIdx; i < nestedBlocks.length; i++) {
634-
if (isRenderableBlock(nestedBlocks[i] as any)) {
641+
if (isRenderableTimelineBlock(nestedBlocks[i] as any)) {
635642
hasRenderableAfter = true
636643
break
637644
}
@@ -642,7 +649,7 @@ export const MessageBlock = memo(
642649
style={{
643650
flexDirection: 'column',
644651
gap: 0,
645-
marginTop: 0,
652+
marginTop: hasRenderableBefore ? 1 : 0,
646653
marginBottom: hasRenderableAfter ? 1 : 0,
647654
}}
648655
>
@@ -834,21 +841,14 @@ export const MessageBlock = memo(
834841
Boolean,
835842
) as React.ReactNode[]
836843
if (nonNullGroupNodes.length > 0) {
844+
const hasRenderableBefore =
845+
start > 0 &&
846+
isRenderableTimelineBlock(sourceBlocks[start - 1] as any)
847+
837848
// Check for any subsequent renderable blocks without allocating a slice
838849
let hasRenderableAfter = false
839850
for (let j = i; j < sourceBlocks.length; j++) {
840-
const b = sourceBlocks[j] as any
841-
if (b.type === 'tool') {
842-
if ((b as any).toolName !== 'end_turn') {
843-
hasRenderableAfter = true
844-
break
845-
}
846-
} else if (
847-
b.type === 'text' ||
848-
b.type === 'html' ||
849-
b.type === 'agent' ||
850-
b.type === 'agent-list'
851-
) {
851+
if (isRenderableTimelineBlock(sourceBlocks[j] as any)) {
852852
hasRenderableAfter = true
853853
break
854854
}
@@ -859,7 +859,7 @@ export const MessageBlock = memo(
859859
style={{
860860
flexDirection: 'column',
861861
gap: 0,
862-
marginTop: 0,
862+
marginTop: hasRenderableBefore ? 1 : 0,
863863
marginBottom: hasRenderableAfter ? 1 : 0,
864864
}}
865865
>

0 commit comments

Comments
 (0)