Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions cli/src/components/session-ended-banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ export const SessionEndedBanner: React.FC<SessionEndedBannerProps> = ({
const bannerTitle = premiumQuota
? `Session ended · ${formatSessionUnits(premiumQuota.recentCount)} of ${premiumQuota.limit} ${quotaLabel} used today`
: 'Session ended'
const landingButtonLabel =
accessTier === 'limited' ? 'Back to start' : 'Change model'
const landingPendingLabel =
accessTier === 'limited'
? 'Opening start screen…'
: 'Opening model selection…'

// While a request is still streaming, restart is disabled: it would
// unmount <Chat> and abort the in-flight agent run. The promise is "we
Expand Down Expand Up @@ -167,10 +173,11 @@ export const SessionEndedBanner: React.FC<SessionEndedBannerProps> = ({
}}
>
{pendingAction === 'waiting-room' ? (
'Opening model selection…'
landingPendingLabel
) : (
<>
Change model<span fg={theme.muted}>{' Esc'}</span>
{landingButtonLabel}
<span fg={theme.muted}>{' Esc'}</span>
</>
)}
</text>
Expand Down
35 changes: 31 additions & 4 deletions cli/src/hooks/use-freebuff-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,25 @@ function shouldReleaseSlot(current: FreebuffSessionResponse | null): boolean {
)
}

function toLandingSession(
current: FreebuffSessionResponse | null,
): Extract<FreebuffSessionResponse, { status: 'none' }> {
const accessTier =
current && 'accessTier' in current ? current.accessTier : undefined
const queueDepthByModel =
current && 'queueDepthByModel' in current
? current.queueDepthByModel
: undefined
const rateLimitsByModel = getRateLimitsByModel(current)

return {
status: 'none',
...(accessTier ? { accessTier } : {}),
...(queueDepthByModel ? { queueDepthByModel } : {}),
...(rateLimitsByModel ? { rateLimitsByModel } : {}),
}
}

/** Best-effort DELETE of the caller's session row, gated on actually holding
* one. Used both by exit paths and any flow that wants the next POST to
* start clean (rejoin, return-to-landing). Always swallows errors — the
Expand Down Expand Up @@ -588,7 +607,10 @@ export function useFreebuffSession(): UseFreebuffSessionResult {
// picker metadata from the response, ignoring whatever status it
// claims. Polling resumes when the user commits to a model via
// joinFreebuffQueue.
apply({ status: 'none' })
const landingSession = toLandingSession(
useFreebuffSessionStore.getState().session,
)
apply(landingSession)
const fetchController = abortController
callSession('GET', token, { signal: fetchController.signal })
.then((response) => {
Expand All @@ -602,9 +624,14 @@ export function useFreebuffSession(): UseFreebuffSessionResult {
if (response.status === 'none' || response.status === 'queued') {
apply({
status: 'none',
accessTier: response.accessTier,
queueDepthByModel: response.queueDepthByModel,
rateLimitsByModel: response.rateLimitsByModel,
accessTier:
response.accessTier ?? landingSession.accessTier,
queueDepthByModel:
response.queueDepthByModel ??
landingSession.queueDepthByModel,
rateLimitsByModel:
response.rateLimitsByModel ??
landingSession.rateLimitsByModel,
})
}
})
Expand Down
Loading