Repository navigation
fix(settings): give model-provider and plugin rows their own busy guards - #1928
Conversation
a7025d4 to
35ff383
Compare
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.
35ff383 to
da50c3a
Compare
muzimu217
left a comment
There was a problem hiding this comment.
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 →
testingIdbecomes 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 !== nullfrom the list-widebusyexpression is the intended trade: other rows stay interactive during a test, and a second click on the same row is rejected bybegin. Worth a line in the description so a reviewer does not read it as a regression. busyAccountIdstaying 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 astestingIddid.
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.
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,removeProviderandsaveProviderKeyset one sharedbusyIdslot with no entry guard at all and an unconditionalfinally setBusyId(null);testProvidershares thetestingIdslot 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-widebusygate 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,runInstallandreloadPluginshare the singlebusyId/reloadingIdslots 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-busyguard #1881 introduced:busygate keeps only its modal-dialog terms (setupFor,editingAccountId,busyAccountId,savingAccount,login), andisRowBusyreads the per-row predicate.isPluginBusy(id)instead of the removedbusyIdslot, and the four surfaces (InstalledPluginsPanel,MarketplacePanel,PluginDetailSheet,PluginDialogs) read the predicate.reloadingIdstays 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 afinally; thebusyIdslot must be gone from both pages; the plugin surfaces must consume the predicate. Plus the existingrow-busy-guardunit tests. 6/6 pass locally.