Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Sep 15, 2025

Description

This PR attempts to address Issue #7991 where the IO Intelligence model picker was reverting to the previous selection when trying to change models.

Problem

The ModelPicker component was incorrectly reinitializing the model selection when selectedModelId was falsy (empty string or undefined). This caused the IO Intelligence model picker to revert to the default model whenever a user tried to change the selection.

Solution

Fixed the initialization logic to check if the field is truly uninitialized (undefined) in the API configuration rather than just checking if selectedModelId is falsy. This prevents unwanted reinitialization of already-set values.

Changes

  • Modified the initialization condition in ModelPicker.tsx to check apiConfiguration[modelIdKey] === undefined instead of !selectedModelId
  • Updated the useEffect dependency array to include apiConfiguration instead of selectedModelId

Testing

  • All existing tests pass (1034 tests passed)
  • Linting and type checking pass
  • The fix specifically targets the reported issue without affecting other providers

Fixes #7991

Feedback and guidance are welcome!


Important

Fixes model selection reversion in ModelPicker by checking for undefined initialization, ensuring correct model persistence.

  • Behavior:
    • Fixes model selection reversion in ModelPicker by checking apiConfiguration[modelIdKey] === undefined instead of !selectedModelId.
    • Updates useEffect dependencies to include apiConfiguration instead of selectedModelId.
  • Testing:
    • All existing tests pass (1034 tests passed).
    • Linting and type checking pass.
    • Fix targets reported issue without affecting other providers.

This description was created by Ellipsis for ac5204f. You can customize this summary. It will automatically update as commits are pushed.

The ModelPicker component was incorrectly reinitializing the model selection
when selectedModelId was falsy (empty string or undefined). This caused the
IO Intelligence model picker to revert to the default model.

Fixed by checking if the field is truly uninitialized (undefined) rather than
just falsy, preventing unwanted reinitialization of already-set values.

Fixes #7991
@roomote roomote bot requested review from cte, jr and mrubens as code owners September 15, 2025 15:47
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Sep 15, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing my own code is like debugging in a mirror - everything looks backward and I still missed the obvious bugs.

const initialValue = modelIds.includes(selectedModelId) ? selectedModelId : defaultModelId
// Only initialize if the field has never been set (undefined), not when it's an empty string
if (apiConfiguration[modelIdKey] === undefined && !isInitialized.current) {
const initialValue = defaultModelId
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see we're removing the model validation logic here. The original code checked modelIds.includes(selectedModelId) to ensure only valid models were set. Without this check, we might initialize with an invalid model ID. Was this intentional, or should we preserve the validation while fixing the empty string issue?

Suggested change
const initialValue = defaultModelId
// Only initialize if the field has never been set (undefined), not when it's an empty string
if (apiConfiguration[modelIdKey] === undefined && !isInitialized.current) {
const initialValue = modelIds.includes(defaultModelId) ? defaultModelId : modelIds[0] || defaultModelId
setApiConfigurationField(modelIdKey, initialValue, false) // false = automatic initialization


isInitialized.current = true
}, [modelIds, setApiConfigurationField, modelIdKey, selectedModelId, defaultModelId])
}, [modelIds, setApiConfigurationField, modelIdKey, apiConfiguration, defaultModelId])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By changing the dependency from selectedModelId to apiConfiguration, this effect now runs whenever ANY field in apiConfiguration changes, not just the model ID. This could trigger unnecessary re-initializations. Should we be more specific and use apiConfiguration[modelIdKey] instead?

Suggested change
}, [modelIds, setApiConfigurationField, modelIdKey, apiConfiguration, defaultModelId])
}, [modelIds, setApiConfigurationField, modelIdKey, apiConfiguration[modelIdKey], defaultModelId])

useEffect(() => {
if (!selectedModelId && !isInitialized.current) {
const initialValue = modelIds.includes(selectedModelId) ? selectedModelId : defaultModelId
// Only initialize if the field has never been set (undefined), not when it's an empty string
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment could be more specific about why this distinction matters. Consider adding context about the IO Intelligence provider issue:

Suggested change
// Only initialize if the field has never been set (undefined), not when it's an empty string
// Only initialize if the field has never been set (undefined), not when it's an empty string
// IO Intelligence can have empty string as a valid state, and we shouldn't reinitialize in that case

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 15, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Sep 15, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Sep 15, 2025
@daniel-lxs
Copy link
Member

I think it makes sense to address the review by Roomote, specially around the ´apiConfiguration´ dependency.

@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Draft / In Progress] in Roo Code Roadmap Sep 17, 2025
@daniel-lxs daniel-lxs marked this pull request as draft September 17, 2025 21:23
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 22, 2025
@github-project-automation github-project-automation bot moved this from PR [Draft / In Progress] to Done in Roo Code Roadmap Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working PR - Draft / In Progress size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[BUG] IO Intelligence model picker reverts to previous selection

4 participants