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(ui): truncate conversation titles by available width
vastsafd18fc8084f3
diff --git a/apps/desktop/src/components/ConversationTopbar.tsx b/apps/desktop/src/components/ConversationTopbar.tsxindex 17c68912b..7790abaed 100644--- a/apps/desktop/src/components/ConversationTopbar.tsx+++ b/apps/desktop/src/components/ConversationTopbar.tsx@@ -20,15 +20,6 @@ function isDefaultSessionTitle(title?: string | null) {return ["new task", "new chat", "新建任务", "新对话"].includes(trimmed);}-const TOPBAR_TITLE_MAX_LENGTH = 10;--function truncateTopbarTitle(title: string) {- const characters = Array.from(title);- return characters.length > TOPBAR_TITLE_MAX_LENGTH- ? `${characters.slice(0, TOPBAR_TITLE_MAX_LENGTH).join("")}…`- : title;-}-export function ConversationTopbar({sidebarCollapsed,workPanelOpen,@@ -52,7 +43,6 @@ export function ConversationTopbar({const fullTaskTitle = isDefaultSessionTitle(activeSession?.title)? t("chat.untitledTask"): activeSession?.title || t("chat.untitledTask");- const taskTitle = truncateTopbarTitle(fullTaskTitle);const project = projectName(workspace?.path, workspace?.name);return (@@ -85,7 +75,7 @@ export function ConversationTopbar({className="ct-title-wrap"title={project ? `${project} · ${fullTaskTitle}` : fullTaskTitle}>- <span className="ct-title">{taskTitle}</span>+ <span className="ct-title">{fullTaskTitle}</span></div></div>diff --git a/apps/desktop/test/thinking-ui.test.mjs b/apps/desktop/test/thinking-ui.test.mjsindex fb819853a..6d28e42f7 100644--- a/apps/desktop/test/thinking-ui.test.mjs+++ b/apps/desktop/test/thinking-ui.test.mjs@@ -109,8 +109,13 @@ test("conversation topbar keeps the title and actions free of a running indicatoassert.doesNotMatch(topbarSource, /className="ct-project"/);assert.doesNotMatch(topbarSource, /className="ct-title-chevron"/);assert.match(topbarSource, /className="ct-title"/);+ assert.doesNotMatch(topbarSource, /TOPBAR_TITLE_MAX_LENGTH|truncateTopbarTitle/);assert.doesNotMatch(topbarSource, /runningSessions|const isRunning|ct-running|role="status"/);assert.match(stylesSource, /\.conversation-topbar \.ct-title-wrap[\s\S]*?align-items: center/);+ assert.match(+ stylesSource,+ /\.conversation-topbar \.ct-title[\s\S]*?overflow:\s*hidden[\s\S]*?text-overflow:\s*ellipsis[\s\S]*?white-space:\s*nowrap/,+ );assert.match(stylesSource,/\.conversation-topbar \.ct-title[\s\S]*?font-size: var\(--text-base\)/,diff --git a/apps/desktop/test/topbar-title-rendering.test.mjs b/apps/desktop/test/topbar-title-rendering.test.mjsnew file mode 100644index 000000000..34ea88259--- /dev/null+++ b/apps/desktop/test/topbar-title-rendering.test.mjs@@ -0,0 +1,46 @@+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";++test("topbar preserves complete titles for width-based clipping and tooltips", async () => {+ 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 } } });+ for (const title of ["Draft reference check", "修复会话标题在窗口顶部的显示", "New task"]) {+ Object.assign(useAppStore.getInitialState(), {+ activeSessionId: "title-test",+ sessions: [{ id: "title-test", title }],+ workspace: { path: "/project", name: "Project" },+ });+ for (const sidebarCollapsed of [false, true]) {+ const html = renderToStaticMarkup(createElement(I18nextProvider, { i18n },+ createElement(ConversationTopbar, {+ 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}"`));+ }+ }+ } finally {+ await server.close();+ }+});diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.mdindex 6824d7457..dcbb67c58 100644--- a/docs/spec/04-ux/08-component-spec.md+++ b/docs/spec/04-ux/08-component-spec.md@@ -271,8 +271,10 @@ 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 and shows at most the first 10 Unicode- characters plus an ellipsis; the full title remains in the native tooltip.+- 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.@@ -319,7 +321,7 @@ combined model × reasoning selection (§11).| Element | Default | Running | Error | No workspace ||---|---|---|---|---|-| Task title | session title (or untitled), capped at 10 characters with an ellipsis when needed | same | same | same |+| Task title | session title (or untitled), uses the available width, with an ellipsis only on overflow | same | same | 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 |diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex 3829eb82b..48ae8abf8 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -151,17 +151,19 @@ Each scenario is documented in this format:## E2E Main Integration ValidationEvery code-bearing change must pass the E2E suites relevant to its regression-surface on the integrated local `main` that carries the change, before the-request branch is pushed and the pull request is opened. Code-bearing changes-include Renderer, Electron Main, Preload, Agent Runtime, Rust host-core,-sessions, transcripts, plans, plugins, MCP, permissions, provider/model-runtime, persistence, process lifecycle, packaging/runtime startup, and build-or CI behavior that affects application execution. Documentation-only changes-are exempt when they do not alter executable behavior.--Run the selected suites from the latest integrated local `main` checkout and-commit. An E2E run on the request branch is exploratory and does not satisfy-this gate.+surface on a candidate that already contains the latest `origin/main`, before+the request branch is pushed and the pull request is opened. Code-bearing+changes include Renderer, Electron Main, Preload, Agent Runtime, Rust+host-core, sessions, transcripts, plans, plugins, MCP, permissions,+provider/model runtime, persistence, process lifecycle, packaging/runtime+startup, and build or CI behavior that affects application execution.+Documentation-only changes are exempt when they do not alter executable+behavior.++Run the selected suites from the request worktree after `pnpm check:pr-base`+passes. An E2E run on a branch that is behind `origin/main` is exploratory and+does not satisfy this gate. Do not merge the task into local `main` to create+the candidate.Use the root `package.json` as the source of truth for executable commands.The minimum selection is:@@ -1486,8 +1488,11 @@ identify the platform validation still needed.or Agent|Plan|Goal mode control. Theleft-of-input Composer chip owns the active session's Agent/Plan/Goal switch,and the Composer-right combined chip owns model and reasoning selection. The- task title is the only visible title text and is capped at 10 characters- with an ellipsis; project scope is available through its tooltip. The sidebar+ task title is the only visible title text and uses the available width,+ with an ellipsis only on overflow. Check an English title longer than 10+ characters in wide and narrow layouts, with the sidebar expanded/collapsed+ and the work panel open/closed; titles must not overlap the action buttons.+ The complete title and project scope remain available through its tooltip. The sidebartoggle is present only in the collapsed state (noduplicate of the sidebar's control). On every other route the frameless dragband renders instead (no chat top-bar controls) while retaining the samediff --git a/docs/zh-CN/spec/04-ux/08-component-spec.md b/docs/zh-CN/spec/04-ux/08-component-spec.mdindex 3b296af1a..dd447e675 100644--- a/docs/zh-CN/spec/04-ux/08-component-spec.md+++ b/docs/zh-CN/spec/04-ux/08-component-spec.md@@ -224,9 +224,8 @@ Composer 拥有 Agent/Plan/Goal 控件以及组合的模型 × 推理选择(§交互式控件上的 `no-drag`; macOS 仅在侧边栏折叠时保留左侧 88px 的交通灯空间,Windows/Linux保留权利本机窗口控件为 112px-- 标题簇(任务标题)最多可显示前 10 个 Unicode- 字符加省略号;完整标题保留在本机工具提示中。-右侧集群(操作图标)是 `flex: 0 0 auto`+- 标题簇(任务标题)在预留侧边栏引导、操作图标、工作面板开关和平台窗口控件之后,占用剩余宽度。可见标题仅在该宽度溢出时使用 CSS 省略号;完整标题保留在本机工具提示中。+ 右侧集群(操作图标)是 `flex: 0 0 auto`并且永远不会被长标题所挤压。对话表面保持`min-width` 因此其内容不会在狭窄的窗口上被压垮。- 项目范围可从标题工具提示中获取,但不会呈现为@@ -258,7 +257,7 @@ Composer 拥有 Agent/Plan/Goal 控件以及组合的模型 × 推理选择(§| 元素 | 默认 | 跑步 | 错误 | 没有工作空间 ||---|---|---|---|---|-| 任务标题 | 会话标题(或无标题),上限为 10 个字符,需要时使用省略号 | 相同,加上一个紧凑的脉冲状态点 | 一样 | 一样 |+| 任务标题 | 会话标题(或无标题),使用可用宽度,仅在溢出时显示省略号 | 相同,加上一个紧凑的脉冲状态点 | 一样 | 一样 || 新任务/搜索 | 图标按钮 | 一样 | 一样 | 一样 || Composer 停止控件 | 隐藏的 | 仅在运行中的草稿为空时可见 | 隐藏的 | 隐藏的 || 项目名称 | 仅标题工具提示 | 一样 | 一样 | 省略 |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.mdindex 5a642745f..504aea0d0 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@@ -97,7 +97,7 @@ unit/integration 测试;代码 pull request 使用有选择且高价值的 E2E## E2E PR 合入门-每个代码 pull request 都必须在合入前通过与其回归面相关的 E2E。代码变更包括渲染器、Electron Main、Preload、Agent Runtime、Rust host-core、会话、转录、计划、插件、MCP、权限、供应商/模型运行时、持久化、进程生命周期、打包/启动,以及影响应用执行的构建或 CI 行为。仅文档更改在不影响可执行行为时可豁免。+每个代码 pull request 都必须在打开或更新前,在已经包含最新 `origin/main` 的候选上通过与其回归面相关的 E2E(`pnpm check:pr-base`)。不得打开落后于 `origin/main` 的 PR。不要为了跑 E2E 把任务合进本地 `main`。代码变更包括渲染器、Electron Main、Preload、Agent Runtime、Rust host-core、会话、转录、计划、插件、MCP、权限、供应商/模型运行时、持久化、进程生命周期、打包/启动,以及影响应用执行的构建或 CI 行为。仅文档更改在不影响可执行行为时可豁免。根目录 `package.json` 是可执行命令的事实来源。最低选择如下:@@ -616,8 +616,9 @@ unit/integration 测试;代码 pull request 使用有选择且高价值的 E2E- **预期**:在聊天路径上,对话顶部栏仅显示标题和操作;它没有模型或 Agent|Plan|Goal 模式控制。左侧输入 Composer 芯片拥有活动会话的 Agent/Plan/Goal 开关,Composer 右侧组合芯片拥有模型和推理选择。的- 任务标题是唯一可见的标题文本,最多 10 个字符- 带有省略号;项目范围可通过其工具提示获得。紧凑型+ 任务标题是唯一可见的标题文本,使用可用宽度,仅在溢出时显示省略号。+ 在宽窄布局、侧边栏展开/折叠及工作面板打开/关闭时,检查超过 10 个字符的+ 英文标题,确保标题不会覆盖操作按钮。完整标题和项目范围可通过工具提示获得。紧凑型运行时出现状态点。侧边栏切换仅在折叠状态下存在(没有侧边栏控件的重复)。在所有其他路线上均采用无框拖曳