Skip to content

Conversation

@omniwired
Copy link
Contributor

Problem

When changing providers/models in the CLI using /provider select, the StatusBar would briefly show the new model but then revert back to the previous one. This happened because:

  1. User selects a new provider via /provider select
  2. CLI updates local config and sends update to extension
  3. Extension processes the change and broadcasts new state
  4. BUT the extension also sends periodic state updates that contain the old configuration
  5. These stale state updates overwrite the local UI atoms, reverting the model indicator

Solution

Add a protection mechanism that prevents stale extension state updates from overwriting recent local changes:

  • Track timestamps when apiConfiguration and extensionMode are set locally
  • When receiving extension state updates, skip updating these atoms if they were modified locally within the last 60 seconds
  • Directly update UI atoms when selecting providers for immediate visual feedback
  • Call loadApiConfiguration to ensure the extension activates the new profile
  • Clear the current task after provider change so new tasks use the new configuration

Test Plan

  1. Run the CLI: cd cli && node dist/index.js
  2. Check current model in StatusBar (bottom of screen)
  3. Run /provider select <different-provider>
  4. Verify the StatusBar immediately updates to show the new model
  5. Wait 10+ seconds and verify the model indicator stays on the new selection (doesn't revert)
  6. Send a message and verify it uses the newly selected provider

When changing providers/models in the CLI, the extension state updates
could race with local changes, causing the UI to revert to the previous
model selection. This was most visible in the StatusBar model indicator
not reflecting the newly selected model.

Changes:
- Add protection timestamps to apiConfiguration and extensionMode atoms
- Skip extension state updates that arrive within 60s of a local change
- Directly update UI atoms when selecting providers for immediate feedback
- Call loadApiConfiguration to ensure extension activates the new profile
- Clear current task after provider change so new tasks use new config
@changeset-bot
Copy link

changeset-bot bot commented Dec 3, 2025

🦋 Changeset detected

Latest commit: fdbc205

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@kilocode/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@omniwired
Copy link
Contributor Author

BEFORE ( check the problem of the model and provider switching back by itself)

before.mp4

AFTER the fix

after.mp4

cc: @iscekic

@marius-kilocode
Copy link
Contributor

Hi @omniwired,

thanks for the contribution. I will look into it!

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