Skip to content

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

fix(project-delete): require explicit confirmation

vastsa6efc1b0ab95f
diff --git a/apps/desktop/src/components/Sidebar.tsx b/apps/desktop/src/components/Sidebar.tsx
index 827ba753b..412dc2d1d 100644
--- a/apps/desktop/src/components/Sidebar.tsx
+++ b/apps/desktop/src/components/Sidebar.tsx
@@ -259,14 +259,12 @@ export function Sidebar({
const refreshProject = useAppStore((s) => s.refreshProject);
const clearProject = useAppStore((s) => s.clearProject);
const activateProject = useAppStore((s) => s.activateProject);
- const closeProjectAction = useAppStore((s) => s.closeProject);
const renameProject = useAppStore((s) => s.renameProject);
const toggleSessionPinned = useAppStore((s) => s.toggleSessionPinned);
const archiveSessionAction = useAppStore((s) => s.archiveSession);
const restoreSession = useAppStore((s) => s.restoreSession);
const renameSession = useAppStore((s) => s.renameSession);
const deleteSessionAction = useAppStore((s) => s.deleteSession);
- const deleteProjectAction = useAppStore((s) => s.deleteProject);
const setSessionSort = useAppStore((s) => s.setSessionSort);
const moveSessionProject = useAppStore((s) => s.moveSessionProject);
const setSessionArchiveVisibility = useAppStore((s) => s.setSessionArchiveVisibility);
@@ -1393,37 +1391,10 @@ export function Sidebar({
setSelectedIds(new Set());
};
- /** Menu items of different surfaces never share an armed key. */
- const projectDeleteKey = (entry: ProjectEntry) => `project:${entry.key}`;
-
- /**
- * Two-step delete for a project row that keeps the running-task safety. The
- * second click deletes an idle project straight away; a project whose turn is
- * still live opens the dialog that names those sessions and stops them.
- */
- const requestDeleteProject = async (entry: ProjectEntry) => {
- const key = projectDeleteKey(entry);
- if (armedDelete !== key) {
- setArmedDelete(key);
- return;
- }
- setArmedDelete(null);
+ /** Always route project deletion through the explicit confirmation dialog. */
+ const requestDeleteProject = (entry: ProjectEntry) => {
closeMenus(false);
- if (entry.sessions.some((session) => runningSessions[session.id] === true)) {
- setDeleteProjectFor(entry);
- return;
- }
- try {
- await deleteProjectAction(entry.path);
- showToast(t("project.deleted", { name: entry.name }), { variant: "success" });
- } catch (error) {
- // The host refuses a project whose task started after this render.
- reportError(
- (error as { errorCode?: unknown } | null)?.errorCode === ErrorCodes.CONFLICT
- ? new Error(t("project.deleteRunningBlocked"))
- : error,
- );
- }
+ setDeleteProjectFor(entry);
};
const openProjectFolder = async (entry: ProjectEntry) => {
@@ -1519,15 +1490,6 @@ export function Sidebar({
}
};
- const closeProject = async (entry: ProjectEntry) => {
- closeMenus();
- try {
- await closeProjectAction(entry.path);
- } catch (error) {
- reportError(error);
- }
- };
-
const createSession = async (options?: { projectPath?: string | null }) => {
try {
await newSession(options);
@@ -2317,26 +2279,13 @@ export function Sidebar({
<button
type="button"
role="menuitem"
- className={cx("danger", armedDelete === projectDeleteKey(entry) && "is-armed")}
+ className="danger"
data-action="delete-project"
- data-armed={armedDelete === projectDeleteKey(entry) ? "true" : undefined}
- onClick={() => void requestDeleteProject(entry)}
+ onClick={() => requestDeleteProject(entry)}
>
<IconTrash size={14} />
- {armedDelete === projectDeleteKey(entry)
- ? t("project.deleteMenuConfirm", { defaultValue: "Delete?" })
- : t("project.delete", { defaultValue: "Delete project" })}
+ {t("project.delete", { defaultValue: "Delete project" })}
</button>
- {entry.open ? (
- <button
- type="button"
- role="menuitem"
- onClick={() => void closeProject(entry)}
- >
- <IconX size={14} />
- {t("project.close")}
- </button>
- ) : null}
</>
) : null}
</div>,
diff --git a/apps/desktop/src/pages/ProjectsPage.tsx b/apps/desktop/src/pages/ProjectsPage.tsx
index 7821a2039..5737196d1 100644
--- a/apps/desktop/src/pages/ProjectsPage.tsx
+++ b/apps/desktop/src/pages/ProjectsPage.tsx
@@ -1,7 +1,6 @@
import { useEffect, useMemo, useRef, useState, type KeyboardEvent } from "react";
import { useTranslation } from "react-i18next";
import type { ProjectGroupRecord } from "@pi-desktop/shared";
-import { ErrorCodes } from "@pi-desktop/shared";
import { useAppStore } from "../stores/app-store";
import { api } from "../lib/api";
import { Button, TooltipButton, SegmentedControl, cx } from "../components/ui";
@@ -27,7 +26,6 @@ import { ProjectMemoryDialog } from "../components/ProjectMemoryDialog";
import { ProjectEditDialog } from "../components/ProjectEditDialog";
import { ProjectDeleteDialog } from "../components/ProjectDeleteDialog";
import { SessionRenameDialog } from "../components/SessionRenameDialog";
-import { useArmedDelete } from "../hooks/use-armed-delete";
import { AnchoredMenu } from "../components/settings/AnchoredMenu";
import {
INITIAL_VISIBLE_SESSION_COUNT,
@@ -54,11 +52,9 @@ export function ProjectsPage() {
const openProject = useAppStore((s) => s.openProject);
const activateProject = useAppStore((s) => s.activateProject);
const clearProject = useAppStore((s) => s.clearProject);
- const closeProject = useAppStore((s) => s.closeProject);
const renameProject = useAppStore((s) => s.renameProject);
const toggleProjectPinned = useAppStore((s) => s.toggleProjectPinned);
const archiveProject = useAppStore((s) => s.archiveProject);
- const deleteProjectAction = useAppStore((s) => s.deleteProject);
const restoreProject = useAppStore((s) => s.restoreProject);
const newSession = useAppStore((s) => s.newSession);
const selectSession = useAppStore((s) => s.selectSession);
@@ -80,8 +76,6 @@ export function ProjectsPage() {
const [openPath, setOpenPath] = useState<string | null>(null);
const [visibleSessionCounts, setVisibleSessionCounts] = useState<Record<string, number>>({});
const [menuFor, setMenuFor] = useState<string | null>(null);
- // Which row menu item is armed for its second, confirming click.
- const { armed: armedDelete, setArmed: setArmedDelete } = useArmedDelete();
const [renameFor, setRenameFor] = useState<SessionIndexRecord | null>(null);
const [editProjectFor, setEditProjectFor] = useState<{
path: string;
@@ -232,51 +226,15 @@ export function ProjectsPage() {
}
};
- /** Menu items of different surfaces never share an armed key. */
- const projectDeleteKey = (path: string) => `project:${normalizeProjectPath(path)}`;
-
- /**
- * Two-step delete for an index row. The first click arms the menu item and
- * relabels it; the second deletes an idle project straight away. A project
- * with a live turn keeps the dialog that names those sessions and stops them
- * before the delete.
- */
- const requestDeleteProject = async (project: ProjectIndexItem, totalSessions: number) => {
- const key = projectDeleteKey(project.path);
- if (armedDelete !== key) {
- setArmedDelete(key);
- return;
- }
- setArmedDelete(null);
+ /** Always require the explicit confirmation dialog before deleting a project. */
+ const requestDeleteProject = (project: ProjectIndexItem, totalSessions: number) => {
setMenuFor(null);
- const liveSessions = sessions.filter(
- (session) =>
- sessionMatchesIndexProject(session, project) && runningSessions[session.id] === true,
- );
- if (liveSessions.length > 0) {
- setDeleteFor({
- name: project.name,
- path: project.path,
- sessionCount: totalSessions,
- roots: project.roots,
- });
- return;
- }
- try {
- await deleteProjectAction(project.path);
- setRecents(loadRecentProjects());
- showToast(t("project.deleted", { name: project.name }), { variant: "success" });
- } catch (error) {
- // The host refuses a project whose task started after this render.
- showToast(
- (error as { errorCode?: unknown } | null)?.errorCode === ErrorCodes.CONFLICT
- ? t("project.deleteRunningBlocked")
- : error instanceof Error
- ? error.message
- : String(error),
- { variant: "error" },
- );
- }
+ setDeleteFor({
+ name: project.name,
+ path: project.path,
+ sessionCount: totalSessions,
+ roots: project.roots,
+ });
};
const toggleProjectArchive = async (project: (typeof items)[number]) => {
@@ -312,17 +270,6 @@ export function ProjectsPage() {
}
};
- const closeProjectFromIndex = async (path: string) => {
- try {
- await closeProject(path);
- setSettingsTab("projects");
- } catch (error) {
- showToast(error instanceof Error ? error.message : String(error), {
- variant: "error",
- });
- }
- };
-
const addProject = () =>
void openProject().then(() => setRecents(loadRecentProjects()));
@@ -340,11 +287,6 @@ export function ProjectsPage() {
const selectedActive =
project != null &&
normalizeProjectPath(workspace?.path) === normalizeProjectPath(project.path);
- const selectedRetained =
- project != null &&
- openProjectPaths.some(
- (path) => normalizeProjectPath(path) === normalizeProjectPath(project.path),
- );
const selectedArchived = project?.archived === true;
/*
@@ -644,35 +586,13 @@ export function ProjectsPage() {
<button
type="button"
role="menuitem"
- className={cx(
- "danger",
- armedDelete === projectDeleteKey(project.path) && "is-armed",
- )}
+ className="danger"
data-action="delete-project"
- data-armed={
- armedDelete === projectDeleteKey(project.path) ? "true" : undefined
- }
- onClick={() => void requestDeleteProject(project, totalSessions)}
+ onClick={() => requestDeleteProject(project, totalSessions)}
>
<IconTrash size={14} />
- {armedDelete === projectDeleteKey(project.path)
- ? t("project.deleteMenuConfirm")
- : t("project.delete")}
+ {t("project.delete")}
</button>
- {selectedRetained ? (
- <button
- type="button"
- role="menuitem"
- className="danger"
- onClick={() => {
- setMenuFor(null);
- void closeProjectFromIndex(project.path);
- }}
- >
- <IconX size={14} />
- {t("project.close")}
- </button>
- ) : null}
</AnchoredMenu>
</>
}
diff --git a/apps/desktop/test/project-delete-dialog-user-path.test.mjs b/apps/desktop/test/project-delete-dialog-user-path.test.mjs
new file mode 100644
index 000000000..e79529a1e
--- /dev/null
+++ b/apps/desktop/test/project-delete-dialog-user-path.test.mjs
@@ -0,0 +1,149 @@
+import assert from "node:assert/strict";
+import { spawn } from "node:child_process";
+import { createRequire } from "node:module";
+import { mkdtemp, rm, writeFile } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import test from "node:test";
+import { repositoryRoot, resolveElectronBinary } from "../../../scripts/e2e/boot.mjs";
+
+const root = repositoryRoot();
+const { build } = createRequire(join(root, "packages/agent-runtime/package.json"))("esbuild");
+const fixture = String.raw`
+import React from "react";
+import { createRoot } from "react-dom/client";
+import { flushSync } from "react-dom";
+import i18n from "i18next";
+import { initReactI18next } from "react-i18next";
+import { catalogs, flattenCatalog } from "@pi-desktop/i18n";
+import { ProjectDeleteDialog } from "../../apps/desktop/src/components/ProjectDeleteDialog";
+import { useAppStore } from "../../apps/desktop/src/stores/app-store";
+
+await i18n.use(initReactI18next).init({ lng: "en", keySeparator: false,
+ resources: { en: { translation: flattenCatalog(catalogs.en) } },
+ interpolation: { escapeValue: false } });
+window.piDesktop = { platform: "darwin", on() { return () => {}; },
+ invoke() { throw new Error("Unexpected IPC in project-delete dialog test"); } };
+const deleteCalls = [];
+let closeCount = 0;
+let deletedCount = 0;
+useAppStore.setState({
+ deleteProject: async (path) => { deleteCalls.push(path); },
+ abortSession: async () => { throw new Error("No running sessions expected"); },
+});
+function Surface() {
+ const [open, setOpen] = React.useState(true);
+ return open ? React.createElement(ProjectDeleteDialog, {
+ project: { name: "Fixture project", path: "/fixture/project", sessionCount: 0 },
+ runningSessionIds: [],
+ onClose() { closeCount += 1; setOpen(false); },
+ onDeleted() { deletedCount += 1; setOpen(false); },
+ onError(error) { throw error; },
+ }) : React.createElement("button", { onClick: () => setOpen(true) }, "Open delete dialog");
+}
+const rootNode = createRoot(document.getElementById("root"));
+flushSync(() => rootNode.render(React.createElement(Surface)));
+const frame = () => new Promise(requestAnimationFrame);
+async function settle() { await frame(); await frame(); }
+function check(condition, message) { if (!condition) throw new Error(message); }
+async function until(predicate, message) {
+ for (let n = 0; n < 120; n += 1) {
+ if (predicate()) return;
+ await frame();
+ }
+ throw new Error(message + " body=" + document.body.textContent);
+}
+window.projectDeleteProbe = async () => {
+ await settle();
+ check(document.querySelector('[role="dialog"]'), "confirmation dialog did not render");
+ flushSync(() => document.querySelector(".project-instructions-dialog-close").click());
+ await settle();
+ check(closeCount === 1, "X did not dismiss the dialog");
+ check(deleteCalls.length === 0, "X invoked project deletion");
+ check(!document.querySelector('[role="dialog"]'), "X left the dialog open");
+
+ flushSync(() => [...document.querySelectorAll("button")]
+ .find((button) => button.textContent.trim() === "Open delete dialog").click());
+ await settle();
+ check(document.querySelector('[role="dialog"]'), "dialog did not reopen");
+ flushSync(() => document.querySelector(".project-delete-dialog-confirm").click());
+ await until(() => deletedCount === 1, "confirmation did not complete");
+ await settle();
+ check(deleteCalls.length === 1 && deleteCalls[0] === "/fixture/project",
+ "explicit confirmation did not delete exactly once");
+ check(!document.querySelector('[role="dialog"]'), "confirmed dialog stayed open");
+ flushSync(() => rootNode.unmount());
+ return { passed: true, deleteCalls };
+};
+`;
+
+test("project-delete dialog X cancels and explicit confirmation deletes", {
+ skip: process.platform === "linux" && !process.env.DISPLAY ? "Electron requires a display" : false,
+}, async () => {
+ const temp = await mkdtemp(join(tmpdir(), "pi-project-delete-ui-"));
+ try {
+ await build({
+ stdin: { contents: fixture, resolveDir: join(root, "scripts/e2e"), loader: "tsx" },
+ outfile: join(temp, "renderer.js"),
+ bundle: true,
+ platform: "browser",
+ format: "esm",
+ jsx: "automatic",
+ define: { "process.env.NODE_ENV": '"production"' },
+ alias: {
+ "@pi-desktop/i18n": join(root, "packages/i18n/src"),
+ "@pi-desktop/shared": join(root, "packages/shared/src"),
+ react: join(root, "apps/desktop/node_modules/react"),
+ "react-dom": join(root, "apps/desktop/node_modules/react-dom"),
+ i18next: join(root, "apps/desktop/node_modules/i18next"),
+ "react-i18next": join(root, "apps/desktop/node_modules/react-i18next"),
+ },
+ nodePaths: [join(root, "apps/desktop/node_modules")],
+ });
+ await writeFile(join(temp, "index.html"),
+ '<!doctype html><meta charset="utf-8"><div id="root"></div><script type="module" src="renderer.js"></script>');
+ await writeFile(join(temp, "main.cjs"), `
+const { app, BrowserWindow } = require("electron");
+const path = require("node:path");
+app.setPath("userData", path.join(__dirname, "profile"));
+app.whenReady().then(async () => {
+ const win = new BrowserWindow({ show: false, width: 640, height: 480,
+ webPreferences: { sandbox: true, contextIsolation: true, nodeIntegration: false, backgroundThrottling: false } });
+ try {
+ await win.loadFile(path.join(__dirname, "index.html"));
+ console.log("PROJECT_DELETE_PROBE " + JSON.stringify(await win.webContents.executeJavaScript("window.projectDeleteProbe()")));
+ app.exit(0);
+ } catch (error) { console.error(error?.stack ?? error); app.exit(1); }
+});`);
+ const env = { ...process.env };
+ delete env.ELECTRON_RUN_AS_NODE;
+ const child = spawn(resolveElectronBinary(root).electronBinary, [join(temp, "main.cjs")], {
+ env,
+ stdio: ["ignore", "pipe", "pipe"],
+ });
+ let output = "";
+ for (const stream of [child.stdout, child.stderr]) {
+ stream.setEncoding("utf8");
+ stream.on("data", (chunk) => { output += chunk; });
+ }
+ const timer = setTimeout(() => child.kill("SIGKILL"), 45_000);
+ let code;
+ try {
+ code = await new Promise((resolve, reject) => {
+ child.once("error", reject);
+ child.once("close", resolve);
+ });
+ } finally {
+ clearTimeout(timer);
+ }
+ assert.equal(code, 0, output.slice(-6000));
+ const line = output.split(/\r?\n/).find((item) => item.startsWith("PROJECT_DELETE_PROBE "));
+ assert.ok(line, output.slice(-6000));
+ assert.deepEqual(JSON.parse(line.slice("PROJECT_DELETE_PROBE ".length)), {
+ passed: true,
+ deleteCalls: ["/fixture/project"],
+ });
+ } finally {
+ await rm(temp, { recursive: true, force: true });
+ }
+});
diff --git a/apps/desktop/test/project-delete.test.mjs b/apps/desktop/test/project-delete.test.mjs
index d4ec2b357..262e650c5 100644
--- a/apps/desktop/test/project-delete.test.mjs
+++ b/apps/desktop/test/project-delete.test.mjs
@@ -84,16 +84,15 @@ function dialogProps(source) {
}
/**
- * The body of the two-step project delete, from its declaration to the closing
- * brace at component indentation. The click handler of the menu item is checked
- * separately, so this helper owns the second half of the flow.
+ * The project delete request handler, through its closing brace.
+ * Both project surfaces must route every delete through the modal.
*/
function requestBlock(source) {
- const start = source.indexOf("const requestDeleteProject = async");
- assert.ok(start >= 0, "the two-step delete handler is present");
+ const start = source.indexOf("const requestDeleteProject");
+ assert.ok(start >= 0, "the project delete handler is present");
const rest = source.slice(start);
const end = rest.indexOf("\n };");
- assert.ok(end > 0, "the two-step delete handler closes");
+ assert.ok(end > 0, "the project delete handler closes");
return rest.slice(0, end);
}
@@ -139,9 +138,8 @@ test("both project menus expose a destructive delete action", () => {
["ProjectsPage", projectsSource],
["Sidebar", sidebarSource],
]) {
- // The item keeps its destructive styling and adds the armed state on top.
- // The item keeps its destructive styling and adds the armed state on top.
- assert.match(source, /className=\{cx\(\s*"danger",/, surface);
+ // The destructive style stays on the menu action until confirmation.
+ assert.match(source, /className="danger"/, surface);
assert.match(source, /data-action="delete-project"/, surface);
assert.match(source, /<ProjectDeleteDialog/, surface);
}
@@ -152,6 +150,11 @@ test("both project menus expose a destructive delete action", () => {
projectsSource.indexOf("toggleProjectArchive(project)"),
"ProjectsPage orders delete after archive",
);
+ assert.ok(
+ sidebarSource.indexOf('data-action="delete-project"') >
+ sidebarSource.indexOf('data-action="toggle-project-archive"'),
+ "Sidebar orders delete after archive",
+ );
assert.match(projectsSource, /sessionCount: totalSessions/);
assert.match(projectsSource, /setDeleteFor\(\{/);
assert.match(
@@ -159,87 +162,53 @@ test("both project menus expose a destructive delete action", () => {
/setRecents\(loadRecentProjects\(\)\);\s+showToast\(t\("project\.deleted", \{ name: deleteFor\.name \}\), \{ variant: "success" \}\)/,
);
- const sidebarDelete = sidebarSource.indexOf('data-action="delete-project"');
- assert.ok(
- sidebarDelete > sidebarSource.indexOf('data-action="toggle-project-archive"'),
- "Sidebar orders delete after archive",
- );
- assert.ok(
- sidebarDelete < sidebarSource.indexOf('t("project.close")'),
- "Sidebar orders delete before close",
- );
+ assert.doesNotMatch(projectsSource, /t\("project\.close"\)/);
+ assert.doesNotMatch(sidebarSource, /t\("project\.close"\)/);
assert.match(sidebarSource, /sessionCount: deleteProjectFor\.sessions\.length/);
assert.match(sidebarSource, /onError=\{reportError\}/);
});
-test("the menu item arms first and only a live task reaches the dialog", () => {
+test("both project delete menus require an explicit confirmation dialog", () => {
for (const [surface, source] of [
["ProjectsPage", projectsSource],
["Sidebar", sidebarSource],
]) {
const handler = deleteHandler(source);
- // The item is now the first step of a two-click delete, so the running-task
- // refusal can no longer live in the menu: the click only arms the row.
- assert.doesNotMatch(handler, /deleteRunningBlocked/, `${surface} drops the toast refusal`);
- assert.doesNotMatch(handler, /showToast/, `${surface} does not toast instead of confirming`);
- assert.doesNotMatch(
- handler,
- /setDelete(?:Project)?For\(/,
- `${surface} arms instead of opening the dialog`,
- );
- assert.match(
- handler,
- /requestDeleteProject\(/,
- `${surface} routes the click through the two-step handler`,
- );
- assert.match(handler, /data-armed=/, `${surface} exposes the armed state`);
- // The label has to name the second click while the item is armed.
- assert.match(source, /project\.deleteMenuConfirm/, `${surface} relabels the armed item`);
- assert.match(
- source,
- /t\("project\.delete"(?:, \{ defaultValue: "[^"]*" \})?\)/,
- `${surface} keeps the plain label`,
- );
+ assert.match(handler, /requestDeleteProject\(/, `${surface} routes the menu action`);
const request = requestBlock(source);
- assert.match(request, /if \(armedDelete !== key\) \{/, `${surface} arms on the first click`);
- assert.match(request, /setArmedDelete\(key\)/, `${surface} records the armed key`);
- assert.ok(
- request.indexOf("deleteProjectAction(") > request.indexOf("setArmedDelete(key)"),
- `${surface} deletes only after arming`,
- );
- // A project with a live turn still gets the dialog that stops it.
- assert.match(request, /runningSessions\[session\.id\] === true/, `${surface} checks live turns`);
- assert.match(
- request,
- /setDelete(?:Project)?For\(/,
- `${surface} opens the dialog for a project with a live task`,
- );
- assert.match(
+ assert.doesNotMatch(
request,
- /showToast\(t\("project\.deleted", \{ name: (?:entry|project)\.name \}\), \{ variant: "success" \}\)/,
- `${surface} reports the idle delete`,
+ /armedDelete|setArmedDelete/,
+ `${surface} does not arm a second menu click`,
);
- assert.match(
+ assert.doesNotMatch(
request,
- /errorCode === ErrorCodes\.CONFLICT[\s\S]{0,90}project\.deleteRunningBlocked/,
- `${surface} keeps the host refusal localized`,
+ /deleteProjectAction\(|deleteProject\(/,
+ `${surface} never deletes from the menu handler`,
);
-
- // The dialog still has to learn which of the project's sessions are live.
- const props = dialogProps(source);
- assert.match(props, /runningSessionIds=\{/, `${surface} passes the running sessions`);
- assert.match(
- props,
- /runningSessions\[session\.id\] === true/,
- `${surface} derives them from the live store`,
- );
- assert.match(props, /\.map\(\(session\) => session\.id\)/, `${surface} passes session ids`);
+ assert.match(request, /setDelete(?:Project)?For\(/, `${surface} opens the dialog`);
+ assert.match(source, /<ProjectDeleteDialog/, `${surface} renders the dialog`);
}
- // Each surface counts the sessions that belong to its own row.
- assert.match(dialogProps(projectsSource), /sessionMatchesIndexProject\(session, deleteFor\)/);
- assert.match(dialogProps(sidebarSource), /deleteProjectFor\.sessions\s*\.filter\(/);
+ assert.match(requestBlock(projectsSource), /sessionCount: totalSessions/);
+ assert.match(requestBlock(projectsSource), /roots: project\.roots/);
+ assert.match(requestBlock(sidebarSource), /setDeleteProjectFor\(entry\)/);
+});
+
+test("the dialog X and cancel action dismiss without deleting", () => {
+ const closeButton = dialogSource.match(/<TooltipButton[\s\S]*?<\/TooltipButton>/)?.[0] ?? "";
+ assert.match(closeButton, /onClick=\{onClose\}/, "the X button only closes the dialog");
+ assert.match(
+ dialogSource,
+ /<Button type="button" variant="ghost" disabled=\{busy\} onClick=\{onClose\}>/,
+ "the cancel button only closes the dialog",
+ );
+
+ const confirmBlock =
+ dialogSource.match(/const confirm = async \(\) => \{[\s\S]*?\n \};/)?.[0] ?? "";
+ assert.match(confirmBlock, /await deleteProject\(project\.path\)/);
+ assert.equal((confirmBlock.match(/await deleteProject\(project\.path\)/g) ?? []).length, 1);
});
test("the delete dialog names the running sessions and asks for an explicit confirmation", () => {
diff --git a/apps/desktop/test/two-step-delete.test.mjs b/apps/desktop/test/two-step-delete.test.mjs
index 57e8a3ce8..2bc98bce8 100644
--- a/apps/desktop/test/two-step-delete.test.mjs
+++ b/apps/desktop/test/two-step-delete.test.mjs
@@ -1,9 +1,6 @@
/**
- * The session and project rows delete in two clicks: the first click arms the
- * menu item and relabels it, the second removes the row. The arm is the same
- * one the settings capability rows use (`hooks/use-armed-delete.ts`), and it
- * expires on its own so a row never stays one stray click away from a
- * permanent delete.
+ * Session rows use a two-click delete arm. Project rows use an explicit modal
+ * so dismissal can never be mistaken for confirmation.
*/
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
@@ -84,18 +81,20 @@ test("the arm expires on its own and has a single owner", () => {
assert.match(skillsPageSource, /useArmedDelete\(\)/);
});
-test("the session and project rows share that arm", () => {
- for (const [surface, source] of [
- ["Sidebar", sidebarSource],
- ["ProjectsPage", projectsSource],
- ]) {
- assert.match(
- source,
- /import \{ useArmedDelete \} from "\.\.\/hooks\/use-armed-delete"/,
- surface,
- );
- assert.match(source, /const \{ armed: armedDelete, setArmed: setArmedDelete \} = useArmedDelete\(\)/);
- }
+test("only session rows use the shared two-step delete arm", () => {
+ assert.match(
+ sidebarSource,
+ /import \{ useArmedDelete \} from "\.\.\/hooks\/use-armed-delete"/,
+ );
+ assert.match(
+ sidebarSource,
+ /const \{ armed: armedDelete, setArmed: setArmedDelete \} = useArmedDelete\(\)/,
+ );
+ assert.doesNotMatch(projectsSource, /useArmedDelete|armedDelete/);
+
+ const projectRequest = handlerBlock(sidebarSource, "requestDeleteProject");
+ assert.match(projectRequest, /setDeleteProjectFor\(entry\)/);
+ assert.doesNotMatch(projectRequest, /armedDelete|deleteProjectAction/);
});
test("the session menu deletes on the second click, not the first", () => {
@@ -111,9 +110,7 @@ test("the session menu deletes on the second click, not the first", () => {
sidebarSource,
/\{armedDelete === session\.id\s*\?\s*t\("nav\.deleteTaskConfirm", \{ defaultValue: "Delete\?" \}\)\s*:\s*t\("nav\.deleteTask", \{ defaultValue: "Delete" \}\)\}/,
);
- // The session ids are the armed keys of the sidebar's session items, and the
- // project items namespace theirs so the two menus can never share an arm.
- assert.match(sidebarSource, /const projectDeleteKey = \(entry: ProjectEntry\) => `project:\$\{entry\.key\}`/);
+ // Session ids are the armed keys of the sidebar's session items.
const request = handlerBlock(sidebarSource, "requestDeleteSession");
assert.match(request, /if \(armedDelete !== session\.id\) \{/);
@@ -128,20 +125,20 @@ test("the session menu deletes on the second click, not the first", () => {
assert.doesNotMatch(request, /closeMenus/);
});
-test("both delete labels ship in every catalog and read the same", () => {
+test("the session delete label ships in every catalog", () => {
for (const id of LOCALE_IDS) {
const source = catalogs.get(id);
const expected = CONFIRM_LABELS[id];
- assert.equal(blockValue(catalogBlock(source, "nav", "sessionCollaboration"), "deleteTaskConfirm"), expected, id);
- assert.equal(blockValue(catalogBlock(source, "project", "scheduled"), "deleteMenuConfirm"), expected, id);
+ assert.equal(
+ blockValue(catalogBlock(source, "nav", "sessionCollaboration"), "deleteTaskConfirm"),
+ expected,
+ id,
+ );
if (id !== "en") {
assert.notEqual(expected, CONFIRM_LABELS.en, `${id} is translated`);
}
}
- // The armed label states the same action in the settings rows the pattern is
- // copied from, so the two surfaces never disagree about what a second click
- // does.
assert.equal(
blockValue(catalogBlock(catalogs.get("zh-CN"), "settings", "project"), "capabilityRemoveConfirm"),
"再点一次删除",
diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.md
index d8e59935f..d760c7a05 100644
--- a/docs/spec/04-ux/08-component-spec.md
+++ b/docs/spec/04-ux/08-component-spec.md
@@ -731,8 +731,7 @@ controls.
| Project pin | presentation priority only; no host row deletion/move |
| Project reorder | press-and-move on the title (8px), or ArrowUp/ArrowDown on that title, writes contiguous normalized-path order to sidebar preferences; accent insertion line; no visible grip |
| Project archive | omitted from default view; restorable from archived view |
-| Project close | removes retained tab only; durable project/sessions remain |
-| Project delete | row-menu danger action behind a second confirmation that names the project and the number of its sessions; refused with a message while any of those sessions is running and leaves group membership unchanged; removes the durable project row, those sessions, their transcripts, and its project memory; never deletes the folder on disk; deleting a root of a multi-folder project group detaches it as part of deletion, promotes the first remaining root when the primary is deleted, and removes the group record when its last root is deleted. A path the host no longer knows is still removed from the list. Detaching a root with chats through Edit project preserves them under a standalone project |
+| Project delete | the row-menu danger action always opens a confirmation dialog naming the project and session count; X, Cancel, Escape, and backdrop dismiss without changes; explicit confirmation stops listed running sessions before removing the durable project row, owned sessions/transcripts, and project memory; the folder is never deleted; deleting a root of a stored multi-folder project group is refused until the root is detached through Edit project. Chats on a detached root remain available as a standalone project. A path the host no longer knows is still removed from the list. |
| Project memory | row-menu editor reads and saves a compact list of titled or untitled memory cards for the exact project path; cards can be added, edited, and removed, the context is available in later chats, and it is never a higher-priority instruction |
| Session list | exact-path matches only; no basename grouping; the latest ten unpinned sessions appear initially, Load more reveals the remaining history, and collapsing the project clears that expanded-list state so the next expansion returns to the initial ten |
| Active group | exactly one group reflects the selected host workspace |
diff --git a/docs/spec/04-ux/09-interaction-patterns.md b/docs/spec/04-ux/09-interaction-patterns.md
index 9b65c6f23..041e6c411 100644
--- a/docs/spec/04-ux/09-interaction-patterns.md
+++ b/docs/spec/04-ux/09-interaction-patterns.md
@@ -267,15 +267,15 @@ may be retained while exactly one workspace supplies the visible shell context.
- **Archive** is non-destructive. Archived rows are hidden by default,
available through Show archived, and restorable. Archiving does not cancel
a turn or delete a transcript.
-- **Delete** removes a session or a project permanently and takes two clicks:
- the first arms the overflow item and relabels it (`nav.deleteTaskConfirm` /
- `project.deleteMenuConfirm`), and only the second click removes the row. The
- arm expires on its own, so a row never stays one stray click away from a
- permanent delete, and the folder on disk is never touched. A project whose
- turn is still live still opens the confirmation dialog that names those
- sessions and stops them first; an idle project is removed on that second
- click. Sidebar overflow menus stay inside the window; a tall menu scrolls
- within the available viewport so its last action remains reachable.
+- **Delete** removes a session or project permanently. Session deletion takes two
+ clicks: the first arms the overflow item and relabels it, and only the second
+ click removes the row. Project deletion opens a confirmation dialog as soon as
+ Delete is chosen from its menu. Only the dialog's explicit Delete button
+ removes the project; X, Cancel, Escape, or clicking the backdrop dismisses it
+ without changing anything. The dialog names the project and session count,
+ leaves the folder on disk untouched, and names/stops live sessions only after
+ the user confirms. Sidebar overflow menus stay inside the window; a tall menu
+ scrolls within the available viewport so its last action remains reachable.
- **Create branch** snapshots an idle conversation's complete active
transcript into an independent session in the same project/Temporary scope.
The command is disabled while the source runs. Success selects the child and
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 04bae3348..83de3f811 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -4092,9 +4092,9 @@ window; opening a normal panel afterward must still work.
additional folder with at least one saved chat. All chats are idle.
- **Steps**: 1) Open Edit project and remove the additional folder. 2) Save and
inspect the remaining group and the standalone project row for the detached
- folder. 3) Open the detached project's chat and confirm its transcript is
- intact. 4) Delete the detached project using its two-click delete action.
- 5) Inspect the remaining group, project list, chat list, and folder on disk.
+ folder. 3) Open its chat and confirm the transcript is intact. 4) Choose
+ Delete for the detached project and explicitly confirm in the dialog. 5)
+ Inspect the remaining group, project list, chat list, and folder on disk.
- **Expected**: Removing the folder from the group preserves its project row,
chats, and transcripts, and exposes it as a standalone project. Future chats
use the detached project's path-scoped context; shared instructions and
@@ -10415,32 +10415,31 @@ This test plan spec is accepted when:
- **Preconditions**: three durable projects A, B, and C, each with at least one
session that has a transcript; A archived and retained as a sidebar tab; B the
active workspace; C a root of a stored two-folder project group.
-- **Steps**: open Settings → Project archive, open A's row menu, choose Delete
- project, and confirm in the dialog. Then repeat the same action from the
- sidebar project menu for B while B is the active workspace: the item arms on
- the first click and only the second click removes B. Then attempt the same
- action for C, then for a path the host no longer knows, and finally for a
- fourth project D while one of D's tasks is still running.
-- **Expected**: the dialog names the project, states that the project and its
- sessions with their transcripts are removed permanently, and states that the
- folder on disk is not deleted; nothing is removed before the confirmation, and
- an armed item that is left alone disarms itself and removes nothing.
- After confirming, the durable project row, that project's sessions, their
- transcripts, scratch and review files, and its durable project memory are
- gone, while the folder on disk is untouched. The deleted project disappears
- from Settings → Project archive and from the sidebar immediately and again
- after a reload: no retained tab, no recent-project entry, no session-derived
- row, and no stale pin, archive, or order preference. Sessions and transcripts
- of every other project are untouched. When the deleted project was the active
- workspace, the workspace falls back to another open project or to Temporary,
- and the next launch does not reopen the deleted path. A project whose folder
- was moved or deleted on disk is still removable. Deleting C is refused with a
- message and the group is unchanged; a path the host has no durable row for is
- removed from the archive and the sidebar anyway, without a missing-project
- error. Deleting D while its task runs opens the confirmation dialog instead
- of a warning that disappears with its toast; the dialog names the running
- sessions and its confirm button reads as stopping them, cancelling removes
- nothing, and confirming stops exactly those turns and then deletes D (see
+- **Steps**: open Settings → Project archive, choose Delete project for A, and
+ verify the confirmation dialog appears before anything is removed. Press X
+ and verify A remains. Reopen the dialog and explicitly confirm. From the
+ sidebar project menu, repeat for active project B: choose Delete project,
+ cancel, verify B remains, then reopen and confirm. Then attempt the same
+ action for C, a path the host no longer knows, and a fourth project D while
+ one of D's tasks is still running.
+- **Expected**: choosing Delete immediately opens the dialog for idle projects
+ on both surfaces. X, Cancel, Escape, and backdrop clicks dismiss it without
+ removing the project, sessions, or transcripts. The dialog names the project,
+ states that its sessions and transcripts are removed permanently, and says
+ the folder on disk is untouched. After explicit confirmation, the durable
+ project row, owned sessions, transcripts, scratch and review files, and
+ project memory are gone. The project disappears from Settings → Project
+ archive and the sidebar immediately and after reload, with no retained tab,
+ recent-project entry, session-derived row, or stale pin/archive/order
+ preference. Other projects' sessions and transcripts are untouched. If the
+ deleted project was active, the workspace falls back to another open project
+ or Temporary, and the next launch does not reopen its path. A project whose
+ folder was moved or deleted on disk is still removable. Deleting C is refused
+ with a message and leaves the group unchanged; an unknown host path is removed
+ from the archive and sidebar without a missing-project error. Deleting D
+ while its task runs opens the same dialog with the running sessions named and
+ a stop-and-delete confirm label; cancelling leaves it and its task untouched,
+ while confirming stops exactly those turns before deleting D (see
E2E-PROJECT-delete-running-sessions-are-named-and-stopped).
- **Specs linked**: `03-runtime/06-host-rpc-protocol.md` §Projects,
`03-runtime/04-data-storage.md`, `04-ux/08-component-spec.md` §3.9, ADR 0251
@@ -10480,35 +10479,30 @@ This test plan spec is accepted when:
- **Acceptance criterion**: D (workspace), Quality
- **Milestone**: M6+
- **Status**: Partially automated — `apps/desktop/test/project-delete.test.mjs`
- pins both menus reaching the dialog with the project's live running session
- ids, the dialog's running-session line and stop-and-delete label, the abort
- loop running before `deleteProject`, the `CONFLICT` fallback, and the new
- copy in every shipped catalog; the end-to-end journey remains Draft
+ checks that both menu handlers always open the confirmation dialog without
+ deleting, and that X/Cancel only dismiss while the confirm handler owns the
+ delete call; the rendered Settings/sidebar journey remains Draft
### E2E-SESSION-two-click-delete-arms-first
-- **Preconditions**: a project with one idle session and one running session,
- both reachable from the sidebar session menu, the sidebar project menu, and
- the Projects index.
-- **Steps**: open the session menu of the idle session, press Delete once, and
- leave the item armed until the arm expires before pressing it again to confirm
- the removal. Repeat for a project row from the sidebar menu and from the
- Projects index.
+- **Preconditions**: a project with one idle and one running session, both
+ reachable from the sidebar session menu.
+- **Steps**: open the idle session menu and press Delete once. Verify it arms,
+ then cancel with Escape or wait for expiry and verify the session remains.
+ Reopen the menu, press Delete twice, and verify the session is removed. Repeat
+ the arm/cancel/confirm sequence for the running session after it becomes idle.
- **Expected**: the first press removes nothing and relabels the item to
- `nav.deleteTaskConfirm` / `project.deleteMenuConfirm` ("Delete?" / "确认删除?")
- with `data-armed="true"`; the menu stays open, and an outside press, Escape, or
- the expiry clears the arm without removing anything. Only the second press
- removes the session with its transcript and its row, and only the second press
- on a project row removes an idle project. A session and a project never share
- an arm. Deleting a project whose turn is live still opens the dialog that names
- those sessions and stops them (see
- E2E-PROJECT-delete-running-sessions-are-named-and-stopped).
-- **Specs linked**: `04-ux/09-interaction-patterns.md` §1.6, D421, D431, D441
+ `nav.deleteTaskConfirm` ("Delete?" / "确认删除?") with `data-armed="true"`;
+ the menu stays open, and an outside press, Escape, or expiry clears the arm
+ without removing anything. Only the second press removes a session and its
+ transcript. Project deletion instead requires its explicit confirmation
+ dialog (see E2E-PROJECT-delete-removes-project-and-owned-sessions).
+- **Specs linked**: `04-ux/09-interaction-patterns.md` §1.6, D421, D431
- **Acceptance criterion**: Quality
- **Milestone**: M6+
- **Status**: Partially automated — `apps/desktop/test/two-step-delete.test.mjs`
- pins the shared arm and its expiry, both labels in every shipped catalog, and
- that the first press only arms; the end-to-end journey remains Draft
+ pins the session arm and expiry plus localized labels; the end-to-end journey
+ remains Draft
### US-UI-59 Session-rooted background tools
- Start a visible turn in project A, switch to project B while it runs, and
inspect both sidebar status indicators.
diff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.md
index ac17bfd70..e50c58dfe 100644
--- a/docs/spec/08-meta/decisions-log.md
+++ b/docs/spec/08-meta/decisions-log.md
@@ -5921,6 +5921,7 @@ that was sitting at the bottom — including after the turn had finished.
## 2026-09-17 — Session and project rows delete on the second click (D441)
+- **Amended 2026-10-09**: Project menus now open `ProjectDeleteDialog` immediately, including for idle projects; the project-menu Close action is removed in favor of reversible Archive. Only the dialog's explicit confirm action deletes; X, Cancel, Escape, and backdrop clicks dismiss without changes. Session deletion retains the two-click arm. This supersedes the idle-project shortcut recorded below.
- The sidebar's session item and both project menus (sidebar and Projects index)
removed the row on the first click of Delete. Every other destructive row
action — the settings provider rows, vendor accounts, and the capability
diff --git a/docs/zh-CN/spec/04-ux/08-component-spec.md b/docs/zh-CN/spec/04-ux/08-component-spec.md
index 4ec5a7b23..61678f2f2 100644
--- a/docs/zh-CN/spec/04-ux/08-component-spec.md
+++ b/docs/zh-CN/spec/04-ux/08-component-spec.md
@@ -429,9 +429,9 @@ Collapsed (48px):
休息时视觉上隐藏
- 右键单击 `Sessions` 标题或空独立列表镶边:打开一个
打开无路径未持久化草稿的单项创建菜单
-- 项目溢出:切换、打开文件夹、重命名、pin/unpin、archive/restore、关闭
- 保留选项卡。重命名只修改本地显示名称;打开文件夹在系统文件管理器中
- 显示所选项目行的项目目录。
+- 项目溢出:切换、打开文件夹、重命名、pin/unpin、archive/restore、删除。
+ 归档会从常规列表隐藏项目且可恢复;删除必须在确认对话框中明确确认,
+ 只移除应用记录与会话,不删除磁盘文件夹。
- 对话溢出:pin/unpin、archive/restore、创建分支、复制会话链接、删除。
当该对话运行时,创建分支被禁用;成功
激活独立的子会话并集中输入框。「复制会话链接」对所有读者可见(§20B);
@@ -540,8 +540,7 @@ expanded/collapsed 侧边栏仍为 20px/18px 且启动画面为 64 像素。
| 项目引脚 | 仅限演示优先;无主机行删除/移动 |
| 项目重排 | 按住标题移动 8px,或在该标题上按 `ArrowUp`/`ArrowDown`,会将连续的规范化路径顺序写入侧边栏偏好;强调色插入线;没有可见 grip |
| 项目档案 | 从默认视图中省略;可从存档视图恢复 |
-| 项目结束 | 仅删除保留的选项卡;持久的项目与会话仍然存在 |
-| 删除项目 | 行菜单中的危险操作,位于第二次确认之后,该确认会指明项目名称及其会话数量;只要其中仍有会话在运行就会先被拒绝并给出提示消息;移除持久项目行、这些会话、其转录本及其项目记忆;从不删除磁盘上的文件夹;属于多文件夹项目组的路径会被拒绝并给出提示消息,而宿主已不再知晓的路径仍会从列表中移除 |
+| 删除项目 | 项目菜单中的危险操作会立即打开确认对话框,显示项目名称和会话数量;点击 X、“取消”、按 Escape 或点击遮罩都会关闭对话框且不作更改;明确确认后先停止仍在运行的会话,再移除持久项目行、所属会话、转录本与项目记忆;不会删除磁盘文件夹;删除项目组根路径会被拒绝并提示;宿主已不再知晓的路径仍会从列表移除 |
| 项目记忆 | 行菜单编辑器读取并保存一份紧凑的、按规范项目路径键控的有标题或无标题记忆卡列表;卡片可添加、编辑和移除,该上下文在后续聊天中可用,且它绝不是更高优先级的指令 |
| 会话列表 | 仅精确路径匹配;无基本名称分组;项目组初始显示最新的 10 条未置顶会话,“加载更多”显示剩余历史记录;折叠项目会清除该组的扩展状态,下次展开时恢复到初始的 10 条 |
| 活跃组 | 恰好一组反映了选定的主机工作区 |
diff --git a/docs/zh-CN/spec/04-ux/09-interaction-patterns.md b/docs/zh-CN/spec/04-ux/09-interaction-patterns.md
index 89795c8a0..612f1fbae 100644
--- a/docs/zh-CN/spec/04-ux/09-interaction-patterns.md
+++ b/docs/zh-CN/spec/04-ux/09-interaction-patterns.md
@@ -204,12 +204,12 @@
- **存档**是非破坏性的。默认情况下,存档的行是隐藏的,
可通过显示已存档且可恢复。存档不会取消
转动或删除成绩单。
-- **删除**会永久移除会话或项目,并且需要点击两次:第一次点击武装该溢出菜单项并改写其
- 标签(`nav.deleteTaskConfirm` / `project.deleteMenuConfirm`),只有第二次点击才会移除
- 该行。武装会在几秒后自行失效,因此一行永远不会停留在“再点一次就永久删除”的状态,磁盘
- 上的文件夹也永远不会被触碰。仍有运行中轮次的项目依然会打开确认对话框,由它指明这些会话
- 并先将其停止;空闲的项目在第二次点击时即被移除。
- 侧边栏溢出菜单保持在窗口范围内;较高的菜单会在可用视口内滚动,确保最后一项仍可访问。
+- **删除**会永久移除会话或项目。会话删除需要点击两次:第一次点击会武装溢出菜单项并改写标签,
+ 只有第二次点击才会移除该行。选择项目菜单中的“删除项目”后会立即打开确认对话框;只有点击对话框
+ 中明确的删除按钮才会删除项目。点击右上角 X、“取消”、按 Escape 或点击遮罩层,只会关闭对话框,
+ 不会改变任何内容。对话框会显示项目名称和会话数量,磁盘上的文件夹不会被删除;只有确认后才会
+ 列出并停止仍在运行的会话。侧边栏溢出菜单保持在窗口范围内;较高的菜单会在可用视口内滚动,确保
+ 最后一项仍可访问。
- **创建分支**快照空闲对话的完整活动状态
转录到同一 project/Temporary 范围内的独立会话中。
当源运行时该命令被禁用。成功选择了孩子
diff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
index e9401aa89..21f228127 100644
--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
@@ -2097,7 +2097,7 @@ hover/focus 不带移位标签,项目标题 hover/focus 路径显示
#### E2E-048c:分离含聊天的项目文件夹并单独删除
- **前提:** 一个保留的逻辑项目包含一个主文件夹和一个有至少一条已保存聊天的附加文件夹;所有聊天均处于空闲状态。
-- **步骤:** 1) 打开“编辑项目”并移除附加文件夹。2) 保存后检查剩余项目组及该文件夹对应的独立项目行。3) 打开独立项目中的聊天,确认对话记录完整。4) 使用两步删除操作删除该独立项目。5) 检查剩余项目组、项目列表、聊天列表及磁盘上的文件夹。
+- **步骤:** 1) 打开“编辑项目”并移除附加文件夹。2) 保存后检查剩余项目组及该文件夹对应的独立项目行。3) 打开独立项目中的聊天,确认对话记录完整。4) 对独立项目选择“删除项目”,并在确认对话框中明确确认。5) 检查剩余项目组、项目列表、聊天列表及磁盘上的文件夹。
- **预期:** 从项目组移除文件夹会保留其项目记录、聊天和对话记录,并将其作为独立项目显示。新聊天使用该项目的路径级上下文;共享说明和记忆仍属于原项目组。确认删除后会移除该项目的会话及对话记录,但保留磁盘上的文件夹;原项目组仍保留主文件夹。
- **链接规格:** `03-runtime/04-data-storage.md`、`04-ux/08-component-spec.md`、`04-ux/09-interaction-patterns.md`、ADR 0249、ADR 0251。
- **验收:** C(项目和聊天交互)、F(持久化)、品质。
@@ -6267,23 +6267,8 @@ eleven-tool-round desktop paths are verified by
- **前提条件**:三个持久项目 A、B 和 C,每个都至少有一个带转录本的会话;A 已归档并作为
侧边栏选项卡保留;B 是活动工作区;C 是一个已存储双文件夹项目组的根目录。
-- **步骤**:打开设置 → 项目存档,打开 A 的行菜单,选择删除项目,并在对话框中确认。然后
- 从侧边栏项目菜单对正处于活动工作区的 B 重复同一操作:第一次点击只是武装该项,只有第二次
- 点击才会移除 B。接着对 C 尝试同一操作,然后对一个宿主已不再知晓的路径尝试,最后在 D 的
- 某个任务仍在运行时尝试删除 D。
-- **预期**:对话框会指明项目名称,说明该项目及其会话与转录本会被永久移除,并说明磁盘上的
- 文件夹不会被删除;确认之前不会移除任何内容,被武装后放置不管的项会自行解除武装、不会移除
- 任何东西。确认后,持久项目行、该项目的会话、其转录本、scratch 和 review 文件以及该项目的
- 持久记忆均已消失,而磁盘上的文件夹保持原样。被删除的项目会立即从设置 → 项目存档和侧边栏
- 中消失,重新加载后依然如此:没有保留的选项卡、没有最近项目条目、没有由会话推导的行,也没有
- 残留的 pin、archive 或 order 偏好。其他所有项目的会话与转录本不受影响。当被删除的项目曾是
- 活动工作区时,工作区回退到另一个已打开的项目
- 或 Temporary,且下次启动不会重新打开已删除的路径。磁盘上文件夹已被移动或删除的项目仍可
- 移除。删除 C 会被拒绝并给出提示消息,该组保持不变;宿主已无持久行的路径仍会从项目存档与
- 侧边栏中移除,不会报出缺少项目的错误。当 D 的任务仍在运行时删除 D 会打开确认对话框,而不是给出
- 一条随 toast 消失的警告;对话框会指明正在运行的会话,其确认按钮表述为停止这些任务,取消不会移除
- 任何内容,确认则先停止这些轮次,然后再删除 D(见
- E2E-PROJECT-delete-running-sessions-are-named-and-stopped)。
+- **步骤**:打开设置 → 项目存档,为 A 选择“删除项目”,确认在任何内容移除前会打开确认对话框。点击 X 并确认 A 仍存在,再打开对话框并明确确认删除。然后从侧边栏项目菜单对活动项目 B 重复:选择删除、取消并确认 B 仍存在,再重新打开对话框并确认删除。随后尝试删除 C、宿主已不再知晓的路径,以及仍有任务运行的第四个项目 D。
+- **预期**:两个界面的空闲项目在选择“删除项目”后都会立即打开确认对话框。点击 X、“取消”、按 Escape 或点击遮罩层只会关闭对话框,不会移除项目、会话或转录本。对话框会说明项目、所属会话及转录本将被永久移除,并说明磁盘文件夹不会被删除。明确确认后,持久项目行、所属会话、转录本、scratch、review 文件及项目记忆都会移除。项目会立即从设置 → 项目存档和侧边栏消失,重新加载后也不会重新出现:没有保留的选项卡、最近项目条目、会话推导行或残留的 pin/archive/order 偏好。其他项目的会话和转录本不受影响。若删除的是活动项目,工作区会回退到另一个已打开项目或 Temporary,下次启动也不会重新打开该路径。即使项目文件夹已被移动或删除,仍可移除项目。删除 C 会被拒绝并显示提示,项目组保持不变;宿主已无持久行的路径仍会从项目存档和侧边栏移除,不会报缺少项目错误。删除仍有运行任务的 D 时会打开同一个确认对话框并列出运行中的会话,确认按钮会明确表示停止并删除;取消会保留项目和任务,确认则先停止对应轮次再删除 D(见 E2E-PROJECT-delete-running-sessions-are-named-and-stopped)。
- **链接规格**:`03-runtime/06-host-rpc-protocol.md` §项目、
`03-runtime/04-data-storage.md`、`04-ux/08-component-spec.md` §3.9、ADR 0251
- **验收**:D(工作区)、F(持久化)、品质
@@ -6317,21 +6302,13 @@ eleven-tool-round desktop paths are verified by
### E2E-SESSION-two-click-delete-arms-first
-- **前提条件**:一个包含一个空闲会话和一个运行中会话的项目,二者都可从侧边栏会话菜单、侧边栏
- 项目菜单以及项目索引到达。
-- **步骤**:打开空闲会话的会话菜单,按一次删除,并让该项保持武装直到武装超时,然后再按一次以
- 确认移除。对来自侧边栏菜单与项目索引的项目行重复该操作。
-- **预期**:第一次按下不会移除任何东西,并把该项标签改为 `nav.deleteTaskConfirm` /
- `project.deleteMenuConfirm`("Delete?" / "确认删除?")且带 `data-armed="true"`;菜单保持
- 打开,点击外部、按 Escape 或武装超时都会解除武装且不移除任何内容。只有第二次按下才会移除
- 该会话及其转录本和该行,也只有对项目行的第二次按下才会移除空闲项目。会话与项目永远不会共用
- 一次武装。删除仍有运行中轮次的项目时,仍会打开指明这些会话并停止它们的对话框(见
- E2E-PROJECT-delete-running-sessions-are-named-and-stopped)。
-- **链接规格**:`04-ux/09-interaction-patterns.md` §1.6、D421、D431、D441
+- **前提条件**:一个项目包含一个空闲会话和一个仍在运行中的会话,两者都可从侧边栏会话菜单访问。
+- **步骤**:打开空闲会话菜单并按一次“删除”,确认该项进入武装状态;按 Escape 或等待武装超时后,确认会话仍存在。重新打开菜单,连续点击两次“删除”,确认会话被移除。待运行中的会话结束后,对它重复武装、取消和确认流程。
+- **预期**:第一次点击不会移除内容,并把标签改为 `nav.deleteTaskConfirm`(“Delete?” / “确认删除?”),且带 `data-armed="true"`;菜单保持打开,点击外部、按 Escape 或等待超时都会解除武装且不移除内容。只有第二次点击才会删除会话及其转录本。项目删除则必须通过明确的确认对话框(见 E2E-PROJECT-delete-removes-project-and-owned-sessions)。
+- **链接规格**:`04-ux/09-interaction-patterns.md` §1.6、D421、D431
- **验收**:品质
- **里程碑**:M6+
-- **状态**:部分自动化 —— `apps/desktop/test/two-step-delete.test.mjs` 固定了共享的武装与它的
- 超时、所有已发布语言包中的两个标签,以及第一次按下只做武装;端到端旅程仍为草稿
+- **状态**:部分自动化 —— `apps/desktop/test/two-step-delete.test.mjs` 固定了会话武装状态、超时及本地化标签;端到端旅程仍为草稿
### US-UI-59 基于会话的后台工具
- 在项目 A 中启动可见轮次,在项目 B 运行时切换到项目 B,并且
diff --git a/docs/zh-CN/spec/08-meta/decisions-log.md b/docs/zh-CN/spec/08-meta/decisions-log.md
index 5146c2cb3..c656e779c 100644
--- a/docs/zh-CN/spec/08-meta/decisions-log.md
+++ b/docs/zh-CN/spec/08-meta/decisions-log.md
@@ -4474,6 +4474,7 @@ that amendment are retired by ADR 0268; the upstream work-panel lifecycle stays.
## 2026-09-17 —— 会话与项目行在第二次点击时才删除(D441)
+- **2026-10-09 修订**:两个项目菜单现在都会立即打开 `ProjectDeleteDialog`(包括空闲项目),并移除了“关闭项目”入口,统一使用可恢复的归档来隐藏项目。只有点击对话框中明确的确认按钮才会执行删除;X、“取消”、按 Escape 和点击遮罩都只关闭对话框,不会更改任何内容。会话删除仍保留两步武装。此修订取代下文关于空闲项目第二次点击直接删除的行为。
- 侧边栏的会话菜单项与两个项目菜单(侧边栏与项目索引)此前在第一次点击「删除」时就移除该行。应用内其他所有破坏性行操作 —— 设置里的模型服务行、厂商账户行以及能力表格 —— 都先武装再改写控件标签,于是最不能撤销的两个动作反而是唯一单击即生效的。
- 这一模式现在由 `hooks/use-armed-delete.ts` 为整个渲染层拥有:同一个 `ARMED_DELETE_MS`(3200ms)失效时间与同一个 `useArmedDelete()`。能力页面继续从 `AgentCapabilityLayout` 导入它,而该布局改为再导出这个共享 hook,不再保留一份带自己超时的副本,因此这一模式不会在设置行与两个菜单之间漂移。
- 会话菜单项以 `session.id` 作为武装键;两个项目菜单则以 `project:` 前缀的键武装,因此会话与项目永远不会共用一次武装。被武装的菜单项带 `data-armed="true"`、危险色淡底,并在八种语言里都把标签换成 `nav.deleteTaskConfirm` / `project.deleteMenuConfirm`("Delete?" / "确认删除?")。两次点击之间菜单保持打开;点击外部、按 Escape 或武装超时都会解除武装且不移除任何内容。