From 4b6fec774d01748fac8bba12c73cc9311d49c740 Mon Sep 17 00:00:00 2001 From: Isaac Sanchez-Hawkins <266845420+isanchez404@users.noreply.github.com> Date: Fri, 8 May 2026 09:11:26 -0400 Subject: [PATCH] fix(skills): ignore stale repo scans (#1158) * fix(skills): ignore stale repo scans * fix(skills): clear stale repo identity --------- Co-authored-by: Isaac Sanchez --- .../skills/catalog/InstallFromRepoDialog.tsx | 39 +++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/components/sections/skills/catalog/InstallFromRepoDialog.tsx b/packages/ui/src/components/sections/skills/catalog/InstallFromRepoDialog.tsx index 728dbb87..d6b97712 100644 --- a/packages/ui/src/components/sections/skills/catalog/InstallFromRepoDialog.tsx +++ b/packages/ui/src/components/sections/skills/catalog/InstallFromRepoDialog.tsx @@ -69,6 +69,17 @@ export const InstallFromRepoDialog: React.FC = ({ op const [identities, setIdentities] = React.useState([]); const [gitIdentityId, setGitIdentityId] = React.useState(null); + const scanRequestIdRef = React.useRef(0); + + const invalidateScan = React.useCallback((options?: { clearIdentities?: boolean }) => { + scanRequestIdRef.current += 1; + setItems([]); + setSelected({}); + if (options?.clearIdentities) { + setIdentities([]); + setGitIdentityId(null); + } + }, []); const [conflictsOpen, setConflictsOpen] = React.useState(false); const [conflicts, setConflicts] = React.useState([]); @@ -83,6 +94,7 @@ export const InstallFromRepoDialog: React.FC = ({ op } | null>(null); React.useEffect(() => { + scanRequestIdRef.current += 1; if (!open) return; setSource(''); setSubpath(''); @@ -190,12 +202,21 @@ export const InstallFromRepoDialog: React.FC = ({ op return; } + setItems([]); + setSelected({}); + const requestId = scanRequestIdRef.current + 1; + scanRequestIdRef.current = requestId; + const result = await scanRepo({ source: trimmed, subpath: subpath.trim() || undefined, gitIdentityId: gitIdentityId || undefined, }); + if (scanRequestIdRef.current !== requestId) { + return; + } + if (!result.ok) { if (result.error?.kind === 'authRequired') { if (isVSCodeRuntime()) { @@ -329,7 +350,10 @@ export const InstallFromRepoDialog: React.FC = ({ op
setSource(e.target.value)} + onChange={(e) => { + setSource(e.target.value); + invalidateScan({ clearIdentities: true }); + }} placeholder={t('settings.skills.catalog.shared.field.repositoryPlaceholder')} className="text-foreground placeholder:text-muted-foreground" /> @@ -357,7 +381,10 @@ export const InstallFromRepoDialog: React.FC = ({ op setSubpath(e.target.value)} + onChange={(e) => { + setSubpath(e.target.value); + invalidateScan({ clearIdentities: true }); + }} placeholder={t('settings.skills.catalog.shared.field.subpathPlaceholder')} className="text-foreground placeholder:text-muted-foreground" /> @@ -429,7 +456,13 @@ export const InstallFromRepoDialog: React.FC = ({ op {t('settings.skills.catalog.installFromRepo.authDescription')}
- { + setGitIdentityId(v); + invalidateScan(); + }} + > {identities.find((i) => i.id === gitIdentityId)?.name || t('settings.skills.catalog.shared.auth.chooseIdentity')}