fix(team): harden create preflight cleanup
This commit is contained in:
parent
876527a51d
commit
58ff926f4b
2 changed files with 19 additions and 5 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
|
import { execCli } from '@main/utils/childProcess';
|
||||||
import {
|
import {
|
||||||
getClaudeBasePath,
|
getClaudeBasePath,
|
||||||
getMcpConfigsBasePath,
|
getMcpConfigsBasePath,
|
||||||
getMcpServerBasePath,
|
getMcpServerBasePath,
|
||||||
} from '@main/utils/pathDecoder';
|
} from '@main/utils/pathDecoder';
|
||||||
import { execCli } from '@main/utils/childProcess';
|
|
||||||
import { createLogger } from '@shared/utils/logger';
|
import { createLogger } from '@shared/utils/logger';
|
||||||
import { randomUUID } from 'crypto';
|
import { randomUUID } from 'crypto';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
|
|
||||||
|
|
@ -361,6 +361,10 @@ function cancelScheduledIdle(handle: ScheduledIdleHandle | null): void {
|
||||||
window.clearTimeout(handle.id);
|
window.clearTimeout(handle.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isCurrentPrepareGeneration(ref: { current: number }, generation: number): boolean {
|
||||||
|
return ref.current === generation;
|
||||||
|
}
|
||||||
|
|
||||||
export const CreateTeamDialog = ({
|
export const CreateTeamDialog = ({
|
||||||
open,
|
open,
|
||||||
canCreate,
|
canCreate,
|
||||||
|
|
@ -445,6 +449,7 @@ export const CreateTeamDialog = ({
|
||||||
const [prepareChecks, setPrepareChecks] = useState<ProvisioningProviderCheck[]>([]);
|
const [prepareChecks, setPrepareChecks] = useState<ProvisioningProviderCheck[]>([]);
|
||||||
const prepareRequestSeqRef = useRef(0);
|
const prepareRequestSeqRef = useRef(0);
|
||||||
const prepareIdleHandleRef = useRef<ScheduledIdleHandle | null>(null);
|
const prepareIdleHandleRef = useRef<ScheduledIdleHandle | null>(null);
|
||||||
|
const prepareUnmountGenerationRef = useRef(0);
|
||||||
const appliedDefaultProjectPathRef = useRef<string | null>(null);
|
const appliedDefaultProjectPathRef = useRef<string | null>(null);
|
||||||
const lastAutoDescriptionRef = useRef<string | null>(null);
|
const lastAutoDescriptionRef = useRef<string | null>(null);
|
||||||
const [fieldErrors, setFieldErrors] = useState<{
|
const [fieldErrors, setFieldErrors] = useState<{
|
||||||
|
|
@ -692,11 +697,19 @@ export const CreateTeamDialog = ({
|
||||||
}, [open]);
|
}, [open]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
const generation = ++prepareUnmountGenerationRef.current;
|
||||||
return () => {
|
return () => {
|
||||||
cancelScheduledIdle(prepareIdleHandleRef.current);
|
// React StrictMode replays effect cleanup/setup in development; defer
|
||||||
prepareIdleHandleRef.current = null;
|
// invalidation so the replay does not cancel the live prepare request.
|
||||||
prepareRequestSeqRef.current += 1;
|
queueMicrotask(() => {
|
||||||
lastPrepareRequestSignatureRef.current = null;
|
if (!isCurrentPrepareGeneration(prepareUnmountGenerationRef, generation)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cancelScheduledIdle(prepareIdleHandleRef.current);
|
||||||
|
prepareIdleHandleRef.current = null;
|
||||||
|
prepareRequestSeqRef.current += 1;
|
||||||
|
lastPrepareRequestSignatureRef.current = null;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
@ -1046,6 +1059,7 @@ export const CreateTeamDialog = ({
|
||||||
effectiveMemberDrafts,
|
effectiveMemberDrafts,
|
||||||
effectiveAnthropicRuntimeLimitContext,
|
effectiveAnthropicRuntimeLimitContext,
|
||||||
prepareRequestSignature,
|
prepareRequestSignature,
|
||||||
|
prepareRuntimeStatusSignature,
|
||||||
runtimeProviderStatusById,
|
runtimeProviderStatusById,
|
||||||
selectedModel,
|
selectedModel,
|
||||||
selectedProviderId,
|
selectedProviderId,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue