Repository navigation
fix(session): models that load after the first read show up without reopening - #78
Merged
Merged
Conversation
…eopening The server changes its model, provider and agent catalogs after the app reads them: plugins finish loading after a cold start, and config edits, plugin installs and logins change them too. It announces each change with `model.updated`, `provider.updated` or `agent.updated`, but the app dropped those events, and a session screen read its model catalog once. A model from a plugin that loaded late never appeared in the picker until the session was reopened, and the 30 s catalog cache could hand back the partial list even then. Now `model.updated` and `provider.updated` decode to `ModelsChanged`, which forgets the server's cached model catalogs and makes every open session screen reread its catalog through `reloadModels` (cancelling a read in flight, so a burst leaves one read standing). `agent.updated` decodes to `AgentsChanged`, which lists the agents again while Agent Selection is on. The parity rows note the difference from iOS. Verified: scripts/check.sh :server :feature:session :feature:drawer (assembleDebug, lintDebug, testDebugUnitTest) passes; new tests cover the decoding, the cache, the model reread replacing a partial list after a cancelled read, and the agents relist.
Merged
This branch was previously deployed
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.
The server changes its model, provider and agent lists after the app reads them. Plugins finish loading after a cold start, and config edits, plugin installs and logins change the lists too. The server announces each change on the event stream (
model.updated,provider.updated,agent.updated), but the app dropped those events. A session screen read its model list once and only read it again after a failure or when it was empty.Before: a model from a plugin that finished loading late never appeared in the model picker until the session was reopened. Even then, the 30 s catalog cache could return the partial list.
After: the open session screen reads the model list again when the server says it changed. A partial list is replaced by the full one, without reopening anything.
What changed
model.updatedandprovider.updateddecode toOpenCodeServerEvent.ModelsChanged, andagent.updateddecodes toAgentsChanged. The payloads aren't read.ModelsChangedclears that server's cached model lists (OpenCodeReadCache.forgetModelCatalogs) before the event reaches the reducers, so the next read goes to the server.ModelsChangedrereads the list through the existingreloadModels, which cancels a read in flight, so a burst of events while plugins load leaves one read standing.AgentsChangedlists the agents again while Agent Selection is on.docs/parity/server.md,session.mdanddrawer.mdnote that this differs from iOS on purpose.This pairs with anomalyco/opencode#63814, where the server stops waiting for plugins before answering
/api/model. After that change, the first read on a cold server can return a partial list. That PR should merge after this one ships.Verified
scripts/check.sh :server :feature:session :feature:drawer(assembleDebug, lintDebug, testDebugUnitTest) passes: 337 server tests (2 skipped live checks), 812 session tests, 558 drawer tests.OpenCodeEventDecodingTests.catalogUpdatesDecodeAsCatalogChanges: the three events decode, with or withoutlocationanddata. This replaces the old check thatmodel.updatedandprovider.updateddecode to null.OpenCodeClientDecodingTests.forgettingModelCatalogsDropsOnlyThatServersCatalogsModelPickerTests.aCatalogChangeRereadsModelsAndReplacesAPartialList: a second change cancels the hung first read, and the answer replaces the partial list.SessionFeatureTestsAgentSelection.anAgentsChangeListsAgentsAgain