Skip to content

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

fix(chat): name the open project in the empty home before its first session

vastsa27283332f323
diff --git a/apps/desktop/src/components/ChatSurface.tsx b/apps/desktop/src/components/ChatSurface.tsx
index 3832bda04..4c668877b 100644
--- a/apps/desktop/src/components/ChatSurface.tsx
+++ b/apps/desktop/src/components/ChatSurface.tsx
@@ -86,13 +86,16 @@ export const ChatSurface = memo(function ChatSurface({
),
);
- const heroProject = useMemo(
- () =>
- activeSession?.projectPath?.trim()
- ? projectName(activeSession.projectPath, workspace?.name)
- : null,
- [activeSession?.projectPath, workspace?.name],
- );
+ // The project the empty home names: the session on screen decides when there
+ // is one, because a temporary session deliberately belongs to no project. A
+ // project the user has just opened has no session yet, so its active
+ // workspace names the hero instead of falling back to the generic title.
+ const heroProject = useMemo(() => {
+ const path = activeSession
+ ? activeSession.projectPath?.trim()
+ : workspace?.path?.trim();
+ return path ? projectName(path, workspace?.name) : null;
+ }, [activeSession, workspace?.path, workspace?.name]);
const isTemporarySession = Boolean(
activeSessionId && activeSession && !activeSession.projectPath?.trim(),
);
diff --git a/apps/desktop/test/home-project-name.test.mjs b/apps/desktop/test/home-project-name.test.mjs
new file mode 100644
index 000000000..105dd4d86
--- /dev/null
+++ b/apps/desktop/test/home-project-name.test.mjs
@@ -0,0 +1,117 @@
+import assert from "node:assert/strict";
+import test from "node:test";
+import { fileURLToPath } from "node:url";
+import { createElement } from "react";
+import { renderToStaticMarkup } from "react-dom/server";
+import { createInstance } from "i18next";
+import { I18nextProvider } from "react-i18next";
+import { catalogs } from "@pi-desktop/i18n";
+import { createServer } from "vite";
+
+/**
+ * The empty home names the project the user is working in. Opening a project
+ * creates no session, so the hero has to fall back to the active workspace
+ * instead of showing the generic title; a session on screen still wins, which
+ * is what keeps a temporary session temporary.
+ *
+ * ChatSurface renders the real composer, which reads browser globals at render
+ * time, so this process provides the few it needs. Server rendering runs no
+ * effects: the assertion reads the first frame of the mount.
+ */
+globalThis.window ??= {
+ piDesktop: undefined,
+ addEventListener() {},
+ removeEventListener() {},
+ matchMedia: () => ({
+ matches: false,
+ addEventListener() {},
+ removeEventListener() {},
+ addListener() {},
+ removeListener() {},
+ }),
+ localStorage: { getItem: () => null, setItem() {}, removeItem() {} },
+};
+globalThis.localStorage ??= globalThis.window.localStorage;
+globalThis.requestAnimationFrame ??= (callback) => setTimeout(callback, 0);
+globalThis.cancelAnimationFrame ??= (handle) => clearTimeout(handle);
+
+const emptyStateOf = (html) => ({
+ kind: html.match(/data-home-session-kind="([^"]*)"/)?.[1],
+ title: html.match(/<h1>([\s\S]*?)<\/h1>/)?.[1] ?? "",
+});
+
+test("the empty home names the project even before its first session exists", async (t) => {
+ const server = await createServer({
+ root: fileURLToPath(new URL("..", import.meta.url)),
+ configFile: false,
+ logLevel: "silent",
+ server: { middlewareMode: true, hmr: false, ws: false },
+ esbuild: { jsx: "automatic" },
+ appType: "custom",
+ optimizeDeps: { noDiscovery: true, include: [] },
+ });
+ t.after(() => server.close());
+
+ const { ChatSurface } = await server.ssrLoadModule(
+ "/src/components/ChatSurface.tsx",
+ );
+ const { useAppStore } = await server.ssrLoadModule("/src/stores/app-store.ts");
+ const i18n = createInstance();
+ await i18n.init({ lng: "en", resources: { en: { translation: catalogs.en } } });
+
+ const render = (state) => {
+ Object.assign(useAppStore.getInitialState(), {
+ activeSessionId: undefined,
+ selectingSessionId: undefined,
+ retainedSessionIds: [],
+ sessions: [],
+ messages: [],
+ workspace: null,
+ activeProjectPath: undefined,
+ error: null,
+ ...state,
+ });
+ return emptyStateOf(
+ renderToStaticMarkup(
+ createElement(I18nextProvider, { i18n }, createElement(ChatSurface, {})),
+ ),
+ );
+ };
+
+ // A freshly opened project owns the empty home: the title names it and the
+ // switcher offers the same project path.
+ const opened = render({
+ workspace: { path: "/work/demo-app", name: "Demo App" },
+ activeProjectPath: "/work/demo-app",
+ });
+ assert.equal(opened.kind, "project");
+ assert.match(opened.title, /^What can we build in /);
+ assert.match(opened.title, /switch project: Demo App/i);
+ assert.match(opened.title, /title="\/work\/demo-app"/);
+ assert.doesNotMatch(opened.title, /What can I help you build\?/);
+
+ // Without a project name the hero still names the folder it opened.
+ const unnamed = render({ workspace: { path: "/work/demo-app" } });
+ assert.equal(unnamed.kind, "project");
+ assert.match(unnamed.title, />demo-app<\/button>/);
+
+ // A session on screen decides: a temporary session stays temporary even when
+ // a workspace is still open.
+ const temporary = render({
+ activeSessionId: "s1",
+ sessions: [{ id: "s1", title: "New task", projectPath: null }],
+ workspace: { path: "/work/demo-app", name: "Demo App" },
+ activeProjectPath: "/work/demo-app",
+ });
+ assert.equal(temporary.kind, "temporary");
+ assert.equal(
+ temporary.title,
+ catalogs.en.chat.emptyTitleTemporary,
+ "a temporary session must not inherit the open project's name",
+ );
+
+ // With no project and no session the generic home title is still correct.
+ const bare = render({});
+ assert.equal(bare.kind, "empty");
+ assert.equal(bare.title, catalogs.en.chat.emptyTitle);
+});
diff --git a/docs/spec/04-ux/01-ui-ia.md b/docs/spec/04-ux/01-ui-ia.md
index 3a56d0127..844c30b18 100644
--- a/docs/spec/04-ux/01-ui-ia.md
+++ b/docs/spec/04-ux/01-ui-ia.md
@@ -169,8 +169,8 @@ destination, chat as the home surface, tools and permissions inline.
## 3. Destinations
### 3.1 Chat home (default)
-- Empty state: a restrained hero title ("What can I help you build?" — a
- project-bound session turns the project name into a dotted-underline
+- Empty state: a restrained hero title ("What can I help you build?" — an open
+ project turns its name into a dotted-underline
switcher that lists the sidebar's open projects, can search them, can
clone a git repository from a syntactically public remote (ADR 0247 / D416), and can open another local folder), an optional first-run
checklist, and a bottom-reserved composer. Task entry starts directly in the composer; no
@@ -399,12 +399,14 @@ shared capability contract:
- Selecting a project-scoped thread activates its project before switching to
`chat`. Selecting a temporary thread clears the visible active workspace
before loading it.
-- Empty home has three explicit session states: a project-bound session shows
+- Empty home has four explicit session states: a project-bound session shows
the project-underlined welcome; clicking the name opens a searchable
- switcher of the sidebar's open projects instead of the folder picker. A
- temporary session shows dedicated temporary-chat copy with no project
- underline or switcher; and no active session keeps the generic welcome
- title.
+ switcher of the sidebar's open projects instead of the folder picker. An
+ open project with no session yet names the hero the same way, because that
+ empty home already belongs to it and a task started there lands in the
+ project. A temporary session shows dedicated temporary-chat copy with no
+ project underline or switcher; and with no project open the generic welcome
+ title stands.
- New task resolves the current project or temporary group by its most recent
session: if that session has `messageCount = 0`, it is selected and reused;
otherwise a durable empty session is created immediately and appears in the
diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.md
index 3d8c01660..13a5c07d6 100644
--- a/docs/spec/04-ux/08-component-spec.md
+++ b/docs/spec/04-ux/08-component-spec.md
@@ -889,7 +889,7 @@ pending action cards remain reachable outside a hidden process. See
| State | Behavior |
|---|---|
-| Empty | Restrained hero + optional onboarding checklist in a scrollable content region, with a bottom-reserved home composer and no starter-card or contextual quick-action layer (D111/D204/D206). A project-bound empty session underlines the project name; the control opens a searchable switcher of the sidebar's open projects, with clone-git-project and open-project actions. |
+| Empty | Restrained hero + optional onboarding checklist in a scrollable content region, with a bottom-reserved home composer and no starter-card or contextual quick-action layer (D111/D204/D206). An open project underlines the project name, including before its first session exists; the control opens a searchable switcher of the sidebar's open projects, with clone-git-project and open-project actions. |
| Streaming | Auto-scroll follows while pinned; new tokens append |
| Active progress | Immediately after send, before the first assistant or tool event, a compact localized `Working…` status with elapsed time appears inline. Its model and subagent elapsed labels use the carried-unit format in §9.1. When the runtime names a quiet interval, that same row identifies starting, waiting for the model, preparing the next request, compacting context, recovering an empty response, retrying, or waiting for delegated work (with each running subagent's latest coarse action). It remains visible through thinking, tool execution, completed-tool gaps, and partial answers until the turn ends. Runtime phases take precedence over the Planning/Goal or Working fallback. Pending permissions, questions, and plan/goal approvals suppress the row; history reading never shows live status; no large generic progress card is rendered. The row lives in the reserved tail lane, so it appears and clears mid-turn without changing the transcript's content height. A retrying row remains compact at rest; hovering or focusing it reveals an error-styled tooltip with the localized error summary, stable code/HTTP status, and bounded provider message. The tooltip mixes the error tint over `--ds-bg-elevated-opaque` so transcript text does not show through. |
| Turn outcome | After a failed turn, a session-scoped recovery card summarizes the interruption and tool evidence. Completed turns use the existing transcript and message-scoped InlineReviewCard without an extra success card; failed turns can continue through one localized prompt without losing the transcript. |
@@ -3585,8 +3585,10 @@ Guidance surfaces when key data is absent. Must always provide an **action link*
- Chat home empty: single scrollable stack (hero → optional checklist) centered
in MainChat, with a bottom-reserved composer sibling; task entry starts
directly in that composer without a starter-card or quick-action layer. The
- underlined project name in a project-bound hero is a switcher, not a folder
+ underlined project name in a project hero is a switcher, not a folder
picker; extra actions clone a git repository or open another local folder.
+ Opening a project with no session yet shows that same project hero, so the
+ empty home never hides which project a task would join.
- Other empty surfaces: text-xl heading + text-sm description + primary action
- Icon (48px Lucide / brand mark) above heading where applicable
- Background: bg-primary (transparent, not a card)
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 39d2062d4..993cbe911 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -11773,9 +11773,9 @@ This test plan spec is accepted when:
`scratch/<sessionId>` directory, never to the visible or recently active
project. Relative paths work inside that scratch root, containment and
permission rules remain active, and no project artifact is created. The
- temporary hero is localized and has no project switcher; project and
- no-session hero states remain unchanged. Plan/Goal retain their project-root
- boundary.
+ temporary hero is localized and has no project switcher; the project hero and
+ the no-project generic hero are unchanged by the temporary session. Plan/Goal
+ retain their project-root boundary.
- **Specs linked**: `03-runtime/03-tools-and-permissions.md` §4/§4b,
`03-runtime/10-session-state-machine.md`, `04-ux/01-ui-ia.md`,
`04-ux/02-i18n-english-first.md`, ADR 0124
@@ -14805,7 +14805,8 @@ plugin-form fixtures in an isolated temporary directory at runtime.
#### E2E-256: Empty-home project name switches among sidebar projects
- **Preconditions**: At least two local projects are open in the sidebar; the
- visible chat is an empty project-bound session.
+ visible chat is an empty project-bound session, and one open project has no
+ session at all.
- **Steps**:
1. Confirm the hero title underlines the current project name.
2. Click the underlined name and inspect the menu.
@@ -14815,18 +14816,22 @@ plugin-form fixtures in an isolated temporary directory at runtime.
5. Reopen the menu, choose Clone git project, paste a repository URL, then
pick a parent folder or cancel.
6. Open a temporary empty session and confirm the underline is absent.
+ 7. Click the session-less project in the sidebar and inspect the hero.
- **Expected**: The click opens a searchable, fixed switcher of the sidebar's
open projects instead of the folder picker. Choosing another project
activates it and lands on that project's empty home (reusing an empty
session when one exists). Open project still uses the folder picker. Clone
git project asks for a URL, then a folder, runs `git clone`, and opens the
- cloned project. Temporary and no-session heroes stay without the switcher.
- Escape and outside click dismiss the menu.
+ cloned project. Temporary heroes and the no-project home (no workspace) stay
+ without the switcher, while a project the user opens without any session
+ still names that project and keeps the switcher, because a task sent from
+ that empty home joins the project. Escape and outside click dismiss the menu.
- **Specs linked**: `04-ux/01-ui-ia.md`, `04-ux/08-component-spec.md`
- **Acceptance**: Quality (navigation and accessibility)
- **Milestone**: M5
- **Status**: Unit-covered (`home-project-switcher.test.mjs`,
- `git-clone.test.mjs`, `sidebar-preferences.test.mjs`); full UI scenario Draft
+ `home-project-name.test.mjs`, `git-clone.test.mjs`,
+ `sidebar-preferences.test.mjs`); full UI scenario Draft
(run only in a capable environment when this surface changes)
#### E2E-CLONE-accepts-a-lan-remote-and-rejects-metadata
diff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.md
index 5b9eb208e..01c6aa5ed 100644
--- a/docs/spec/08-meta/decisions-log.md
+++ b/docs/spec/08-meta/decisions-log.md
@@ -7469,3 +7469,19 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.
and safe MCP metadata tests. See
ADR 0319, `04-ux/06-settings-ia.md`, `04-ux/08-component-spec.md`, and
E2E-038 / E2E-043 / E2E-209.
+
+## 2026-10-04 — The empty home names the open project before its first session (D646)
+
+- D646 fixes the empty home after opening a project. The hero title only named
+ a project when a session on screen carried that project's path, so creating
+ a project, or opening one whose sessions are all archived or unselected,
+ left the generic "What can I help you build?" title and hid which project a
+ task started there would join.
+- The hero now falls back to the active workspace when no session is on
+ screen. A session still decides when there is one, so a temporary session
+ keeps its own copy and no project switcher, and with no project open the
+ generic title stands. Session state, IPC, persistence, and the switcher's
+ actions are unchanged.
+- Covered by `apps/desktop/test/home-project-name.test.mjs`, which renders the
+ real surface against the real store. See `04-ux/01-ui-ia.md`,
+ `04-ux/08-component-spec.md`, and E2E-256.
diff --git a/docs/zh-CN/spec/04-ux/01-ui-ia.md b/docs/zh-CN/spec/04-ux/01-ui-ia.md
index ce29cc03f..688441c0e 100644
--- a/docs/zh-CN/spec/04-ux/01-ui-ia.md
+++ b/docs/zh-CN/spec/04-ux/01-ui-ia.md
@@ -140,8 +140,8 @@
## 3. 目的地
-- 空状态:克制的英雄标题(“我可以帮你建造什么?”——项目会话里项目名称
- 变为点下划线按钮,点击展开可搜索的项目切换菜单,列出侧边栏已打开
+- 空状态:克制的英雄标题(“我可以帮你建造什么?”——打开的项目会把项目名称
+ 变为点下划线按钮(该项目还没有任何会话时同样命名),点击展开可搜索的项目切换菜单,列出侧边栏已打开
项目,并可从语法上的公网远程克隆 Git 仓库(ADR 0247 / D416)或打开本地文件夹),可选的首次运行检查表和底部保留
输入框。任务输入直接在composer中启动;没有开发人员入门
渲染卡片或上下文快速操作行 (D204/D206)。
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 8b8aa343d..f1a4e49f2 100644
--- a/docs/zh-CN/spec/04-ux/08-component-spec.md
+++ b/docs/zh-CN/spec/04-ux/08-component-spec.md
@@ -625,7 +625,7 @@ expanded/collapsed 侧边栏仍为 20px/18px 且启动画面为 64 像素。
| 状态 | 行为 |
|---|---|
-| 空 | 可滚动内容区域中的受约束的英雄+可选的入门清单,带有底部保留的主页输入框,没有入门卡或上下文快速操作层(D111/D204/D206) |
+| 空 | 可滚动内容区域中的受约束的英雄+可选的入门清单,带有底部保留的主页输入框,没有入门卡或上下文快速操作层(D111/D204/D206)。打开的项目会给项目名加下划线,即使该项目还没有任何会话;点击可打开侧边栏已打开项目的可搜索切换菜单,并带有克隆 Git 项目与打开项目操作。 |
| 流媒体 | 固定时自动滚动;追加新标记 |
| 积极进展 | 发送后,在第一个助手或工具事件之前,会内联显示一个紧凑的本地化 `Working…` 状态以及经过的时间。思考、工具执行、工具完成后的空档和部分回答都不会隐藏该行。具体运行时阶段优先于规划/目标或工作中提示;等待权限、提问或计划/目标批准时隐藏状态,历史阅读窗口不显示实时状态;不会渲染大型通用进度卡。重试行在静止时保持紧凑;悬停或聚焦会弹出错误色 tooltip,底板为 `--ds-bg-elevated-opaque`,避免透出记录正文。 |
| 回合结果 | 回合失败后,会话范围的恢复卡会总结中断和工具证据。已完成的轮次使用现有的记录和消息范围的 InlineReviewCard,无需额外的成功卡;失败的回合可以重试而不会丢失转录本。 |
@@ -2470,7 +2470,7 @@ Live Voice 受现有开发者模式和开发构建门控约束,包含四种展
- 聊天主页为空:单个可滚动堆栈(英雄→可选清单)居中
在 MainChat 中,有一个保留在底部的输入框兄弟;任务录入开始
- 直接在该输入框中,无需入门卡或快速操作层
+ 直接在该输入框中,无需入门卡或快速操作层。打开而没有会话的项目仍然显示该项目名称:主页空状态不会隐藏任务将进入哪个项目。
- 其他空表面:text-xl 标题 + text-sm 描述 + 主要操作
- 标题上方适用的图标(48px Lucide/品牌标记)
- 背景:bg-primary(透明,不是卡片)
diff --git a/docs/zh-CN/spec/08-meta/decisions-log.md b/docs/zh-CN/spec/08-meta/decisions-log.md
index 45cd6845f..b6e965e6a 100644
--- a/docs/zh-CN/spec/08-meta/decisions-log.md
+++ b/docs/zh-CN/spec/08-meta/decisions-log.md
@@ -5262,3 +5262,14 @@ Markdown 源码,不是 `text/html` 负载;对禁用行内 HTML 的外部编
`import-format.test.mjs` 覆盖。见 ADR 0319、`04-ux/06-settings-ia.md`、
`04-ux/08-component-spec.md`、E2E-038 / E2E-043 / E2E-209 与
E2E-SETTINGS-inline-capability-imports。
+
+## 2026-10-04 —— 空首页在首个会话之前就显示所属项目(D646)
+
+- D646 修复打开项目后的空首页。此前只有当屏幕上的会话带有该项目路径时英雄标题才会写出
+ 项目名,因此新建项目、或打开一个会话全部归档/未选中的项目时,标题会停留在通用的
+ “我可以帮你建造什么?”,用户看不出在这里发出的任务会进入哪个项目。
+- 现在没有会话在屏幕上时英雄回落到当前工作区。有会话时仍以会话为准,临时会话保持自己的
+ 文案且没有项目切换菜单;没有打开项目时仍是通用标题。会话状态、IPC、持久化与切换菜单
+ 的动作均不变。
+- 由 `apps/desktop/test/home-project-name.test.mjs` 覆盖:它用真实 store 渲染真实界面。
+ 见 `04-ux/01-ui-ia.md`、`04-ux/08-component-spec.md` 与 E2E-256。