Skip to content

client: Refresh cloud models on websocket reconnect#57528

Merged
tomhoule merged 1 commit into
mainfrom
tomhoule-wpzkkwmrsytp
May 27, 2026
Merged

client: Refresh cloud models on websocket reconnect#57528
tomhoule merged 1 commit into
mainfrom
tomhoule-wpzkkwmrsytp

Conversation

@tomhoule

@tomhoule tomhoule commented May 22, 2026

Copy link
Copy Markdown
Contributor

Until now, the cloud-hosted model list was only refreshed in response to events that exercise the LLM token (a UserUpdated push, an organization change, or PrivateUserInfoUpdated). If a user wasn't actively using AI features around the time we shipped new models, the list could stay stale until they restarted Zed.

This is the second step toward fixing that, after #57078 made the cloud websocket reconnect on its own. We now treat each successful (re)connect as a hint that the server state may have changed, so possibly new model definitions will be available, and trigger a model list refresh.

The trigger is a new Client::cloud_connection_id() watch that bumps a counter each time the websocket handshake completes. CloudLanguageModelProvider::State subscribes to it and, on every tick after the initial 0, schedules a debounced refresh (with jitter, so we don't have all active clients trying to reconnect at the same time after we deploy in cloud).

Closes CLO-713.

Release Notes:

  • The list of Zed hosted models is now refreshed automatically, without requiring a restart

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 22, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label May 22, 2026
@tomhoule tomhoule force-pushed the tomhoule-wpzkkwmrsytp branch 2 times, most recently from 30726c1 to 56173cd Compare May 26, 2026 08:54
Until now, the cloud-hosted model list was only refreshed in response to events that exercise the LLM token (a `UserUpdated` push, an organization change, or `PrivateUserInfoUpdated`). If a user wasn't actively using AI features around the time we shipped new models, the list could stay stale until they restarted Zed.

This is the second step toward fixing that, after #57078 made the cloud websocket reconnect on its own. We now treat each successful (re)connect as a hint that the server state may have changed, so possibly new model definitions will be available, and trigger a model list refresh.

The trigger is a new `Client::cloud_connection_id()` watch that bumps a counter each time the websocket handshake completes. `CloudLanguageModelProvider::State` subscribes to it and, on every tick after the initial `0`, schedules a debounced refresh. The debounce is trailing-edge with a 5-minute window plus up to 5 minutes of uniform jitter, so a burst of reconnects (rolling deploy, flaky network) coalesces into a single refresh once things have been quiet, and we avoid thundering herd issues from many clients reconnecting at the same time.

Closes CLO-713.

Release Notes:

- The list of Zed managed models is now refreshed automatically, without requiring a restart
@tomhoule tomhoule force-pushed the tomhoule-wpzkkwmrsytp branch from 56173cd to fb3f4ac Compare May 26, 2026 14:44
@tomhoule tomhoule marked this pull request as ready for review May 26, 2026 14:45
///
/// Each reconnect resets the timer (trailing-edge debounce), so a burst of reconnects
/// only triggers a single refresh after things have been quiet for this duration.
const MODELS_REFRESH_DEBOUNCE: Duration = Duration::from_secs(5 * 60);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a very generous debounce (and we re-jitter up to that, so we could wait up to 10 minutes before refreshing). The idea is to avoid spamming model refreshes on clients with patchy connections.

@tomhoule tomhoule added this pull request to the merge queue May 27, 2026
Merged via the queue into main with commit 32f2593 May 27, 2026
32 checks passed
@tomhoule tomhoule deleted the tomhoule-wpzkkwmrsytp branch May 27, 2026 16:42
TomPlanche pushed a commit to TomPlanche/zed that referenced this pull request Jun 2, 2026
…7528)

Until now, the cloud-hosted model list was only refreshed in response to
events that exercise the LLM token (a `UserUpdated` push, an
organization change, or `PrivateUserInfoUpdated`). If a user wasn't
actively using AI features around the time we shipped new models, the
list could stay stale until they restarted Zed.

This is the second step toward fixing that, after zed-industries#57078 made the cloud
websocket reconnect on its own. We now treat each successful (re)connect
as a hint that the server state may have changed, so possibly new model
definitions will be available, and trigger a model list refresh.

The trigger is a new `Client::cloud_connection_id()` watch that bumps a
counter each time the websocket handshake completes.
`CloudLanguageModelProvider::State` subscribes to it and, on every tick
after the initial `0`, schedules a debounced refresh (with jitter, so we
don't have all active clients trying to reconnect at the same time after
we deploy in cloud).

Closes CLO-713.

Release Notes:

- The list of Zed hosted models is now refreshed automatically, without
requiring a restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants