Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(desktop): guard duplicate native pickers (#677)

Gargantua6961725bbba7
diff --git a/apps/desktop/electron/main/ipc/register.ts b/apps/desktop/electron/main/ipc/register.ts
index c937156fa..45fbf2b89 100644
--- a/apps/desktop/electron/main/ipc/register.ts
+++ b/apps/desktop/electron/main/ipc/register.ts
@@ -300,6 +300,7 @@ export function registerIpcHandlers(dependencies: RegisterIpcDependencies) {
});
registerWorkspaceIpc({
registrar,
+ getMainWindow,
getHost,
getSidecar,
dataDir,
diff --git a/apps/desktop/electron/main/ipc/workspace-ipc.ts b/apps/desktop/electron/main/ipc/workspace-ipc.ts
index c6ced60c9..12ea34e45 100644
--- a/apps/desktop/electron/main/ipc/workspace-ipc.ts
+++ b/apps/desktop/electron/main/ipc/workspace-ipc.ts
@@ -1,4 +1,4 @@
-import { dialog, shell } from "electron";
+import { BrowserWindow, dialog, shell, type OpenDialogOptions } from "electron";
import { dirname } from "node:path";
import { homedir } from "node:os";
import { existsSync, statSync } from "node:fs";
@@ -74,6 +74,7 @@ export function createComposerTemplateLoader(
export type WorkspaceIpcDependencies = {
registrar: IpcRegistrar;
+ getMainWindow: () => Electron.BrowserWindow | null;
getHost: () => HostProcess | null;
getSidecar: () => AgentSidecar | null;
dataDir: string;
@@ -91,6 +92,7 @@ export type WorkspaceIpcDependencies = {
export function registerWorkspaceIpc({
registrar,
+ getMainWindow,
getHost,
getSidecar,
dataDir,
@@ -124,6 +126,46 @@ export function registerWorkspaceIpc({
});
};
const assertMainWindowSender = registrar.assertMainWindowSender;
+ let composerPickerActive = false;
+ let projectPickerActive = false;
+
+ // Native composer dialogs are process-wide; reject duplicate requests while
+ // one is open instead of queueing another dialog behind it.
+ const openComposerPicker = async (
+ event: Electron.IpcMainInvokeEvent,
+ options: OpenDialogOptions,
+ ): Promise<{ token: string | null; canceled: boolean }> => {
+ if (composerPickerActive) return { token: null, canceled: true };
+ composerPickerActive = true;
+ try {
+ const owner = BrowserWindow.fromWebContents(event.sender);
+ const result = owner
+ ? await dialog.showOpenDialog(owner, options)
+ : await dialog.showOpenDialog(options);
+ if (result.canceled || result.filePaths.length === 0) {
+ return { token: null, canceled: true };
+ }
+ return {
+ token: rememberComposerPickerSelection(result.filePaths, event.sender.id),
+ canceled: false,
+ };
+ } finally {
+ composerPickerActive = false;
+ }
+ };
+
+ const openProjectPicker = async (options: OpenDialogOptions) => {
+ if (projectPickerActive) return null;
+ projectPickerActive = true;
+ try {
+ const owner = getMainWindow();
+ return owner
+ ? await dialog.showOpenDialog(owner, options)
+ : await dialog.showOpenDialog(options);
+ } finally {
+ projectPickerActive = false;
+ }
+ };
const managedProjectPath = async (input: unknown): Promise<string> => {
if (!host) throw new Error("host unavailable");
@@ -349,10 +391,10 @@ export function registerWorkspaceIpc({
});
handle(IPC.invoke.projectOpen, async () => {
if (!host) throw new Error("host unavailable");
- const result = await dialog.showOpenDialog({
+ const result = await openProjectPicker({
properties: ["openDirectory", "createDirectory"],
});
- if (result.canceled || !result.filePaths[0]) {
+ if (!result || result.canceled || !result.filePaths[0]) {
return { workspace: null, canceled: true };
}
const res = (await host.call("workspace.set", {
@@ -362,10 +404,10 @@ export function registerWorkspaceIpc({
return { workspace: await withGitBranch(res.workspace), canceled: false };
});
handle(IPC.invoke.projectPickFolders, async () => {
- const result = await dialog.showOpenDialog({
+ const result = await openProjectPicker({
properties: ["openDirectory", "multiSelections", "createDirectory"],
});
- if (result.canceled || result.filePaths.length === 0) {
+ if (!result || result.canceled || result.filePaths.length === 0) {
return { folders: [], canceled: true };
}
return { folders: result.filePaths, canceled: false };
@@ -374,11 +416,11 @@ export function registerWorkspaceIpc({
const parentDefault = currentWorkspacePath()
? dirname(currentWorkspacePath()!)
: homedir();
- const picked = await dialog.showOpenDialog({
+ const picked = await openProjectPicker({
defaultPath: parentDefault,
properties: ["openDirectory", "createDirectory"],
});
- if (picked.canceled || !picked.filePaths[0]) {
+ if (!picked || picked.canceled || !picked.filePaths[0]) {
return { workspace: null, canceled: true };
}
const dest = await cloneGitRepository({
@@ -483,34 +525,20 @@ export function registerWorkspaceIpc({
},
);
- handleWithEvent(IPC.invoke.composerPickFiles, async (event) => {
- const result = await dialog.showOpenDialog({
+ handleWithEvent(IPC.invoke.composerPickFiles, async (event) =>
+ openComposerPicker(event, {
properties: ["openFile", "multiSelections"],
- });
- if (result.canceled || result.filePaths.length === 0) {
- return { token: null, canceled: true };
- }
- return {
- token: rememberComposerPickerSelection(result.filePaths, event.sender.id),
- canceled: false,
- };
- });
+ }),
+ );
- handleWithEvent(IPC.invoke.composerPickPhotos, async (event) => {
- const result = await dialog.showOpenDialog({
+ handleWithEvent(IPC.invoke.composerPickPhotos, async (event) =>
+ openComposerPicker(event, {
properties: ["openFile", "multiSelections"],
filters: [
{ name: "Images", extensions: ["png", "jpg", "jpeg", "gif", "webp", "heic", "tif", "tiff"] },
],
- });
- if (result.canceled || result.filePaths.length === 0) {
- return { token: null, canceled: true };
- }
- return {
- token: rememberComposerPickerSelection(result.filePaths, event.sender.id),
- canceled: false,
- };
- });
+ }),
+ );
handleWithEvent(
IPC.invoke.composerImportFiles,
diff --git a/apps/desktop/src/components/HomeProjectSwitcher.tsx b/apps/desktop/src/components/HomeProjectSwitcher.tsx
index dca98698b..4a1ab0b1e 100644
--- a/apps/desktop/src/components/HomeProjectSwitcher.tsx
+++ b/apps/desktop/src/components/HomeProjectSwitcher.tsx
@@ -2,6 +2,7 @@ import {
useCallback,
useEffect,
useMemo,
+ useRef,
useState,
type KeyboardEvent as ReactKeyboardEvent,
} from "react";
@@ -49,6 +50,7 @@ export function HomeProjectSwitcher({
const [cloneUrl, setCloneUrl] = useState("");
const [highlight, setHighlight] = useState(0);
const [busy, setBusy] = useState(false);
+ const busyRef = useRef(false);
const projects = useMemo(
() =>
@@ -86,16 +88,18 @@ export function HomeProjectSwitcher({
const selectProject = useCallback(
async (nextPath: string) => {
- if (busy) return;
+ if (busy || busyRef.current) return;
const nextKey = normalizeProjectPath(nextPath);
close();
if (!nextKey || nextKey === activeKey) return;
+ busyRef.current = true;
setBusy(true);
try {
await newSession({ projectPath: nextPath });
} catch (error) {
reportError(error);
} finally {
+ busyRef.current = false;
setBusy(false);
}
},
@@ -103,7 +107,8 @@ export function HomeProjectSwitcher({
);
const startClone = useCallback(async () => {
- if (busy || !cloneTarget) return;
+ if (busy || busyRef.current || !cloneTarget) return;
+ busyRef.current = true;
setBusy(true);
try {
const previous = normalizeProjectPath(
@@ -119,13 +124,15 @@ export function HomeProjectSwitcher({
} catch (error) {
reportError(error);
} finally {
+ busyRef.current = false;
setBusy(false);
}
}, [busy, cloneProject, cloneTarget, close, newSession, reportError]);
const pickFolder = useCallback(async () => {
- if (busy) return;
+ if (busy || busyRef.current) return;
close();
+ busyRef.current = true;
setBusy(true);
try {
const previous = normalizeProjectPath(
@@ -140,6 +147,7 @@ export function HomeProjectSwitcher({
} catch (error) {
reportError(error);
} finally {
+ busyRef.current = false;
setBusy(false);
}
}, [busy, close, newSession, openProject, reportError]);
diff --git a/apps/desktop/src/components/ProjectCreateDialog.tsx b/apps/desktop/src/components/ProjectCreateDialog.tsx
index a4b552aca..8febd5d3a 100644
--- a/apps/desktop/src/components/ProjectCreateDialog.tsx
+++ b/apps/desktop/src/components/ProjectCreateDialog.tsx
@@ -52,9 +52,11 @@ export function ProjectCreateDialog() {
const [gitUrl, setGitUrl] = useState("");
const [cloneParent, setCloneParent] = useState("");
const [busy, setBusy] = useState(false);
+ const [folderPickerBusy, setFolderPickerBusy] = useState(false);
const inputRef = useRef<HTMLInputElement | null>(null);
const dialogRef = useRef<HTMLDivElement | null>(null);
const busyRef = useRef(false);
+ const folderPickerInFlightRef = useRef(false);
// The repository name seeds the project name until the user types their own.
const nameTouchedRef = useRef(false);
const cloneTarget = parseGitCloneUrl(gitUrl);
@@ -67,8 +69,10 @@ export function ProjectCreateDialog() {
setGitUrl("");
setCloneParent("");
busyRef.current = false;
+ folderPickerInFlightRef.current = false;
nameTouchedRef.current = false;
setBusy(false);
+ setFolderPickerBusy(false);
const previousOverflow = document.body.style.overflow;
const previouslyFocused = document.activeElement as HTMLElement | null;
document.body.style.overflow = "hidden";
@@ -113,7 +117,9 @@ export function ProjectCreateDialog() {
if (!open) return null;
const addFolders = async () => {
- if (busyRef.current) return;
+ if (busyRef.current || folderPickerInFlightRef.current) return;
+ folderPickerInFlightRef.current = true;
+ setFolderPickerBusy(true);
try {
const result = await api.pickProjectFolders();
if (result.canceled || result.folders.length === 0) return;
@@ -127,11 +133,16 @@ export function ProjectCreateDialog() {
showToast(error instanceof Error ? error.message : String(error), {
variant: "error",
});
+ } finally {
+ folderPickerInFlightRef.current = false;
+ setFolderPickerBusy(false);
}
};
const chooseCloneParent = async () => {
- if (busyRef.current) return;
+ if (busyRef.current || folderPickerInFlightRef.current) return;
+ folderPickerInFlightRef.current = true;
+ setFolderPickerBusy(true);
try {
const result = await api.pickProjectFolders();
if (result.canceled || result.folders.length === 0) return;
@@ -140,6 +151,9 @@ export function ProjectCreateDialog() {
showToast(error instanceof Error ? error.message : String(error), {
variant: "error",
});
+ } finally {
+ folderPickerInFlightRef.current = false;
+ setFolderPickerBusy(false);
}
};
@@ -358,7 +372,7 @@ export function ProjectCreateDialog() {
aria-label={t("project.createAddFolder")}
className={`project-create-add-folder${folders.length === 0 ? " is-empty" : ""}`}
onClick={() => void addFolders()}
- disabled={busy}
+ disabled={busy || folderPickerBusy}
>
<span className="project-create-add-folder-icon" aria-hidden>
<IconNewProject size={18} />
@@ -406,7 +420,7 @@ export function ProjectCreateDialog() {
}`}
aria-label={t("project.createChooseLocation")}
onClick={() => void chooseCloneParent()}
- disabled={busy}
+ disabled={busy || folderPickerBusy}
>
<span className="project-create-dialog-location-icon" aria-hidden>
<IconFolder size={17} />
diff --git a/apps/desktop/src/components/ProjectEditDialog.tsx b/apps/desktop/src/components/ProjectEditDialog.tsx
index 0c4c20ef7..7687bb340 100644
--- a/apps/desktop/src/components/ProjectEditDialog.tsx
+++ b/apps/desktop/src/components/ProjectEditDialog.tsx
@@ -61,9 +61,11 @@ export function ProjectEditDialog({
const [primaryPath, setPrimaryPath] = useState(project.path);
const [loading, setLoading] = useState(true);
const [busy, setBusy] = useState(false);
+ const [folderPickerBusy, setFolderPickerBusy] = useState(false);
const inputRef = useRef<HTMLInputElement | null>(null);
const dialogRef = useRef<HTMLDivElement | null>(null);
const busyRef = useRef(false);
+ const folderPickerInFlightRef = useRef(false);
useEffect(() => {
let cancelled = false;
@@ -140,7 +142,9 @@ export function ProjectEditDialog({
}, [onClose]);
const addFolders = async () => {
- if (busyRef.current) return;
+ if (busyRef.current || folderPickerInFlightRef.current) return;
+ folderPickerInFlightRef.current = true;
+ setFolderPickerBusy(true);
try {
const result = await api.pickProjectFolders();
if (result.canceled || result.folders.length === 0) return;
@@ -152,6 +156,9 @@ export function ProjectEditDialog({
]);
} catch (error) {
onError(error);
+ } finally {
+ folderPickerInFlightRef.current = false;
+ setFolderPickerBusy(false);
}
};
@@ -320,7 +327,7 @@ export function ProjectEditDialog({
aria-label={t("project.createAddFolder")}
className={`project-create-add-folder${folders.length === 0 ? " is-empty" : ""}`}
onClick={() => void addFolders()}
- disabled={loading || busy}
+ disabled={loading || busy || folderPickerBusy}
>
<span className="project-create-add-folder-icon" aria-hidden>
<IconNewProject size={18} />
diff --git a/apps/desktop/src/features/chat/composer/hooks/useComposerAttachments.ts b/apps/desktop/src/features/chat/composer/hooks/useComposerAttachments.ts
index 429b1159c..55d4f0ed1 100644
--- a/apps/desktop/src/features/chat/composer/hooks/useComposerAttachments.ts
+++ b/apps/desktop/src/features/chat/composer/hooks/useComposerAttachments.ts
@@ -1,5 +1,6 @@
import {
useState,
+ useRef,
type ClipboardEvent,
type DragEvent as ReactDragEvent,
} from "react";
@@ -79,6 +80,7 @@ export function useComposerAttachments({
draft,
}: UseComposerAttachmentsOptions): ComposerAttachmentsController {
const [pasting, setPasting] = useState(false);
+ const pickerInFlight = useRef(false);
const [dropTargetActive, setDropTargetActive] = useState(false);
const [droppedDirectories, setDroppedDirectories] = useState<ComposerDropItem[]>([]);
const isInputBlocked = inputBlocked || pasting;
@@ -87,11 +89,15 @@ export function useComposerAttachments({
draft.snapshotReferences(sourceSessionId);
const pickAndAttach = async () => {
+ // The ref closes the gap before React re-renders the disabled button.
+ if (pickerInFlight.current || isInputBlocked) return;
+ pickerInFlight.current = true;
+ setPasting(true);
try {
// The picker accepts regular files; the importer classifies images from
// MIME/extension metadata after selection.
const result = await api.pickFiles();
- if (result.canceled || !result.token || isInputBlocked) return;
+ if (result.canceled || !result.token) return;
const editor = draft.ref.current;
const sourceValue = editor ? readEditorValue(editor) : draft.valueRef.current;
@@ -101,55 +107,53 @@ export function useComposerAttachments({
const sourceSessionId = activeSessionId;
const sourceDraftKey = draftKey;
const previousReferences = snapshotReferences(sourceSessionId ?? "");
- setPasting(true);
- try {
- // A picker action is real input, so a home draft gets a durable owner
- // before native paths are copied into scratch.
- const sessionId = sourceSessionId ?? (await materializeDraftSession());
- if (!sessionId) throw new Error("session unavailable");
- const imported = await api.importFiles(sessionId, result.token);
- const chips = imported.files.map((file) => {
- const token = nextChipToken();
- return {
+ // A picker action is real input, so a home draft gets a durable owner
+ // before native paths are copied into scratch.
+ const sessionId = sourceSessionId ?? (await materializeDraftSession());
+ if (!sessionId) throw new Error("session unavailable");
+ const imported = await api.importFiles(sessionId, result.token);
+ const chips = imported.files.map((file) => {
+ const token = nextChipToken();
+ return {
+ token,
+ reference: createFileReference(file.path, file.name, sessionId, {
+ kind: file.kind,
+ mimeType: file.mimeType,
token,
- reference: createFileReference(file.path, file.name, sessionId, {
- kind: file.kind,
- mimeType: file.mimeType,
- token,
- }),
- };
- });
- if (!chips.length) return;
- const inserted = chips.map((chip) => chip.token).join("");
- const nextText =
- sourceValue.slice(0, selectionStart) +
- inserted +
- sourceValue.slice(selectionEnd);
- const nextReferences = [
- ...previousReferences.map((reference) =>
- createFileReference(reference.path, reference.name, sessionId, reference),
- ),
- ...chips.map((chip) => chip.reference),
- ];
- writeComposerDraft(sessionId, {
- text: nextText,
- fileReferences: [
- ...previousReferences,
- ...chips.map((chip) => toDraftReference(chip.reference)),
- ],
- });
- const currentSessionId = useAppStore.getState().activeSessionId;
- if (currentSessionId === sessionId) {
- draft.applyEditorDraft(nextText, nextReferences, selectionStart + inserted.length);
- } else if (sourceDraftKey === HOME_DRAFT_KEY) {
- deleteComposerDraft(HOME_DRAFT_KEY);
- }
- showToast(t, "chat.filesAttached", { count: chips.length }, "success");
- } finally {
- setPasting(false);
+ }),
+ };
+ });
+ if (!chips.length) return;
+ const inserted = chips.map((chip) => chip.token).join("");
+ const nextText =
+ sourceValue.slice(0, selectionStart) +
+ inserted +
+ sourceValue.slice(selectionEnd);
+ const nextReferences = [
+ ...previousReferences.map((reference) =>
+ createFileReference(reference.path, reference.name, sessionId, reference),
+ ),
+ ...chips.map((chip) => chip.reference),
+ ];
+ writeComposerDraft(sessionId, {
+ text: nextText,
+ fileReferences: [
+ ...previousReferences,
+ ...chips.map((chip) => toDraftReference(chip.reference)),
+ ],
+ });
+ const currentSessionId = useAppStore.getState().activeSessionId;
+ if (currentSessionId === sessionId) {
+ draft.applyEditorDraft(nextText, nextReferences, selectionStart + inserted.length);
+ } else if (sourceDraftKey === HOME_DRAFT_KEY) {
+ deleteComposerDraft(HOME_DRAFT_KEY);
}
+ showToast(t, "chat.filesAttached", { count: chips.length }, "success");
} catch (error) {
showErrorToast(t, error);
+ } finally {
+ pickerInFlight.current = false;
+ setPasting(false);
}
};
diff --git a/apps/desktop/test/composer-paste-files.test.mjs b/apps/desktop/test/composer-paste-files.test.mjs
index 2545f34b0..46a160fbd 100644
--- a/apps/desktop/test/composer-paste-files.test.mjs
+++ b/apps/desktop/test/composer-paste-files.test.mjs
@@ -148,6 +148,26 @@ test("composer opens one unified file picker directly from the plus button", ()
assert.doesNotMatch(composer, /plusOpen|plusRef|composer-plus-menu|pickAndAttach\("photos"\)/);
});
+test("composer ignores repeated picker clicks while selection is in flight", () => {
+ assert.match(composer, /const pickerInFlight = useRef\(false\)/);
+ assert.match(composer, /if \(pickerInFlight\.current \|\| isInputBlocked\) return;/);
+ assert.match(
+ composer,
+ /pickerInFlight\.current = true;\s*setPasting\(true\);[\s\S]*?await api\.pickFiles\(\)/,
+ );
+ assert.match(
+ composer,
+ /pickerInFlight\.current = false;\s*setPasting\(false\);/,
+ );
+ assert.match(main, /let composerPickerActive = false/);
+ assert.match(
+ main,
+ /if \(composerPickerActive\) return \{ token: null, canceled: true \};/,
+ );
+ assert.match(main, /BrowserWindow\.fromWebContents\(event\.sender\)/);
+ assert.match(main, /dialog\.showOpenDialog\(owner, options\)/);
+});
+
test("pasted bytes stay in the session scratch directory", () => {
assert.match(saver, /join\(dataDir, "scratch", sessionId, "pasted"\)/);
assert.match(saver, /basename\(normalized\)/);
diff --git a/apps/desktop/test/home-project-switcher.test.mjs b/apps/desktop/test/home-project-switcher.test.mjs
index 312c12e78..e670308fc 100644
--- a/apps/desktop/test/home-project-switcher.test.mjs
+++ b/apps/desktop/test/home-project-switcher.test.mjs
@@ -37,6 +37,13 @@ test("home project switcher lists sidebar projects and can clone a git repo", ()
assert.match(switcher, /initialFocus="input"/);
});
+test("home project switcher guards project operations before React rerenders", () => {
+ assert.match(switcher, /const busyRef = useRef\(false\)/);
+ assert.match(switcher, /if \(busy \|\| busyRef\.current\) return;/);
+ assert.match(switcher, /busyRef\.current = true;\s*setBusy\(true\)/);
+ assert.match(switcher, /busyRef\.current = false;\s*setBusy\(false\)/);
+});
+
test("home project switcher is a fixed portaled menu that stays inline in the hero", () => {
assert.match(
styles,
diff --git a/apps/desktop/test/mcp-control-wiring.test.mjs b/apps/desktop/test/mcp-control-wiring.test.mjs
index 94411239e..3d764ad67 100644
--- a/apps/desktop/test/mcp-control-wiring.test.mjs
+++ b/apps/desktop/test/mcp-control-wiring.test.mjs
@@ -62,7 +62,9 @@ test("native picker handlers and secret-write channels stay out of the MCP catal
const from = starts[index].index ?? 0;
const to = index + 1 < starts.length ? (starts[index + 1].index ?? source.length) : source.length;
const block = source.slice(from, to);
- if (block.includes("showOpenDialog")) pickerKeys.push(starts[index][1]);
+ if (block.includes("showOpenDialog") || block.includes("openProjectPicker")) {
+ pickerKeys.push(starts[index][1]);
+ }
}
}
assert.ok(pickerKeys.includes("pluginLoadDev"));
diff --git a/apps/desktop/test/project-create-dialog.test.mjs b/apps/desktop/test/project-create-dialog.test.mjs
index 1aedcbf67..ea5347299 100644
--- a/apps/desktop/test/project-create-dialog.test.mjs
+++ b/apps/desktop/test/project-create-dialog.test.mjs
@@ -6,8 +6,9 @@ import { readStoreSource } from "./helpers/store-source.mjs";
const read = (relativePath) => readFile(new URL(relativePath, import.meta.url), "utf8");
-const [dialog, store, api, protocol, main, styles] = await Promise.all([
+const [dialog, editDialog, store, api, protocol, main, styles] = await Promise.all([
read("../src/components/ProjectCreateDialog.tsx"),
+ read("../src/components/ProjectEditDialog.tsx"),
readStoreSource(),
read("../src/lib/api.ts"),
read("../../../packages/shared/src/protocol.ts"),
@@ -88,6 +89,28 @@ test("folder picker is a renderer-only multi-directory selection", () => {
assert.doesNotMatch(handler, /workspace\.set/);
});
+test("project folder pickers ignore repeated requests while a dialog is open", () => {
+ for (const source of [dialog, editDialog]) {
+ assert.match(source, /const folderPickerInFlightRef = useRef\(false\)/);
+ assert.match(
+ source,
+ /if \(busyRef\.current \|\| folderPickerInFlightRef\.current\) return;/,
+ );
+ assert.match(
+ source,
+ /folderPickerInFlightRef\.current = true;\s*setFolderPickerBusy\(true\);[\s\S]*?api\.pickProjectFolders\(\)/,
+ );
+ assert.match(
+ source,
+ /folderPickerInFlightRef\.current = false;\s*setFolderPickerBusy\(false\);/,
+ );
+ }
+ assert.match(main, /let projectPickerActive = false/);
+ assert.match(main, /const openProjectPicker = async/);
+ assert.match(main, /if \(!result \|\| result\.canceled/);
+ assert.match(main, /const owner = getMainWindow\(\)/);
+});
+
test("clone checkout handler clones without touching the active workspace", () => {
const start = main.indexOf("IPC.invoke.projectCloneCheckout");
const end = main.indexOf("IPC.invoke.projectSet", start);
diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.md
index 6f9ddf65e..2b4388b28 100644
--- a/docs/spec/04-ux/08-component-spec.md
+++ b/docs/spec/04-ux/08-component-spec.md
@@ -526,6 +526,8 @@ visually distinct from list content.
Git repository as equal filled tiles without strokes (D297); the active source
uses a deeper tile, not a selected border. A repository URL reuses the clone
rules of ADR 0247 and its checkout becomes the primary root of the same group.
+ Repeated clicks on Add folder or the clone destination while a native folder
+ picker is open are ignored; only one project folder picker can be active.
The dialog does not add explanatory copy for durable memory or multi-selection.
The surface has no outer stroke, section rules, footer divider, source-option
stroke, field stroke, or dashed picker border. The action row stays fixed
@@ -2854,6 +2856,8 @@ reasoning-level control.
inserts an inline temporary-file token at the paste position (D197, D209,
D262, ADR 0059, ADR 0070, ADR 0131)
- The Composer `+` button opens one native file picker with no type-choice menu.
+ While that picker or its import is in flight, repeated clicks are ignored so
+ only one composer picker can be active at a time.
The picker accepts regular files, and the importer classifies each selected
item as an image or file from its MIME/extension metadata before copying it
into the active session's scratch `pasted/` directory and adding its compact
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index c5c4e5e72..34e981a06 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -6512,12 +6512,16 @@ identify the platform validation still needed.
- **Preconditions**: The app is running with a home or Agent composer and a
durable session. The native picker can select a text file and an image outside
the active workspace.
-- **Steps**: 1) Click the Composer `+` button; confirm it opens the native file
- picker directly without an intermediate type-choice menu. 2) Select both
+- **Steps**: 1) Click the Composer `+` button twice in quick succession;
+ confirm that only one native file picker opens, directly without an
+ intermediate type-choice menu. 2) Select both
fixtures. 3) Inspect the draft chips and send a prompt asking the agent to
read the text fixture and identify the image marker. 4) Inspect the renderer
request, session transcript, and the session scratch directory.
-- **Expected**: The native picker returns a short-lived one-shot token, never a
+- **Expected**: While the native picker or its renderer import is in flight,
+ repeated `+` clicks are ignored. While the native picker is open, the main
+ process rejects duplicate picker requests instead of opening another dialog.
+ The native picker returns a short-lived one-shot token, never a
source absolute path, and the selections are copied into
`<data_dir>/scratch/<sessionId>/pasted/` before they enter the draft. The app
classifies each selected item from its MIME/extension metadata, so the same
@@ -12739,14 +12743,17 @@ plugin-form fixtures in an isolated temporary directory at runtime.
- **Preconditions**: The Create project dialog opens from the Projects heading
(no existing project is required); `git` is installed.
- **Steps**:
- 1. Switch the source selector to Git repository.
- 2. Paste `https://github.com/octocat/Hello-World.git` and confirm the project
+ 1. Open the Create project dialog and click Add folder twice quickly; confirm
+ that only one native folder picker opens, then cancel it.
+ 2. Switch the source selector to Git repository.
+ 3. Paste `https://github.com/octocat/Hello-World.git` and confirm the project
name field is seeded with `Hello-World`, then type a custom name.
- 3. Choose a clone destination folder and confirm the destination row shows it.
- 4. Confirm Create and inspect the workspace, sidebar, and project archive.
- 5. Reopen the dialog, switch to Git repository, and paste a private or
+ 4. Choose a clone destination folder and confirm the destination row shows it.
+ 5. Confirm Create and inspect the workspace, sidebar, and project archive.
+ 6. Reopen the dialog, switch to Git repository, and paste a private or
malformed remote.
-- **Expected**: The dialog swaps the folder list for a repository URL field plus
+- **Expected**: Repeated folder-picker clicks are ignored while the native
+ picker is open. The dialog swaps the folder list for a repository URL field plus
a clone destination row and keeps one project name field. Source options and
fields are filled tiles without strokes; keyboard focus uses the shared
accent-tinted ring. Create stays