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