@@ -38,7 +38,9 @@ const playAdmissionSound = () => {
3838}
3939
4040const sessionEndpoint = ( ) : string => {
41- const base = ( env . NEXT_PUBLIC_CODEBUFF_APP_URL || 'https://codebuff.com' ) . replace ( / \/ $ / , '' )
41+ const base = (
42+ env . NEXT_PUBLIC_CODEBUFF_APP_URL || 'https://codebuff.com'
43+ ) . replace ( / \/ $ / , '' )
4244 return `${ base } /api/v1/freebuff/session`
4345}
4446
@@ -73,10 +75,13 @@ async function callSession(
7375 // generic error and back off on the 10s error-retry cadence instead of
7476 // tight-polling an unrecognized 200 body.
7577 if ( resp . status === 403 ) {
76- const body = ( await resp . json ( ) . catch ( ( ) => null ) ) as
77- | FreebuffSessionResponse
78- | null
79- if ( body && ( body . status === 'country_blocked' || body . status === 'banned' ) ) {
78+ const body = ( await resp
79+ . json ( )
80+ . catch ( ( ) => null ) ) as FreebuffSessionResponse | null
81+ if (
82+ body &&
83+ ( body . status === 'country_blocked' || body . status === 'banned' )
84+ ) {
8085 return body
8186 }
8287 }
@@ -85,9 +90,9 @@ async function callSession(
8590 // Surface model-switch conflicts and temporary model availability closures
8691 // as non-throw states.
8792 if ( resp . status === 409 && method === 'POST' ) {
88- const body = ( await resp . json ( ) . catch ( ( ) => null ) ) as
89- | FreebuffSessionResponse
90- | null
93+ const body = ( await resp
94+ . json ( )
95+ . catch ( ( ) => null ) ) as FreebuffSessionResponse | null
9196 if (
9297 body &&
9398 ( body . status === 'model_locked' || body . status === 'model_unavailable' )
@@ -101,9 +106,9 @@ async function callSession(
101106 // status (rather than 200) keeps older CLIs in their error path so they
102107 // back off instead of tight-polling an unrecognized 200 body.
103108 if ( resp . status === 429 && method === 'POST' ) {
104- const body = ( await resp . json ( ) . catch ( ( ) => null ) ) as
105- | FreebuffSessionResponse
106- | null
109+ const body = ( await resp
110+ . json ( )
111+ . catch ( ( ) => null ) ) as FreebuffSessionResponse | null
107112 if ( body && body . status === 'rate_limited' ) {
108113 return body
109114 }
@@ -190,9 +195,7 @@ export function getFreebuffInstanceId(): string | undefined {
190195 * holding (queued, active, or in the post-expiry grace window with a live
191196 * instance id). DELETE only matters in those states; otherwise we'd fire a
192197 * spurious request the server has nothing to act on. */
193- function shouldReleaseSlot (
194- current : FreebuffSessionResponse | null ,
195- ) : boolean {
198+ function shouldReleaseSlot ( current : FreebuffSessionResponse | null ) : boolean {
196199 if ( ! current ) return false
197200 return (
198201 current . status === 'queued' ||
@@ -312,7 +315,7 @@ export function markFreebuffSessionSuperseded(): void {
312315
313316/** Flip into the terminal `country_blocked` state from outside the poll loop.
314317 * Used when the chat-completions gate rejects on country even though the
315- * session-level country check had failed open (null detection → admitted) .
318+ * session-level country check did not catch the request first .
316319 * Transitioning the session state here unmounts the Chat surface in favor of
317320 * the waiting-room's country_blocked message, so the user can't keep typing
318321 * and sending doomed requests. */
0 commit comments