Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
feat(chat): show project breadcrumb and inline title editing
v_wyxgwange0f713707fbe
diff --git a/apps/desktop/src/components/ConversationTopbar.tsx b/apps/desktop/src/components/ConversationTopbar.tsxindex ec652a140..6e1f99ee2 100644--- a/apps/desktop/src/components/ConversationTopbar.tsx+++ b/apps/desktop/src/components/ConversationTopbar.tsx@@ -1,6 +1,14 @@+import {+ useEffect,+ useRef,+ useState,+ type KeyboardEvent as ReactKeyboardEvent,+} from "react";import { isRemoteSession } from "../lib/remote-session-safety";+import { normalizeProjectPath } from "../lib/sidebar-session-groups";import {KEYBOARD_SHORTCUTS,+ MAX_SESSION_TITLE_LENGTH,keybindingDisplayParts,resolveKeybinding,type ShortcutPlatform,@@ -13,6 +21,7 @@ import {} from "../features/scheduled/scheduled-return";import {IconChevronLeft,+ IconFolder,IconSidebar,IconNewSession,IconSearch,@@ -48,7 +57,9 @@ export function ConversationTopbar({const { t } = useTranslation();const activeSessionId = useAppStore((s) => s.activeSessionId);const sessions = useAppStore((s) => s.sessions);- const workspace = useAppStore((s) => s.workspace);+ const projectMeta = useAppStore((s) => s.projectMeta);+ const renameSession = useAppStore((s) => s.renameSession);+ const showToast = useAppStore((s) => s.showToast);const keybindings = useAppStore((s) => s.settings?.keybindings);const navStack = useAppStore((s) => s.navStack);const navIndex = useAppStore((s) => s.navIndex);@@ -90,6 +101,85 @@ export function ConversationTopbar({const activeSession = sessions.find((session) => session.id === activeSessionId);+ /*+ * Inline rename. The editor is keyed by the session it belongs to, so a+ * conversation switch can never commit one task's draft onto another; the+ * effect below also drops the key so returning to the first session does not+ * resurrect a closed editor.+ */+ const [editingId, setEditingId] = useState<string | null>(null);+ const [draft, setDraft] = useState("");+ const inputRef = useRef<HTMLInputElement | null>(null);+ /* Set once an Enter/Escape/blur has resolved the draft; the next blur is the+ same commit, not a second one. */+ const renameSettledRef = useRef(false);++ const remoteSession = isRemoteSession(activeSession);+ /* Scheduled runs and remote transcripts are host-owned: their titles are not+ editable from this desktop. */+ const canRename = Boolean(+ activeSession && !isRemoteSession(activeSession) && !activeSession.scheduledRun,+ );+ const editing = editingId !== null && editingId === activeSession?.id;++ useEffect(() => {+ setEditingId(null);+ }, [activeSessionId]);++ useEffect(() => {+ if (!editing) return;+ /* The input only exists after this render; select-all must follow it. */+ const frame = requestAnimationFrame(() => {+ inputRef.current?.focus();+ inputRef.current?.select();+ });+ return () => cancelAnimationFrame(frame);+ }, [editing]);++ const beginRename = () => {+ if (!canRename || !activeSession) return;+ renameSettledRef.current = false;+ setDraft(activeSession.title ?? "");+ setEditingId(activeSession.id);+ };++ const cancelRename = () => {+ if (!editing) return;+ renameSettledRef.current = true;+ setEditingId(null);+ };++ const commitRename = () => {+ if (!editing || !activeSession || renameSettledRef.current) return;+ renameSettledRef.current = true;+ const sessionId = activeSession.id;+ const previousTitle = activeSession.title;+ const nextTitle = draft.trim();+ setEditingId(null);+ if (!nextTitle || nextTitle === previousTitle) return;+ void renameSession(sessionId, nextTitle).catch((error) => {+ showToast(error instanceof Error ? error.message : String(error), {+ variant: "error",+ });+ });+ };++ const onRenameKeyDown = (event: ReactKeyboardEvent<HTMLInputElement>) => {+ /* An IME owns Enter and Escape while a composition is in flight. */+ if (event.nativeEvent.isComposing) return;+ if (event.key === "Enter") {+ event.preventDefault();+ commitRename();+ return;+ }+ if (event.key === "Escape") {+ event.preventDefault();+ /* Escape belongs to the editor here, not to a window-level dismisser. */+ event.stopPropagation();+ cancelRename();+ }+ };+/** A scheduled run's conversation is read from the Scheduled route, and the* session list keeps automation transcripts out, so this row is the way@@ -110,9 +200,25 @@ export function ConversationTopbar({const fullTaskTitle = isDefaultSessionTitle(activeSession?.title)? t("chat.untitledTask"): activeSession?.title || t("chat.untitledTask");- const project = isRemoteSession(activeSession)- ? activeSession?.remoteWorkspaceLabel- : projectName(workspace?.path, workspace?.name);+ /*+ * The crumb names the project the conversation lives in, not the workspace+ * the app happens to show: a task can be opened from a project other than+ * the active one. A remote session carries its display-only label; a local+ * one resolves its project path through the sidebar's naming preferences,+ * and a draft-like session with no project keeps the plain title.+ */+ const sessionProjectPath = remoteSession ? null : activeSession?.projectPath;+ const projectKey = sessionProjectPath+ ? normalizeProjectPath(sessionProjectPath)+ : null;+ const project = remoteSession+ ? activeSession?.remoteWorkspaceLabel?.trim() || null+ : projectKey+ ? projectMeta[projectKey]?.name?.trim() || projectName(sessionProjectPath)+ : null;+ const breadcrumbTitle = project+ ? `${project} · ${fullTaskTitle}`+ : fullTaskTitle;return (<div@@ -153,12 +259,60 @@ export function ConversationTopbar({<span className="ct-back-label">{t("nav.backToScheduled")}</span></button>) : null}+ {/* The hover tooltip would otherwise keep advertising the old title+ and the crumb while the title is an editor. */}<divclassName="ct-title-wrap"- title={project ? `${project} · ${fullTaskTitle}` : fullTaskTitle}+ title={editing ? undefined : breadcrumbTitle}>- <span className="ct-title">{fullTaskTitle}</span>- {isRemoteSession(activeSession) && <span className="thread-item-source">{t("remote:remote")} · {activeSession?.remoteHostLabel}</span>}+ {project ? (+ <>+ <span className="ct-project">+ <IconFolder size={12} aria-hidden />+ <span className="ct-project-name">{project}</span>+ </span>+ <span className="ct-sep" aria-hidden>+ /+ </span>+ </>+ ) : null}+ {editing ? (+ <input+ ref={inputRef}+ className="ct-title-input"+ value={draft}+ aria-label={t("session.renameLabel")}+ spellCheck={false}+ autoComplete="off"+ autoCorrect="off"+ autoCapitalize="off"+ onChange={(event) =>+ setDraft(+ Array.from(event.target.value)+ .slice(0, MAX_SESSION_TITLE_LENGTH)+ .join(""),+ )+ }+ onKeyDown={onRenameKeyDown}+ onBlur={commitRename}+ />+ ) : (+ <h1 className="ct-title">+ {canRename ? (+ <button+ type="button"+ className="ct-title-trigger"+ aria-label={t("session.renameAction", { title: fullTaskTitle })}+ onClick={beginRename}+ >+ {fullTaskTitle}+ </button>+ ) : (+ fullTaskTitle+ )}+ </h1>+ )}+ {remoteSession && <span className="thread-item-source">{t("remote:remote")} · {activeSession?.remoteHostLabel}</span>}</div></div>diff --git a/apps/desktop/src/styles/chrome.css b/apps/desktop/src/styles/chrome.cssindex 08c40cdb2..e337552cb 100644--- a/apps/desktop/src/styles/chrome.css+++ b/apps/desktop/src/styles/chrome.css@@ -571,7 +571,7 @@.conversation-topbar .ct-title-wrap {display: flex;align-items: center;- gap: 0;+ gap: 6px;flex: 1 1 auto;min-width: 0;overflow: hidden;@@ -580,19 +580,115 @@app-region: drag;}+/*+ * The project crumb names where the conversation lives, one step quieter than+ * the task title it prefixes. It may truncate, but it never forces the title+ * or the action lane out of the bar.+ */+.conversation-topbar .ct-project {+ display: inline-flex;+ flex: 0 1 auto;+ min-width: 0;+ align-items: center;+ gap: 6px;+ color: var(--ds-text-faint);+ font-size: var(--text-xs);+ line-height: var(--leading-compact);+ white-space: nowrap;+}++.conversation-topbar .ct-project > svg {+ flex: 0 0 auto;+}++.conversation-topbar .ct-project-name {+ min-width: 0;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+}++.conversation-topbar .ct-sep {+ flex: 0 0 auto;+ color: var(--ds-border-strong);+ font-size: var(--text-xs);+ line-height: var(--leading-compact);+}+.conversation-topbar .ct-title {min-width: 0;flex: 1 1 auto;overflow: hidden;+ margin: 0;text-overflow: ellipsis;white-space: nowrap;color: var(--ds-text-primary);- font-size: var(--text-base);+ font-size: var(--text-sm-plus);font-weight: var(--font-weight-medium);letter-spacing: var(--tracking-tight);line-height: var(--leading-compact);}+/*+ * Click-to-edit title. The button only exists to give the text real pointer and+ * keyboard semantics; it must paint and measure exactly like the plain title,+ * so every font/ink property is inherited and the ellipsis stays on the text.+ */+.conversation-topbar .ct-title-trigger {+ display: block;+ width: fit-content;+ max-width: 100%;+ margin: 0;+ overflow: hidden;+ padding: 0;+ border: 0;+ background: transparent;+ color: inherit;+ font: inherit;+ letter-spacing: inherit;+ line-height: inherit;+ text-align: left;+ text-overflow: ellipsis;+ white-space: nowrap;+ cursor: text;+ -webkit-app-region: no-drag;+ app-region: no-drag;+}++/* The title lane clips its children, so a ring would vanish; underline instead. */+.conversation-topbar .ct-title-trigger:focus-visible {+ outline: none;+ text-decoration: underline;+ text-decoration-thickness: 1.5px;+ text-underline-offset: 2px;+ text-decoration-color: var(--ds-accent);+}++/*+ * The editor is deliberately boxless: the title keeps its own type metrics and+ * only the caret marks the mode change. Inside the draggable bar the field+ * must still opt into pointer events or the click never reaches it.+ */+.conversation-topbar .ct-title-input {+ flex: 1 1 auto;+ min-width: 0;+ margin: 0;+ padding: 0;+ border: 0;+ outline: none;+ appearance: none;+ background: transparent;+ box-shadow: none;+ color: var(--ds-text-primary);+ font-family: inherit;+ font-size: var(--text-sm-plus);+ font-weight: var(--font-weight-medium);+ letter-spacing: var(--tracking-tight);+ line-height: var(--leading-compact);+ -webkit-app-region: no-drag;+ app-region: no-drag;+}+/** Where a scheduled run's conversation was opened from: the session list keeps* automation transcripts out of the project groups, so this is the way back todiff --git a/apps/desktop/test/plan-mode-source-contract.test.mjs b/apps/desktop/test/plan-mode-source-contract.test.mjsindex 985872561..4fc29384b 100644--- a/apps/desktop/test/plan-mode-source-contract.test.mjs+++ b/apps/desktop/test/plan-mode-source-contract.test.mjs@@ -136,7 +136,7 @@ test("the component spec assigns mode ownership to Composer", () => {componentSpec.indexOf("## 11. Composer"),componentSpec.indexOf("## 12.", componentSpec.indexOf("## 11. Composer")),);- assert.match(topbarSpec, /Project\s+scope/);+ assert.match(topbarSpec, /project breadcrumb/i);assert.doesNotMatch(topbarSpec, /model picker/);assert.doesNotMatch(topbarSpec, /Agent \| Plan|mode toggle|mode indicator/);assert.match(composerSpec, /combined model ×\s+reasoning-level control/);diff --git a/apps/desktop/test/thinking-ui.test.mjs b/apps/desktop/test/thinking-ui.test.mjsindex 401c10618..7dbbbe038 100644--- a/apps/desktop/test/thinking-ui.test.mjs+++ b/apps/desktop/test/thinking-ui.test.mjs@@ -46,7 +46,8 @@ const modelMenuSource = await readFile("utf8",);// Agent/Plan mode and model selection are owned by the Composer; the-// conversation top bar only hosts the task title and window actions.+// conversation top bar only hosts the project crumb, task title, and window+// actions.const topbarSource = await readFile(new URL("../src/components/ConversationTopbar.tsx", import.meta.url),"utf8",@@ -130,9 +131,12 @@ test("Composer owns the mode and model controls", () => {assert.doesNotMatch(composerModelPickerSource, /composer-menu-back/);});-test("conversation topbar keeps the title and actions free of a running indicator", () => {- assert.doesNotMatch(topbarSource, /IconFolder|IconChevronRight/);- assert.doesNotMatch(topbarSource, /className="ct-project"/);+test("conversation topbar keeps the crumb and title free of a running indicator", () => {+ // The left lane is a project crumb plus the task title; neither may grow a+ // running status, and the title still owns width-based clipping.+ assert.match(topbarSource, /IconFolder/);+ assert.match(topbarSource, /className="ct-project"/);+ assert.doesNotMatch(topbarSource, /IconChevronRight/);assert.doesNotMatch(topbarSource, /className="ct-title-chevron"/);assert.match(topbarSource, /className="ct-title"/);assert.doesNotMatch(topbarSource, /TOPBAR_TITLE_MAX_LENGTH|truncateTopbarTitle/);@@ -144,7 +148,7 @@ test("conversation topbar keeps the title and actions free of a running indicato);assert.match(stylesSource,- /\.conversation-topbar \.ct-title[\s\S]*?font-size: var\(--text-base\)/,+ /\.conversation-topbar \.ct-title[\s\S]*?font-size: var\(--text-sm-plus\)/,);assert.doesNotMatch(stylesSource, /\.conversation-topbar \.ct-running(?:-dot)?\b/);});diff --git a/apps/desktop/test/topbar-title-inline-rename.test.mjs b/apps/desktop/test/topbar-title-inline-rename.test.mjsnew file mode 100644index 000000000..50958b9b7--- /dev/null+++ b/apps/desktop/test/topbar-title-inline-rename.test.mjs@@ -0,0 +1,188 @@+import assert from "node:assert/strict";+import test from "node:test";+import { readFile } from "node:fs/promises";+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";+import { loadStyles } from "./helpers/styles.mjs";++const read = (path) => readFile(new URL(path, import.meta.url), "utf8");++async function withTopbar(work) {+ const server = await createServer({+ root: fileURLToPath(new URL("..", import.meta.url)),+ configFile: false,+ server: { middlewareMode: true, hmr: false, ws: false },+ esbuild: { jsx: "automatic" },+ appType: "custom",+ optimizeDeps: { noDiscovery: true, include: [] },+ });+ try {+ const { ConversationTopbar } = await server.ssrLoadModule(+ "/src/components/ConversationTopbar.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(), {+ workspace: { path: "/workspace", name: "Workspace" },+ projectMeta: {},+ ...state,+ });+ return renderToStaticMarkup(+ createElement(+ I18nextProvider,+ { i18n },+ createElement(ConversationTopbar, {+ sidebarCollapsed: false,+ workPanelOpen: false,+ onToggleSidebar() {},+ onNewTask() {},+ onOpenSearch() {},+ }),+ ),+ );+ };++ return await work({ render });+ } finally {+ await server.close();+ }+}++test("an editable session renders the title as a real rename trigger", async () => {+ await withTopbar(async ({ render }) => {+ const html = render({+ activeSessionId: "session-local",+ sessions: [{ id: "session-local", title: "Draft reference check", projectPath: "/project" }],+ projectMeta: { "/project": { name: "Project" } },+ });++ assert.match(+ html,+ /<h1 class="ct-title"><button type="button" class="ct-title-trigger" aria-label="Rename task Draft reference check">Draft reference check<\/button><\/h1>/,+ );+ assert.ok(!html.includes("ct-title-input"), "the editor only appears after a click");+ assert.ok(html.includes('title="Project · Draft reference check"'));+ });+});++test("remote, scheduled and empty sessions render a plain title", async () => {+ await withTopbar(async ({ render }) => {+ const remote = render({+ activeSessionId: "remote:7",+ sessions: [+ {+ id: "remote:7",+ source: "remote",+ title: "Remote build",+ remoteWorkspaceLabel: "Remote workspace",+ remoteHostLabel: "builder",+ },+ ],+ });+ assert.match(remote, /<h1 class="ct-title">Remote build<\/h1>/);+ assert.ok(!remote.includes("ct-title-trigger"));++ const scheduled = render({+ activeSessionId: "session-scheduled",+ sessions: [{ id: "session-scheduled", title: "Nightly check", scheduledRun: true }],+ });+ assert.match(scheduled, /<h1 class="ct-title">Nightly check<\/h1>/);+ assert.ok(!scheduled.includes("ct-title-trigger"));++ const empty = render({ activeSessionId: null, sessions: [] });+ assert.match(empty, /<h1 class="ct-title">New task<\/h1>/);+ assert.ok(!empty.includes("ct-title-trigger"));+ });+});++test("inline rename wires the edit lifecycle through the store", async () => {+ const source = await read("../src/components/ConversationTopbar.tsx");++ // Entry: a labelled button replaces the h1 with a focused, selected editor.+ assert.match(source, /aria-label=\{t\("session\.renameAction", \{ title: fullTaskTitle \}\)\}/);+ assert.match(source, /aria-label=\{t\("session\.renameLabel"\)\}/);+ assert.match(+ source,+ /const frame = requestAnimationFrame\(\(\) => \{[\s\S]*?inputRef\.current\?\.focus\(\);[\s\S]*?inputRef\.current\?\.select\(\);[\s\S]*?\}\);/,+ );++ // Enter commits, Escape cancels, and blur is the third commit path.+ assert.match(source, /onKeyDown=\{onRenameKeyDown\}/);+ assert.match(source, /onBlur=\{commitRename\}/);+ assert.match(source, /if \(event\.nativeEvent\.isComposing\) return;/);+ assert.match(source, /if \(event\.key === "Enter"\) \{[\s\S]*?commitRename\(\);/);+ assert.match(source, /if \(event\.key === "Escape"\) \{[\s\S]*?cancelRename\(\);/);++ // Trimmed and unchanged drafts are silent no-ops; a changed one is persisted.+ assert.match(source, /const nextTitle = draft\.trim\(\);/);+ assert.match(source, /if \(!nextTitle \|\| nextTitle === previousTitle\) return;/);+ assert.match(source, /renameSession\(sessionId, nextTitle\)/);+ assert.match(+ source,+ /showToast\(error instanceof Error \? error\.message : String\(error\), \{[\s\S]*?variant: "error",[\s\S]*?\}\);/,+ );++ // The editor only exists for an editable session and cannot outlive it.+ assert.match(source, /activeSession && !isRemoteSession\(activeSession\) && !activeSession\.scheduledRun/);+ assert.match(source, /canRename \? \([\s\S]*?className="ct-title-trigger"/);+ assert.match(source, /useEffect\(\(\) => \{\s*setEditingId\(null\);\s*\}, \[activeSessionId\]\)/);+ assert.match(source, /title=\{editing \? undefined : breadcrumbTitle\}/);++ // Double commits are blocked once Enter/Escape/blur has settled the draft.+ assert.match(source, /const renameSettledRef = useRef\(false\)/);+ assert.match(source, /if \(!editing \|\| !activeSession \|\| renameSettledRef\.current\) return;/);+ assert.match(source, /renameSettledRef\.current = true;/);++ // The editor takes code-point slices of the shared limit.+ assert.match(source, /MAX_SESSION_TITLE_LENGTH/);+ assert.match(+ source,+ /Array\.from\(event\.target\.value\)[\s\S]*?\.slice\(0, MAX_SESSION_TITLE_LENGTH\)[\s\S]*?\.join\(""\)/,+ );+});++test("the title editor is visually unstyled but clickable", async () => {+ const styles = await loadStyles();+ const block = (selector) => {+ const match = styles.match(new RegExp(`${selector} \\{([\\s\\S]*?)\\}`));+ assert.ok(match, `${selector} rules not found`);+ return match[1];+ };++ const trigger = block("\\.conversation-topbar \\.ct-title-trigger");+ assert.match(trigger, /font: inherit;/);+ assert.match(trigger, /color: inherit;/);+ assert.match(trigger, /text-overflow: ellipsis;/);+ assert.match(trigger, /cursor: text;/);+ assert.match(trigger, /-webkit-app-region: no-drag;/);+ assert.match(trigger, /app-region: no-drag;/);+ assert.doesNotMatch(trigger, /font-size:/, "the trigger keeps the title's type metrics");++ // The lane clips a ring, so keyboard focus is an accent underline instead.+ const focus = block("\\.conversation-topbar \\.ct-title-trigger:focus-visible");+ assert.match(focus, /outline: none;/);+ assert.match(focus, /text-decoration: underline;/);+ assert.match(focus, /text-decoration-color: var\(--ds-accent\);/);++ const input = block("\\.conversation-topbar \\.ct-title-input");+ assert.match(input, /border: 0;/);+ assert.match(input, /padding: 0;/);+ assert.match(input, /background: transparent;/);+ assert.match(input, /box-shadow: none;/);+ assert.match(input, /font-size: var\(--text-sm-plus\);/);+ assert.match(input, /font-weight: var\(--font-weight-medium\);/);+ assert.match(input, /line-height: var\(--leading-compact\);/);+ assert.match(input, /-webkit-app-region: no-drag;/);+ assert.match(input, /app-region: no-drag;/);++ const wrap = block("\\.conversation-topbar \\.ct-title-wrap");+ assert.match(wrap, /-webkit-app-region: drag;/, "the empty title lane stays draggable");+});diff --git a/apps/desktop/test/topbar-title-rendering.test.mjs b/apps/desktop/test/topbar-title-rendering.test.mjsindex 34ea88259..b48a83df7 100644--- a/apps/desktop/test/topbar-title-rendering.test.mjs+++ b/apps/desktop/test/topbar-title-rendering.test.mjs@@ -1,5 +1,6 @@import assert from "node:assert/strict";import test from "node:test";+import { readFile } from "node:fs/promises";import { fileURLToPath } from "node:url";import { createElement } from "react";import { renderToStaticMarkup } from "react-dom/server";@@ -7,8 +8,13 @@ import { createInstance } from "i18next";import { I18nextProvider } from "react-i18next";import { catalogs } from "@pi-desktop/i18n";import { createServer } from "vite";+import { loadStyles } from "./helpers/styles.mjs";-test("topbar preserves complete titles for width-based clipping and tooltips", async () => {+/**+ * The topbar reads the store through `getInitialState` on the server, so the+ * harness mutates that snapshot instead of calling actions (no IPC in tests).+ */+async function withTopbar(work) {const server = await createServer({root: fileURLToPath(new URL("..", import.meta.url)),configFile: false,@@ -18,29 +24,175 @@ test("topbar preserves complete titles for width-based clipping and tooltips", aoptimizeDeps: { noDiscovery: true, include: [] },});try {- const { ConversationTopbar } = await server.ssrLoadModule("/src/components/ConversationTopbar.tsx");+ const { ConversationTopbar } = await server.ssrLoadModule(+ "/src/components/ConversationTopbar.tsx",+ );const { useAppStore } = await server.ssrLoadModule("/src/stores/app-store.ts");+ const { remoteEn } = await server.ssrLoadModule("/src/locales/remote.ts");const i18n = createInstance();- await i18n.init({ lng: "en", resources: { en: { translation: catalogs.en } } });- for (const title of ["Draft reference check", "修复会话标题在窗口顶部的显示", "New task"]) {+ await i18n.init({+ lng: "en",+ resources: { en: { translation: catalogs.en, remote: remoteEn } },+ });++ const render = (state, sidebarCollapsed = false) => {Object.assign(useAppStore.getInitialState(), {- activeSessionId: "title-test",- sessions: [{ id: "title-test", title }],- workspace: { path: "/project", name: "Project" },+ /* A different global workspace proves the crumb follows the session. */+ workspace: { path: "/workspace", name: "Workspace" },+ projectMeta: {},+ ...state,});- for (const sidebarCollapsed of [false, true]) {- const html = renderToStaticMarkup(createElement(I18nextProvider, { i18n },+ return renderToStaticMarkup(+ createElement(+ I18nextProvider,+ { i18n },createElement(ConversationTopbar, {- sidebarCollapsed, workPanelOpen: false,- onToggleSidebar() {}, onNewTask() {}, onOpenSearch() {},+ sidebarCollapsed,+ workPanelOpen: false,+ onToggleSidebar() {},+ onNewTask() {},+ onOpenSearch() {},}),- ));- const expected = title === "New task" ? catalogs.en.chat.untitledTask : title;- assert.equal(html.match(/class="ct-title">([^<]*)<\/span>/)?.[1], expected);- assert.ok(html.includes(`title="Project · ${expected}"`));- }- }+ ),+ );+ };++ return await work({ render });} finally {await server.close();}+}++test("topbar renders the session's project crumb and preserves complete titles", async () => {+ await withTopbar(async ({ render }) => {+ for (const title of ["Draft reference check", "修复会话标题在窗口顶部的显示", "New task"]) {+ for (const sidebarCollapsed of [false, true]) {+ const html = render(+ {+ activeSessionId: "title-test",+ sessions: [{ id: "title-test", title, projectPath: "/project" }],+ projectMeta: { "/project": { name: "Project" } },+ },+ sidebarCollapsed,+ );+ const expected =+ title === "New task" ? catalogs.en.chat.untitledTask : title;+ const trigger = html.match(+ /<h1 class="ct-title"><button type="button" class="ct-title-trigger" aria-label="([^"]*)">([^<]*)<\/button><\/h1>/,+ );++ assert.ok(trigger, "the title keeps a real, labelled rename trigger");+ assert.equal(trigger[2], expected, "the full title is never shortened for width");+ assert.equal(+ trigger[1],+ `Rename task ${expected}`,+ "the rename affordance carries the visible title",+ );+ assert.ok(+ html.includes('class="ct-project"') &&+ html.includes('class="ct-project-name">Project</span>'),+ "the crumb names the session's project",+ );+ assert.ok(+ html.includes('<span class="ct-sep" aria-hidden="true">/</span>'),+ "the project and the task are separated by a slash",+ );+ assert.ok(html.includes(`title="Project · ${expected}"`));+ assert.ok(+ !html.includes("Workspace"),+ "the crumb never falls back to the global workspace",+ );+ assert.ok(!html.includes("ct-title-input"), "the editor is closed at rest");+ }+ }+ });+});++test("a session without a project keeps only the title", async () => {+ await withTopbar(async ({ render }) => {+ const html = render({+ activeSessionId: "temp-test",+ sessions: [{ id: "temp-test", title: "Scratch pad" }],+ projectMeta: { "/project": { name: "Project" } },+ });++ assert.ok(!html.includes('class="ct-project"'), "no folder crumb without a project");+ assert.ok(!html.includes('class="ct-sep"'), "no separator without a project");+ assert.match(html, /class="ct-title">[\s\S]*?Scratch pad/);+ assert.ok(html.includes('title="Scratch pad"'));+ });+});++test("a remote session shows its remote workspace label and keeps the title read-only", async () => {+ await withTopbar(async ({ render }) => {+ const html = render({+ activeSessionId: "remote:42",+ sessions: [+ {+ id: "remote:42",+ source: "remote",+ title: "Remote build",+ /* A remote summary's path is display data, never a local project. */+ projectPath: "/local-ignored",+ remoteWorkspaceLabel: "Remote workspace",+ remoteHostLabel: "builder",+ },+ ],+ projectMeta: { "/local-ignored": { name: "Local project" } },+ });++ assert.ok(+ html.includes('class="ct-project-name">Remote workspace</span>'),+ "the remote label replaces the local project name",+ );+ assert.ok(!html.includes("Local project"));+ assert.ok(!html.includes("ct-title-trigger"), "host-owned titles are not editable here");+ assert.match(html, /<h1 class="ct-title">Remote build<\/h1>/);+ assert.ok(html.includes("Remote · builder"));+ assert.ok(html.includes('title="Remote workspace · Remote build"'));+ });+});++test("a scheduled run keeps its plain title and its way back", async () => {+ await withTopbar(async ({ render }) => {+ const html = render({+ activeSessionId: "session-scheduled",+ sessions: [+ {+ id: "session-scheduled",+ title: "Nightly dependency check",+ scheduledRun: true,+ projectPath: "/project",+ },+ ],+ projectMeta: { "/project": { name: "Project" } },+ });++ assert.ok(html.includes('class="ct-project-name">Project</span>'));+ assert.ok(!html.includes("ct-title-trigger"), "automation transcripts stay read-only");+ assert.match(html, /<h1 class="ct-title">Nightly dependency check<\/h1>/);+ assert.match(html, /class="ct-back"/);+ });+});++test("the crumb keeps the top bar's quiet type scale and six-pixel rhythm", async () => {+ const styles = await loadStyles();+ const source = await readFile(+ new URL("../src/components/ConversationTopbar.tsx", import.meta.url),+ "utf8",+ );++ assert.match(+ styles,+ /\.conversation-topbar \.ct-title-wrap \{[\s\S]*?gap: 6px;/,+ );+ assert.match(+ styles,+ /\.conversation-topbar \.ct-project \{[\s\S]*?gap: 6px;[\s\S]*?color: var\(--ds-text-faint\);[\s\S]*?font-size: var\(--text-xs\);/,+ );+ assert.match(+ styles,+ /\.conversation-topbar \.ct-sep \{[\s\S]*?color: var\(--ds-border-strong\);/,+ );+ assert.match(source, /<IconFolder size=\{12\} aria-hidden \/>/);});diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.mdindex 7fbc06daa..a984f8258 100644--- a/docs/spec/04-ux/08-component-spec.md+++ b/docs/spec/04-ux/08-component-spec.md@@ -246,15 +246,15 @@ See [ADR tray-session-shortcuts](/adr/tray-session-shortcuts).### 2.1 Purpose-Global controls bar: task title and window actions. Project scope remains-available in the title tooltip. The active session's Agent/Plan/Goal control and-model selection belong to the Composer. (Settings is reached from the command-palette / application menu, not the top bar.)+Global controls bar: the conversation's project breadcrumb, its task title, and+window actions. A local task title is editable in place. The active session's+Agent/Plan/Goal control and model selection belong to the Composer. (Settings is+reached from the command palette / application menu, not the top bar.)### 2.2 Anatomy```text-[☰ Sidebar] [Task title] [+ New] [🔍 Search]+[☰ Sidebar] [Folder · Project / Task title] [+ New] [🔍 Search]```(Icons described functionally; actual render uses Lucide SVGs. The `[☰ Sidebar]`@@ -270,10 +270,20 @@ explicitly unbound shortcut is omitted. The accessible name remains thelocalized action label.The conversation top bar renders for the chat route only; Scheduled, Plugins,-and Settings keep the frameless drag band. It owns the task title and-window actions only. Project scope remains in the title tooltip instead of adding-another visible label. The Composer owns the Agent/Plan/Goal control and the-combined model × reasoning selection (§11).+and Settings keep the frameless drag band. It owns the project breadcrumb, the+task title, and window actions only. The crumb resolves from the active+session's project — a remote session's workspace label, a local session's+project path and naming preference — and is omitted for a temporary chat with+no project. The title follows the crumb after a `/` separator. Its full text+remains in the native tooltip as `Project · Task title`. The Composer owns the+Agent/Plan/Goal control and the combined model × reasoning selection (§11).++The local task title is a rename trigger. Activating it swaps the heading for a+boxless inline editor seeded with the stored title; Enter or blur commits the+trimmed value through the existing session-rename path, Escape cancels, and an+in-flight IME composition owns both keys. Empty and unchanged drafts are+no-ops. Remote and scheduled-run transcripts render a plain title because their+titles are host-owned. The editor closes if the active session changes.### 2.3 Layout@@ -298,15 +308,15 @@ combined model × reasoning selection (§11).overlay hiding tabs or panel actions.Resource close actions stay in their tabs so a second header `×` does not echothe native Windows close control (D357).-- Title cluster (task title) flexes to the remaining width after toolbar- reservations (sidebar lead-in, action icons, work-panel toggle, and- platform window controls). The visible title uses CSS ellipsis only when- that width overflows; the full title remains in the native tooltip.- The right cluster (action icons) is `flex: 0 0 auto`- and is never squeezed by a long title. The conversation surface keeps a- `min-width` so its content is not crushed on narrow windows.-- Project scope is available from the title tooltip but is not rendered as a- second visible label.+- Title cluster (project crumb, separator, task title) flexes to the remaining+ width after toolbar reservations (sidebar lead-in, action icons, work-panel+ toggle, and platform window controls). The crumb uses the 11px quiet text+ scale, the `/` separator uses `border-strong`, and the title uses the 12.5px+ medium scale. Project and title truncate with CSS ellipsis only when that+ width overflows; the full breadcrumb remains in the native tooltip. The right+ cluster (action icons) is `flex: 0 0 auto` and is never squeezed by a long+ title. The conversation surface keeps a `min-width` so its content is not+ crushed on narrow windows.- macOS fullscreen resets the left reserve to 8px (mirrors the sidebar header).- Sticky: `z-sticky`- Items: left-aligned controls, right-aligned actions@@ -351,14 +361,19 @@ combined model × reasoning selection (§11).| Element | Default | Running | Error | No workspace ||---|---|---|---|---|-| Task title | session title (or untitled), uses the available width, with an ellipsis only on overflow | same | same | same |+| Project crumb | folder glyph + session project name, quiet text scale | same | same | omitted for a temporary chat |+| Task title | session title (or untitled); local tasks are an inline rename trigger with ellipsis only on overflow; remote/scheduled titles are plain text | same | same | same |+| Task title editor | boxless input, focused and selected, capped at the shared title limit | same | toast on failed save; the previous title remains | same || New task / Search | icon buttons | same | same | same || Composer stop control | hidden | visible only when the running composer draft is empty | hidden | hidden |-| Project name | title tooltip only | same | same | omitted |### 2.5 Accessibility- Every control is keyboard-reachable with Tab+- The title rename trigger is a real button whose accessible name is+ `Rename task {{title}}`; the inline editor is labelled with the task-name+ label. Enter commits, Escape cancels, blur commits, and IME composition+ suppresses both keys.- Composer stop control has `aria-label="Stop generating"`- The Composer renders no transcription or speech control; the host speechcapability is reachable only from IPC and plugins (ADR 0291).