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(transcript): stop repeating a conversation chip above its own message
vastsa7f9c49aec78f
diff --git a/apps/desktop/src/features/chat/transcript/MessageRow.tsx b/apps/desktop/src/features/chat/transcript/MessageRow.tsxindex 33314111b..3bba2f174 100644--- a/apps/desktop/src/features/chat/transcript/MessageRow.tsx+++ b/apps/desktop/src/features/chat/transcript/MessageRow.tsx@@ -8,7 +8,7 @@ import {type ReactNode,} from "react";import { useTranslation } from "react-i18next";-import type { UiMessage } from "@pi-desktop/shared";+import type { MessageAttachment, UiMessage } from "@pi-desktop/shared";import { useOpenChatFileRef } from "../../../hooks/use-preview-target";import { splitChatText } from "../../../lib/chat-links";import { useAppStore } from "../../../stores/app-store";@@ -30,7 +30,6 @@ import {LinkifiedText,MessageAttachmentImage,MessageTimestamp,- SessionRefChip,} from "./shared";import {useChatTextActions,@@ -117,7 +116,12 @@ export const MessageRow = memo(function MessageRow({.filter((segment): segment is { kind: "target"; text: string; label: string; target: { kind: "file"; path: string } } => segment.kind === "target" && segment.target.kind === "file").map((segment) => segment.target.path),);- return attachments.filter((attachment) => !inline.has(attachment.ref));+ // A conversation reference is already its chip in the body link, so it+ // needs no second block; only a file the body does not show inline does.+ return attachments.filter(+ (attachment): attachment is MessageAttachment & { kind: "file" | "image" } =>+ attachment.kind !== "session" && !inline.has(attachment.ref),+ );}, [message.attachments, message.content, workspaceRoot]);const beginEdit = async () => {if (!editableUserMessage || isRunning || loadingEdit) return;@@ -265,10 +269,6 @@ export const MessageRow = memo(function MessageRow({attachment={attachment}onOpenFile={openFileRef}/>- ) : attachment.kind === "session" ? (- <span key={`${attachment.ref}:${attachment.name}`} role="listitem">- <SessionRefChip attachment={attachment} />- </span>) : (<spankey={`${attachment.ref}:${attachment.name}`}diff --git a/apps/desktop/src/features/chat/transcript/shared.tsx b/apps/desktop/src/features/chat/transcript/shared.tsxindex 4861b3ccb..544a82ff6 100644--- a/apps/desktop/src/features/chat/transcript/shared.tsx+++ b/apps/desktop/src/features/chat/transcript/shared.tsx@@ -506,11 +506,6 @@ function SessionChip({ sessionId, fallbackName, ...position }: {);}-/** A structured session attachment on a user message (issue #1324). */-export function SessionRefChip({ attachment }: { attachment: MessageAttachment }) {- return <SessionChip sessionId={attachment.ref} fallbackName={attachment.name} />;-}-/** A bare `pi-desktop://session/<id>` link in prose, rendered as that chip. */export function SessionLinkChip({ sessionId, ...position }: { sessionId: string } & SourcePositionProps) {return (diff --git a/apps/desktop/test/session-reference-ui.test.mjs b/apps/desktop/test/session-reference-ui.test.mjsindex 94ceb6cb6..4a17dae02 100644--- a/apps/desktop/test/session-reference-ui.test.mjs+++ b/apps/desktop/test/session-reference-ui.test.mjs@@ -15,6 +15,7 @@ import { renderToStaticMarkup } from "react-dom/server";import ts from "typescript";import { catalogs } from "@pi-desktop/i18n";import { formatSessionLink, isRenderableAttachment } from "@pi-desktop/shared";+import { splitChatText } from "../src/lib/chat-links.ts";const here = dirname(fileURLToPath(import.meta.url));register(pathToFileURL(join(here, "helpers/ts-import-hooks.mjs")));@@ -76,7 +77,8 @@ const shared = load(new URL("../src/features/chat/transcript/shared.tsx", import},"../../../hooks/use-chat-file-menu": { useChatFileMenu: () => ({}) },"../../../hooks/use-verified-chat-text": {- useVerifiedChatText: (text) => [{ kind: "text", text: String(text ?? "") }],+ // The real segmentation, so a session link in the body reaches its chip.+ useVerifiedChatText: (text) => splitChatText(String(text ?? ""), undefined),},"../../../components/ContextMenu": { ContextMenu: () => null },"../../../components/ImageHoverCard": { ImageHoverCard: () => null },@@ -141,13 +143,13 @@ const userMessage = {};const renderChip = () =>- renderToStaticMarkup(React.createElement(shared.SessionRefChip, { attachment: referenced }));+ renderToStaticMarkup(React.createElement(shared.SessionLinkChip, { sessionId: "session-a" }));const renderRow = (message) =>renderToStaticMarkup(React.createElement(MessageRow, { message, isRunning: false }));test("a referenced conversation renders as a chip naming its own target", () => {locale = "en";- store.sessions = [];+ store.sessions = [{ id: "session-a", title: "Nightly review" }];const html = renderChip();assert.match(html, /data-action="open-session-reference"/);assert.match(html, /data-session-id="session-a"/);@@ -169,7 +171,7 @@ 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 = [];+ store.sessions = [{ id: "session-a", title: "Nightly review" }];const html = renderChip();assert.match(html, /会话引用 · Nightly review/);assert.match(html, /title="打开会话 Nightly review"/);@@ -187,30 +189,37 @@ test("a renamed conversation follows through to every message that references itstore.sessions = [{ id: "session-b", title: "另一段对话" }];assert.match(renderChip(),- /会话引用 · Nightly review/,- "an unlisted conversation keeps the name recorded on the message",+ /会话引用 · session-/,+ "an unlisted conversation falls back to the id it points at",);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",+ /会话引用 · session-/,+ "an empty title falls back to the id",);store.sessions = [];});-test("a user message shows the reference next to its own words", () => {+test("a user message shows the reference as its body chip, not a second block", () => {locale = "en";+ store.sessions = [{ id: "session-a", title: "Nightly review" }];const html = renderRow(userMessage);- assert.match(html, /class="message-attachments"/);- assert.match(html, /data-action="open-session-reference"/);- assert.match(html, /data-session-id="session-a"/);- assert.ok(- html.includes(formatSessionLink("session-a")),- "the link text stays in the message: it is what main re-resolves",+ assert.doesNotMatch(+ html,+ /class="message-attachments"/,+ "the reference needs no attachment row of its own",+ );+ assert.equal(+ html.match(/data-action="open-session-reference"/g)?.length,+ 1,+ "the message carries the reference once",);+ assert.match(html, /data-session-id="session-a"/);+ assert.match(html, /Conversation · Nightly review/);+ assert.doesNotMatch(html, /pi-desktop:\/\/session\/session-a/, "the raw link is replaced by the chip");});test("a referenced conversation is not rendered as a file chip", () => {@@ -220,9 +229,9 @@ test("a referenced conversation is not rendered as a file chip", () => {attachments: [referenced, { kind: "file", name: "notes.md", ref: "/p/notes.md" }],};const html = renderRow(withFile);- assert.match(html, /data-action="open-session-reference"/, "the reference keeps its own chip");+ assert.match(html, /data-action="open-session-reference"/, "the reference is its body chip");assert.match(html, /aria-label="notes\.md — \/p\/notes\.md"/, "an ordinary file attachment is untouched");- assert.equal(html.match(/chat-file-chip/g).length, 2, "two attachments, two chips");+ assert.equal(html.match(/chat-file-chip/g).length, 2, "the body chip and the file chip");});test("a referenced conversation never reaches the file-attachment resolver", async () => {diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.mdindex 30dc45758..3d8c01660 100644--- a/docs/spec/04-ux/08-component-spec.md+++ b/docs/spec/04-ux/08-component-spec.md@@ -4201,7 +4201,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 current title |+| Reference attached | The body link renders as a chat-icon chip named with the catalog's reference label and the referenced conversation's current title; the message shows no second block for it || Reference skipped | Nothing is attached; the body link still renders as that chip || 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 |diff --git a/docs/zh-CN/spec/04-ux/08-component-spec.md b/docs/zh-CN/spec/04-ux/08-component-spec.mdindex 873a52b0a..8b8aa343d 100644--- a/docs/zh-CN/spec/04-ux/08-component-spec.md+++ b/docs/zh-CN/spec/04-ux/08-component-spec.md@@ -2919,7 +2919,7 @@ Sidebar footer Popover (360px max)| 状态 | 外观 ||---|---|-| 已附带引用 | 用户消息上的聊天图标芯片,标签为语言目录里的引用标签加被引用对话的当前标题 |+| 已附带引用 | 正文链接渲染为聊天图标芯片,标签为语言目录里的引用标签加被引用对话的当前标题;消息不再为它单独显示第二个块 || 引用被跳过 | 不附带任何东西;正文里的链接仍渲染为该芯片 || 另一个项目 | 同样跳过:那段转写不是本轮的上下文 || 自引用 | 在任何读取之前就被丢弃,当前对话永远不会成为引用 |