ACP session snapshot (Zed-style); falls back to seeded / on-disk cache from the last live session.
()
| 238 | |
| 239 | /** ACP session snapshot (Zed-style); falls back to seeded / on-disk cache from the last live session. */ |
| 240 | async function listCursorModelsWhileAcpActive(): Promise<ListCursorModelsResponse> { |
| 241 | const acp = getCursorAcpModelsSnapshot(); |
| 242 | if (acp && acp.availableModels.length > 0) { |
| 243 | return applyInMemoryCache({ success: true, ...acp }); |
| 244 | } |
| 245 | // Session child writes the on-disk cache; prefer it over this process's in-memory entry. |
| 246 | const shared = readSharedCursorModelsCache(); |
| 247 | if (shared) { |
| 248 | return applyInMemoryCache(shared); |
| 249 | } |
| 250 | if (cache.expiresAt > Date.now() && (cache.response.availableModels?.length ?? 0) > 0) { |
| 251 | const shared = readSharedCursorModelsCache(); |
| 252 | const cachedSkus = mergeCliModelSkus( |
| 253 | cache.response.cliModelSkus ?? [], |
| 254 | shared?.cliModelSkus ?? [] |
| 255 | ); |
| 256 | return attachCliSkusToResponse(cache.response, cachedSkus); |
| 257 | } |
| 258 | return { success: true, availableModels: [], currentModelId: null }; |
| 259 | } |
| 260 | |
| 261 | export async function listCursorModels(): Promise<ListCursorModelsResponse> { |
| 262 | if (isAgentAcpTransportActive()) { |
no test coverage detected