Skip to content

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

fix(transcript): break a conversation chip with the line it sits on

vastsadcfed446af2d
diff --git a/apps/desktop/src/features/chat/transcript/shared.tsx b/apps/desktop/src/features/chat/transcript/shared.tsx
index 544a82ff6..3b0dbcf34 100644
--- a/apps/desktop/src/features/chat/transcript/shared.tsx
+++ b/apps/desktop/src/features/chat/transcript/shared.tsx
@@ -487,22 +487,35 @@ function SessionChip({ sessionId, fallbackName, ...position }: {
);
const name = (liveTitle ?? "").trim() || fallbackName;
const label = `${t("chat.sessionReference")} · ${name}`;
+ const open = () => void selectSession(sessionId).catch(() => undefined);
+ // This chip carries a conversation title, so it can be wider than whatever
+ // space a line has left. Chromium never fragments a `<button>` across lines:
+ // as one it is pushed whole onto the next line and the rest of the line it
+ // left stays blank. The button role and its keyboard behaviour therefore sit
+ // on a span, which the message stylesheet lays out as an inline run that
+ // breaks with the text.
return (
- <button
- type="button"
+ <span
+ role="button"
+ tabIndex={0}
className="composer-chip chat-file-chip"
{...position}
data-action="open-session-reference"
data-session-id={sessionId}
title={t("chat.sessionReferenceOpen", { title: name })}
aria-label={label}
- onClick={() => void selectSession(sessionId).catch(() => undefined)}
+ onClick={open}
+ onKeyDown={(event) => {
+ if (event.key !== "Enter" && event.key !== " ") return;
+ event.preventDefault();
+ open();
+ }}
>
<span className="composer-chip-icon" aria-hidden>
<IconChat size={13} />
</span>
<span className="composer-chip-name">{label}</span>
- </button>
+ </span>
);
}
diff --git a/apps/desktop/src/styles/messages.css b/apps/desktop/src/styles/messages.css
index c785789bc..005ff6334 100644
--- a/apps/desktop/src/styles/messages.css
+++ b/apps/desktop/src/styles/messages.css
@@ -64,6 +64,36 @@
vertical-align: top;
}
+/* A conversation reference is the message chip whose label can be as long as a
+ conversation title. An atomic chip that does not fit is pushed whole onto the
+ next line and leaves the rest of its line blank, so this one is an inline run
+ instead: it breaks with the text, its first line still reaches the right edge
+ of the line it started on, and the tile continues over the break. */
+.message-row .composer-chip[data-action="open-session-reference"] {
+ display: inline;
+ /* An inline box is as tall as the font (about 1.18em here), so half of the
+ leading has to come back as padding for the tile to cover the line box. */
+ padding: 0.186em 6px;
+ vertical-align: baseline;
+ white-space: normal;
+ -webkit-box-decoration-break: clone;
+ box-decoration-break: clone;
+}
+
+/* `gap` only spaces flex items: an inline run needs the icon's own gap. */
+.message-row .composer-chip[data-action="open-session-reference"] .composer-chip-icon {
+ margin-right: 4px;
+}
+
+/* Break the label where the line needs it instead of ellipsising it: on a full
+ line the label is the only part long enough to reach the right edge. */
+.message-row .composer-chip[data-action="open-session-reference"] .composer-chip-name {
+ overflow: visible;
+ overflow-wrap: anywhere;
+ text-overflow: clip;
+ white-space: normal;
+}
+
.message-row.assistant .message-col,
.message-row.system .message-col,
.message-row.tool .message-col {
diff --git a/apps/desktop/test/renderer-review-fixes.test.mjs b/apps/desktop/test/renderer-review-fixes.test.mjs
index e5e91e7cf..4aaad72b8 100644
--- a/apps/desktop/test/renderer-review-fixes.test.mjs
+++ b/apps/desktop/test/renderer-review-fixes.test.mjs
@@ -82,6 +82,28 @@ test("a chip inside a message reads at that message's own type scale", () => {
assert.doesNotMatch(block, /height: 20px/);
});
+test("a conversation chip breaks with the line instead of emptying it", () => {
+ const selector = '.message-row .composer-chip[data-action="open-session-reference"]';
+ const start = messages.indexOf(`${selector} {`);
+ assert.notEqual(start, -1, "the conversation chip has no inline-run rule");
+ const block = messages.slice(start, messages.indexOf("}", start));
+ // Chromium never fragments a `<button>`: as one, a chip that does not fit is
+ // pushed whole onto the next line and the line it left keeps its blank. An
+ // inline run breaks with the text, so its first line still reaches the edge.
+ assert.match(block, /display: inline;/);
+ assert.match(block, /white-space: normal;/);
+ assert.match(block, /box-decoration-break: clone;/);
+ const nameStart = messages.indexOf(`${selector} .composer-chip-name {`);
+ assert.notEqual(nameStart, -1, "the label is never told it may break");
+ const nameBlock = messages.slice(nameStart, messages.indexOf("}", nameStart));
+ assert.match(nameBlock, /overflow-wrap: anywhere;/);
+ assert.match(nameBlock, /white-space: normal;/);
+ assert.doesNotMatch(nameBlock, /text-overflow: ellipsis;/);
+ const iconStart = messages.indexOf(`${selector} .composer-chip-icon {`);
+ assert.notEqual(iconStart, -1, "an inline run has no flex gap, so the icon needs its own");
+ assert.match(messages.slice(iconStart, messages.indexOf("}", iconStart)), /margin-right:/);
+});
+
test("dead components are gone", () => {
assert.ok(!existsSync(join(here, "../src/components/Topbar.tsx")));
assert.ok(!existsSync(join(here, "../src/components/HomeQuickActions.tsx")));
diff --git a/apps/desktop/test/session-reference-ui.test.mjs b/apps/desktop/test/session-reference-ui.test.mjs
index 4a17dae02..6dceef259 100644
--- a/apps/desktop/test/session-reference-ui.test.mjs
+++ b/apps/desktop/test/session-reference-ui.test.mjs
@@ -155,9 +155,18 @@ test("a referenced conversation renders as a chip naming its own target", () =>
assert.match(html, /data-session-id="session-a"/);
assert.match(
read("../src/features/chat/transcript/shared.tsx"),
- /onClick=\{\(\) => void selectSession\(sessionId\)\.catch\(\(\) => undefined\)\}/,
+ /const open = \(\) => void selectSession\(sessionId\)\.catch\(\(\) => undefined\)/,
"activating the chip opens the referenced conversation",
);
+ // The chip is a span, not a <button>, because Chromium never fragments a
+ // button across lines and an atomic chip leaves the line it left blank.
+ assert.match(html, /role="button"/, "the chip is announced as a button");
+ assert.match(html, /tabindex="0"/, "the chip is reachable from the keyboard");
+ assert.match(
+ read("../src/features/chat/transcript/shared.tsx"),
+ /if \(event\.key !== "Enter" && event\.key !== " "\) return;\s*\n\s*event\.preventDefault\(\);\s*\n\s*open\(\);/,
+ "Enter and Space activate the chip, the way a button does",
+ );
assert.ok(
html.includes(`${catalogs.en.chat.sessionReference} · Nightly review`),
"the chip names the reference from the catalog",
diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.md
index ac9907d86..7d3bb8f23 100644
--- a/docs/spec/04-ux/08-component-spec.md
+++ b/docs/spec/04-ux/08-component-spec.md
@@ -4242,9 +4242,14 @@ Conversation overflow Composer draft (unsent)
its tile is sized and aligned by that leading so it covers exactly one line of
message text: the label sits on the line's baseline instead of poking out of
the composer's compact box. The 11.5px/20px metric is draft-only.
-- The chip is a button with a catalog-built accessible name and a tooltip
- naming the conversation it opens; it is keyboard-activatable and leaves the
- surrounding selectable message text intact.
+- A conversation reference is an inline run rather than an atomic chip: it breaks
+ with the line it sits on, so a reference too wide for the line continues on the
+ next line and leaves the line it started on filled. Chromium never fragments a
+ `<button>`, so this chip carries the button role and its Enter and Space
+ behaviour on an activatable span.
+- The chip carries the button role with a catalog-built accessible name and a
+ tooltip naming the conversation it opens; it is keyboard-activatable and leaves
+ the surrounding selectable message text intact.
- `pi-desktop://` is not yet an operating-system protocol handler; opening a
link from outside the app is a separate change (issue #1324, option A). This
section covers the in-app reference.
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 b201bfdca..4e4bd383b 100644
--- a/docs/zh-CN/spec/04-ux/08-component-spec.md
+++ b/docs/zh-CN/spec/04-ux/08-component-spec.md
@@ -2945,7 +2945,10 @@ Sidebar footer Popover (360px max)
本来打不开的转写。
- 消息里的芯片沿用该消息自身的字体、字号与行高,底色块按该行高取尺寸与对齐,正好覆盖
一行消息文本:标签落在该行基线上,不再从输入框那套紧凑盒子里冒出来。11.5px/20px 的尺寸只属于草稿。
-- 芯片是按钮,无障碍名称由语言目录生成,工具提示说明它会打开哪段对话;可键盘激活,
+- 对话引用是行内可断行的文字块,不是原子芯片:这一行放不下时随正文换行续写,起始那一行保持填满、
+ 不留空白。Chromium 不会把 `<button>` 拆到多行,因此这个芯片把 button 角色与 Enter/Space
+ 键盘行为放在可激活的 span 上。
+- 芯片带 button 角色,无障碍名称由语言目录生成,工具提示说明它会打开哪段对话;可键盘激活,
并保持周围可选中的消息文本不变。
- `pi-desktop://` 目前还不是操作系统协议处理器;从应用外打开链接是另一项改动
(issue #1324 的 A 方案)。本节只覆盖应用内的引用。