Skip to content

Fix selected model mark if ACP doesn't return updated configOptions after a model change#149

Open
ro0gr wants to merge 1 commit intocarlos-algms:mainfrom
ro0gr:bugfix/selected-model
Open

Fix selected model mark if ACP doesn't return updated configOptions after a model change#149
ro0gr wants to merge 1 commit intocarlos-algms:mainfrom
ro0gr:bugfix/selected-model

Conversation

@ro0gr
Copy link

@ro0gr ro0gr commented Mar 13, 2026

Using opencode. The model picker always highlights the default model as the selected one.

Знімок екрана 2026-03-14 о 00 11 52

TODO

  • - test
  • - verify if it works locally

The other UX issue I've noticed is that the selected model can be rendered somewhere in the middle of a long model list. It makes it difficult to figure out which model is currently selected. I'd keep the selected model on top of the list. Let me know, and I can work on it in a follow-up PR.

@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 09ecddbf-0ce6-476b-8683-dab342c7cc1b

📥 Commits

Reviewing files that changed from the base of the PR and between b140d1b and 667459e.

📒 Files selected for processing (2)
  • lua/agentic/session_manager.lua
  • lua/agentic/session_manager.test.lua

📝 Walkthrough

Walkthrough

The pull request adds state synchronization to the model-switching callback handler in SessionManager. When a model change succeeds, the current model ID is now persisted to the legacy state structure, matching the existing pattern used for mode changes. Additionally, comprehensive test coverage is introduced to validate the model selector UI behavior, including verifying that model selections are properly marked, persisted, and restored across reopenings.

Possibly related PRs

Poem

🐰 A model change, smooth and true,
State now syncs in every view,
Tests assert the UI's glow,
Selection marks steal the show! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fix: updating the selected model mark when ACP doesn't return updated configOptions after a model change, matching the core implementation change.
Description check ✅ Passed The description is directly related to the changeset, explaining the problem (model picker highlighting wrong model), including a screenshot, testing status, and mentioning a follow-up improvement.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

Migrating from UI to YAML configuration.

Use the @coderabbitai configuration command in a PR comment to get a dump of all your UI settings in YAML format. You can then edit this YAML file and upload it to the root of your repository to configure CodeRabbit programmatically.

@ro0gr
Copy link
Author

ro0gr commented Mar 13, 2026

Oh.. seems I was too fast to publish this PR. Local testing has failed. I'll keep working on it

Mirror the mode change handler pattern to ensure legacy_agent_models state
is updated when the provider doesn't return updated configOptions.

Also add a happy-path test for modern model change with configOptions
@ro0gr ro0gr force-pushed the bugfix/selected-model branch from c0774d3 to 667459e Compare March 14, 2026 17:42
@ro0gr ro0gr marked this pull request as ready for review March 14, 2026 17:45
Copilot AI review requested due to automatic review settings March 14, 2026 17:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to fix the model picker’s selected-item marking so the currently selected model is correctly indicated after switching models, even when the provider doesn’t return updated configOptions.

Changes:

  • Added SessionManager tests around model selection rendering/marking for both configOptions-backed and legacy model lists.
  • Updated SessionManager:_handle_model_change to persist the selected legacy model id on successful model change.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
lua/agentic/session_manager.lua Updates legacy model selection state after a successful model change.
lua/agentic/session_manager.test.lua Adds tests validating selected-model re-marking on reopen for configOptions and legacy model selectors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Owner

@carlos-algms carlos-algms left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution.
It's nice and simple.

I just have this comment in the tests, lets address it so we can merge.

end)
end)

describe("show_model_selector", function()
Copy link
Owner

Choose a reason for hiding this comment

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

Can we move this test to the dedicated file?

describe("show_model_selector", function()

So we can reduce its scope and avoid mocking too much.

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.

3 participants