Skip to content

Commit f1c8be1

Browse files
committed
Improve layout
1 parent 9675177 commit f1c8be1

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

cli/src/components/tools/suggest-followups.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Button } from '../button'
55
import { defineToolComponent } from './types'
66
import { useTheme } from '../../hooks/use-theme'
77
import { useChatStore } from '../../state/chat-store'
8+
import { useTerminalDimensions } from '../../hooks/use-terminal-dimensions'
89

910
import type { ToolRenderConfig } from './types'
1011
import type { SuggestedFollowup } from '../../state/chat-store'
@@ -13,13 +14,15 @@ interface FollowupCardProps {
1314
followup: SuggestedFollowup
1415
index: number
1516
isClicked: boolean
17+
isStacked: boolean
1618
onSendFollowup: (prompt: string, index: number) => void
1719
}
1820

1921
const FollowupCard = ({
2022
followup,
2123
index,
2224
isClicked,
25+
isStacked,
2326
onSendFollowup,
2427
}: FollowupCardProps) => {
2528
const theme = useTheme()
@@ -53,9 +56,8 @@ const FollowupCard = ({
5356
paddingRight: 2,
5457
paddingTop: 0,
5558
paddingBottom: 0,
56-
maxWidth: 40,
59+
...(isStacked ? { width: '100%' } : { flexGrow: 1, flexShrink: 1 }),
5760
borderColor,
58-
flexGrow: 1,
5961
}}
6062
>
6163
<box style={{ flexDirection: 'column' }}>
@@ -89,12 +91,16 @@ interface SuggestFollowupsItemProps {
8991
onSendFollowup: (prompt: string, index: number) => void
9092
}
9193

94+
// Threshold width to switch between horizontal and stacked layouts
95+
const WIDE_SCREEN_THRESHOLD = 100
96+
9297
const SuggestFollowupsItem = ({
9398
toolCallId,
9499
followups,
95100
onSendFollowup,
96101
}: SuggestFollowupsItemProps) => {
97102
const theme = useTheme()
103+
const { terminalWidth } = useTerminalDimensions()
98104
const suggestedFollowups = useChatStore((state) => state.suggestedFollowups)
99105

100106
// Get clicked indices for this specific tool call
@@ -103,6 +109,9 @@ const SuggestFollowupsItem = ({
103109
? suggestedFollowups.clickedIndices
104110
: new Set<number>()
105111

112+
// Use stacked layout on narrow screens
113+
const isStacked = terminalWidth < WIDE_SCREEN_THRESHOLD
114+
106115
return (
107116
<box
108117
style={{
@@ -115,8 +124,7 @@ const SuggestFollowupsItem = ({
115124
</text>
116125
<box
117126
style={{
118-
flexDirection: 'row',
119-
flexWrap: 'wrap',
127+
flexDirection: isStacked ? 'column' : 'row',
120128
}}
121129
>
122130
{followups.map((followup, index) => (
@@ -125,6 +133,7 @@ const SuggestFollowupsItem = ({
125133
followup={followup}
126134
index={index}
127135
isClicked={clickedIndices.has(index)}
136+
isStacked={isStacked}
128137
onSendFollowup={onSendFollowup}
129138
/>
130139
))}

0 commit comments

Comments
 (0)