Repository navigation
fix(agent): follow server model switches via session.model.selected - #508
Merged
Merged
Conversation
Contributor
that sounds like an upstream bug to me. did you check if any issues exist? |
|
U have available to sarvice in |
jensenojs
force-pushed
the
feat/sync-model-from-server
branch
from
October 14, 2026 06:21
183bcc3 to
3c8322b
Compare
jensenojs
force-pushed
the
feat/sync-model-from-server
branch
from
October 14, 2026 07:03
3c8322b to
ea23d9e
Compare
jensenojs
marked this pull request as ready for review
October 14, 2026 07:06
Collaborator
Author
Yes — upstream fixed this in 2.0.22. we just subscribes to that event now, no workaround needed. Thanks! |
This was referenced Oct 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
An attached nvim client can go stale: switching the model or variant in the TUI (or any other client sharing the server) while the panel is closed or unfocused leaves nvim showing the old selection forever.
Upstream now broadcasts switches as
session.model.selectedon/api/event(added in #52499, first released with 2.0.22; verified live on 2.0.28). On older servers (<=2.0.21) the event stream is completely silent at switch time — verified by watching it while switching — so pollingGET /api/session/{id}was the only channel then.Approach
OpencodeEvent:session.model.selected(the v2 observation layer already re-emits every server event as an autocmd). Switches for the active session apply live via a sharedapply_server_selection— same entry point used by the GET path.sync_from_server()once to converge state that drifted while the client was not attached (events are incremental; the opening GET closes the gap).Verification
./run_tests.shgreen;stylua --checkclean. New unit tests coverapply_server_selection(V1/V2 model shapes, variant presence, incomplete refs).