Skip to content

Commit 686f85e

Browse files
committed
Hide mode button when narrow width
1 parent 7aec03b commit 686f85e

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

cli/src/chat.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,9 @@ export const Chat = ({
113113

114114
const { separatorWidth, terminalWidth, terminalHeight } =
115115
useTerminalDimensions()
116-
const { height: heightLayout } = useTerminalLayout()
116+
const { height: heightLayout, width: widthLayout } = useTerminalLayout()
117117
const isCompactHeight = heightLayout.is('xs')
118+
const isNarrowWidth = widthLayout.is('xs')
118119
const messageAvailableWidth = separatorWidth
119120

120121
const theme = useTheme()
@@ -640,6 +641,7 @@ export const Chat = ({
640641
initialPrompt,
641642
onSubmitPrompt,
642643
isCompactHeight,
644+
isNarrowWidth,
643645
})
644646

645647
const {
@@ -1218,6 +1220,7 @@ export const Chat = ({
12181220
shouldCenterInputVertically={shouldCenterInputVertically}
12191221
inputBoxTitle={inputBoxTitle}
12201222
isCompactHeight={isCompactHeight}
1223+
isNarrowWidth={isNarrowWidth}
12211224
feedbackMode={feedbackMode}
12221225
handleExitFeedback={handleExitFeedback}
12231226
handleSubmit={handleSubmit}

cli/src/components/chat-input-bar.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ interface ChatInputBarProps {
5353
shouldCenterInputVertically: boolean
5454
inputBoxTitle: string | undefined
5555
isCompactHeight: boolean
56+
isNarrowWidth: boolean
5657

5758
// Feedback mode
5859
feedbackMode: boolean
@@ -86,6 +87,7 @@ export const ChatInputBar = ({
8687
shouldCenterInputVertically,
8788
inputBoxTitle,
8889
isCompactHeight,
90+
isNarrowWidth,
8991
feedbackMode,
9092
handleExitFeedback,
9193
handleSubmit,
@@ -413,7 +415,7 @@ export const ChatInputBar = ({
413415
cursorPosition={cursorPosition}
414416
/>
415417
</box>
416-
{modeConfig.showAgentModeToggle && (
418+
{modeConfig.showAgentModeToggle && !isNarrowWidth && (
417419
<box
418420
style={{
419421
flexShrink: 0,

cli/src/hooks/use-chat-input.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ interface UseChatInputOptions {
1414
initialPrompt: string | null
1515
onSubmitPrompt: (content: string, mode: AgentMode) => void | Promise<unknown>
1616
isCompactHeight: boolean
17+
isNarrowWidth: boolean
1718
}
1819

1920
const BUILD_IT_TEXT = 'Build it!'
@@ -26,13 +27,14 @@ export const useChatInput = ({
2627
initialPrompt,
2728
onSubmitPrompt,
2829
isCompactHeight,
30+
isNarrowWidth,
2931
}: UseChatInputOptions) => {
3032
const hasAutoSubmittedRef = useRef(false)
3133
const inputMode = useChatStore((state) => state.inputMode)
3234

3335
// Estimate the collapsed toggle width as rendered by AgentModeToggle.
34-
// In bash mode or compact height, we don't show the toggle, so no width needed.
35-
const estimatedToggleWidth = inputMode !== 'default' || isCompactHeight
36+
// In bash mode, compact height, or narrow width, we don't show the toggle, so no width needed.
37+
const estimatedToggleWidth = inputMode !== 'default' || isCompactHeight || isNarrowWidth
3638
? 0
3739
: stringWidth(`< ${agentMode}`) + 6 // 2 padding + 2 borders + 2 gap
3840

0 commit comments

Comments
 (0)