Repository navigation
Conversation
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
First review of this model-cache recovery fix (1 commit, 2 files).
get_cachedpreserves stale data on failure (lua/CopilotChat/client.lua:83-91) — anilfrom the filler now returns any previously cached value and leaves_expires_atuntouched, so the entry stays expired and is refetched on the next call instead of caching an empty result for the full 5-minute TTL. Because the innercacheis a plain table (not thedefaulttablewrapper),cache[key] or {}does not auto-vivify and_expires_atis only ever written alongsidecache[key], so the_expires_at > nowcomparison can't be reached with anil/table value.Client:modelsreports failure asnil(lua/CopilotChat/client.lua:243-255) — the auth-failure andget_models-failure branches nowreturn nil, and anilprovider result is passed through unchanged, engaging the recovery path. Genuinely successful empty lists are still cached.- New regression suite (
tests/client_spec.lua) — 243 lines covering first-fetch caching, retry after auth/model-fetch failure, the expiry boundary, stale preservation then recovery, preservation when auth refresh fails, persistent-failure retry without an internal loop, genuine empty-list caching, nil provider result not cached, independent per-provider caching, and an end-to-endautorecovery after an invalid JSON response.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the delta since the prior pullfrog review (efadf6a → 597b597), which extends the cache-recovery fix with retry throttling, shared in-flight fetches, and a completion-trigger correction. All 112 tests pass locally on Neovim 0.11.4 with plenary.
- Added a 60-second retry cooldown to
get_cached— failed fills now record<key>_retry_atand preserve any stale value, so a failing provider is contacted at most once per cooldown instead of on every call. - Coalesced concurrent fills with a
Condvar— a<key>_pendingentry makes concurrent callers (including the authentication step inside the filler) wait for the in-flight request, then return the refreshed or stale result. - Hardened the owner path with
pcall— the pending entry is always cleared and waiters always notified; unexpected filler errors are re-raised to the owner and to waiting callers. - Anchored the completion trigger to the cursor —
M.completenow matchesinfo.pattern .. '$'and bails whenprefix == '', soTextChangedI/<Tab>over ordinary chat text no longer schedules model discovery. - Extended the regression suite — new cooldown, shared-fetch, shared-auth, waiter-release and stale-preservation tests in
tests/client_spec.lua, plustests/completion_spec.luafor trigger anchoring.
I traced the new ordering for the cache path: _pending is cleared before notify_all(), and the read→wait() sequence contains no yield, so a waiter cannot miss a notification; stale values survive both failure shapes and the cooldown boundary behaves as asserted. The completion change is also benign for the async omnifunc path (-2 means "stay in completion mode", and the next keystroke exits it).
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
c8ed65f to
e5c4b7a
Compare

Problem
Failed model discovery is cached as an empty list for five minutes, hiding
available models and replacing previously successful results. Retrying on every
call instead can flood the API, especially when chat completion runs while typing.
Fix
This fixes failure caching and excessive discovery attempts, not the underlying
invalid API response. Existing curl retries are unchanged.
Tests
All 112 tests, StyLua, and whitespace checks pass. Regression coverage includes
cooldowns, concurrent requests, stale-cache preservation, and completion triggers.
Manually verified with a real Copilot account.
Related: #1343 also changes discovery error handling; this approach preserves
cached models and allows other providers to remain usable.