[Backport jb-v7.12.x] fix(models): ensure Tool Cody is only added when enabled #6759
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
FIX https://linear.app/sourcegraph/issue/CODY-4737
The issue was that the Tool Cody model was being added to the list of primary models regardless of whether the feature was enabled or not. The root cause was that the check for the existence of the Tool Cody model was not properly scoped to the
isToolCodyEnabled
flag but was checking the observable instead, which would always returns true as the observable is defined.This change fixes the issue by only adding the Tool Cody model to the list of primary models if the
isToolCodyEnabled
flag is true and the Tool Cody model is not already present in the list of primary models.Included some minor clean up.
Test plan
Verify Tool Cody is not showing up in your model dropdown if you don't have the configuration in your settings:
<img width="603" alt="image" src="https://github.com/user-attachments/assets/6ebdbb6e-650d-4bc4-ad62-40a285a13f5f" />
Backport ae351c2 from #6753