Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

Stop blocking Setup on AI-tool detection (PRD-7684, PRD-8324) (#4095)

Nick Gomez89c8dc367735
diff --git a/.changeset/consent-dialog-start-not-blocked-by-detection.md b/.changeset/consent-dialog-start-not-blocked-by-detection.md
new file mode 100644
index 000000000..84fed19e6
--- /dev/null
+++ b/.changeset/consent-dialog-start-not-blocked-by-detection.md
@@ -0,0 +1,11 @@
+---
+"@inkeep/open-knowledge": patch
+---
+
+Setting up OpenKnowledge in an existing folder no longer ignores you if you hit Enter or Setup straight away.
+
+The setup dialog checks which AI tools are on your machine so it can offer to wire them into the project. That check runs in the background, and until it finished the Setup button was disabled. A disabled Setup button also means the browser refuses to submit the form when you press Enter, so pressing Enter in the first second or so did nothing at all: no spinner, no error, no project. The dialog just sat there, and the only way to find out you had to try again was to try again.
+
+Detecting your AI tools is an enhancement, not a precondition for setting up a folder, so it no longer gates the button. Setup is live as soon as the dialog is.
+
+A setup you start while the check is still running waits for it and then proceeds, so your tools are wired up just as they would be if you had waited. The wait is bounded from the moment the dialog opens rather than from when you press Setup, so waiting a while and then pressing it costs you nothing extra. If the check has not come back within eight seconds, setup goes ahead and connects nothing rather than leaving you looking at a dialog that will not respond, and the AI tools row stops saying it is still checking so you can wire them up later from Settings. Cancel and Escape stay live the whole time, and Setup shows a spinner while it waits.
diff --git a/packages/app/src/components/ConsentDialogBody.dom.test.tsx b/packages/app/src/components/ConsentDialogBody.dom.test.tsx
index e446a42c8..659f55974 100644
--- a/packages/app/src/components/ConsentDialogBody.dom.test.tsx
+++ b/packages/app/src/components/ConsentDialogBody.dom.test.tsx
@@ -49,6 +49,37 @@ function statusBridge(
integrations: {
status: () => (opts.pending ? new Promise(() => {}) : Promise.resolve(status)),
},
+ onboarding: {
+ probeContent: async () => ({ ok: true, count: 0, sample: [], truncated: false }),
+ },
+ };
+}
+
+function deferredStatusBridge(detectedEditorIds: string[]) {
+ let release!: () => void;
+ const gate = new Promise<void>((resolve) => {
+ release = resolve;
+ });
+ const status = {
+ available: true,
+ editors: detectedEditorIds.map((id) => ({ id, state: 'installed' })),
+ path: { shellDetected: false, rcFilesToTouch: [], installed: false },
+ skills: [],
+ detectedEditorIds,
+ };
+ return {
+ bridge: {
+ integrations: {
+ status: async () => {
+ await gate;
+ return status;
+ },
+ },
+ onboarding: {
+ probeContent: async () => ({ ok: true, count: 0, sample: [], truncated: false }),
+ },
+ },
+ release,
};
}
@@ -60,7 +91,7 @@ function setBridge(bridge: unknown) {
});
}
-function makeStore() {
+function makeStore(opts: { cancelError?: string; confirmError?: string } = {}) {
const confirmCalls: OkOnboardingConfirmRequest[] = [];
const cancelCalls: string[] = [];
const store: ConsentStore = {
@@ -69,11 +100,13 @@ function makeStore() {
subscribe: () => () => {},
confirm: async (request) => {
confirmCalls.push(request);
- return { ok: true };
+ return opts.confirmError === undefined
+ ? { ok: true }
+ : { ok: false, error: opts.confirmError };
},
cancel: async () => {
cancelCalls.push('cancel');
- return { ok: true };
+ return opts.cancelError === undefined ? { ok: true } : { ok: false, error: opts.cancelError };
},
dismiss: () => {},
};
@@ -100,6 +133,7 @@ describe('ConsentDialogBody runtime form behavior', () => {
afterEach(() => {
cleanup();
setBridge(undefined);
+ vi.restoreAllMocks();
});
test('exports the default component', () => {
@@ -245,17 +279,271 @@ describe('ConsentDialogBody runtime form behavior', () => {
expect(harness.confirmCalls[0]?.connectEditors).toBe(false);
});
- test('Setup is disabled while the detection probe is in flight', async () => {
+ test('a never-settling detection probe keeps Cancel live and degrades to no wiring', async () => {
+ const harness = makeStore();
+ setBridge(statusBridge([], { pending: true }));
+ vi.spyOn(console, 'warn').mockImplementation(() => {});
+ render(<ConsentDialogBody payload={payload} store={harness.store} detectionGraceMs={150} />);
+
+ expect(screen.getByTestId('consent-editors-status').getAttribute('data-status')).toBe(
+ 'probing',
+ );
+ expect((screen.getByTestId('consent-start') as HTMLButtonElement).disabled).toBe(false);
+
+ fireEvent.submit(screen.getByTestId('consent-form') as HTMLFormElement);
+
+ await waitFor(() => {
+ expect(
+ (screen.getByTestId('consent-start') as HTMLButtonElement).getAttribute('aria-busy'),
+ ).toBe('true');
+ });
+ expect((screen.getByTestId('consent-cancel') as HTMLButtonElement).disabled).toBe(false);
+
+ await waitFor(() => {
+ expect(harness.confirmCalls).toHaveLength(1);
+ });
+ expect(harness.confirmCalls[0]?.editorIds).toEqual([]);
+ expect(harness.confirmCalls[0]?.connectEditors).toBe(true);
+ });
+
+ test('Escape during the detection wait cancels instead of being swallowed', async () => {
+ const harness = makeStore();
+ setBridge(statusBridge([], { pending: true }));
+ render(<ConsentDialogBody payload={payload} store={harness.store} />);
+
+ fireEvent.submit(screen.getByTestId('consent-form') as HTMLFormElement);
+ await waitFor(() => {
+ expect(
+ (screen.getByTestId('consent-start') as HTMLButtonElement).getAttribute('aria-busy'),
+ ).toBe('true');
+ });
+
+ fireEvent.keyDown(document.body, { key: 'Escape', code: 'Escape' });
+
+ await waitFor(() => {
+ expect(harness.cancelCalls).toEqual(['cancel']);
+ });
+ });
+
+ test('a rejected detection probe does not hang the submit', async () => {
+ const harness = makeStore();
+ let reject!: (err: Error) => void;
+ const gate = new Promise<never>((_resolve, r) => {
+ reject = (err) => r(err);
+ });
+ setBridge({
+ integrations: { status: () => gate },
+ onboarding: {
+ probeContent: async () => ({ ok: true, count: 0, sample: [], truncated: false }),
+ },
+ });
+ render(<ConsentDialogBody payload={payload} store={harness.store} />);
+
+ fireEvent.submit(screen.getByTestId('consent-form') as HTMLFormElement);
+ reject(new Error('detection blew up'));
+
+ await waitFor(() => {
+ expect(harness.confirmCalls).toHaveLength(1);
+ });
+ expect(harness.confirmCalls[0]?.editorIds).toEqual([]);
+ expect(harness.confirmCalls[0]?.connectEditors).toBe(true);
+ });
+
+ test('a failed cancel leaves the dialog usable — the next Setup still confirms', async () => {
+ const harness = makeStore({ cancelError: 'nope' });
+ setBridge(statusBridge(['claude']));
+ render(<ConsentDialogBody payload={payload} store={harness.store} />);
+ await awaitDetected();
+
+ fireEvent.click(screen.getByTestId('consent-cancel'));
+ await waitFor(() => {
+ expect(harness.cancelCalls).toEqual(['cancel']);
+ });
+ await waitFor(() => {
+ expect((screen.getByTestId('consent-start') as HTMLButtonElement).disabled).toBe(false);
+ });
+
+ fireEvent.submit(screen.getByTestId('consent-form') as HTMLFormElement);
+
+ await waitFor(() => {
+ expect(harness.confirmCalls).toHaveLength(1);
+ });
+ });
+
+ test('two rapid cancels during the detection wait issue a single cancel', async () => {
const harness = makeStore();
setBridge(statusBridge([], { pending: true }));
render(<ConsentDialogBody payload={payload} store={harness.store} />);
+ fireEvent.submit(screen.getByTestId('consent-form') as HTMLFormElement);
+ await waitFor(() => {
+ expect(
+ (screen.getByTestId('consent-start') as HTMLButtonElement).getAttribute('aria-busy'),
+ ).toBe('true');
+ });
+
+ fireEvent.click(screen.getByTestId('consent-cancel'));
+ fireEvent.keyDown(document.body, { key: 'Escape', code: 'Escape' });
+
+ await waitFor(() => {
+ expect(harness.cancelCalls).toEqual(['cancel']);
+ });
+ await new Promise((resolve) => setTimeout(resolve, 0));
+ expect(harness.cancelCalls).toEqual(['cancel']);
+ });
+
+ test('a cancel during the detection wait suppresses the parked confirm, even if the cancel fails', async () => {
+ const harness = makeStore({ cancelError: 'nope' });
+ setBridge(statusBridge([], { pending: true }));
+ vi.spyOn(console, 'warn').mockImplementation(() => {});
+ render(<ConsentDialogBody payload={payload} store={harness.store} detectionGraceMs={150} />);
+
+ fireEvent.submit(screen.getByTestId('consent-form') as HTMLFormElement);
+ expect(
+ (screen.getByTestId('consent-start') as HTMLButtonElement).getAttribute('aria-busy'),
+ ).toBe('true');
+ fireEvent.click(screen.getByTestId('consent-cancel'));
+
+ await waitFor(() => {
+ expect(harness.cancelCalls).toEqual(['cancel']);
+ });
+
+ await waitFor(() => {
+ expect(screen.getByTestId('consent-editors-status').getAttribute('data-status')).toBe('none');
+ });
+ expect(harness.confirmCalls).toEqual([]);
+ });
+
+ test('the detection grace is anchored at mount, so a resubmit does not restart it', async () => {
+ const harness = makeStore({ cancelError: 'nope' });
+ setBridge(statusBridge([], { pending: true }));
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
+ render(<ConsentDialogBody payload={payload} store={harness.store} detectionGraceMs={150} />);
+
+ fireEvent.submit(screen.getByTestId('consent-form') as HTMLFormElement);
+ fireEvent.click(screen.getByTestId('consent-cancel'));
+ await waitFor(() => {
+ expect(harness.cancelCalls).toEqual(['cancel']);
+ });
+ await waitFor(() => {
+ expect((screen.getByTestId('consent-start') as HTMLButtonElement).disabled).toBe(false);
+ });
+
+ fireEvent.submit(screen.getByTestId('consent-form') as HTMLFormElement);
+ await waitFor(() => {
+ expect(harness.confirmCalls).toHaveLength(1);
+ });
+
+ await new Promise((resolve) => setTimeout(resolve, 400));
+ const graceWarnings = warn.mock.calls.filter((call) =>
+ String(call[0]).includes('did not settle within'),
+ );
+ expect(graceWarnings).toHaveLength(1);
+ });
+
+ test('a successful cancel during the wait suppresses the parked confirm', async () => {
+ const harness = makeStore();
+ const detection = deferredStatusBridge(['claude']);
+ setBridge(detection.bridge);
+ render(<ConsentDialogBody payload={payload} store={harness.store} />);
+
+ fireEvent.submit(screen.getByTestId('consent-form') as HTMLFormElement);
+ await waitFor(() => {
+ expect(
+ (screen.getByTestId('consent-start') as HTMLButtonElement).getAttribute('aria-busy'),
+ ).toBe('true');
+ });
+
+ fireEvent.click(screen.getByTestId('consent-cancel'));
+ await waitFor(() => {
+ expect(harness.cancelCalls).toEqual(['cancel']);
+ });
+
+ detection.release();
+ await waitFor(() => {
+ expect(screen.getByTestId('consent-editors-status').getAttribute('data-status')).toBe(
+ 'ready',
+ );
+ });
+ expect(harness.confirmCalls).toEqual([]);
+ });
+
+ test('a probe that settles after the grace still wires the editors the dialog is showing', async () => {
+ const harness = makeStore();
+ const detection = deferredStatusBridge(['claude']);
+ setBridge(detection.bridge);
+ vi.spyOn(console, 'warn').mockImplementation(() => {});
+ render(<ConsentDialogBody payload={payload} store={harness.store} detectionGraceMs={150} />);
+
+ await waitFor(() => {
+ expect(screen.getByTestId('consent-editors-status').getAttribute('data-status')).toBe('none');
+ });
+
+ detection.release();
+ await awaitDetected();
+
+ fireEvent.submit(screen.getByTestId('consent-form') as HTMLFormElement);
+
+ await waitFor(() => {
+ expect(harness.confirmCalls).toHaveLength(1);
+ });
+ expect(harness.confirmCalls[0]?.editorIds).toEqual(['claude']);
+ });
+
+ test('a probe that settles inside the grace does not warn', async () => {
+ const harness = makeStore();
+ const detection = deferredStatusBridge(['claude']);
+ setBridge(detection.bridge);
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
+ render(<ConsentDialogBody payload={payload} store={harness.store} detectionGraceMs={150} />);
+ detection.release();
+ await awaitDetected();
+
+ await new Promise((resolve) => setTimeout(resolve, 300));
+ const graceWarnings = warn.mock.calls.filter((call) =>
+ String(call[0]).includes('did not settle within'),
+ );
+ expect(graceWarnings).toEqual([]);
+ });
+
+ test('grace expiry stops the row claiming it is still checking', async () => {
+ const harness = makeStore();
+ setBridge(statusBridge([], { pending: true }));
+ vi.spyOn(console, 'warn').mockImplementation(() => {});
+ render(<ConsentDialogBody payload={payload} store={harness.store} detectionGraceMs={150} />);
+
expect(screen.getByTestId('consent-editors-status').getAttribute('data-status')).toBe(
'probing',
);
- expect((screen.getByTestId('consent-start') as HTMLButtonElement).disabled).toBe(true);
+
+ await waitFor(() => {
+ expect(screen.getByTestId('consent-editors-status').getAttribute('data-status')).toBe('none');
+ });
+ });
+
+ test('a failed confirm re-arms the dialog and surfaces the error', async () => {
+ const harness = makeStore({ confirmError: 'main said no' });
+ const errors: string[] = [];
+ setBridge(statusBridge(['claude']));
+ render(
+ <ConsentDialogBody
+ payload={payload}
+ store={harness.store}
+ toast={{ error: (message) => errors.push(message) }}
+ />,
+ );
+ await awaitDetected();
+
fireEvent.submit(screen.getByTestId('consent-form') as HTMLFormElement);
- expect(harness.confirmCalls).toHaveLength(0);
+
+ await waitFor(() => {
+ expect(harness.confirmCalls).toHaveLength(1);
+ });
+ await waitFor(() => {
+ expect((screen.getByTestId('consent-start') as HTMLButtonElement).disabled).toBe(false);
+ });
+ expect(errors).toEqual(['main said no']);
+ expect((screen.getByTestId('consent-cancel') as HTMLButtonElement).disabled).toBe(false);
});
test('an invalid default content dir force-opens Advanced settings and shows the error without expanding', () => {
@@ -347,4 +635,37 @@ describe('ConsentDialogBody runtime form behavior', () => {
'docs/notes',
);
});
+ test('a submit raised while detection is in flight still confirms', async () => {
+ const harness = makeStore();
+ const detection = deferredStatusBridge(['claude']);
+ setBridge(detection.bridge);
+ render(<ConsentDialogBody payload={payload} store={harness.store} />);
+
+ fireEvent.submit(screen.getByTestId('consent-form') as HTMLFormElement);
+ detection.release();
+
+ await waitFor(() => {
+ expect(harness.confirmCalls).toHaveLength(1);
+ });
+ expect(harness.confirmCalls[0]?.editorIds).toEqual(['claude']);
+ expect(harness.confirmCalls[0]?.connectEditors).toBe(true);
+ });
+
+ test('a second submit while the first is in flight is ignored', async () => {
+ const harness = makeStore();
+ const detection = deferredStatusBridge([]);
+ setBridge(detection.bridge);
+ render(<ConsentDialogBody payload={payload} store={harness.store} />);
+
+ const form = screen.getByTestId('consent-form') as HTMLFormElement;
+ fireEvent.submit(form);
+ fireEvent.submit(form);
+ detection.release();
+
+ await waitFor(() => {
+ expect(harness.confirmCalls).toHaveLength(1);
+ });
+ await new Promise((resolve) => setTimeout(resolve, 0));
+ expect(harness.confirmCalls).toHaveLength(1);
+ });
});
diff --git a/packages/app/src/components/ConsentDialogBody.tsx b/packages/app/src/components/ConsentDialogBody.tsx
index 0b10103d0..65eddc581 100644
--- a/packages/app/src/components/ConsentDialogBody.tsx
+++ b/packages/app/src/components/ConsentDialogBody.tsx
@@ -8,7 +8,7 @@ import { msg } from '@lingui/core/macro';
import { Trans, useLingui } from '@lingui/react/macro';
import { ChevronRight } from 'lucide-react';
import type React from 'react';
-import { useEffect, useId, useState } from 'react';
+import { useEffect, useId, useRef, useState } from 'react';
import { toast as sonnerToast } from 'sonner';
import { ProjectAiToolsField } from '@/components/ProjectAiToolsField';
import {
@@ -28,6 +28,7 @@ import {
DialogTitle,
} from '@/components/ui/dialog';
import { Input } from '@/components/ui/input';
+import { Spinner } from '@/components/ui/spinner';
import { Textarea } from '@/components/ui/textarea';
import { type ConsentStore, consentStore as defaultConsentStore } from '@/lib/consent-store';
import type {
@@ -40,6 +41,20 @@ import { isContentDirSafe, relativeToProject } from '@/lib/project-paths';
const PROBE_THROTTLE_MS = 750;
+/* STOP: this backstop must exceed the main-process detection ceiling, or it silently truncates
+ working probes instead of catching wedged ones. That ceiling is the SLOWEST SINGLE LEG, and a
+ leg is a SUM, not a max: detectProtocol races getApplicationInfoForProtocol against
+ DEFAULT_PROBE_TIMEOUT_MS = 2000 (desktop/src/main/ipc-handlers.ts) and only THEN awaits the OS
+ probe, which loops MACOS_APP_NAMES candidates SERIALLY at INSTALLED_AGENTS_PROBE_TIMEOUT_MS =
+ 2000 each (server/src/handoff-api.ts). One candidate per scheme today, so that leg is 4000; the
+ CLI leg is PROBE_TIMEOUT_MS = 5000 (desktop/src/main/claude-readiness.ts) fanned out in
+ parallel. Ceiling is 5000 and headroom is 3000. Three ways to breach it, none of which any test
+ here catches because the grace-dependent tests inject a small detectionGraceMs: raise any of the
+ three constants (2000 -> 6000 lands at exactly 8000), serialise a parallel fan-out, or add a
+ third MACOS_APP_NAMES alias for one scheme (also exactly 8000, touching no constant named
+ above). */
+const DETECTION_GRACE_MS = 8_000;
+
const WARNING_COPY: Record<OkOnboardingWarningKind, MessageDescriptor> = {
root: msg`You picked the filesystem root (/). Scaffolding here will scan every file on this machine — make sure that's what you want.`,
home: msg`You picked your home directory. OpenKnowledge will index everything in your home tree — large and may surface personal files.`,
@@ -54,6 +69,7 @@ interface ConsentDialogBodyProps {
store?: ConsentStore;
toast?: ToastImpl;
payload?: OkOnboardingShowPayload;
+ detectionGraceMs?: number;
}
export interface ToastImpl {
@@ -68,19 +84,28 @@ function ConsentDialogBody({
store = defaultConsentStore,
toast = defaultToast,
payload,
+ detectionGraceMs = DETECTION_GRACE_MS,
}: ConsentDialogBodyProps = {}) {
const snapshot = payload ?? store.getSnapshot();
if (!snapshot) return null;
- return <ConsentDialogForm payload={snapshot} store={store} toast={toast} />;
+ return (
+ <ConsentDialogForm
+ payload={snapshot}
+ store={store}
+ toast={toast}
+ detectionGraceMs={detectionGraceMs}
+ />
+ );
}
interface ConsentDialogFormProps {
payload: OkOnboardingShowPayload;
store: ConsentStore;
toast: ToastImpl;
+ detectionGraceMs: number;
}
-function ConsentDialogForm({ payload, store, toast }: ConsentDialogFormProps) {
+function ConsentDialogForm({ payload, store, toast, detectionGraceMs }: ConsentDialogFormProps) {
const { t } = useLingui();
const initGit = true;
const formId = useId();
@@ -95,6 +120,10 @@ function ConsentDialogForm({ payload, store, toast }: ConsentDialogFormProps) {
const [busy, setBusy] = useState(false);
const [browseError, setBrowseError] = useState<string | null>(null);
const [advancedOpen, setAdvancedOpen] = useState(false);
+ const [awaitingDetection, setAwaitingDetection] = useState(false);
+ const detectionRef = useRef<Promise<readonly OkMcpWiringEditorId[]> | null>(null);
+ const cancelInFlightRef = useRef(false);
+ const confirmEpochRef = useRef(0);
useEffect(() => {
if (!isContentDirSafe(contentDir)) {
@@ -130,33 +159,48 @@ function ConsentDialogForm({ payload, store, toast }: ConsentDialogFormProps) {
return;
}
let cancelled = false;
- bridge.integrations
+ const detection: Promise<readonly OkMcpWiringEditorId[]> = bridge.integrations
.status()
.then((status) => {
- if (cancelled) return;
const userMcpInstalled = new Set(
status.editors.filter((e) => e.state === 'installed').map((e) => e.id),
);
- setDetectedEditors(
- status.detectedEditorIds.filter((id) =>
- receivesProjectIntegrationWrite(id, {
- userMcpEntryInstalled: userMcpInstalled.has(id),
- }),
- ),
+ return status.detectedEditorIds.filter((id) =>
+ receivesProjectIntegrationWrite(id, {
+ userMcpEntryInstalled: userMcpInstalled.has(id),
+ }),
);
})
.catch((err: unknown) => {
console.warn('[ConsentDialog] editor-detection probe failed:', err);
- if (!cancelled) setDetectedEditors([]);
+ return [];
});
+ let graceTimer: ReturnType<typeof setTimeout> | undefined;
+ detectionRef.current = Promise.race([
+ detection,
+ new Promise<readonly OkMcpWiringEditorId[]>((resolve) => {
+ graceTimer = setTimeout(() => {
+ console.warn(
+ `[ConsentDialog] editor detection did not settle within ${detectionGraceMs}ms`,
+ );
+ if (!cancelled) setDetectedEditors([]);
+ resolve([]);
+ }, detectionGraceMs);
+ }),
+ ]);
+ void detection.then((editors) => {
+ clearTimeout(graceTimer);
+ if (!cancelled) setDetectedEditors(editors);
+ });
return () => {
cancelled = true;
+ clearTimeout(graceTimer);
};
- }, []);
+ }, [detectionGraceMs]);
const contentDirSafe = isContentDirSafe(contentDir);
- const detectionPending = connectEditors && detectedEditors === null;
- const startDisabled = busy || detectionPending || !contentDirSafe;
+ const startDisabled = busy || !contentDirSafe;
+ const exitsLive = !busy || awaitingDetection;
const advancedExpanded = advancedOpen || !contentDirSafe;
const projectDir = payload.projectDir;
@@ -183,13 +227,28 @@ function ConsentDialogForm({ payload, store, toast }: ConsentDialogFormProps) {
setContentDir(relative);
}
+ async function resolveDetectedEditors(): Promise<readonly OkMcpWiringEditorId[]> {
+ if (!connectEditors) return [];
+ if (detectedEditors !== null) return detectedEditors;
+ const pending = detectionRef.current;
+ if (pending === null) return [];
+ setAwaitingDetection(true);
+ const detected = await pending;
+ setAwaitingDetection(false);
+ return detected;
+ }
+
async function onConfirm() {
+ const epoch = confirmEpochRef.current + 1;
+ confirmEpochRef.current = epoch;
setBusy(true);
+ const detected = await resolveDetectedEditors();
+ if (confirmEpochRef.current !== epoch) return;
const result = await store.confirm({
initGit,
contentDir,
additionalIgnores,
- editorIds: connectEditors ? [...(detectedEditors ?? [])] : [],
+ editorIds: [...detected],
connectEditors,
sharing,
});
@@ -206,16 +265,21 @@ function ConsentDialogForm({ payload, store, toast }: ConsentDialogFormProps) {
}
async function onCancel() {
+ if (cancelInFlightRef.current) return;
+ cancelInFlightRef.current = true;
+ confirmEpochRef.current += 1;
setBusy(true);
const result = await store.cancel();
if (!result.ok) {
+ cancelInFlightRef.current = false;
+ setAwaitingDetection(false);
toast.error(result.error);
setBusy(false);
}
}
function onOpenChange(open: boolean) {
- if (!open && !busy) void onCancel();
+ if (!open && exitsLive) void onCancel();
}
return (
@@ -384,12 +448,19 @@ function ConsentDialogForm({ payload, store, toast }: ConsentDialogFormProps) {
type="button"
variant="outline"
onClick={() => void onCancel()}
- disabled={busy}
+ disabled={!exitsLive}
data-testid="consent-cancel"
>
<Trans>Cancel</Trans>
</Button>
- <Button type="submit" form={formId} disabled={startDisabled} data-testid="consent-start">
+ <Button
+ type="submit"
+ form={formId}
+ disabled={startDisabled}
+ aria-busy={awaitingDetection}
+ data-testid="consent-start"
+ >
+ {awaitingDetection ? <Spinner aria-hidden="true" /> : null}
<Trans comment="Primary button — begins scaffolding the project">Setup</Trans>
</Button>
</DialogFooter>