feat(frontend): persist the query cache and restore the signed-in session offline

Allowlisted query data is persisted to localStorage for 24h, scoped to the origin and user and cleared on sign-out. The last validated user is remembered so a cold start opens with cached lists when the session check fails on the network, while a 401 or signed-out response still signs out. Lists keep cached data when a refetch fails.
This commit is contained in:
Chris Scott committed 2026-10-24 19:24:26 -04:00
1 parent 881529728d
commit b6c21de0bb
28 files changed
+1325 -102

No files matched your search

+5
View File
@@ -14,6 +14,7 @@ import {
testOpenCodeServerById,
updateOpenCodeServer,
} from '@/api/opencodeServers'
import { cachedListStates } from '@/lib/queryState'
const OPENCODE_SERVERS_QUERY_KEY = ['opencode-servers']
const OPENCODE_SERVER_STATUSES_QUERY_KEY = ['opencode-server-statuses']
@@ -55,9 +56,13 @@ export function useOpenCodeServers(options: { enabled?: boolean } = {}) {
mutationFn: (id: string) => testOpenCodeServerById(id),
})
const serversListState = cachedListStates(serversQuery.data, serversQuery.isError)
return {
servers: serversQuery.data ?? [],
isLoading: serversQuery.isLoading,
/** True only while no server list is cached and no error settled, so a restore is not read as a missing server. */
showsInitialLoading: serversListState.showsInitialLoading,
isSuccess: serversQuery.isSuccess,
error: serversQuery.error,
refetch: serversQuery.refetch,