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