Skip to content

Commit aa2e800

Browse files
committed
Better selector of freebuff model
1 parent 85fdfc0 commit aa2e800

2 files changed

Lines changed: 62 additions & 45 deletions

File tree

cli/src/components/freebuff-model-selector.tsx

Lines changed: 59 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -84,47 +84,65 @@ export const FreebuffModelSelector: React.FC = () => {
8484
<text style={{ fg: theme.muted, marginBottom: 1 }}>
8585
Model — tap or press 1-{FREEBUFF_MODELS.length} to switch
8686
</text>
87-
{FREEBUFF_MODELS.map((model, idx) => {
88-
const isSelected = model.id === selectedModel
89-
const isPending = pending === model.id
90-
const isHovered = hoveredId === model.id
91-
const indicator = isSelected ? '●' : '○'
92-
const indicatorColor = isSelected ? theme.primary : theme.muted
93-
const labelColor = isSelected ? theme.foreground : theme.muted
94-
const interactable = !pending && !isSelected
95-
const ahead = aheadByModel?.[model.id]
96-
const hint =
97-
ahead === undefined
98-
? model.tagline
99-
: ahead === 0
100-
? 'No wait'
101-
: `${ahead} ahead`
102-
return (
103-
<Button
104-
key={model.id}
105-
onClick={() => pick(model.id)}
106-
onMouseOver={() => interactable && setHoveredId(model.id)}
107-
onMouseOut={() => setHoveredId((curr) => (curr === model.id ? null : curr))}
108-
style={{ paddingLeft: 0, paddingRight: 1 }}
109-
>
110-
<text>
111-
<span fg={indicatorColor}>{indicator} </span>
112-
<span fg={theme.muted}>{idx + 1}. </span>
113-
<span
114-
fg={labelColor}
115-
attributes={isSelected ? TextAttributes.BOLD : TextAttributes.NONE}
116-
>
117-
{model.displayName}
118-
</span>
119-
<span fg={theme.muted}> {hint}</span>
120-
{isPending && <span fg={theme.muted}> switching…</span>}
121-
{isHovered && interactable && !isPending && (
122-
<span fg={theme.muted}></span>
123-
)}
124-
</text>
125-
</Button>
126-
)
127-
})}
87+
<box
88+
style={{
89+
flexDirection: 'row',
90+
gap: 2,
91+
}}
92+
>
93+
{FREEBUFF_MODELS.map((model, idx) => {
94+
const isSelected = model.id === selectedModel
95+
const isPending = pending === model.id
96+
const isHovered = hoveredId === model.id
97+
const indicator = isSelected ? '●' : '○'
98+
const indicatorColor = isSelected ? theme.primary : theme.muted
99+
const labelColor = isSelected ? theme.foreground : theme.muted
100+
const interactable = !pending && !isSelected
101+
const ahead = aheadByModel?.[model.id]
102+
const hint =
103+
ahead === undefined
104+
? model.tagline
105+
: ahead === 0
106+
? 'No wait'
107+
: `${ahead} ahead`
108+
109+
const borderColor = isSelected
110+
? theme.primary
111+
: isHovered && interactable
112+
? theme.foreground
113+
: theme.border
114+
115+
return (
116+
<Button
117+
key={model.id}
118+
onClick={() => pick(model.id)}
119+
onMouseOver={() => interactable && setHoveredId(model.id)}
120+
onMouseOut={() => setHoveredId((curr) => (curr === model.id ? null : curr))}
121+
style={{
122+
borderStyle: 'single',
123+
borderColor,
124+
paddingLeft: 1,
125+
paddingRight: 1,
126+
}}
127+
border={['top', 'bottom', 'left', 'right']}
128+
>
129+
<text>
130+
<span fg={indicatorColor}>{indicator} </span>
131+
<span fg={theme.muted}>{idx + 1}. </span>
132+
<span
133+
fg={labelColor}
134+
attributes={isSelected ? TextAttributes.BOLD : TextAttributes.NONE}
135+
>
136+
{model.displayName}
137+
</span>
138+
<span fg={theme.muted}> {hint}</span>
139+
{isPending && <span fg={theme.muted}> switching…</span>}
140+
141+
</text>
142+
</Button>
143+
)
144+
})}
145+
</box>
128146
</box>
129147
)
130148
}

cli/src/components/waiting-room-screen.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,14 @@ export const WaitingRoomScreen: React.FC<WaitingRoomScreenProps> = ({
174174
: "You're in the waiting room"}
175175
</text>
176176

177+
<FreebuffModelSelector />
178+
177179
<box
178180
style={{
179181
flexDirection: 'column',
180182
alignItems: 'flex-start',
181183
gap: 0,
184+
marginTop: 1,
182185
}}
183186
>
184187
<text style={{ fg: theme.foreground, alignSelf: 'flex-start' }}>
@@ -201,10 +204,6 @@ export const WaitingRoomScreen: React.FC<WaitingRoomScreenProps> = ({
201204
{formatElapsed(elapsedMs)}
202205
</text>
203206
</box>
204-
205-
<box style={{ marginTop: 1 }}>
206-
<FreebuffModelSelector />
207-
</box>
208207
</>
209208
)}
210209

0 commit comments

Comments
 (0)