Skip to content

Commit 930f0f2

Browse files
committed
Address review nits: docstring, dead prop, stale docs, import order
- Update switchFreebuffModel docstring to match the silent auto-revert the tick loop actually does (not the prompt-to-end-first flow it used to describe). - Remove the unused `disabled` prop on FreebuffModelSelector; the only caller never set it, so the component's internal `pending` state is the only disable path. - Refresh docs/freebuff-waiting-room.md for per-model queues: mermaid, schema (with the `model` column from migration 0044), admission loop (per-model advisory locks, getFleetHealth), tunables, POST semantics, model_locked response shape, and the CLI / multi-pod sections. - Group endAndRejoinFreebuffSession with the other ../hooks/* imports in command-registry.ts.
1 parent 469e998 commit 930f0f2

4 files changed

Lines changed: 89 additions & 65 deletions

File tree

cli/src/commands/command-registry.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { CLAUDE_OAUTH_ENABLED } from '@codebuff/common/constants/claude-oauth'
33
import { safeOpen } from '../utils/open-url'
44

55
import { handleAdsEnable, handleAdsDisable } from './ads'
6-
import { buildInterviewPrompt, buildPlanPrompt, buildReviewPromptFromArgs } from './prompt-builders'
7-
import { endAndRejoinFreebuffSession } from '../hooks/use-freebuff-session'
8-
import { useThemeStore } from '../hooks/use-theme'
96
import { handleHelpCommand } from './help'
107
import { handleImageCommand } from './image'
118
import { handleInitializationFlowLocally } from './init'
9+
import { buildInterviewPrompt, buildPlanPrompt, buildReviewPromptFromArgs } from './prompt-builders'
1210
import { runBashCommand } from './router'
1311
import { handleUsageCommand } from './usage'
12+
import { endAndRejoinFreebuffSession } from '../hooks/use-freebuff-session'
13+
import { useThemeStore } from '../hooks/use-theme'
1414
import { WEBSITE_URL } from '../login/constants'
1515
import { useChatStore } from '../state/chat-store'
1616
import { useFeedbackStore } from '../state/feedback-store'

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

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,33 @@ import { useTheme } from '../hooks/use-theme'
1111

1212
import type { KeyEvent } from '@opentui/core'
1313

14-
interface FreebuffModelSelectorProps {
15-
/** Disables interaction while a switch / refresh is mid-flight so the user
16-
* can't queue up a second switch and double-bounce themselves to the back
17-
* of yet another queue. */
18-
disabled?: boolean
19-
}
20-
2114
/**
2215
* Lets the user pick which model's queue they're in. Tapping (or pressing the
2316
* row's number key) on a different model triggers a re-POST: the server moves
2417
* them to the back of the new model's queue.
2518
*/
26-
export const FreebuffModelSelector: React.FC<FreebuffModelSelectorProps> = ({
27-
disabled = false,
28-
}) => {
19+
export const FreebuffModelSelector: React.FC = () => {
2920
const theme = useTheme()
3021
const selectedModel = useFreebuffModelStore((s) => s.selectedModel)
3122
const [pending, setPending] = useState<string | null>(null)
3223
const [hoveredId, setHoveredId] = useState<string | null>(null)
3324

3425
const pick = useCallback(
3526
(modelId: string) => {
36-
if (disabled || pending) return
27+
if (pending) return
3728
if (modelId === selectedModel) return
3829
setPending(modelId)
3930
switchFreebuffModel(modelId).finally(() => setPending(null))
4031
},
41-
[disabled, pending, selectedModel],
32+
[pending, selectedModel],
4233
)
4334

4435
// Number-key shortcuts (1-9) so keyboard-only users can switch without
4536
// hunting for a clickable region.
4637
useKeyboard(
4738
useCallback(
4839
(key: KeyEvent) => {
49-
if (disabled || pending) return
40+
if (pending) return
5041
const name = key.name ?? ''
5142
if (!/^[1-9]$/.test(name)) return
5243
const digit = Number(name)
@@ -57,7 +48,7 @@ export const FreebuffModelSelector: React.FC<FreebuffModelSelectorProps> = ({
5748
pick(target.id)
5849
}
5950
},
60-
[disabled, pending, pick, selectedModel],
51+
[pending, pick, selectedModel],
6152
),
6253
)
6354

@@ -79,7 +70,7 @@ export const FreebuffModelSelector: React.FC<FreebuffModelSelectorProps> = ({
7970
const indicator = isSelected ? '●' : '○'
8071
const indicatorColor = isSelected ? theme.primary : theme.muted
8172
const labelColor = isSelected ? theme.foreground : theme.muted
82-
const interactable = !disabled && !pending && !isSelected
73+
const interactable = !pending && !isSelected
8374
return (
8475
<Button
8576
key={model.id}

cli/src/hooks/use-freebuff-session.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,10 @@ export async function refreshFreebuffSession(opts: { resetChat?: boolean } = {})
170170
/**
171171
* User picked a different model in the waiting room. Persist the choice and
172172
* re-POST so the server moves them to the back of the new model's queue. If
173-
* the user has an active session bound to a different model, the server
174-
* responds with `model_locked` and the UI prompts them to end first.
173+
* the server has already admitted them on a different model, it responds
174+
* with `model_locked`; the tick loop silently reverts the local selection to
175+
* the locked model so the active session stays intact. Users who really want
176+
* to switch can /end-session deliberately.
175177
*/
176178
export async function switchFreebuffModel(model: string): Promise<void> {
177179
if (!IS_FREEBUFF) return

0 commit comments

Comments
 (0)