Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 4, 2025

_currentModelObs reads undesired models synchronously via _undesiredModelsManager.isUndesiredModelId(), but that state is updated asynchronously in setCurrentModelId. This causes stale reads when the observable recomputes before async updates complete.

Changes

  • Make undesired models state observable: Added ISettableObservable<string[]> to UndesiredModels.Manager, exposed via modelsObservable getter
  • Wire observable into dependency chain: _currentModelObs now reads undesiredModelIds from the observable
  • Pass state explicitly to _pickModel: Accepts undesiredModelIds: string[] parameter instead of reading from manager
this._currentModelObs = derived<Model, void>((reader) => {
    return this._pickModel({
        preferredModelName: this._preferredModelNameObs.read(reader),
        models: this._modelsObs.read(reader),
        undesiredModelIds: this._undesiredModelsManager.modelsObservable.read(reader),
    });
}).recomputeInitiallyAndOnChange(this._store);

The observable updates after persisting to global state, ensuring the dependency chain recomputes with consistent data.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: ulugbekna <16353531+ulugbekna@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on prioritizing exp model config in nes models Fix race condition in undesired models state by making it observable Dec 4, 2025
Copilot AI requested a review from ulugbekna December 4, 2025 19:30
Copilot finished work on behalf of ulugbekna December 4, 2025 19:30
Base automatically changed from ulugbekna/firm-cougar to main December 4, 2025 19:47
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.

2 participants