fix(desktop): extend profile startup REST timeouts (#48504)

This commit is contained in:
Tranquil-Flow 2026-06-18 18:10:50 +02:00 committed by brooklyn!
parent 4d88facfc1
commit 584d3ae532
3 changed files with 51 additions and 4 deletions

View file

@ -1,6 +1,12 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { getSessionMessages, listAllProfileSessions, listSessions } from './hermes'
import {
getProfiles,
getSessionMessages,
listAllProfileSessions,
listSessions
} from './hermes'
import { refreshActiveProfile } from './store/profile'
const emptySessionsResponse = {
limit: 0,
@ -47,6 +53,42 @@ describe('Hermes REST session helpers', () => {
)
})
it('uses a longer timeout for profile listing during desktop startup', async () => {
api.mockResolvedValue({ profiles: [] })
await getProfiles()
expect(api).toHaveBeenCalledWith(
expect.objectContaining({
path: '/api/profiles',
timeoutMs: 60_000
})
)
})
it('uses a longer timeout for active profile refresh during desktop startup', async () => {
api
.mockResolvedValueOnce({ current: 'default' })
.mockResolvedValueOnce({ profiles: [] })
await refreshActiveProfile()
expect(api).toHaveBeenNthCalledWith(
1,
expect.objectContaining({
path: '/api/profiles/active',
timeoutMs: 60_000
})
)
expect(api).toHaveBeenNthCalledWith(
2,
expect.objectContaining({
path: '/api/profiles',
timeoutMs: 60_000
})
)
})
it('tags cross-profile message reads for Electron routing and backend lookup', async () => {
api.mockResolvedValue({ messages: [], session_id: 'session-1' })

View file

@ -47,6 +47,7 @@ import type {
ToolsetInfo
} from '@/types/hermes'
export const STARTUP_PROFILE_REQUEST_TIMEOUT_MS = 60_000
const DEFAULT_GATEWAY_REQUEST_TIMEOUT_MS = 30_000
const SESSION_LIST_REQUEST_TIMEOUT_MS = 60_000
// prompt.submit is effectively fire-and-forget: turn completion is signaled by
@ -702,7 +703,8 @@ export function deleteCronJob(jobId: string): Promise<{ ok: boolean }> {
export function getProfiles(): Promise<ProfilesResponse> {
return window.hermesDesktop.api<ProfilesResponse>({
path: '/api/profiles'
path: '/api/profiles',
timeoutMs: STARTUP_PROFILE_REQUEST_TIMEOUT_MS
})
}

View file

@ -1,6 +1,6 @@
import { atom, computed } from 'nanostores'
import { getProfiles, setApiRequestProfile } from '@/hermes'
import { getProfiles, setApiRequestProfile, STARTUP_PROFILE_REQUEST_TIMEOUT_MS } from '@/hermes'
import { queryClient } from '@/lib/query-client'
import {
arraysEqual,
@ -110,7 +110,10 @@ interface ActiveProfileResponse {
// Best-effort: failures (backend not up yet) leave the prior values intact.
export async function refreshActiveProfile(): Promise<void> {
try {
const res = await window.hermesDesktop.api<ActiveProfileResponse>({ path: '/api/profiles/active' })
const res = await window.hermesDesktop.api<ActiveProfileResponse>({
path: '/api/profiles/active',
timeoutMs: STARTUP_PROFILE_REQUEST_TIMEOUT_MS
})
setActiveProfile(res.current || 'default')
} catch {