Skip to content

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

fix(chat): name a referenced conversation from its current title

Hanawab96e2915e045
diff --git a/apps/desktop/src/features/chat/transcript/shared.tsx b/apps/desktop/src/features/chat/transcript/shared.tsx
index 6154ea551..431bcf198 100644
--- a/apps/desktop/src/features/chat/transcript/shared.tsx
+++ b/apps/desktop/src/features/chat/transcript/shared.tsx
@@ -464,14 +464,23 @@ export function FileRefChip({
export function SessionRefChip({ attachment }: { attachment: MessageAttachment }) {
const { t } = useTranslation();
const selectSession = useAppStore((state) => state.selectSession);
- const label = `${t("chat.sessionReference")} · ${attachment.name}`;
+ // The chip names a conversation, not the name that conversation carried when
+ // the link was pasted: a rename — manual, or the first-turn summary — follows
+ // through to every message that references it. The recorded name is what the
+ // model block quotes, and it stays the fallback for a conversation this
+ // viewer no longer lists.
+ const liveTitle = useAppStore(
+ (state) => state.sessions.find((session) => session.id === attachment.ref)?.title,
+ );
+ const name = (liveTitle ?? "").trim() || attachment.name;
+ const label = `${t("chat.sessionReference")} · ${name}`;
return (
<button
type="button"
className="composer-chip chat-file-chip"
data-action="open-session-reference"
data-session-id={attachment.ref}
- title={t("chat.sessionReferenceOpen", { title: attachment.name })}
+ title={t("chat.sessionReferenceOpen", { title: name })}
aria-label={label}
onClick={() => void selectSession(attachment.ref).catch(() => undefined)}
>
diff --git a/apps/desktop/test/session-reference-ui.test.mjs b/apps/desktop/test/session-reference-ui.test.mjs
index e61849ab5..d85addd63 100644
--- a/apps/desktop/test/session-reference-ui.test.mjs
+++ b/apps/desktop/test/session-reference-ui.test.mjs
@@ -36,7 +36,9 @@ const t = (key, values) => {
: raw;
};
-const useAppStore = (selector) => selector({ selectSession: async () => {} });
+/** The chip reads the live conversation title from the store, like the app. */
+const store = { selectSession: async () => {}, sessions: [] };
+const useAppStore = (selector) => selector(store);
const Icon = () => React.createElement("svg", { "aria-hidden": true });
@@ -144,6 +146,7 @@ const renderRow = (message) =>
test("a referenced conversation renders as a chip naming its own target", () => {
locale = "en";
+ store.sessions = [];
const html = renderChip();
assert.match(html, /data-action="open-session-reference"/);
assert.match(html, /data-session-id="session-a"/);
@@ -165,12 +168,38 @@ test("a referenced conversation renders as a chip naming its own target", () =>
test("the chip speaks the reader's language", () => {
locale = "zh-CN";
+ store.sessions = [];
const html = renderChip();
assert.match(html, /会话引用 · Nightly review/);
assert.match(html, /title="打开会话 Nightly review"/);
assert.match(html, /aria-label="会话引用 · Nightly review"/);
});
+test("a renamed conversation follows through to every message that references it", () => {
+ locale = "zh-CN";
+ store.sessions = [{ id: "session-a", title: "依赖清理顺序(改名后)" }];
+ const renamed = renderChip();
+ assert.match(renamed, /会话引用 · 依赖清理顺序(改名后)/);
+ assert.match(renamed, /title="打开会话 依赖清理顺序(改名后)"/);
+ assert.doesNotMatch(renamed, /Nightly review/, "the pasted name does not survive a rename");
+
+ store.sessions = [{ id: "session-b", title: "另一段对话" }];
+ assert.match(
+ renderChip(),
+ /会话引用 · Nightly review/,
+ "an unlisted conversation keeps the name recorded on the message",
+ );
+ assert.doesNotMatch(renderChip(), /另一段对话/, "another conversation's title is not borrowed");
+
+ store.sessions = [{ id: "session-a", title: " " }];
+ assert.match(
+ renderChip(),
+ /会话引用 · Nightly review/,
+ "an empty title falls back to the recorded name",
+ );
+ store.sessions = [];
+});
+
test("a user message shows the reference next to its own words", () => {
locale = "en";
const html = renderRow(userMessage);
diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.md
index 22aef527b..ceeab155b 100644
--- a/docs/spec/04-ux/08-component-spec.md
+++ b/docs/spec/04-ux/08-component-spec.md
@@ -4216,7 +4216,7 @@ Conversation overflow Composer draft (unsent)
| State | Appearance |
|---|---|
-| Reference attached | Chat-icon chip on the user message, named with the catalog's reference label and the referenced conversation's title |
+| Reference attached | Chat-icon chip on the user message, named with the catalog's reference label and the referenced conversation's current title |
| Reference skipped | Nothing is attached; the link stays plaintext in the message |
| Another project | Skipped the same way: that transcript is not this turn's context |
| Self-reference | Dropped before any read, so the conversation itself is never a reference |
@@ -4238,6 +4238,11 @@ Conversation overflow Composer draft (unsent)
re-resolves it from that conversation's current content.
- Activating the chip opens the referenced conversation; the reference is a
link, not a copy of that transcript.
+- The chip names the conversation from its current title, so a rename — manual
+ or the first-turn summary — follows through to every message that references
+ it. The name recorded when the reference was made stays the fallback for a
+ conversation this viewer no longer lists, and is the name the quoted block
+ keeps for the model.
- The visible text is never rewritten: the link a reader typed stays in the
message, and only the attached excerpt is additive.
- Boundary: only conversations of the same project are read, the current
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 9531d61dc..af2e17deb 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -1849,7 +1849,7 @@ identify the platform validation still needed.
link and read the clipboard. 2) Open B, paste the link into the Composer
draft, send it, and inspect the user message. 3) Ask a follow-up in B without
repeating the link. 4) Paste C's link into B and send. 5) In A, send A's own
- link.
+ link. 6) Rename A from its conversation overflow menu, then return to B.
- **Expected**: The clipboard holds `pi-desktop://session/<A's id>`. B's user
message keeps the link text visible and shows a chat-icon chip labelled with
the catalog's reference label and A's title; activating the chip opens A. The
@@ -1858,6 +1858,9 @@ identify the platform validation still needed.
nothing: the message keeps its plaintext and the model receives no excerpt
from them, because the resolver drops a self-reference before any read and
discards an excerpt whose conversation belongs to another project.
+ Renaming A afterwards renames the chip in B, which names the conversation from
+ its current title; the excerpt the model already read keeps the name recorded
+ when the reference was made.
- **Specs linked**: `04-ux/08-component-spec.md` §20B,
`03-runtime/04-data-storage.md`, `03-runtime/02-agent-runtime.md`
- **Acceptance criterion**: C — Conversation & stream
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 ec1f3a3d5..cc9b60205 100644
--- a/docs/zh-CN/spec/04-ux/08-component-spec.md
+++ b/docs/zh-CN/spec/04-ux/08-component-spec.md
@@ -2951,7 +2951,7 @@ Sidebar footer Popover (360px max)
| 状态 | 外观 |
|---|---|
-| 已附带引用 | 用户消息上的聊天图标芯片,标签为语言目录里的引用标签加被引用对话的标题 |
+| 已附带引用 | 用户消息上的聊天图标芯片,标签为语言目录里的引用标签加被引用对话的当前标题 |
| 引用被跳过 | 不附带任何东西;链接在消息里保持纯文本 |
| 另一个项目 | 同样跳过:那段转写不是本轮的上下文 |
| 自引用 | 在任何读取之前就被丢弃,当前对话永远不会成为引用 |
@@ -2969,6 +2969,8 @@ Sidebar footer Popover (360px max)
块引用给模型,因此后续轮次读到的仍是同一份引用,而重发仍含链接的消息会按该对话
当前内容重新解析。
- 激活芯片会打开被引用的对话;引用是链接,不是那段转写的副本。
+- 芯片按被引用对话的当前标题命名:手动改名或首轮自动摘要改名,都会跟随出现在每一处引用上。
+ 粘贴链接时记录的名称,则作为这位读者已无法列出该对话时的回退,它也是引用块留给模型的名字。
- 可见文本从不被改写:读者输入的链接留在消息里,只有附带的摘录是新增的。
- 边界:只读取同一项目的对话,当前对话在任何读取之前就被丢弃,指向其他项目、不存
在的 id 或 `remote:` 标识的链接保持纯文本,不会变成引用。粘贴无法让应用读取读者
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.md
index 7d5306cbf..465b98957 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
@@ -775,12 +775,14 @@ task-candidate E2E 从请求工作树运行,但使用主工作区已经准备
- **步骤**: 1) 在 A 的对话溢出菜单选「复制会话链接」,读取剪贴板。
2) 打开 B,把链接粘贴进输入框草稿并发送,检查用户消息。
3) 在 B 里追问一次,不再重复链接。 4) 把 C 的链接粘贴进 B 并发送。
- 5) 在 A 里发送 A 自己的链接。
+ 5) 在 A 里发送 A 自己的链接。 6) 从 A 的对话溢出菜单给它改名,然后回到 B。
- **预期**:剪贴板内容是 `pi-desktop://session/<A 的 id>`。B 的用户消息保留可见的链接
文本,并显示聊天图标芯片,标签为语言目录里的引用标签加 A 的标题;激活芯片会打开 A。
回答使用 A 的内容,追问仍然读到同一份引用,而无需再次写入链接。C 的链接与 A 自己的
链接什么都不附带:消息保持纯文本,模型收不到它们的任何摘录——解析器在任何读取之前
丢掉自引用,并丢弃属于其他项目的对话摘录。
+ 事后给 A 改名,B 里的芯片会跟着改名——芯片按被引用对话的当前标题命名;模型已经读过的
+ 摘录则保留引用产生时记录的名称。
- **关联规范**:`04-ux/08-component-spec.md` §20B、`03-runtime/04-data-storage.md`、
`03-runtime/02-agent-runtime.md`
- **验收标准**:C — 对话与流