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(composer): show each @ file row's full relative path
xiaokbf0fe74774c1
diff --git a/apps/desktop/src/components/ComposerAutocomplete.tsx b/apps/desktop/src/components/ComposerAutocomplete.tsxindex f18338a75..b28811c83 100644--- a/apps/desktop/src/components/ComposerAutocomplete.tsx+++ b/apps/desktop/src/components/ComposerAutocomplete.tsx@@ -141,13 +141,14 @@ export function ComposerAutocomplete({return (<button{...commonProps}- aria-label={`${displayName} — ${item.entry.path}`}+ aria-label={item.entry.path}title={item.entry.path}><span className="composer-ac-icon">{isDir ? <IconFolder size={14} /> : <IconFileText size={14} />}</span><span className="composer-ac-name">{displayName}</span>+ <span className="composer-ac-path">{item.entry.path}</span></button>);};diff --git a/apps/desktop/src/styles/composer-autocomplete.css b/apps/desktop/src/styles/composer-autocomplete.cssindex ee1cda534..637fb9eb7 100644--- a/apps/desktop/src/styles/composer-autocomplete.css+++ b/apps/desktop/src/styles/composer-autocomplete.css@@ -89,6 +89,20 @@font-size: var(--text-xs-plus, var(--text-sm));}+.composer-ac-path {+ /* The relative path takes the remaining width and truncates first, so the+ leaf name survives as long as it can. */+ flex: 1 1 0;+ min-width: 0;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+ text-align: left;+ color: var(--ds-text-muted);+ font-family: var(--font-mono, ui-monospace, monospace);+ font-size: var(--text-xs-plus, var(--text-sm));+}+.composer-ac-hl {color: var(--ds-accent);font-weight: var(--font-weight-semibold);diff --git a/apps/desktop/src/styles/composer-menus.css b/apps/desktop/src/styles/composer-menus.cssindex 40218c4b2..f5690deeb 100644--- a/apps/desktop/src/styles/composer-menus.css+++ b/apps/desktop/src/styles/composer-menus.css@@ -606,7 +606,7 @@border-radius: var(--radius-sm);}-.composer-plus-item.active span:last-child {+.composer-plus-item.active span:last-child:not(.composer-ac-path) {color: var(--ds-text-primary);}diff --git a/apps/desktop/test/composer-file-reference-display.test.mjs b/apps/desktop/test/composer-file-reference-display.test.mjsindex a17ee1af2..9540a364a 100644--- a/apps/desktop/test/composer-file-reference-display.test.mjs+++ b/apps/desktop/test/composer-file-reference-display.test.mjs@@ -14,22 +14,24 @@ const [autocomplete, autocompleteHook, autocompleteStyles, composer, composerStyread("../src/styles/composer.css"),]);-test("file autocomplete rows keep the path out of the persistent label", () => {+test("file autocomplete rows show the leaf name with the full relative path", () => {assert.match(autocomplete,/const displayName = `\$\{name\}\$\{isDir \? "\/" : ""\}`/,);assert.match(autocomplete, /className="composer-ac-name">\{displayName\}/);- assert.doesNotMatch(autocomplete, /composer-ac-path/);- assert.doesNotMatch(autocompleteStyles, /\.composer-ac-path/);+ // The trailing path span always carries the entry's full workspace-relative path.+ assert.match(autocomplete, /className="composer-ac-path">\{item\.entry\.path\}/);+ assert.match(autocompleteStyles, /\.composer-ac-path\s*\{[^{}]*flex: 1 1 0/);+ assert.match(+ autocompleteStyles,+ /\.composer-ac-path\s*\{[^{}]*text-overflow: ellipsis/,+ );});test("accepted files become compact references while directories keep completion", () => {assert.match(autocomplete, /title=\{item\.entry\.path\}/);- assert.match(- autocomplete,- /aria-label=\{`\$\{displayName\} — \$\{item\.entry\.path\}`\}/,- );+ assert.match(autocomplete, /aria-label=\{item\.entry\.path\}/);assert.match(autocompleteHook,/item\.kind === "path" && item\.entry\.kind === "file"/,diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.mdindex edce529ca..ed1b4f5b9 100644--- a/docs/spec/04-ux/08-component-spec.md+++ b/docs/spec/04-ux/08-component-spec.md@@ -3397,9 +3397,13 @@ Anatomy:hints can still truncate when they themselves exceed the available row width;neither command rows nor file rows overflow the menu.- File mode (`@` token at cursor, boundary-preceded): rows persistently show- only the leaf file or directory name; directories get a trailing `/` and- continue completion on accept. The complete relative path remains available- through the row tooltip and accessible name. Accepting a completed file+ the leaf file or directory name followed by the entry's complete+ workspace-relative path in a de-emphasized mono span; directories keep a+ trailing `/` on the leaf name and continue completion on accept, and the+ path span renders the raw `entry.path` without a trailing slash. The path+ span takes the row's remaining width and ellipsizes before the leaf name+ can, while the row tooltip and accessible name still carry the complete+ relative path. Accepting a completed file(Enter, Tab, or click) replaces the `@` token with an inline leaf-name chipat the caret — the same sentinel-backed chip as a pasted file — whosecanonical value is the original `entry.path`; the menu closes and that Enterdiff --git a/docs/spec/04-ux/09-interaction-patterns.md b/docs/spec/04-ux/09-interaction-patterns.mdindex 43bde07c6..ad5d5e8d8 100644--- a/docs/spec/04-ux/09-interaction-patterns.md+++ b/docs/spec/04-ux/09-interaction-patterns.md@@ -1268,9 +1268,10 @@ Project drag/drop follows these patterns:token (`@"…`) is treated as one token until the closing quote.- Pasting text never opens a menu unless the caret lands inside a validtrigger token.-- File results keep each row compact by rendering only the leaf name (with a- trailing `/` for directories). The full relative path remains available as- the row tooltip and accessible name. Accepting a file (Enter/Tab/click)+- File results render the leaf name (with a trailing `/` for directories)+ followed by the entry's complete workspace-relative path in a de-emphasized+ span that ellipsizes before the leaf name can. The full relative path also+ remains the row tooltip and accessible name. Accepting a file (Enter/Tab/click)replaces the `@` token with an inline sentinel-backed leaf-name chip at thecaret, backed by the full `entry.path`; that confirmation does not send.Accepting a directory keeps the full literal path in the draft so deeperdiff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex 5e695c4e2..6ba338d3e 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -8422,7 +8422,7 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.- **Status**: Unit-covered (`apps/desktop/test/composer-drag-drop.test.mjs`);full desktop gesture journey Draft (run only in a capable environment when this surface changes)-#### E2E-102a: Composer file reference results use compact leaf names+#### E2E-102a: Composer file reference results show leaf names with full relative paths- **Preconditions**: The app is running with an Agent session in a workspacecontaining nested files, duplicate leaf names in different directories, and@@ -8435,8 +8435,11 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.and continue to a child file. 4) Send the completed references and inspectthe persisted user message.- **Expected**:- - Each result persistently renders only its leaf name; directories retain a- trailing `/`, and no parent path consumes horizontal row space.+ - Each result persistently renders its leaf name followed by the entry's+ complete workspace-relative path in a de-emphasized span; directories+ retain a trailing `/` on the leaf name, the span carries the raw+ `entry.path`, and it ellipsizes before the leaf name can while the row+ never overflows the menu.- The tooltip and accessible name retain the complete relative path soduplicate leaf names remain distinguishable.- Enter/Tab/click on a file replaces the `@` token with an inline chip that@@ -8447,12 +8450,13 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.the agent can read both selected files normally.- **Specs linked**: `04-ux/08-component-spec.md` §11.8,`04-ux/09-interaction-patterns.md` §8a, `03-runtime/01-ipc-protocol.md` §13c,- `08-meta/decisions-log.md` (D124, D209, D362), ADR 0024, ADR 0070+ `08-meta/decisions-log.md` (D124, D209, D362, D658), ADR 0024, ADR 0070- **Acceptance**: C (conversation & stream), Quality- **Milestone**: M5- **Status**: Unit-covered- (`apps/desktop/test/composer-file-reference-display.test.mjs`); full UI- journey Draft (run only in a capable environment when this surface changes)+ (`apps/desktop/test/composer-file-reference-display.test.mjs`); file-mode row+ layout covered by `scripts/e2e-composer-autocomplete.mjs`; full UI journey+ Draft (run only in a capable environment when this surface changes)#### E2E-102b: Unanswered Stop restores compact file-reference draftsdiff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.mdindex f8aa947e5..b532a750f 100644--- a/docs/spec/08-meta/decisions-log.md+++ b/docs/spec/08-meta/decisions-log.md@@ -484,6 +484,7 @@ section mirrors only marketplace/catalog items still blocking nothing.| D152 | Direct runtime stream rendering | **Assistant content renders each runtime stream chunk directly through the incremental Markdown block cache. The renderer does not add a requestAnimationFrame typewriter state loop. KaTeX's Vite-inlined fonts remain local-only assets and are admitted by the narrow `font-src 'self' data:` CSP directive.** | The duplicate animation loop could trip React's nested-update guard during sustained streams, while the previous CSP blocked bundled math fonts and produced console errors. || D153 | Reasoning sessions default to maximum thinking | *(superseded by D303)* **A newly created session whose inherited default model supports reasoning starts at the highest canonical entry in that model's pi-published `supportedThinkingLevels`. Non-reasoning models and missing capability metadata start at `off`; existing sessions retain their durable choice. This refines D096 without adding a provider override.** | Reasoning-capable models should use their strongest available effort by default while preserving explicit per-session choices and pi-ai's model authority. || D264 | Composer typing avoids full sorts and redundant DOM writes | **The `@` file menu picks its visible rows with a bounded top-K selection over the match list instead of sorting every match; the selection returns exactly the row set and order a full sort produced, and the small, kind-grouped command list keeps its full sort. Composer auto-resize and `--composer-dock-height` publication are idempotent: an unchanged height performs no DOM write and no document-wide style invalidation, and the `height: auto` measurement probe is taken only when the box may need to shrink. Growth through seven rows, internal scrolling past the seventh, and contraction on delete or submit are unchanged. Draft file-reference state and the cursor keep their identity and value when a keystroke changes neither, so the draft-cache serialization effect and autocomplete trigger detection stop re-running per keystroke. No IPC, storage, host-protocol, or schema change.** | With a large workspace and the `@` menu open, every keystroke paid a full sort over the whole 8000-entry file index to show 50 rows, plus a forced synchronous reflow from the measurement probe, while a fresh `fileReferences` array identity per keystroke re-ran the draft-cache serialization effect. The cost was typing latency, not correctness; ordering equivalence with the full sort is covered by unit tests. |+| D658 | Composer file menu rows always show the full relative path | **Amend the `@` file-completion row presentation of D124 (specs `04-ux/08-component-spec.md` §11.8, `04-ux/09-interaction-patterns.md` §8a.1, E2E-102a): every row renders the leaf name — directories keep the trailing `/` — followed by the entry's complete workspace-relative path in a de-emphasized mono span that carries the raw `entry.path` without a trailing slash. The span takes the row's remaining width and ellipsizes before the leaf name can, and no row overflows the menu. The tooltip keeps the complete relative path and the accessible name becomes the path alone, because the visible row already includes the leaf name. D209/D362 chip rendering, completion, insertion, and serialization are unchanged; no earlier decision owned the old leaf-only row wording, so no entry is marked amended.** | Duplicate leaf names in different directories were indistinguishable until hover, and the relative location — often the actual intent of an `@` reference — was invisible in the persistent row. |## T. Release delivery decisions@@ -7656,3 +7657,23 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.`apps/desktop/test/browser-local-file-feedback.test.mjs`, and E2E-059. SeeADR 0328, `04-ux/08-component-spec.md`, `07-plugins/03-plugin-api.md`, and`05-security/01-security.md`.++## 2026-10-14 — Composer file menu rows always show the full relative path (D658)++- D658 amends the `@` file-completion row contract in+ `04-ux/08-component-spec.md` §11.8, `04-ux/09-interaction-patterns.md` §8a.1,+ and E2E-102a: each row persists the leaf name (directories keep the trailing+ `/`) followed by the entry's complete workspace-relative path in a+ de-emphasized mono span that renders the raw `entry.path` without a trailing+ slash. The span takes the row's remaining width and ellipsizes before the+ leaf name can, so a short leaf name never truncates and no row overflows the+ menu.+- The tooltip still carries the complete relative path, and the accessible+ name becomes the path alone — the visible row already includes the leaf+ name, so the old `leaf — path` label would have read it twice.+- Reference chips (D209/D362, ADR 0024/ADR 0070), completion, insertion, and+ serialization are unchanged, and no earlier decision owned the old+ leaf-only row wording, so no entry is marked amended.+- Covered by `apps/desktop/test/composer-file-reference-display.test.mjs` and+ the file-mode fixture of `scripts/e2e-composer-autocomplete.mjs`. See+ `04-ux/08-component-spec.md` and `04-ux/09-interaction-patterns.md`.diff --git a/docs/zh-CN/spec/04-ux/08-component-spec.md b/docs/zh-CN/spec/04-ux/08-component-spec.mdindex a2498e2dd..d9a7a3cad 100644--- a/docs/zh-CN/spec/04-ux/08-component-spec.md+++ b/docs/zh-CN/spec/04-ux/08-component-spec.md@@ -2273,9 +2273,11 @@ Live Voice 受现有开发者模式和开发构建门控约束,包含四种展长描述也应优先省略,不能把短命令名称挤成省略号。名称或提示自身超过行宽时仍可省略;命令行和文件行都不得溢出菜单。- 文件模式(光标处的 `@` 标记,边界之前):行持续显示- 仅叶文件或目录名称;目录有一个尾随的 `/` 和- 接受后继续完成。完整的相对路径仍然可用- 通过行工具提示和可访问的名称。接受已完成的文件+ 叶文件或目录名称,并在其后以弱化的等宽样式显示该条目完整的+ 工作区相对路径;目录叶名带尾随 `/`,接受后继续完成,+ 路径 span 渲染原始 `entry.path`(不带尾斜杠)。路径 span 吸收行的+ 剩余宽度并先于叶名截断;行工具提示与可访问名仍携带完整的+ 相对路径。接受已完成的文件(Enter、Tab 或点击)会把 `@` 标记替换为光标处的行内叶名芯片—— 与粘贴文件相同的哨兵芯片 —— 其规范值为原始 `entry.path`;菜单关闭且这次 Enter 不会发送。接受目录会将文字路径保留在草稿中,diff --git a/docs/zh-CN/spec/04-ux/09-interaction-patterns.md b/docs/zh-CN/spec/04-ux/09-interaction-patterns.mdindex 612f1fbae..6caf6b41a 100644--- a/docs/zh-CN/spec/04-ux/09-interaction-patterns.md+++ b/docs/zh-CN/spec/04-ux/09-interaction-patterns.md@@ -986,9 +986,10 @@ Mode/provider/model/permission/shell 配置和新提示仍然存在代币 (`@"…`) 在收盘报价之前被视为一种代币。- 粘贴文本永远不会打开菜单,除非插入符号落在有效的区域内触发令牌。-- 文件结果通过仅渲染叶名称(带有- 目录尾随 `/`)。完整的相对路径仍然可用- 行工具提示和可访问的名称。接受文件(Enter/Tab/点击)+- 文件结果渲染叶名称(目录带尾随 `/`),+ 并在其后以弱化样式显示条目完整的工作区相对路径,该路径先于叶名+ 截断。完整的相对路径同时仍是行工具提示与可访问名。+ 接受文件(Enter/Tab/点击)会把 `@` 标记替换为光标处的行内哨兵叶名芯片,由完整的`entry.path` 支持;该确认不会发送。接受目录保留草稿中的完整文字路径,以便可以继续进行更深入的补全。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 88071b20f..4698a8092 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@@ -5145,7 +5145,7 @@ eleven-tool-round desktop paths are verified by及完整提供商发送仍需人工验证。应在更新后的任务候选版本运行并记录修订;随后按权威 `AGENTS.md` 工作流验证 PR 集成候选,无需先合入本地 main。-#### E2E-102a:Composer 文件引用结果使用紧凑的叶名称+#### E2E-102a:Composer 文件引用结果显示叶名称与完整相对路径- **先决条件**:应用程序正在工作区中使用 Agent 会话运行包含嵌套文件、不同目录中的重复叶名称,以及@@ -5157,8 +5157,9 @@ eleven-tool-round desktop paths are verified by接受目录结果并继续子文件。 4) 发送完整的引用并检查持久化的用户消息。- **预期**:- - 每个结果持久地仅呈现其叶名称;目录保留一个- 尾随 `/`,并且没有父路径消耗水平行空间。+ - 每个结果持久地呈现其叶名称,并在其后以弱化样式显示条目完整的+ 工作区相对路径;目录叶名保留尾随 `/`,该 span 携带原始+ `entry.path`,并先于叶名截断,行永不溢出菜单。- 工具提示和可访问名称保留完整的相对路径,以便重复的叶子名称仍然可以区分。- 对文件按 Enter/Tab/点击会把 `@` 标记替换为留在草稿中的行内芯片;@@ -5168,11 +5169,12 @@ eleven-tool-round desktop paths are verified by空格引用,代理可以正常读取两个选定的文件。- **链接规格**:`04-ux/08-component-spec.md` §11.8,`04-ux/09-interaction-patterns.md` §8a、`03-runtime/01-ipc-protocol.md` §13c、- `08-meta/decisions-log.md`(D124、D209、D362)、ADR 0024、ADR 0070+ `08-meta/decisions-log.md`(D124、D209、D362、D658)、ADR 0024、ADR 0070- **接受**:C(对话和直播),质量- **里程碑**:M5- **状态**:单位覆盖- (`apps/desktop/test/composer-file-reference-display.test.mjs`);完整的用户界面+ (`apps/desktop/test/composer-file-reference-display.test.mjs`);文件模式行+ 布局由 `scripts/e2e-composer-autocomplete.mjs` 覆盖;完整的用户界面旅程草稿(适用变更合入前需在具备条件的环境中运行 E2E)#### E2E-102b:未答复的停止恢复紧凑的文件参考草稿diff --git a/docs/zh-CN/spec/08-meta/decisions-log.md b/docs/zh-CN/spec/08-meta/decisions-log.mdindex 526300583..d76f9222d 100644--- a/docs/zh-CN/spec/08-meta/decisions-log.md+++ b/docs/zh-CN/spec/08-meta/decisions-log.md@@ -484,6 +484,7 @@| D264 | Composer 输入避开全量排序与冗余 DOM 写入 | **`@` 文件菜单用有界 top-K 选择从匹配列表中挑出可见行,而不再排序全部匹配;该选择返回的行集合与顺序与完整排序完全一致,而较小且按命令类型分组的命令列表保留完整排序。Composer 自动调整高度与 `--composer-dock-height` 发布都是幂等的:高度未变化时不做 DOM 写入,也不会使整个文档样式失效,`height: auto` 测量探针仅在文本框可能需要收缩时读取。增长到七行、超过第七行后内部滚动,以及 delete/submit 后的收缩均保持不变。当一次按键既未改变草稿文件引用状态也未改变光标位置时,两者都保持原有的身份与取值,因此草稿缓存序列化 effect 和自动完成触发检测不再每次按键都重跑。不改动 IPC、存储、主机协议或 schema。** | 在大型工作区中打开 `@` 菜单时,每次按键都要对整个 8000 条的文件索引做一次完整排序才显示 50 行,还要为测量探针付一次强制同步重排,而每次按键新建的 `fileReferences` 数组身份又会重跑草稿缓存序列化 effect。代价是输入延迟而非正确性;与完整排序的顺序等价性由单元测试覆盖。 || D632 | Composer 按 ↑/↓ 召回当前会话的提交历史 | **修订 D125 / D209 / D301:每个会话仅记录已接受的常规或 steering 提示,以及已派发的 slash、扩展和模式命令;记录按新到旧存入渲染器 `localStorage`(`pi.desktop.composerInputHistory`),每会话最多 100 条、最多 20 个会话,连续重复项合并。空草稿按 ↑ 开始召回,↑/↓ 在历史中导航,越过最新项后恢复为空;编辑、提交或切换会话会结束浏览,IME 与自动补全优先。召回同时恢复该会话自己的文件和图片引用;首页无会话时不提供召回。首页首条消息被接受时,提交流程将实际 materialize 的 sessionId 回传给历史记录器,不再于异步结束后读取全局活动会话,因此导航竞态不会串写历史。不改协议、host、schema、权限、主题或打包。** | 重复输入指令无需重打;按会话隔离可保持上下文一致,并可无条件恢复存于该会话 scratch 目录的附件。 || D633 | 已完成回合的过程默认收起 | **修订 ADR turn-process-and-thinking-display:详细模式仅在回合运行时默认展开整体过程;回合完成后,未操作过程默认收起,用户明确选择仍生效。紧凑模式恢复、搜索定位、回答/操作面位置及持久化语义不变。** | 完成后的过程是唯一默认展开的分支,导致进度和工具详情在工作结束后仍占据对话区。收起未操作过程可让最终回答重新成为回合焦点,同时保留用户主动查看的入口。 |+| D658 | Composer 文件菜单行始终显示完整相对路径 | **修订 D124 的 `@` 文件补全行呈现(规格 `04-ux/08-component-spec.md` §11.8、`04-ux/09-interaction-patterns.md` §8a.1、E2E-102a):每一行在叶名称——目录保留尾随 `/`——之后,以弱化的等宽样式渲染该条目完整的工作区相对路径,路径 span 携带原始 `entry.path`(不带尾斜杠)。该 span 吸收行的剩余宽度并先于叶名截断,行不会溢出菜单。工具提示保留完整相对路径,可访问名改为只念路径本身,因为可视行已包含叶名。D209/D362 的芯片渲染、补全、插入与序列化均不变;此前没有决策拥有旧的纯叶名行措辞,因此没有条目被标记为已修订。** | 不同目录下的同名文件在悬停前无法区分,而相对位置往往才是 `@` 引用的真实意图,此前在持久行中完全不可见。 |## T. 发布交付决策@@ -5399,3 +5400,18 @@ Markdown 源码,不是 `text/html` 负载;对禁用行内 HTML 的外部编- 由 `apps/desktop/test/browser-pane-navigation.test.mjs`、`apps/desktop/test/browser-local-file-feedback.test.mjs` 与 E2E-059 覆盖。见 ADR 0328、`04-ux/08-component-spec.md`、`07-plugins/03-plugin-api.md` 与 `05-security/01-security.md`。++## 2026-10-14 —— Composer 文件菜单行始终显示完整相对路径(D658)++- D658 修订 `04-ux/08-component-spec.md` §11.8、`04-ux/09-interaction-patterns.md` §8a.1+ 与 E2E-102a 中 `@` 文件补全的行契约:每行在叶名称(目录保留尾随 `/`)之后,+ 以弱化的等宽样式渲染条目完整的工作区相对路径,span 携带原始 `entry.path`+ (不带尾斜杠)。该 span 吸收行的剩余宽度并先于叶名截断,因此短叶名不会被+ 截断,行也不会溢出菜单。+- 工具提示仍携带完整相对路径;可访问名改为只念路径本身——可视行已包含叶名,+ 旧的 `叶名 — 路径` 标签会把它念两遍。+- 引用芯片(D209/D362、ADR 0024/ADR 0070)、补全、插入与序列化均不变;+ 此前没有决策拥有旧的纯叶名行措辞,因此没有条目被标记为已修订。+- 由 `apps/desktop/test/composer-file-reference-display.test.mjs` 与+ `scripts/e2e-composer-autocomplete.mjs` 的 file-mode fixture 覆盖。见+ `04-ux/08-component-spec.md` 与 `04-ux/09-interaction-patterns.md`。diff --git a/scripts/e2e/composer-autocomplete-layout.tsx b/scripts/e2e/composer-autocomplete-layout.tsxindex 6ed7e6100..2409cfb13 100644--- a/scripts/e2e/composer-autocomplete-layout.tsx+++ b/scripts/e2e/composer-autocomplete-layout.tsx@@ -28,9 +28,22 @@ const items: AutocompleteItem[] = [command("template", longDescription, { kind: "template", argumentHint: "<file>" }),command("very-long-command-".repeat(20), longDescription),];+// File mode: one short leaf name with a deep relative path — the path must+// claim the remaining row width and truncate before the leaf name can — one+// oversized leaf name, which must still truncate on its own, and one directory+// row, whose leaf name keeps the trailing `/` while the path span stays the+// raw `entry.path` (no trailing slash).+const shortLeafPath = `src/components/chat/${"nested/".repeat(10)}Composer.tsx`;+const oversizedLeafPath = `nested/${"long-file-name-".repeat(30)}.ts`;+const dirEntryPath = "src/components/chat";+const fileItems: AutocompleteItem[] = [+ { kind: "path", entry: { path: shortLeafPath, kind: "file" }, match: { score: 1, ranges: [] } },+ { kind: "path", entry: { path: oversizedLeafPath, kind: "file" }, match: { score: 1, ranges: [] } },+ { kind: "path", entry: { path: dirEntryPath, kind: "dir" }, match: { score: 1, ranges: [] } },+];function Fixture({ width, fileMode }: { width: number; fileMode: boolean }) {const anchorRef = useRef<HTMLTextAreaElement>(null);- const rows = fileMode ? [{ kind: "path", entry: { path: `nested/${"long-file-name-".repeat(30)}.ts`, kind: "file" }, match: { score: 1, ranges: [] } } as AutocompleteItem] : items;+ const rows = fileMode ? fileItems : items;const ac: ReturnType<typeof useComposerAutocomplete> = {open: true, mode: fileMode ? "file" : "slash", query: "", items: rows,hasItems: true, highlight: 0, setHighlight: noop, truncated: false,@@ -61,7 +74,9 @@ globalThis.autocompleteLayoutProbe = async (width, fileMode = false) => {const measurements = rows.map((row) => {const name = row.querySelector<HTMLElement>(".composer-ac-name")!;const desc = row.querySelector<HTMLElement>(".composer-ac-desc");+ const path = row.querySelector<HTMLElement>(".composer-ac-path");return { name: name.textContent, nameWidth: name.clientWidth, nameContent: name.scrollWidth,+ path: path?.textContent, pathWidth: path?.clientWidth, pathContent: path?.scrollWidth,descriptionWidth: desc?.clientWidth, descriptionContent: desc?.scrollWidth,rowWidth: row.clientWidth, rowContent: row.scrollWidth };});@@ -74,9 +89,17 @@ globalThis.autocompleteLayoutProbe = async (width, fileMode = false) => {if (!fileMode && index < items.length - 1 && row.nameContent > row.nameWidth + 1) failures.push(`command ${row.name} is truncated`);if (!fileMode && [0, 1, 4, 5].includes(index) && !(row.descriptionContent! > row.descriptionWidth!)) failures.push(`long description ${index} is not truncated`);}- const oversizedName = measurements[fileMode ? 0 : measurements.length - 1];+ if (fileMode) {+ const shortLeaf = measurements[0];+ if (shortLeaf.nameContent > shortLeaf.nameWidth + 1) failures.push("short file leaf name is truncated");+ if (shortLeaf.path !== shortLeafPath) failures.push("file row lost the full relative path text");+ if (!(shortLeaf.pathContent! > shortLeaf.pathWidth!)) failures.push("long relative path is not truncated");+ const dirRow = measurements[2];+ if (dirRow.name !== "chat/") failures.push("directory row lost the trailing slash on its leaf name");+ if (dirRow.path !== dirEntryPath) failures.push("directory row path span is not the raw entry.path");+ }+ const oversizedName = measurements[fileMode ? 1 : measurements.length - 1];if (oversizedName.nameContent <= oversizedName.nameWidth) failures.push("oversized name no longer truncates");- if (fileMode && measurements[0].nameWidth < width - 70) failures.push("file name no longer uses available width");accepted = -1;rows[0].dispatchEvent(new MouseEvent("mousedown", { bubbles: true, cancelable: true }));if (accepted !== 0 || document.activeElement !== input) failures.push("acceptance lost row identity or input focus");