diff --git a/src/renderer/src/components/skills/SkillInstallDialog.test.tsx b/src/renderer/src/components/skills/SkillInstallDialog.test.tsx index 5c13dc42736..fbd40bd31e7 100644 --- a/src/renderer/src/components/skills/SkillInstallDialog.test.tsx +++ b/src/renderer/src/components/skills/SkillInstallDialog.test.tsx @@ -145,4 +145,32 @@ describe('SkillInstallDialog', () => { ) expect(skills.installShare).not.toHaveBeenCalled() }) + + it('keeps asking for review when the updated link can no longer be resolved', async () => { + const skills = installApi( + vi.fn().mockResolvedValue({ + status: 'ok', + value: { + name: 'private-skill', + packageDigest: DIGEST, + destinationIdentity: 'local:global', + currentState: 'absent', + providers: [] + } + }) + ) + skills.installShare.mockResolvedValue({ status: 'version-changed' }) + Object.defineProperty(window, 'api', { configurable: true, value: { skills } }) + render( undefined} />) + await inspectSkill() + + fireEvent.click(screen.getByRole('button', { name: 'Install skill' })) + await screen.findByText('private-skill was updated. Review it again.') + skills.resolveShare.mockResolvedValue({ status: 'reconnect-required' }) + fireEvent.click(screen.getByRole('button', { name: 'Review again' })) + + expect((await screen.findByRole('alert')).textContent).toContain('This share is unavailable') + expect(screen.getByText('private-skill was updated. Review it again.')).toBeTruthy() + expect(screen.queryByRole('button', { name: 'Install skill' })).toBeNull() + }) }) diff --git a/src/renderer/src/components/skills/SkillInstallDialog.tsx b/src/renderer/src/components/skills/SkillInstallDialog.tsx index c07d9f8880a..882db1bb4a1 100644 --- a/src/renderer/src/components/skills/SkillInstallDialog.tsx +++ b/src/renderer/src/components/skills/SkillInstallDialog.tsx @@ -106,8 +106,6 @@ export function SkillInstallDialog({ setResult(null) try { const operation = await resolveSkillShareForInstall(shareId) - setVersionChanged(false) - setDestinationPreview(null) if (operation.status !== 'ok') { setError( operation.status === 'unconfigured' @@ -119,6 +117,9 @@ export function SkillInstallDialog({ ) return } + // Only a successful re-resolve leaves the updated state; a failure keeps it, so the stale review never returns. + setVersionChanged(false) + setDestinationPreview(null) setPreview({ shareId, version: operation.value.version }) } catch (cause) { console.warn('[skills] share resolution failed:', cause) @@ -363,7 +364,7 @@ export function SkillInstallDialog({ )} - {!bundleVersion && error ? ( + {(!bundleVersion || versionChanged) && error ? (

{error}

diff --git a/src/renderer/src/components/skills/SkillSharedLinkRow.tsx b/src/renderer/src/components/skills/SkillSharedLinkRow.tsx index cbc2e778f10..7a938b3b8a9 100644 --- a/src/renderer/src/components/skills/SkillSharedLinkRow.tsx +++ b/src/renderer/src/components/skills/SkillSharedLinkRow.tsx @@ -72,6 +72,7 @@ export function SkillSharedLinkRow({ share, olderShares = NO_SHARES, busy, + stopsDisabled = false, onRevoke, onRevokeLinks, onDeleted @@ -79,6 +80,8 @@ export function SkillSharedLinkRow({ share: SkillCloudOwnedShare olderShares?: SkillCloudOwnedShare[] busy: boolean + /** Another link's stop is running; stops wait for it. */ + stopsDisabled?: boolean onRevoke: () => void onRevokeLinks?: (links: SkillCloudOwnedShare[]) => void onDeleted: () => void @@ -166,7 +169,7 @@ export function SkillSharedLinkRow({ className="shrink-0" // The icon unmounts on confirmation; explicitly transfer keyboard focus to its replacement. autoFocus - disabled={busy || deleting} + disabled={busy || stopsDisabled || deleting} onClick={() => (confirming === 'revoke' ? onRevoke() : void deletePackage())} > {busy || deleting ? : null} @@ -183,7 +186,7 @@ export function SkillSharedLinkRow({ size="icon-sm" variant="ghost" className="shrink-0 text-muted-foreground hover:text-destructive" - disabled={busy} + disabled={busy || stopsDisabled} onClick={() => setConfirming('revoke')} aria-label={t( 'auto.components.settings.shareSkills.stopSharing', @@ -204,7 +207,7 @@ export function SkillSharedLinkRow({ size="icon-sm" variant="ghost" className="shrink-0" - disabled={busy} + disabled={busy || stopsDisabled} aria-label={t( 'auto.components.skills.SkillSharedLinkRow.moreActions', 'More actions for {{name}}', @@ -260,6 +263,7 @@ export function SkillSharedLinkRow({ share={share} olderShares={olderShares} busy={busy} + disabled={busy || stopsDisabled} onRevokeLinks={onRevokeLinks} /> ) : null} diff --git a/src/renderer/src/components/skills/SkillSharedLinksView.test.tsx b/src/renderer/src/components/skills/SkillSharedLinksView.test.tsx index 612e8140c77..ebb7ff8b83f 100644 --- a/src/renderer/src/components/skills/SkillSharedLinksView.test.tsx +++ b/src/renderer/src/components/skills/SkillSharedLinksView.test.tsx @@ -69,3 +69,50 @@ it('keeps the row disabled until Stop all has stopped every link', async () => { await act(async () => releaseOlder1()) await waitFor(() => expect([...live]).toEqual([])) }) + +it('holds every row while one stop runs so two stops cannot race', async () => { + const shares = ['alpha', 'beta'].map((id) => ({ + id, + packageId: `pkg_${id}`, + name: id, + description: '', + url: `https://share.onorca.dev/skills/share/${id}`, + createdAt: '2026-11-08T00:00:00.000Z', + canonical: true, + pinnedVersionId: 'v1' + })) + let releaseAlpha!: () => void + const alphaHeld = new Promise((resolve) => { + releaseAlpha = resolve + }) + const revokeShare = vi.fn(async (id: string) => { + if (id === 'alpha') { + await alphaHeld + } + return { status: 'ok' } + }) + Object.defineProperty(window, 'api', { + configurable: true, + value: { + skills: { + listOwnedShares: vi.fn().mockResolvedValue({ status: 'ok', value: shares }), + revokeShare + } + } + }) + render() + + const [alphaStop] = await screen.findAllByRole('button', { name: 'Stop sharing' }) + fireEvent.click(alphaStop!) + fireEvent.click(screen.getByRole('button', { name: 'Confirm stop' })) + await waitFor(() => expect(revokeShare).toHaveBeenCalledWith('alpha')) + + for (const button of screen.getAllByRole('button', { name: 'Stop sharing' })) { + expect(button).toHaveProperty('disabled', true) + } + await act(async () => releaseAlpha()) + await waitFor(() => + expect(screen.getAllByRole('button', { name: 'Stop sharing' })).toHaveLength(1) + ) + expect(screen.getByRole('button', { name: 'Stop sharing' })).toHaveProperty('disabled', false) +}) diff --git a/src/renderer/src/components/skills/SkillSharedLinksView.tsx b/src/renderer/src/components/skills/SkillSharedLinksView.tsx index 5b94cbcfc4e..c600ab0f5e9 100644 --- a/src/renderer/src/components/skills/SkillSharedLinksView.tsx +++ b/src/renderer/src/components/skills/SkillSharedLinksView.tsx @@ -71,6 +71,7 @@ export function SkillSharedLinksView({ share={share} olderShares={olderShares} busy={busyPackageId === share.packageId} + stopsDisabled={busyPackageId !== null} onRevoke={() => void revoke(share)} onRevokeLinks={(links) => void revokeMany(links)} onDeleted={refresh} diff --git a/src/renderer/src/components/skills/SkillSharedOlderLinks.tsx b/src/renderer/src/components/skills/SkillSharedOlderLinks.tsx index e1429c35d45..5a00a2a554d 100644 --- a/src/renderer/src/components/skills/SkillSharedOlderLinks.tsx +++ b/src/renderer/src/components/skills/SkillSharedOlderLinks.tsx @@ -9,11 +9,13 @@ export function SkillSharedOlderLinks({ share, olderShares, busy, + disabled, onRevokeLinks }: { share: SkillCloudOwnedShare olderShares: SkillCloudOwnedShare[] busy: boolean + disabled: boolean onRevokeLinks: (links: SkillCloudOwnedShare[]) => void }): React.JSX.Element { const t = useTranslate() @@ -45,7 +47,7 @@ export function SkillSharedOlderLinks({ type="button" size="xs" variant={confirming === older.id ? 'destructive' : 'ghost'} - disabled={busy} + disabled={disabled} onClick={() => stop(older.id, [older])} > {stopLabel(older.id)} @@ -57,7 +59,7 @@ export function SkillSharedOlderLinks({ type="button" size="xs" variant={confirming === 'all' ? 'destructive' : 'outline'} - disabled={busy} + disabled={disabled} onClick={() => stop('all', [share, ...olderShares])} > {busy ? : null} diff --git a/src/renderer/src/components/skills/use-owned-skill-shares.ts b/src/renderer/src/components/skills/use-owned-skill-shares.ts index dab8031d791..e8d87317635 100644 --- a/src/renderer/src/components/skills/use-owned-skill-shares.ts +++ b/src/renderer/src/components/skills/use-owned-skill-shares.ts @@ -19,7 +19,7 @@ export type OwnedSkillShares = { shares: SkillCloudOwnedShare[] loading: boolean error: string | null - /** Package whose links are being stopped; its row stays busy until every stop settles. */ + /** Package whose links are being stopped; one stop runs at a time, so every row waits for it. */ busyPackageId: string | null refresh: () => void revoke: (share: SkillCloudOwnedShare) => Promise @@ -33,6 +33,7 @@ export function useOwnedSkillShares(): OwnedSkillShares { const [busyPackageId, setBusyPackageId] = useState(null) const [error, setError] = useState(null) const generation = useRef(0) + const revoking = useRef(false) const load = useCallback(async (): Promise => { const current = ++generation.current @@ -67,6 +68,11 @@ export function useOwnedSkillShares(): OwnedSkillShares { }, [load]) const revokeMany = useCallback(async (targets: SkillCloudOwnedShare[]): Promise => { + // Why: one shared busy state and error; overlapping stops would clear or overwrite each other's. + if (revoking.current) { + return + } + revoking.current = true setBusyPackageId(targets[0]?.packageId ?? null) setError(null) const stopped = new Set() @@ -89,6 +95,7 @@ export function useOwnedSkillShares(): OwnedSkillShares { // Why: removing rows mid-sequence would change the row's identity and re-enable its stops. setShares((current) => current.filter((candidate) => !stopped.has(candidate.id))) setBusyPackageId(null) + revoking.current = false const live = targets.filter((share) => !stopped.has(share.id)) if (live.length === 0) { toast.success(translate('auto.components.settings.shareSkills.linkRevoked', 'Link revoked'))