Skip to content

fix(settings): give model-provider and plugin rows their own busy guards - #1928

Merged
vastsa merged 4 commits into
vastsa:mainfrom
SeanLiu326:fix/row-busy-models-plugins
Oct 28, 2026
Merged

vastsa merged 4 commits into
vastsa:mainfrom
SeanLiu326:fix/row-busy-models-plugins

Conversation

@SeanLiu326

Copy link
Copy Markdown
Contributor

Follow-up to #1881, extending the same per-row busy guard to the two remaining settings surfaces that still run row-keyed async operations through single shared slots.

The defects

Models page (apps/desktop/src/components/settings/ModelConfigPage.tsx): toggleEnabled, removeProvider and saveProviderKey set one shared busyId slot with no entry guard at all and an unconditional finally setBusyId(null); testProvider shares the testingId slot the same way. Interleaving two rows: whichever request settles first clears the other row's guard mid-flight, so a second click double-fires the host write from an optimistically flipped state. The list-wide busy gate additionally froze every row for any one row's operation — the opposite trade of what #1881 pinned for the capability pages.

Plugins page (apps/desktop/src/features/plugins/usePluginsPage.ts): confirmReview, runInstall and reloadPlugin share the single busyId/reloadingId slots with unconditional finally clears — the exact shape #1880 described for the capability pages.

The fix

Both pages claim one independent key per row through the use-row-busy guard #1881 introduced:

  • Models page: the four operations above begin/end their own provider id; the list-wide busy gate keeps only its modal-dialog terms (setupFor, editingAccountId, busyAccountId, savingAccount, login), and isRowBusy reads the per-row predicate.
  • Plugins page: the three operations begin/end their own plugin id; the page model exposes isPluginBusy(id) instead of the removed busyId slot, and the four surfaces (InstalledPluginsPanel, MarketplacePanel, PluginDetailSheet, PluginDialogs) read the predicate.

reloadingId stays as a display flag (spinner state) but its guard job moves to the row key, so a settled reload cannot re-arm a plugin still loading.

Tests

apps/desktop/test/row-busy-pages.test.mjs (new): every listed operation must claim its row before the first await and release it in a finally; the busyId slot must be gone from both pages; the plugin surfaces must consume the predicate. Plus the existing row-busy-guard unit tests. 6/6 pass locally.

@SeanLiu326
SeanLiu326 force-pushed the fix/row-busy-models-plugins branch from a7025d4 to 35ff383 Compare October 27, 2026 17:06
The models page and the plugins page ran their row-keyed async operations
through single shared busy slots — busyId, testingId and reloadingId —
with unconditional finally clears and, on the models page, no entry guard
at all. The first request to settle re-armed every row still in flight
(a second click double-fires the host write from an optimistically
flipped state), and the models list-wide busy gate froze all rows for
one row's operation.

Both pages now claim one independent key per row through the use-row-busy
guard introduced for the capability pages (vastsa#1881): toggleEnabled,
removeProvider, saveProviderKey and testProvider on the models page;
confirmReview, runInstall and reloadPlugin on the plugins page. The
plugins page model exposes isPluginBusy(id) instead of the busyId slot,
and the models list keeps only its modal-dialog terms in the page-wide
gate.
…predicate

plugin-runtime-risk asserted the marketplace/detail install buttons
through the removed single busyId slot; the guard job moved to
isPluginBusy in the parent commit, so the pins follow the predicate.
@SeanLiu326
SeanLiu326 force-pushed the fix/row-busy-models-plugins branch from 35ff383 to da50c3a Compare October 27, 2026 17:07

@muzimu217 muzimu217 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The guard conversion is right: useRowBusy is the hook #1881 already established, begin runs before any await and rejects a second click on the same row, and every finally releases the same key it claimed. Reusing the existing hook instead of a second mechanism is the part that makes this reviewable.

One defect remains, and it only becomes visible because this fix works.

testProvider now guards with rowBusy.begin(provider.id) but still drives the spinner through the single testingId slot (ModelConfigPage.tsx, the setTestingId(provider.id) / finally setTestingId(null) pair). Before this change the shared slot also gated every other row through isRowBusy, so two tests could never overlap and the single slot was unobservable. Now that two rows can be tested concurrently:

  • testing A, then B → testingId becomes B and A's spinner disappears while A is still running;
  • whichever finishes first runs setTestingId(null) and clears the other row's spinner mid-flight.

The guard is correct, so this is not a double-fire, but the indicator now lies about which rows are in flight. Making it a Set<string> (or a Record<string, boolean> keyed by provider id, with add/delete in begin/end) fixes it with the same shape as the guard.

Two confirmations rather than requests:

  • Dropping testingId !== null from the list-wide busy expression is the intended trade: other rows stay interactive during a test, and a second click on the same row is rejected by begin. Worth a line in the description so a reviewer does not read it as a regression.
  • busyAccountId staying a single shared slot is fine as long as account-level operations are deliberately serialized across the page; if two accounts can authenticate at once, it has the same problem as testingId did.

Track active provider tests by row so one settled request cannot clear another row's in-flight indicator. Cover the page-to-list wiring with a regression check.
@vastsa
vastsa merged commit feaf61a into vastsa:main Oct 28, 2026
6 checks passed

This branch was previously deployed

1 inactive deployment
Preview — 1dae233b Deployed Oct 28, 2026 by vercel[bot]
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