Skip to content

Commit 2cb41c6

Browse files
authored
Make Fireworks deployment hours daily (#547)
1 parent 4058f1a commit 2cb41c6

6 files changed

Lines changed: 17 additions & 41 deletions

File tree

common/src/__tests__/freebuff-models.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('freebuff model availability', () => {
1212
locale: 'en-US',
1313
timeZone: 'America/Los_Angeles',
1414
}),
15-
).toBe('until 5:00 PM local')
15+
).toBe('until 5:00 PM')
1616
})
1717

1818
test('formats the next open time in the user local timezone while deployment is closed', () => {
@@ -21,16 +21,16 @@ describe('freebuff model availability', () => {
2121
locale: 'en-US',
2222
timeZone: 'America/Los_Angeles',
2323
}),
24-
).toBe('opens 6:00 AM local')
24+
).toBe('opens 6:00 AM')
2525
})
2626

2727
test('includes the weekday when the next opening is on a later local day', () => {
2828
expect(
29-
getFreebuffDeploymentAvailabilityLabel(new Date('2026-01-10T20:00:00Z'), {
29+
getFreebuffDeploymentAvailabilityLabel(new Date('2026-01-11T03:00:00Z'), {
3030
locale: 'en-US',
3131
timeZone: 'America/Los_Angeles',
3232
}),
33-
).toBe('opens Mon 6:00 AM local')
33+
).toBe('opens Sun 6:00 AM')
3434
})
3535

3636
test('tracks deployment hours correctly across the open and close boundaries', () => {
@@ -46,5 +46,8 @@ describe('freebuff model availability', () => {
4646
expect(isFreebuffDeploymentHours(new Date('2026-01-06T01:00:00Z'))).toBe(
4747
false,
4848
)
49+
expect(isFreebuffDeploymentHours(new Date('2026-01-10T20:00:00Z'))).toBe(
50+
true,
51+
)
4952
})
5053
})

common/src/constants/freebuff-models.ts

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export interface FreebuffModelOption {
2020
/** Server-facing fallback copy for APIs and provider errors that can't know
2121
* the caller's local timezone. The CLI should render
2222
* `getFreebuffDeploymentAvailabilityLabel()` instead. */
23-
export const FREEBUFF_DEPLOYMENT_HOURS_LABEL = '9am ET-5pm PT'
23+
export const FREEBUFF_DEPLOYMENT_HOURS_LABEL = '9am ET-5pm PT every day'
2424
export const FREEBUFF_GLM_MODEL_ID = 'z-ai/glm-5.1'
2525
export const FREEBUFF_MINIMAX_MODEL_ID = 'minimax/minimax-m2.7'
2626
const FREEBUFF_EASTERN_TIMEZONE = 'America/New_York'
@@ -30,7 +30,6 @@ interface ZonedDateParts {
3030
year: number
3131
month: number
3232
day: number
33-
weekday: string
3433
hour: number
3534
minute: number
3635
}
@@ -96,7 +95,6 @@ function getZonedParts(date: Date, timeZone: string): ZonedDateParts {
9695
year: 'numeric',
9796
month: '2-digit',
9897
day: '2-digit',
99-
weekday: 'short',
10098
hour: '2-digit',
10199
minute: '2-digit',
102100
hourCycle: 'h23',
@@ -112,7 +110,6 @@ function getZonedParts(date: Date, timeZone: string): ZonedDateParts {
112110
year,
113111
month,
114112
day,
115-
weekday: value('weekday') ?? '',
116113
hour,
117114
minute,
118115
}
@@ -165,34 +162,11 @@ function getUtcForZonedTime(
165162
return guess
166163
}
167164

168-
function isWeekend(
169-
parts: Pick<ZonedDateParts, 'year' | 'month' | 'day'>,
170-
): boolean {
171-
const weekday = getWeekdayIndex(parts)
172-
return weekday === 0 || weekday === 6
173-
}
174-
175-
function getWeekdayIndex(
176-
parts: Pick<ZonedDateParts, 'year' | 'month' | 'day'>,
177-
): number {
178-
return new Date(Date.UTC(parts.year, parts.month - 1, parts.day)).getUTCDay()
179-
}
180-
181165
function getNextFreebuffDeploymentStart(now: Date): Date {
182166
const easternNow = getZonedParts(now, FREEBUFF_EASTERN_TIMEZONE)
183-
const weekday = getWeekdayIndex(easternNow)
184167
const isBeforeTodayOpen = easternNow.hour < 9
185168

186-
const offset =
187-
weekday === 6
188-
? 2
189-
: weekday === 0
190-
? 1
191-
: isBeforeTodayOpen
192-
? 0
193-
: weekday === 5
194-
? 3
195-
: 1
169+
const offset = isBeforeTodayOpen ? 0 : 1
196170

197171
return getUtcForZonedTime(
198172
addDaysToYmd(easternNow.year, easternNow.month, easternNow.day, offset),
@@ -241,17 +215,16 @@ export function getFreebuffDeploymentAvailabilityLabel(
241215
): string {
242216
if (isFreebuffDeploymentHours(now)) {
243217
const closesAt = getCurrentFreebuffDeploymentEnd(now)
244-
return `until ${formatLocalTime(closesAt, now, options)} local`
218+
return `until ${formatLocalTime(closesAt, now, options)}`
245219
}
246220

247221
const opensAt = getNextFreebuffDeploymentStart(now)
248-
return `opens ${formatLocalTime(opensAt, now, options)} local`
222+
return `opens ${formatLocalTime(opensAt, now, options)}`
249223
}
250224

251225
export function isFreebuffDeploymentHours(now: Date = new Date()): boolean {
252226
const eastern = getZonedParts(now, FREEBUFF_EASTERN_TIMEZONE)
253227
const pacific = getZonedParts(now, FREEBUFF_PACIFIC_TIMEZONE)
254-
if (eastern.weekday === 'Sat' || eastern.weekday === 'Sun') return false
255228
return (
256229
eastern.hour * 60 + eastern.minute >= 9 * 60 &&
257230
pacific.hour * 60 + pacific.minute < 17 * 60

web/src/app/api/v1/freebuff/session/__tests__/session.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ describe('POST /api/v1/freebuff/session', () => {
167167
expect(resp.status).toBe(409)
168168
const body = await resp.json()
169169
expect(body.status).toBe('model_unavailable')
170-
expect(body.availableHours).toBe('9am ET-5pm PT')
170+
expect(body.availableHours).toBe('9am ET-5pm PT every day')
171171
expect(sessionDeps.rows.size).toBe(0)
172172
})
173173

web/src/llm-api/__tests__/fireworks-deployment.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ function createMockLogger(): Logger {
3030

3131
describe('Fireworks deployment routing', () => {
3232
describe('deployment hours', () => {
33-
it('is active from 9am ET until before 5pm PT on weekdays', () => {
33+
it('is active from 9am ET until before 5pm PT every day', () => {
3434
expect(isDeploymentHours(BEFORE_DEPLOYMENT_HOURS)).toBe(false)
3535
expect(isDeploymentHours(IN_DEPLOYMENT_HOURS)).toBe(true)
3636
expect(isDeploymentHours(AFTER_DEPLOYMENT_HOURS)).toBe(false)
3737
expect(isDeploymentHours(WEEKDAY_AFTER_DEPLOYMENT_HOURS)).toBe(false)
3838
})
3939

40-
it('is inactive on weekends', () => {
41-
expect(isDeploymentHours(WEEKEND_DEPLOYMENT_HOURS)).toBe(false)
40+
it('is active on weekends during deployment hours', () => {
41+
expect(isDeploymentHours(WEEKEND_DEPLOYMENT_HOURS)).toBe(true)
4242
})
4343
})
4444

web/src/llm-api/fireworks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const FIREWORKS_MODEL_MAP: Record<string, string> = {
4141
/** Flag to enable custom Fireworks deployments (set to false to use global API only) */
4242
const FIREWORKS_USE_CUSTOM_DEPLOYMENT = true
4343

44-
/** Check if current time is within deployment hours: Mon-Fri, 9am ET to 5pm PT. */
44+
/** Check if current time is within deployment hours: daily, 9am ET to 5pm PT. */
4545
export function isDeploymentHours(now: Date = new Date()): boolean {
4646
return isFreebuffDeploymentHours(now)
4747
}

web/src/server/free-session/__tests__/public-api.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ describe('requestSession', () => {
209209
expect(state).toEqual({
210210
status: 'model_unavailable',
211211
requestedModel: 'z-ai/glm-5.1',
212-
availableHours: '9am ET-5pm PT',
212+
availableHours: '9am ET-5pm PT every day',
213213
})
214214
expect(deps.rows.size).toBe(0)
215215
})

0 commit comments

Comments
 (0)