Skip to content

Conversation

@hannesrudolph
Copy link
Collaborator

@hannesrudolph hannesrudolph commented Nov 12, 2025

Related GitHub Issue

Closes: #9179

Roo Code Task Context (Optional)

No Roo Code task context for this PR

Description

Synchronize the running task’s API configuration when switching provider profiles so the selected model/profile is immediately applied to the active task.

What changed:

  • Core: Updated ClineProvider.updateTaskApiHandlerIfNeeded() to:
    • Rebuild the API handler only if provider or model changed (preserves existing behavior)
    • Always sync task.apiConfiguration = providerSettings so subsequent requests and UI logic use the current profile
  • Tests: Extended coverage in ClineProvider.apiHandlerRebuild.spec.ts
    • No-rebuild when provider/model unchanged, but task.apiConfiguration still syncs non-model fields
    • Added A → B → A switching regression test to ensure task.apiConfiguration updates each switch

Why:

  • Fixes regression where switching back to a model that shows reasoning did not re-apply (UI selector showed Model A but responses behaved like Model B). The root cause was the running task retaining a stale apiConfiguration.

Test Procedure

  • Unit:
    • cd src && npx vitest run core/webview/tests/ClineProvider.apiHandlerRebuild.spec.ts
    • cd src && npx vitest run (full suite)
  • Manual sanity (optional):
    • Start a task with Model A (reasoning-capable), observe reasoning visible
    • Switch to Model B (no reasoning), observe reasoning off
    • Switch back to Model A, reasoning should be visible again

Pre-Submission Checklist

  • Issue Linked
  • Scope focused on linked issue
  • Self-review performed
  • Tests updated/added
  • Documentation impact considered
  • Contributor Guidelines followed

Screenshots / Videos

No UI changes in this PR

Documentation Updates

  • No documentation updates are required.

Additional Notes

None

Get in Touch

@hannesrudolph


Important

Synchronize task's API configuration on provider profile switch in ClineProvider.ts, ensuring correct model/profile application, with tests verifying behavior.

  • Behavior:
    • updateTaskApiHandlerIfNeeded() in ClineProvider.ts now always syncs task.apiConfiguration with providerSettings, ensuring the current profile is applied.
    • Rebuilds API handler only if provider or model changes.
  • Tests:
    • Added tests in ClineProvider.apiHandlerRebuild.spec.ts to verify that task.apiConfiguration is synced even when provider/model is unchanged.
    • Tests ensure API handler rebuilds only when provider or model changes.
    • Added regression test for profile switching sequence A → B → A to ensure task.apiConfiguration updates correctly.

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

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Nov 12, 2025
@roomote
Copy link
Contributor

roomote bot commented Nov 12, 2025

Rooviewer Clock   Follow along on Roo Cloud

Reviewed latest commit (70de139). One issue from the previous review has been resolved. One issue remains:

  • Avoid any cast when writing to task.apiConfiguration (line 1322)
Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Nov 12, 2025
…in ClineProvider.updateTaskApiHandlerIfNeeded(); address review feedback
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Nov 12, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 12, 2025
@mrubens mrubens merged commit 2c91724 into main Nov 12, 2025
13 checks passed
@mrubens mrubens deleted the fix/issue-9179-model-switch-sync branch November 12, 2025 01:11
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Nov 12, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Nov 12, 2025