Skip to content

fix(providers): discard stale model discovery results - #977

Open
Quine-rq wants to merge 1 commit into
fathah:mainfrom
Quine-rq:codex/fix-model-discovery-lifecycle
Open

Quine-rq wants to merge 1 commit into
fathah:mainfrom
Quine-rq:codex/fix-model-discovery-lifecycle

Conversation

@Quine-rq

Copy link
Copy Markdown
Contributor

The model picker combines the current provider's saved models with discovery results. Switching provider, endpoint, credentials or profile keeps the previous request's models available while the replacement request loads. A response arriving after the picker closes can also restore results into an idle discovery state.

Clear models, free-model metadata and the cache flag for each new request, and cancel response handling in the effect cleanup. Keep the existing debounce and allow discovery to restart normally when reopened.

Eight hook regressions cover request identity changes, disabled discovery, late responses, closing/reopening the same provider and unmounting. The initial provider-switch and disabled-response cases both fail before the fix.

Validation: 2,316 tests across 222 files, type checks, uncached ESLint, production build and lat checks passed. Tests exercise the real hook with controlled discovery IPC; packaged desktop/live-provider validation remains pending.

@greptile-apps

greptile-apps Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; no actionable correctness, security, or quality issues were identified.

Summary

This PR prevents stale model-discovery responses from updating renderer state after the request identity changes, discovery is disabled, or the hook unmounts.

  • Clears models, free-model metadata, and cache state whenever a new discovery lifecycle begins.
  • Uses effect-scoped cancellation to discard superseded or late asynchronous responses.
  • Adds regression coverage for provider, endpoint, credential, profile, disablement, reopen, and unmount scenarios.
  • Documents the discovery request lifecycle in the provider setup guide.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Discovery inputs change] --> B[Clean up previous effect]
  B --> C[Mark previous request cancelled]
  C --> D[Clear prior discovery state]
  D --> E{Enabled and provider present?}
  E -- No --> F[Set status to idle]
  E -- Yes --> G[Set status to loading]
  G --> H[Wait for debounce]
  H --> I[Request provider models]
  I --> J{Effect cancelled?}
  J -- Yes --> K[Discard response]
  J -- No --> L[Publish models, metadata, and status]
Loading

Reviews (1) · Last reviewed commit: "fix(providers): discard stale model disc..."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant