Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(settings): close the project archive card by clicking its row again
vastsa5bd2ac4102ef
diff --git a/apps/desktop/src/features/projects/ProjectArchiveIndex.tsx b/apps/desktop/src/features/projects/ProjectArchiveIndex.tsxindex f0e0d0fc1..83c1c4840 100644--- a/apps/desktop/src/features/projects/ProjectArchiveIndex.tsx+++ b/apps/desktop/src/features/projects/ProjectArchiveIndex.tsx@@ -32,6 +32,7 @@ export function projectRowId(path: string) {export function ProjectArchiveIndex({groups,selectedPath,+ openPath,workspacePath,openProjectPaths,locale,@@ -42,6 +43,8 @@ export function ProjectArchiveIndex({}: {groups: { id: GroupId; rows: ProjectIndexItem[] }[];selectedPath: string | null;+ /** Path whose card is open. `null` when the selected row's card is closed. */+ openPath: string | null;workspacePath?: string | null;openProjectPaths: readonly string[];locale?: string;@@ -68,6 +71,7 @@ export function ProjectArchiveIndex({<div className="projects-group-rows" role="list">{group.rows.map((project) => {const selected = selectedPath === project.path;+ const open = openPath === project.path;const status = projectStatus({project,workspacePath,@@ -83,6 +87,7 @@ export function ProjectArchiveIndex({className={cx("projects-row-block",selected && "selected",+ open && "open",status === "active" && "active",status === "archived" && "archived",)}@@ -92,7 +97,7 @@ export function ProjectArchiveIndex({className="projects-row"title={project.path}aria-label={t("project.selectProject", { name: project.name })}- aria-expanded={selected}+ aria-expanded={open}aria-current={selected ? "true" : undefined}onClick={() => onSelect(project.path)}onDoubleClick={() => onActivate(project.path)}@@ -129,7 +134,7 @@ export function ProjectArchiveIndex({<IconChevronRight size={14} /></span></button>- {selected && detail ? (+ {open && detail ? (<divclassName="projects-inspector"role="region"diff --git a/apps/desktop/src/lib/project-archive.ts b/apps/desktop/src/lib/project-archive.tsindex 3666e889b..e54e3b5b5 100644--- a/apps/desktop/src/lib/project-archive.ts+++ b/apps/desktop/src/lib/project-archive.ts@@ -168,6 +168,31 @@ export function projectStatus(args: {return null;}+/**+ * Whether one project's card is open. Kept apart from the selection so the+ * disclosure indicator can mean what it looks like: the selected row stays the+ * current row while its card is closed again.+ */+export type ArchiveCardState = { selectedPath: string; open: boolean };++/**+ * One row click, resolved. The row whose card is already open closes it, any+ * other row becomes the selection and opens. Without this the index had no+ * collapse path at all: clicking the open row re-selected it and the card+ * stayed up, while the rotating indicator promised otherwise.+ */+export function toggleArchiveRow(args: {+ selectedPath: string | null;+ open: boolean;+ clickedPath: string;+}): ArchiveCardState {+ const { selectedPath, open, clickedPath } = args;+ if (clickedPath === selectedPath && open) {+ return { selectedPath: clickedPath, open: false };+ }+ return { selectedPath: clickedPath, open: true };+}+export function compareProjects(a: ProjectIndexItem,b: ProjectIndexItem,diff --git a/apps/desktop/src/pages/ProjectsPage.tsx b/apps/desktop/src/pages/ProjectsPage.tsxindex 4b861c007..39387b60c 100644--- a/apps/desktop/src/pages/ProjectsPage.tsx+++ b/apps/desktop/src/pages/ProjectsPage.tsx@@ -39,6 +39,7 @@ import {neighborPath,resolveSelectedPath,sessionMatchesIndexProject,+ toggleArchiveRow,type ProjectIndexItem,type SessionIndexRecord,type SortMode,@@ -78,6 +79,8 @@ export function ProjectsPage() {const [selectedPath, setSelectedPath] = useState<string | null>(null);const [visibleSessionCounts, setVisibleSessionCounts] = useState<Record<string, number>>({});const [menuFor, setMenuFor] = useState<string | null>(null);+ // The card under the selected row: closed again by clicking that same row.+ const [cardOpen, setCardOpen] = useState(true);// Which row menu item is armed for its second, confirming click.const { armed: armedDelete, setArmed: setArmedDelete } = useArmedDelete();const [renameFor, setRenameFor] = useState<SessionIndexRecord | null>(null);@@ -365,6 +368,7 @@ export function ProjectsPage() {);if (!next || next === selectedPath) return;setSelectedPath(next);+ setCardOpen(true);setMenuFor(null);document.getElementById(projectRowId(next))@@ -493,13 +497,20 @@ export function ProjectsPage() {<div className="projects-workbench" tabIndex={0} onKeyDown={onIndexKeyDown}><ProjectArchiveIndexgroups={groups}+ openPath={cardOpen ? selectedPath : null}selectedPath={selectedPath}workspacePath={workspace?.path}openProjectPaths={openProjectPaths}locale={locale}sessionCounts={sessionCounts}onSelect={(path) => {- setSelectedPath(path);+ const next = toggleArchiveRow({+ selectedPath,+ open: cardOpen,+ clickedPath: path,+ });+ setSelectedPath(next.selectedPath);+ setCardOpen(next.open);setMenuFor(null);}}onActivate={(path) => void activate(path)}diff --git a/apps/desktop/src/styles/projects.css b/apps/desktop/src/styles/projects.cssindex 5c87d8601..ed0bf0f3a 100644--- a/apps/desktop/src/styles/projects.css+++ b/apps/desktop/src/styles/projects.css@@ -416,7 +416,9 @@transition: transform var(--motion-duration-fast) var(--motion-ease-out);}-.projects-row-block.selected .projects-row-disclosure {+/* Keyed on the open card, not on selection: a selected row whose card was+ closed again must point right, or the indicator lies about the state. */+.projects-row-block.open .projects-row-disclosure {transform: rotate(90deg);color: var(--ds-text-muted);}diff --git a/apps/desktop/test/project-archive.test.mjs b/apps/desktop/test/project-archive.test.mjsindex 68f68bc3c..dafb69aa2 100644--- a/apps/desktop/test/project-archive.test.mjs+++ b/apps/desktop/test/project-archive.test.mjs@@ -14,6 +14,7 @@ import {sessionMatchesQuery,sessionTimestamp,shortenPath,+ toggleArchiveRow,} from "../src/lib/project-archive.ts";test("the archive never hides archived rows behind a filter", () => {@@ -149,3 +150,31 @@ test("the index merges durable groups ahead of recents and session seeds", () =>assert.equal(INITIAL_VISIBLE_SESSION_COUNT, 8);assert.ok(sessionTimestamp("2026-01-02T00:00:00.000Z") > 0);});++test("one row click toggles that row's card and opens any other", () => {+ // The open card closes again: this is the path the index was missing, where+ // clicking the selected row re-selected it and the card stayed up.+ assert.deepEqual(+ toggleArchiveRow({ selectedPath: "/a", open: true, clickedPath: "/a" }),+ { selectedPath: "/a", open: false },+ );+ // Clicking the closed row reopens it rather than collapsing "nothing".+ assert.deepEqual(+ toggleArchiveRow({ selectedPath: "/a", open: false, clickedPath: "/a" }),+ { selectedPath: "/a", open: true },+ );+ // Any other row becomes the selection and opens, whichever row was open.+ assert.deepEqual(+ toggleArchiveRow({ selectedPath: "/a", open: true, clickedPath: "/b" }),+ { selectedPath: "/b", open: true },+ );+ assert.deepEqual(+ toggleArchiveRow({ selectedPath: "/a", open: false, clickedPath: "/b" }),+ { selectedPath: "/b", open: true },+ );+ // First click with nothing selected yet opens that row.+ assert.deepEqual(+ toggleArchiveRow({ selectedPath: null, open: false, clickedPath: "/a" }),+ { selectedPath: "/a", open: true },+ );+});diff --git a/apps/desktop/test/settings-project-archive.test.mjs b/apps/desktop/test/settings-project-archive.test.mjsindex 144ce636f..7b4ebd9e0 100644--- a/apps/desktop/test/settings-project-archive.test.mjs+++ b/apps/desktop/test/settings-project-archive.test.mjs@@ -126,7 +126,7 @@ test("the index row carries identity and the selected row is its own card headerassert.match(projectsIndexSource, /projects-row-disclosure/);assert.match(projectsPartialSource,- /\.projects-row-block\.selected \.projects-row-disclosure\s*\{[^}]*rotate\(90deg\)/,+ /\.projects-row-block\.open \.projects-row-disclosure\s*\{[^}]*rotate\(90deg\)/,);// The open card is headed by that same row, so the detail never repeats the// name, the path, or the status tag: no second source of truth on screen.@@ -138,6 +138,21 @@ test("the index row carries identity and the selected row is its own card headerassert.doesNotMatch(projectsDetailSource, /projects-tag/);});+test("the selected row's card can be closed again", () => {+ // One click resolves through the shared toggle, so clicking the open row+ // closes it instead of re-selecting it and leaving the card up.+ assert.match(projectsPageSource, /toggleArchiveRow\(\{/);+ assert.match(projectArchiveSource, /export function toggleArchiveRow\(/);+ // Selection and the open card are separate: the ring stays on the current+ // row while the card is closed, and only the open row renders the panel.+ assert.match(projectsIndexSource, /const open = openPath === project\.path/);+ assert.match(projectsIndexSource, /aria-expanded=\{open\}/);+ assert.match(projectsIndexSource, /\{open && detail \? \(/);+ assert.match(projectsPageSource, /openPath=\{cardOpen \? selectedPath : null\}/);+ // Moving the selection with the keyboard always opens the row it landed on.+ assert.match(projectsPageSource, /setSelectedPath\(next\);\n\s+setCardOpen\(true\);/);+});+test("the selected row is selected by one shared status helper", () => {assert.match(projectArchiveSource, /export function projectStatus\(/);assert.match(projectArchiveSource, /active: "project\.active"/);diff --git a/docs/spec/04-ux/06-settings-ia.md b/docs/spec/04-ux/06-settings-ia.mdindex d7037efa3..4ba009abb 100644--- a/docs/spec/04-ux/06-settings-ia.md+++ b/docs/spec/04-ux/06-settings-ia.md@@ -607,7 +607,10 @@ system while preserving their different data ownership:time, closed by the row's disclosure indicator. The colored glyph uses Folderfor ordinary projects and a filled Star for pinned projects. Rows are tilesseparated by the row gap, never by rules. A click selects the row and keeps- Settings open; double-click or Enter activates the project and returns to chat+ Settings open, and a click on the row whose card is already open closes that+ card again; the disclosure indicator turns down only while the card is open,+ so it never claims a closed card is open. Double-click or Enter activates the+ project and returns to chat- The card under the selected row is the detail panel, and it repeats nothingthe row already states — no second copy of the name, the path, or the statustag. It opens with an action bar (New task, Open while the project is not thediff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.mdindex 3126cf93e..fc996344b 100644--- a/docs/spec/08-meta/decisions-log.md+++ b/docs/spec/08-meta/decisions-log.md@@ -6282,6 +6282,12 @@ that was sitting at the bottom — including after the turn had finished.that differ only in separators can no longer collide. An empty index shows thepending indicator until the host listing settles instead of "no projects yet",and the expanded card and the disclosure indicator honor reduced motion.+- Clicking the row whose card is open closes it again, through one shared+ toggle. Selection and the open card are separate states, so the current row+ keeps its ring while its card is closed and the disclosure indicator turns+ down only while the card is really open. Moving the selection with the arrow+ keys always opens the row it landed on.+ Presentation only: no IPC, storage, host-protocol, orPresentation only: no IPC, storage, host-protocol, oractivation-semantics change. See `04-ux/06-settings-ia.md`,`04-ux/07-ui-design-system.md`, and ADR 0294.diff --git a/docs/zh-CN/spec/04-ux/06-settings-ia.md b/docs/zh-CN/spec/04-ux/06-settings-ia.mdindex ad122e9cb..294528a31 100644--- a/docs/zh-CN/spec/04-ux/06-settings-ia.md+++ b/docs/zh-CN/spec/04-ux/06-settings-ia.md@@ -262,7 +262,9 @@ Token 用量**不是设置目的地**(D335 / ADR 0173)。已完成回合历(当前 / 已打开 / 已归档)、用于区分同名项目的缩短等宽路径,然后是右对齐的会话计数与相对上次活动时间,最后是该行的展开指示器。普通项目用文件夹字形,置顶项目用实心星标。行靠行间距分隔,从不使用分隔线。- 单击选中并留在设置页;双击或 Enter 激活项目并返回聊天+ 单击选中并留在设置页,再次单击已展开卡片的那一行则收起该卡片;+ 展开指示器只在卡片展开时转向下方,不会把已收起的卡片说成展开。+ 双击或 Enter 激活项目并返回聊天- 选中行下方的卡片即详情面板,它不重复行上已有的信息 —— 不会有第二份名称、路径或状态标签。它先是一个操作栏(新任务、项目不是当前工作区时的“打开”、以及更多菜单),接着是只读的文件夹与分支信息、会话计数,diff --git a/docs/zh-CN/spec/08-meta/decisions-log.md b/docs/zh-CN/spec/08-meta/decisions-log.mdindex 2a9dfd428..27310e872 100644--- a/docs/zh-CN/spec/08-meta/decisions-log.md+++ b/docs/zh-CN/spec/08-meta/decisions-log.md@@ -4506,5 +4506,9 @@ that amendment are retired by ADR 0268; the upstream work-panel lifecycle stays.焦点移到该行;该处理器会让位于展开的卡片,因此详情内的 Enter 仍是该控件自身的操作。行元素 id 经过编码,只靠分隔符区分的两条路径不会再撞车。索引为空时在宿主列表返回前显示等待指示器,而不是「暂无项目」;展开的卡片与展开指示器遵循减少动效设置。+- 再次单击已展开卡片的那一行会收起卡片,走同一个共享切换函数。选中与卡片展开是+ 两个独立状态:当前行在卡片收起时仍保留选中环,展开指示器只在卡片真正展开时+ 转向下方。用方向键移动选中时总会展开落点所在的那一行。+ 仅演示层:无 IPC、存储、宿主协议或激活语义改动。见 `04-ux/06-settings-ia.md`、仅演示层:无 IPC、存储、宿主协议或激活语义改动。见 `04-ux/06-settings-ia.md`、`04-ux/07-ui-design-system.md` 与 ADR 0294。