()
| 114 | * Fetch bootstrap data from the API and persist to disk cache. |
| 115 | */ |
| 116 | export async function fetchBootstrapData(): Promise<void> { |
| 117 | try { |
| 118 | const response = await fetchBootstrapAPI() |
| 119 | if (!response) return |
| 120 | |
| 121 | const clientData = response.client_data ?? null |
| 122 | const additionalModelOptions = response.additional_model_options ?? [] |
| 123 | |
| 124 | // Only persist if data actually changed — avoids a config write on every startup. |
| 125 | const config = getGlobalConfig() |
| 126 | if ( |
| 127 | isEqual(config.clientDataCache, clientData) && |
| 128 | isEqual(config.additionalModelOptionsCache, additionalModelOptions) |
| 129 | ) { |
| 130 | logForDebugging('[Bootstrap] Cache unchanged, skipping write') |
| 131 | return |
| 132 | } |
| 133 | |
| 134 | logForDebugging('[Bootstrap] Cache updated, persisting to disk') |
| 135 | saveGlobalConfig(current => ({ |
| 136 | ...current, |
| 137 | clientDataCache: clientData, |
| 138 | additionalModelOptionsCache: additionalModelOptions, |
| 139 | })) |
| 140 | } catch (error) { |
| 141 | logError(error) |
| 142 | } |
| 143 | } |
no test coverage detected