Skip to content

Commit d6a3db3

Browse files
committed
feat cli: add stop button on status bar
1 parent 840b152 commit d6a3db3

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

cli/src/chat.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,7 @@ export const Chat = ({
14401440
isAtBottom={isAtBottom}
14411441
scrollToLatest={scrollToLatest}
14421442
statusIndicatorState={statusIndicatorState}
1443+
onStop={chatKeyboardHandlers.onInterruptStream}
14431444
/>
14441445
)}
14451446

cli/src/components/status-bar.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react'
22

33
import { ScrollToBottomButton } from './scroll-to-bottom-button'
44
import { ShimmerText } from './shimmer-text'
5+
import { StopButton } from './stop-button'
56
import { useTheme } from '../hooks/use-theme'
67
import { formatElapsedTime } from '../utils/format-elapsed-time'
78

@@ -15,13 +16,15 @@ interface StatusBarProps {
1516
isAtBottom: boolean
1617
scrollToLatest: () => void
1718
statusIndicatorState: StatusIndicatorState
19+
onStop?: () => void
1820
}
1921

2022
export const StatusBar = ({
2123
timerStartTime,
2224
isAtBottom,
2325
scrollToLatest,
2426
statusIndicatorState,
27+
onStop,
2528
}: StatusBarProps) => {
2629
const theme = useTheme()
2730
const [elapsedSeconds, setElapsedSeconds] = useState(0)
@@ -161,9 +164,14 @@ export const StatusBar = ({
161164
flexBasis: 0,
162165
flexDirection: 'row',
163166
justifyContent: 'flex-end',
167+
alignItems: 'center',
168+
gap: 1,
164169
}}
165170
>
166171
<text style={{ wrapMode: 'none' }}>{elapsedTimeContent}</text>
172+
{onStop && (statusIndicatorState.kind === 'waiting' || statusIndicatorState.kind === 'streaming') && (
173+
<StopButton onClick={onStop} />
174+
)}
167175
</box>
168176
</box>
169177
)

cli/src/components/stop-button.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { TextAttributes } from '@opentui/core'
2+
import { useState } from 'react'
3+
4+
import { Button } from './button'
5+
import { useTheme } from '../hooks/use-theme'
6+
7+
interface StopButtonProps {
8+
onClick: () => void
9+
}
10+
11+
export const StopButton = ({ onClick }: StopButtonProps) => {
12+
const theme = useTheme()
13+
const [hovered, setHovered] = useState(false)
14+
15+
return (
16+
<Button
17+
style={{ paddingLeft: 1, paddingRight: 1 }}
18+
onClick={onClick}
19+
onMouseOver={() => setHovered(true)}
20+
onMouseOut={() => setHovered(false)}
21+
>
22+
<text>
23+
<span
24+
fg={theme.secondary}
25+
attributes={hovered ? TextAttributes.BOLD : TextAttributes.DIM}
26+
>
27+
■ Stop
28+
</span>
29+
</text>
30+
</Button>
31+
)
32+
}

0 commit comments

Comments
 (0)