You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(agent-cli-update): drop update groups for hosts that were removed - #48517
The status bar's CLI updates list kept showing a server after you removed it (or re-paired that slot to a different server), until the window reloaded. Now a removed server drops off the list right away.
Files
Added
Deleted
Net
Test
1
$\color{#1a7f37}{\Huge{\mathbf{+}}}$83
$\color{#cf222e}{\Huge{\mathbf{−}}}$2
$\color{#1a7f37}{\Huge{\mathbf{+}}}$81
Prod
3
$\color{#1a7f37}{\Huge{\mathbf{+}}}$31
$\color{#cf222e}{\Huge{\mathbf{−}}}$3
$\color{#1a7f37}{\Huge{\mathbf{+}}}$28
What Changed
Before: the agentCliUpdates store slice only ever added hosts. Removing a paired server, or re-pairing the same environment id to another peer, left its group in the CLI updates popover. An answer or run result from the old host that arrived later could also put it back.
After: when setRuntimeEnvironments retires environment ids (removed, or a same-id re-pair), it calls the new forgetAgentCliUpdateHosts(ids). This runs next to the other per-host purges (purgeStaleRuntimeHostState, clearHostWorkspaceStatuses). It:
deletes those hosts' entries from agentCliUpdates, and returns the same state when nothing changed, so there's no re-render;
clears their check timestamps and in-flight checks, so a re-paired peer gets asked again instead of reusing the old peer's pending promise;
stops late results from adding the host back. An in-flight check only writes if it is still the current check for that key, and writeHost ignores ids listed in removedRuntimeEnvironmentIds, so a late runAgentCliUpdate result can't re-add a removed host either.
A host that is disconnected but still configured keeps its entry. This computer ('' key) is never touched.
Why
Hooking into the existing retirement point in setRuntimeEnvironments reuses the same signal every other per-host cache already uses. It needs no polling, no new RPCs and no new subscriptions.
This is a partial fix. The issue's other half, asking paired servers that are used only through terminals (servers this window never asked), is still open and needs a separate change.
N/A. This is a store-level change: an entry leaves the popover once its environment is removed. Showing it needs two paired remote servers and a GUI run, which aren't available for this landing step. The behavior is covered by the store tests below, which drive the same setRuntimeEnvironments path the UI uses.
Testing
pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/store/slices/runtime-host-updates/: 4/4 pass.
The 2 new tests fail when the source change is reverted and the tests are kept. Without the fix the removed host stays in the map, and the old peer's late answer overwrites the re-paired one.
drops removed hosts and their late answers and run results, keeping this computer and remaining hosts
asks a re-paired peer afresh and drops the old peer answer that arrives late
pnpm run tc:web, oxlint, oxfmt, anti-slop, code-quality native plugins, ast-grep and check-changed-code-quality.mjs all pass on the touched files.
Platform: macOS (unit and store level). The logic has no platform-specific paths.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Performance
None. forgetAgentCliUpdateHosts runs only when setRuntimeEnvironments retires ids, which is rare (the user removes or re-pairs a server). The writeHost guard is one Set.has. Micro-benchmark (Node, 20k iterations): writeHost 0.139 µs old vs 0.124 µs new with 3 hosts, and 28.6 µs vs 27.8 µs with 1000 hosts (within noise). Forgetting 1 of 1000 hosts takes 27 µs, and forgetting all 1000 takes 51 µs, far under a 16 ms frame. There is no new polling, I/O, subprocess or RPC work.
Risk
Level: Low
Renderer store only. The worst case is that a host's update group disappears when it shouldn't, and it comes back on the next check. Only retired ids are dropped, and a disconnected but still-configured host is kept. Nothing changes over the wire, so older paired servers are unaffected. Back out with a plain revert.
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
A removed or re-paired server stayed in the status bar CLI updates list
until reload, because nothing told the agentCliUpdates slice when an
environment was retired. setRuntimeEnvironments now calls
forgetAgentCliUpdateHosts with the retired ids (removed, or a same-id
re-pair to another peer), next to the other per-host purges. It drops
their entries, check times and in-flight checks, so a late answer,
failure or run result from the old host can't list it again. A recheck
still pending for a removed host asks nothing, because its runtime
status was purged with it. A disconnected but still-configured host
keeps its entry. No polling or new RPCs.
Tests use the shared publicRuntimeEnvironment and agentCliUpdateHostTarget
fixtures, and cover a failed run result that resolves after its host is
removed.
Refs #48464 (asking paired hosts the list never asked stays open)
When runtime environments are removed or replaced, the runtime status slice now clears agent CLI update state for those hosts. The update slice ignores writes for removed hosts and applies check results only when the request is still current. Tests cover removal, late results, and peer re-pairing.
Merge Risk: Moderate · up to ae6cf
Removed paired servers now drop out of the CLI update status promptly. When a server ID is re-paired to a different peer, a late result from the old peer's update run can still overwrite the new peer's state and allow a second update to start. A queued refresh can also be dropped. Both gaps should be fixed before merge.
Pre-merge checks: 3 · 1
Failed checks: 1 inconclusive
Check name
Status
Explanation
Resolution
Description check
The description follows the template well. It covers ELI5, What Changed (before and after with mechanism), Why (including why this hook and that the fix is partial), Linked Issue (Refs #48464, not Fix…
Confirm whether the author is a stablyai maintainer. If not, link an actual issue with 'Fixes #' instead of 'Refs #48464'. Fill in or mark the AI Disclosure section. Mark the Review section if it applies. Run pnpm lint, pnpm typecheck, pnpm…
Passed checks: 3 passed
Check name
Status
Explanation
Title check
The title names the main change: removing CLI update groups for hosts that were removed. The change clears the agentCliUpdates entries, check timestamps, and in-flight checks for retired runtime envir…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: removing CLI update groups for hosts that were removed. The change clears the agentCliUpdates entries, check timestamps, and in-flight checks for retired runtime environments. The title uses the fix prefix and a specific scope, and it matches the changeset.
Full details: Description check
Explanation
The description follows the template well. It covers ELI5, What Changed (before and after with mechanism), Why (including why this hook and that the fix is partial), Linked Issue (Refs #48464, not Fixes), Visual Proof (N/A with reason), Testing with named tests and platform, Performance with measurements, Risk with level and back-out, and the Agent skill boundary checkbox. Gaps: the template asks for a Linked Issue with 'Fixes #', but the author used 'Refs #' and the template says Refs is not sufficient for outside contributors. The AI Disclosure and Review sections are left blank or unaddressed. The 'pnpm lint, typecheck, test, build' checkbox is unchecked, and the author did not report full runs of those commands. The author should confirm whether the contributor is a maintainer, since that changes the linked-issue requirement.
Resolution
Confirm whether the author is a stablyai maintainer. If not, link an actual issue with 'Fixes #' instead of 'Refs #48464'. Fill in or mark the AI Disclosure section. Mark the Review section if it applies. Run pnpm lint, pnpm typecheck, pnpm test, and pnpm build, or state that CI will cover them, and update the checklist to match. The Testing section also reports platform as macOS only, which the template asks the author to state explicitly, so this is already covered.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Major · Stability & Availability · Quick win
Fence run completions against same-ID peer replacement.
If peer A has a pending run when its environment ID is re-paired to B, cleanup removes A's running marker. B can then start a run under the same ID. Because that ID is not tombstoned, A's completion still passes this guard.
A's failure overwrites B's running marker with failed. A's success removes B's running marker and update. Either path permits another B run while B's first run is pending. A transport rejection also reaches the failure write.
Capture a host-incarnation token when each run starts. Invalidate that token in forgetAgentCliUpdateHosts, and check it before either completion write. Preserve normal completion for an unchanged host.
Based on learnings, delayed writes need an identity check when an ID can be reused.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Clear queued rechecks when a host is forgotten, and stop stale rechecks from changing the replacement host's tracking.
forgetAgentCliUpdateHosts removes checkedAt and checks for a retired environment ID, but leaves rechecking set. If a recheck was queued for the old peer, the replacement peer's recheck returns at the rechecking.has(key) guard and is dropped. When the old check settles first, its continuation calls checkAgentCliUpdates. That call joins the replacement check that is still pending, so no check runs after the replacement's answer. An update finished on the replacement can stay out of the status bar until another check runs.
Forgetting a host should also clear its queued recheck. The recheck continuation should run only while it still owns the key, using the same identity check as the check callbacks.
…#48517)
A removed or re-paired server stayed in the status bar CLI updates list
until reload, because nothing told the agentCliUpdates slice when an
environment was retired. setRuntimeEnvironments now calls
forgetAgentCliUpdateHosts with the retired ids (removed, or a same-id
re-pair to another peer), next to the other per-host purges. It drops
their entries, check times and in-flight checks, so a late answer,
failure or run result from the old host can't list it again. A recheck
still pending for a removed host asks nothing, because its runtime
status was purged with it. A disconnected but still-configured host
keeps its entry. No polling or new RPCs.
Tests use the shared publicRuntimeEnvironment and agentCliUpdateHostTarget
fixtures, and cover a failed run result that resolves after its host is
removed.
Refs #48464 (asking paired hosts the list never asked stays open)
…, spawning nothing
Review on stablyai#49232: an automatic agentCliUpdate.check on every connected host
spawns --version for each installed CLI (and a login-shell capture on
SSH/WSL), the pattern decided against in stablyai#48287/stablyai#48517.
The host now keeps each agent's last check answer and serves it for
agentCliUpdate.check with `cached: true`, without resolving, spawning or
fetching anything; an update run drops the agent's answer. Hosts advertise
agent-cli-update.cached.v1, and the renderer reads the cache only from
those (older hosts ignore unknown params and would run a full check), once
per connection. A cached answer never counts as a check, so the next
user-triggered check still asks the host for real.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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
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.
ELI5
The status bar's CLI updates list kept showing a server after you removed it (or re-paired that slot to a different server), until the window reloaded. Now a removed server drops off the list right away.
What Changed
Before: the
agentCliUpdatesstore slice only ever added hosts. Removing a paired server, or re-pairing the same environment id to another peer, left its group in the CLI updates popover. An answer or run result from the old host that arrived later could also put it back.After: when
setRuntimeEnvironmentsretires environment ids (removed, or a same-id re-pair), it calls the newforgetAgentCliUpdateHosts(ids). This runs next to the other per-host purges (purgeStaleRuntimeHostState,clearHostWorkspaceStatuses). It:agentCliUpdates, and returns the same state when nothing changed, so there's no re-render;writeHostignores ids listed inremovedRuntimeEnvironmentIds, so a laterunAgentCliUpdateresult can't re-add a removed host either.A host that is disconnected but still configured keeps its entry. This computer (
''key) is never touched.Why
Hooking into the existing retirement point in
setRuntimeEnvironmentsreuses the same signal every other per-host cache already uses. It needs no polling, no new RPCs and no new subscriptions.This is a partial fix. The issue's other half, asking paired servers that are used only through terminals (servers this window never asked), is still open and needs a separate change.
Linked Issue
Refs #48464
Visual Proof
N/A. This is a store-level change: an entry leaves the popover once its environment is removed. Showing it needs two paired remote servers and a GUI run, which aren't available for this landing step. The behavior is covered by the store tests below, which drive the same
setRuntimeEnvironmentspath the UI uses.Testing
pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/store/slices/runtime-host-updates/: 4/4 pass.The 2 new tests fail when the source change is reverted and the tests are kept. Without the fix the removed host stays in the map, and the old peer's late answer overwrites the re-paired one.
drops removed hosts and their late answers and run results, keeping this computer and remaining hostsasks a re-paired peer afresh and drops the old peer answer that arrives latepnpm run tc:web, oxlint, oxfmt, anti-slop, code-quality native plugins, ast-grep andcheck-changed-code-quality.mjsall pass on the touched files.Platform: macOS (unit and store level). The logic has no platform-specific paths.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Performance
None.
forgetAgentCliUpdateHostsruns only whensetRuntimeEnvironmentsretires ids, which is rare (the user removes or re-pairs a server). ThewriteHostguard is oneSet.has. Micro-benchmark (Node, 20k iterations):writeHost0.139 µs old vs 0.124 µs new with 3 hosts, and 28.6 µs vs 27.8 µs with 1000 hosts (within noise). Forgetting 1 of 1000 hosts takes 27 µs, and forgetting all 1000 takes 51 µs, far under a 16 ms frame. There is no new polling, I/O, subprocess or RPC work.Risk
Level: Low
Renderer store only. The worst case is that a host's update group disappears when it shouldn't, and it comes back on the next check. Only retired ids are dropped, and a disconnected but still-configured host is kept. Nothing changes over the wire, so older paired servers are unaffected. Back out with a plain revert.
Agent skill upstream boundary
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Reported by @mmarabel