Skip to content

Commit 9912dc9

Browse files
Fix freebuff model switch landing (#669)
Co-authored-by: James Grugett <jahooma@gmail.com>
1 parent 0228cbd commit 9912dc9

2 files changed

Lines changed: 40 additions & 6 deletions

File tree

cli/src/components/session-ended-banner.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ export const SessionEndedBanner: React.FC<SessionEndedBannerProps> = ({
5252
const bannerTitle = premiumQuota
5353
? `Session ended · ${formatSessionUnits(premiumQuota.recentCount)} of ${premiumQuota.limit} ${quotaLabel} used today`
5454
: 'Session ended'
55+
const landingButtonLabel =
56+
accessTier === 'limited' ? 'Back to start' : 'Change model'
57+
const landingPendingLabel =
58+
accessTier === 'limited'
59+
? 'Opening start screen…'
60+
: 'Opening model selection…'
5561

5662
// While a request is still streaming, restart is disabled: it would
5763
// unmount <Chat> and abort the in-flight agent run. The promise is "we
@@ -167,10 +173,11 @@ export const SessionEndedBanner: React.FC<SessionEndedBannerProps> = ({
167173
}}
168174
>
169175
{pendingAction === 'waiting-room' ? (
170-
'Opening model selection…'
176+
landingPendingLabel
171177
) : (
172178
<>
173-
Change model<span fg={theme.muted}>{' Esc'}</span>
179+
{landingButtonLabel}
180+
<span fg={theme.muted}>{' Esc'}</span>
174181
</>
175182
)}
176183
</text>

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

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,25 @@ function shouldReleaseSlot(current: FreebuffSessionResponse | null): boolean {
216216
)
217217
}
218218

219+
function toLandingSession(
220+
current: FreebuffSessionResponse | null,
221+
): Extract<FreebuffSessionResponse, { status: 'none' }> {
222+
const accessTier =
223+
current && 'accessTier' in current ? current.accessTier : undefined
224+
const queueDepthByModel =
225+
current && 'queueDepthByModel' in current
226+
? current.queueDepthByModel
227+
: undefined
228+
const rateLimitsByModel = getRateLimitsByModel(current)
229+
230+
return {
231+
status: 'none',
232+
...(accessTier ? { accessTier } : {}),
233+
...(queueDepthByModel ? { queueDepthByModel } : {}),
234+
...(rateLimitsByModel ? { rateLimitsByModel } : {}),
235+
}
236+
}
237+
219238
/** Best-effort DELETE of the caller's session row, gated on actually holding
220239
* one. Used both by exit paths and any flow that wants the next POST to
221240
* start clean (rejoin, return-to-landing). Always swallows errors — the
@@ -588,7 +607,10 @@ export function useFreebuffSession(): UseFreebuffSessionResult {
588607
// picker metadata from the response, ignoring whatever status it
589608
// claims. Polling resumes when the user commits to a model via
590609
// joinFreebuffQueue.
591-
apply({ status: 'none' })
610+
const landingSession = toLandingSession(
611+
useFreebuffSessionStore.getState().session,
612+
)
613+
apply(landingSession)
592614
const fetchController = abortController
593615
callSession('GET', token, { signal: fetchController.signal })
594616
.then((response) => {
@@ -602,9 +624,14 @@ export function useFreebuffSession(): UseFreebuffSessionResult {
602624
if (response.status === 'none' || response.status === 'queued') {
603625
apply({
604626
status: 'none',
605-
accessTier: response.accessTier,
606-
queueDepthByModel: response.queueDepthByModel,
607-
rateLimitsByModel: response.rateLimitsByModel,
627+
accessTier:
628+
response.accessTier ?? landingSession.accessTier,
629+
queueDepthByModel:
630+
response.queueDepthByModel ??
631+
landingSession.queueDepthByModel,
632+
rateLimitsByModel:
633+
response.rateLimitsByModel ??
634+
landingSession.rateLimitsByModel,
608635
})
609636
}
610637
})

0 commit comments

Comments
 (0)