Skip to content

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

fix(desktop): restore archived sessions opened from projects

xjx0f92be09a6f1
diff --git a/apps/desktop/src/pages/ProjectsPage.tsx b/apps/desktop/src/pages/ProjectsPage.tsx
index a5fefa181..d83e86bea 100644
--- a/apps/desktop/src/pages/ProjectsPage.tsx
+++ b/apps/desktop/src/pages/ProjectsPage.tsx
@@ -62,6 +62,7 @@ export function ProjectsPage() {
const restoreProject = useAppStore((s) => s.restoreProject);
const newSession = useAppStore((s) => s.newSession);
const selectSession = useAppStore((s) => s.selectSession);
+ const restoreSession = useAppStore((s) => s.restoreSession);
const setPage = useAppStore((s) => s.setPage);
const setSettingsTab = useAppStore((s) => s.setSettingsTab);
const renameSession = useAppStore((s) => s.renameSession);
@@ -223,6 +224,9 @@ export function ProjectsPage() {
}
try {
await selectSession(sessionId);
+ if (useAppStore.getState().sessionMeta[sessionId]?.archived === true) {
+ restoreSession(sessionId);
+ }
} catch (e) {
showToast(e instanceof Error ? e.message : String(e), { variant: "error" });
}
diff --git a/apps/desktop/test/settings-project-archive.test.mjs b/apps/desktop/test/settings-project-archive.test.mjs
index 71873ffb5..fc1848938 100644
--- a/apps/desktop/test/settings-project-archive.test.mjs
+++ b/apps/desktop/test/settings-project-archive.test.mjs
@@ -70,6 +70,21 @@ test("project archive makes project sessions searchable and progressively visibl
assert.match(projectsDetailSource, /projects-detail-task-updated/);
});
+test("opening an archived project session restores it after selection succeeds", () => {
+ const openSession =
+ projectsPageSource.match(
+ /const openProjectSession = async[\s\S]*?\n };/,
+ )?.[0] ?? "";
+ assert.match(openSession, /await selectSession\(sessionId\)/);
+ assert.match(openSession, /sessionMeta\[sessionId\]\?\.archived === true/);
+ assert.match(openSession, /restoreSession\(sessionId\)/);
+ assert.ok(
+ openSession.indexOf("await selectSession(sessionId)") <
+ openSession.indexOf("restoreSession(sessionId)"),
+ "the archive state changes only after the session opens successfully",
+ );
+});
+
test("project archive is no longer a standalone app page", () => {
assert.doesNotMatch(searchDialogSource, /page: "projects"/);
assert.doesNotMatch(appSource, /page === "projects"/);
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 1f9a9f6b7..c1892b563 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -2066,8 +2066,8 @@ identify the platform validation still needed.
#### E2E-038: Settings owns the project archive destination
- **Preconditions**: App running with at least one configured provider, one supported local session store, one retained project, and one archived project.
-- **Steps**: 1) Open Settings. 2) Inspect the complete settings rail. 3) Open Basics and change the theme in its Appearance card using the searchable theme picker. 4) Open 全局 AI and inspect the Permissions and Defaults cards, including the Command shell row; confirm Context management has no settings card. 5) Open Shortcuts and inspect the Keyboard shortcuts card. 6) Open Instructions and save global instructions. 7) Open Model configuration and inspect the provider studio. 8) Open Import, Project archive, and Info in order. 9) Search Settings for "project" or "archive". 10) In Project archive, compare each group strip's count with its rendered rows. 11) Switch the sort control from Recent to Name. 12) Search for a known session title, confirm the owning project is selected and its inspector lists matching sessions, then reveal more than eight sessions; clear the search with the clear affordance. 13) Open the inspector menu, dismiss it with Escape and with an outside press. 14) Restore the archived project, then activate it. 15) Return to the app shell and open Plugins.
-- **Expected**: The rail contains exactly Basics, 全局 AI/AI, Shortcuts, Instructions, Model configuration, Import, Project archive, and Info in that order, each with its semantic Lucide icon (Sliders / Sparkles / Keyboard / FileText / Bot / Download / Archive / Info). The flat directory is visually grouped under four muted, non-interactive headings — Personal / 个人 for Basics, AI, and Shortcuts; Agent / 智能体 for Instructions and Model configuration; Workspace / 工作区 for Import and Project archive; About / 关于 for Info — with whitespace and no divider lines between groups; searching keeps the destination results flat and hides empty groups together with their headings. Appearance remains in Basics, while Permissions, Defaults, and the Command shell row live under 全局 AI; an available selected shell is represented by the selector without a duplicate Configured status, while default, fallback, and no-effective-shell states remain explicit; Context management has no settings card; Keyboard shortcuts and global instructions have their own destinations; Developer lives under Info; Project archive shows active, closed, and archived durable rows without a visibility toggle, grouping them under the always-visible Pinned / All projects / Archived strips (D168/D267/D455) with per-section counts in a one-column workbench. The destination renders no hero block and no page-level counter run: the intro is one quiet description line, and each group strip's count agrees with its rendered rows; a click selects a row without leaving Settings; sorting by Name reorders rows inside every section without hiding any; search matches project fields and session titles and reports a match count, a session-title result selects its owning project, lists sessions in the inspector by latest activity with relative update times, and reveals history in batches of eight; clearing the search restores the complete index. The inspector menu closes on Escape and on an outside press. Bootstrap completion and background refreshes do not return Settings or Extensions to the chat home; the destination changes only after an explicit navigation action. Restore keeps the archive open and activation returns to chat with the restored project retained in the sidebar; the home sidebar and global page results have no standalone Projects destination; Settings search finds Project archive; Plugins remains an independent app-shell destination.
+- **Steps**: 1) Open Settings. 2) Inspect the complete settings rail. 3) Open Basics and change the theme in its Appearance card using the searchable theme picker. 4) Open 全局 AI and inspect the Permissions and Defaults cards, including the Command shell row; confirm Context management has no settings card. 5) Open Shortcuts and inspect the Keyboard shortcuts card. 6) Open Instructions and save global instructions. 7) Open Model configuration and inspect the provider studio. 8) Open Import, Project archive, and Info in order. 9) Search Settings for "project" or "archive". 10) In Project archive, compare each group strip's count with its rendered rows. 11) Switch the sort control from Recent to Name. 12) Search for a known session title, confirm the owning project is selected and its inspector lists matching sessions, then reveal more than eight sessions; clear the search with the clear affordance. 13) Open the inspector menu, dismiss it with Escape and with an outside press. 14) Restore the archived project, then activate it. 15) Archive one project session, open it from Project archive, and return to Project archive. 16) Return to the app shell and open Plugins.
+- **Expected**: The rail contains exactly Basics, 全局 AI/AI, Shortcuts, Instructions, Model configuration, Import, Project archive, and Info in that order, each with its semantic Lucide icon (Sliders / Sparkles / Keyboard / FileText / Bot / Download / Archive / Info). The flat directory is visually grouped under four muted, non-interactive headings — Personal / 个人 for Basics, AI, and Shortcuts; Agent / 智能体 for Instructions and Model configuration; Workspace / 工作区 for Import and Project archive; About / 关于 for Info — with whitespace and no divider lines between groups; searching keeps the destination results flat and hides empty groups together with their headings. Appearance remains in Basics, while Permissions, Defaults, and the Command shell row live under 全局 AI; an available selected shell is represented by the selector without a duplicate Configured status, while default, fallback, and no-effective-shell states remain explicit; Context management has no settings card; Keyboard shortcuts and global instructions have their own destinations; Developer lives under Info; Project archive shows active, closed, and archived durable rows without a visibility toggle, grouping them under the always-visible Pinned / All projects / Archived strips (D168/D267/D455) with per-section counts in a one-column workbench. The destination renders no hero block and no page-level counter run: the intro is one quiet description line, and each group strip's count agrees with its rendered rows; a click selects a row without leaving Settings; sorting by Name reorders rows inside every section without hiding any; search matches project fields and session titles and reports a match count, a session-title result selects its owning project, lists sessions in the inspector by latest activity with relative update times, and reveals history in batches of eight; clearing the search restores the complete index. The inspector menu closes on Escape and on an outside press. Bootstrap completion and background refreshes do not return Settings or Extensions to the chat home; the destination changes only after an explicit navigation action. Restore keeps the archive open and activation returns to chat with the restored project retained in the sidebar. Opening an archived session succeeds before clearing its archived state, returns to chat with that session selected, and makes it visible in the project sidebar; returning to Project archive no longer shows that session as archived. The home sidebar and global page results have no standalone Projects destination; Settings search finds Project archive; Plugins remains an independent app-shell destination.
- **Specs linked**: `04-ux/06-settings-ia.md`, `04-ux/01-ui-ia.md`, `03-runtime/11-provider-model-system.md`
- **Acceptance**: B (model configuration), F (session import)
- **Milestone**: M4
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 94a4a91e0..be61c6c18 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
@@ -1003,8 +1003,8 @@ unit/integration 测试;代码 pull request 使用有选择且高价值的 E2E
#### E2E-038:设置拥有项目存档目标
- **先决条件**:应用程序运行时至少有一个已配置的提供程序、一个受支持的本地会话存储、一个保留的项目和一个存档的项目。
-- **步骤**:1) 打开设置。 2) 检查完整的设置导轨。 3) 打开Basics 并使用可搜索主题选择器更改其外观卡中的主题。 4) 打开全局 AI 并检查权限和默认项卡,包括命令 Shell 行;确认上下文管理没有设置卡。 5) 打开快捷方式并检查键盘快捷方式卡。 6) 打开指令并保存全局指令。 7) 打开模型配置并检查提供商工作室。 8) 按顺序打开“导入”、“项目存档”和“信息”。 9) 搜索设置“项目”或“存档”。 10) 在项目存档中,将每个分组条的计数与其呈现的行进行比较。 11) 将排序控件从“最近”切换到“名称”。 12) 搜索已知的会话标题,检查其展开的项目行,然后显示八个以上的会话;通过清晰的功能来清除搜索。 13) 打开行菜单,使用 Escape 并按下外部按钮将其关闭。 14) 恢复存档的项目,然后激活它。 15) 返回应用程序外壳并打开插件。
-- **预期**:该导轨按顺序包含基础知识、全局 AI/AI、快捷方式、说明、模型配置、导入、项目存档和信息,每个都有其语义 Lucide 图标(滑块/火花/键盘/文件文本/机器人/下载/存档/信息);行按四个柔和的非交互标题分组:Personal / 个人包含基础知识、全局 AI 和快捷键,Agent / 智能体包含说明和模型配置,Workspace / 工作区包含导入和项目存档,About / 关于包含信息;分组之间使用留白而不是分割线,搜索保持目的地结果扁平,并将空分组及其标题一起隐藏。外观保留在基础下,权限、默认项和命令 Shell 行位于全局 AI 下;可用的已选 Shell 由选择器表示,不重复显示“已配置”状态;默认、回退和无实际 Shell 状态仍明确展示;上下文管理没有设置卡;键盘快捷键和全局指令都有自己的目的地;开发者生活在 Info 下;项目存档显示活动、关闭和存档的持久行,无需可见性切换,将它们分组在一个面板内始终可见的固定/所有项目/存档分组条 (D168/D267) 下,并带有每个部分的计数。该目的地不呈现英雄区块,也没有页面级计数器串:引导区是一条安静的说明行,每个分组条的计数与其呈现的行一致;按名称排序会重新排序每个部分内的行,而不隐藏任何行;搜索匹配项目字段和会话标题并报告匹配计数,会话标题结果扩展其所属项目,按最新活动和相对更新时间列出会话,并以八个批次显示历史记录;清除搜索将恢复完整索引。行菜单在 Escape 和外部按下时关闭。恢复使存档保持打开状态,激活返回以与侧栏中保留的恢复项目聊天;主页侧边栏和全局页面结果没有独立的项目目标;设置搜索找到项目存档;插件仍然是一个独立的应用程序外壳目的地。
+- **步骤**:1) 打开设置。 2) 检查完整的设置导轨。 3) 打开Basics 并使用可搜索主题选择器更改其外观卡中的主题。 4) 打开全局 AI 并检查权限和默认项卡,包括命令 Shell 行;确认上下文管理没有设置卡。 5) 打开快捷方式并检查键盘快捷方式卡。 6) 打开指令并保存全局指令。 7) 打开模型配置并检查提供商工作室。 8) 按顺序打开“导入”、“项目存档”和“信息”。 9) 搜索设置“项目”或“存档”。 10) 在项目存档中,将每个分组条的计数与其呈现的行进行比较。 11) 将排序控件从“最近”切换到“名称”。 12) 搜索已知的会话标题,检查其展开的项目行,然后显示八个以上的会话;通过清晰的功能来清除搜索。 13) 打开行菜单,使用 Escape 并按下外部按钮将其关闭。 14) 恢复存档的项目,然后激活它。 15) 归档一个项目会话,从项目归档中打开它,然后返回项目归档。 16) 返回应用程序外壳并打开插件。
+- **预期**:该导轨按顺序包含基础知识、全局 AI/AI、快捷方式、说明、模型配置、导入、项目存档和信息,每个都有其语义 Lucide 图标(滑块/火花/键盘/文件文本/机器人/下载/存档/信息);行按四个柔和的非交互标题分组:Personal / 个人包含基础知识、全局 AI 和快捷键,Agent / 智能体包含说明和模型配置,Workspace / 工作区包含导入和项目存档,About / 关于包含信息;分组之间使用留白而不是分割线,搜索保持目的地结果扁平,并将空分组及其标题一起隐藏。外观保留在基础下,权限、默认项和命令 Shell 行位于全局 AI 下;可用的已选 Shell 由选择器表示,不重复显示“已配置”状态;默认、回退和无实际 Shell 状态仍明确展示;上下文管理没有设置卡;键盘快捷键和全局指令都有自己的目的地;开发者生活在 Info 下;项目存档显示活动、关闭和存档的持久行,无需可见性切换,将它们分组在一个面板内始终可见的固定/所有项目/存档分组条 (D168/D267) 下,并带有每个部分的计数。该目的地不呈现英雄区块,也没有页面级计数器串:引导区是一条安静的说明行,每个分组条的计数与其呈现的行一致;按名称排序会重新排序每个部分内的行,而不隐藏任何行;搜索匹配项目字段和会话标题并报告匹配计数,会话标题结果扩展其所属项目,按最新活动和相对更新时间列出会话,并以八个批次显示历史记录;清除搜索将恢复完整索引。行菜单在 Escape 和外部按下时关闭。恢复使存档保持打开状态,激活返回以与侧栏中保留的恢复项目聊天。打开归档会话时,应用会先成功选择该会话,再清除它的归档状态;聊天页选中该会话,项目侧边栏重新显示它,返回项目归档后它也不再处于归档状态。主页侧边栏和全局页面结果没有独立的项目目标;设置搜索找到项目存档;插件仍然是一个独立的应用程序外壳目的地。
- **链接规格**:`04-ux/06-settings-ia.md`、`04-ux/01-ui-ia.md`、`03-runtime/11-provider-model-system.md`
- **接受**:B(模型配置),F(会话导入)
- **里程碑**:M4