fix(skills): ignore stale repo scans (#1158)
* fix(skills): ignore stale repo scans * fix(skills): clear stale repo identity --------- Co-authored-by: Isaac Sanchez <isanchez-hawkins@arize.com>
This commit is contained in:
committed by
GitHub
co-authored by
Isaac Sanchez
parent
088237c606
commit
4b6fec774d
@@ -69,6 +69,17 @@ export const InstallFromRepoDialog: React.FC<InstallFromRepoDialogProps> = ({ op
|
|||||||
|
|
||||||
const [identities, setIdentities] = React.useState<IdentityOption[]>([]);
|
const [identities, setIdentities] = React.useState<IdentityOption[]>([]);
|
||||||
const [gitIdentityId, setGitIdentityId] = React.useState<string | null>(null);
|
const [gitIdentityId, setGitIdentityId] = React.useState<string | null>(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 [conflictsOpen, setConflictsOpen] = React.useState(false);
|
||||||
const [conflicts, setConflicts] = React.useState<SkillConflict[]>([]);
|
const [conflicts, setConflicts] = React.useState<SkillConflict[]>([]);
|
||||||
@@ -83,6 +94,7 @@ export const InstallFromRepoDialog: React.FC<InstallFromRepoDialogProps> = ({ op
|
|||||||
} | null>(null);
|
} | null>(null);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
scanRequestIdRef.current += 1;
|
||||||
if (!open) return;
|
if (!open) return;
|
||||||
setSource('');
|
setSource('');
|
||||||
setSubpath('');
|
setSubpath('');
|
||||||
@@ -190,12 +202,21 @@ export const InstallFromRepoDialog: React.FC<InstallFromRepoDialogProps> = ({ op
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setItems([]);
|
||||||
|
setSelected({});
|
||||||
|
const requestId = scanRequestIdRef.current + 1;
|
||||||
|
scanRequestIdRef.current = requestId;
|
||||||
|
|
||||||
const result = await scanRepo({
|
const result = await scanRepo({
|
||||||
source: trimmed,
|
source: trimmed,
|
||||||
subpath: subpath.trim() || undefined,
|
subpath: subpath.trim() || undefined,
|
||||||
gitIdentityId: gitIdentityId || undefined,
|
gitIdentityId: gitIdentityId || undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (scanRequestIdRef.current !== requestId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!result.ok) {
|
if (!result.ok) {
|
||||||
if (result.error?.kind === 'authRequired') {
|
if (result.error?.kind === 'authRequired') {
|
||||||
if (isVSCodeRuntime()) {
|
if (isVSCodeRuntime()) {
|
||||||
@@ -329,7 +350,10 @@ export const InstallFromRepoDialog: React.FC<InstallFromRepoDialogProps> = ({ op
|
|||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Input
|
<Input
|
||||||
value={source}
|
value={source}
|
||||||
onChange={(e) => setSource(e.target.value)}
|
onChange={(e) => {
|
||||||
|
setSource(e.target.value);
|
||||||
|
invalidateScan({ clearIdentities: true });
|
||||||
|
}}
|
||||||
placeholder={t('settings.skills.catalog.shared.field.repositoryPlaceholder')}
|
placeholder={t('settings.skills.catalog.shared.field.repositoryPlaceholder')}
|
||||||
className="text-foreground placeholder:text-muted-foreground"
|
className="text-foreground placeholder:text-muted-foreground"
|
||||||
/>
|
/>
|
||||||
@@ -357,7 +381,10 @@ export const InstallFromRepoDialog: React.FC<InstallFromRepoDialogProps> = ({ op
|
|||||||
<label className="typography-ui-label font-medium text-foreground">{t('settings.skills.catalog.shared.field.optionalSubpath')}</label>
|
<label className="typography-ui-label font-medium text-foreground">{t('settings.skills.catalog.shared.field.optionalSubpath')}</label>
|
||||||
<Input
|
<Input
|
||||||
value={subpath}
|
value={subpath}
|
||||||
onChange={(e) => setSubpath(e.target.value)}
|
onChange={(e) => {
|
||||||
|
setSubpath(e.target.value);
|
||||||
|
invalidateScan({ clearIdentities: true });
|
||||||
|
}}
|
||||||
placeholder={t('settings.skills.catalog.shared.field.subpathPlaceholder')}
|
placeholder={t('settings.skills.catalog.shared.field.subpathPlaceholder')}
|
||||||
className="text-foreground placeholder:text-muted-foreground"
|
className="text-foreground placeholder:text-muted-foreground"
|
||||||
/>
|
/>
|
||||||
@@ -429,7 +456,13 @@ export const InstallFromRepoDialog: React.FC<InstallFromRepoDialogProps> = ({ op
|
|||||||
{t('settings.skills.catalog.installFromRepo.authDescription')}
|
{t('settings.skills.catalog.installFromRepo.authDescription')}
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-2">
|
<div className="mt-2">
|
||||||
<Select value={gitIdentityId || ''} onValueChange={(v) => setGitIdentityId(v)}>
|
<Select
|
||||||
|
value={gitIdentityId || ''}
|
||||||
|
onValueChange={(v) => {
|
||||||
|
setGitIdentityId(v);
|
||||||
|
invalidateScan();
|
||||||
|
}}
|
||||||
|
>
|
||||||
<SelectTrigger size="lg" className="w-full justify-between">
|
<SelectTrigger size="lg" className="w-full justify-between">
|
||||||
<span>{identities.find((i) => i.id === gitIdentityId)?.name || t('settings.skills.catalog.shared.auth.chooseIdentity')}</span>
|
<span>{identities.find((i) => i.id === gitIdentityId)?.name || t('settings.skills.catalog.shared.auth.chooseIdentity')}</span>
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
|
|||||||
Reference in New Issue
Block a user