Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix: 引用消息 chip 不再露出 Markdown 原文、上下文范围与内部 ID

Dash0a57c58faf5f
diff --git a/apps/desktop/src/renderer/__tests__/sentAgentReferencePresentation.test.tsx b/apps/desktop/src/renderer/__tests__/sentAgentReferencePresentation.test.tsx
index 6b39c7c608..bd19456452 100644
--- a/apps/desktop/src/renderer/__tests__/sentAgentReferencePresentation.test.tsx
+++ b/apps/desktop/src/renderer/__tests__/sentAgentReferencePresentation.test.tsx
@@ -10,7 +10,10 @@ import {
projectSentInlinePlainText,
projectSentRanges,
} from '@/components/chat/UserMessage';
-import { SentAgentReferenceChip } from '@/components/chat/SentAgentReferenceChip';
+import {
+ SentAgentReferenceChip,
+ sentAgentReferenceDisplayLabel,
+} from '@/components/chat/SentAgentReferenceChip';
import { formatQuoteForSend, parseChatQuoteSegments } from '@/lib/chatQuotes';
afterEach(cleanup);
@@ -170,4 +173,27 @@ describe('sent structured reference chips', () => {
expect(container.querySelector('[data-inline-reference-chip]')).not.toBeNull();
expect(container.querySelector('button')).toBeNull();
});
+
+ it('falls back to neutral labels instead of internal ids when text or title is missing', () => {
+ const messageLabel = sentAgentReferenceDisplayLabel({
+ kind: 'message',
+ start: 0,
+ end: 16,
+ href: 'cindy://session/session-1?message=message-1',
+ sessionId: 'session-1',
+ messageClientId: 'message-1',
+ });
+ const sessionLabel = sentAgentReferenceDisplayLabel({
+ kind: 'session',
+ start: 0,
+ end: 16,
+ href: 'cindy://session/session-1',
+ sessionId: 'session-1',
+ });
+
+ expect(messageLabel).toBeTruthy();
+ expect(messageLabel).not.toContain('message-1');
+ expect(sessionLabel).toBeTruthy();
+ expect(sessionLabel).not.toContain('session-1');
+ });
});
diff --git a/apps/desktop/src/renderer/__tests__/sentPastedTextPreview.test.ts b/apps/desktop/src/renderer/__tests__/sentPastedTextPreview.test.ts
index aae573fd55..0452d091d8 100644
--- a/apps/desktop/src/renderer/__tests__/sentPastedTextPreview.test.ts
+++ b/apps/desktop/src/renderer/__tests__/sentPastedTextPreview.test.ts
@@ -152,17 +152,6 @@ describe('UserMessage pasted-text chip wiring', () => {
expect(source.match(/handlePastedTextChipClick/g)?.length).toBe(3);
});
- it('S1b 两个调用点都拿到同一份 sessionReferences(不再有 undefined 占位)', () => {
- // 召唤卡 prompt 曾经漏传 sessionReferences(PR #966 review);该插槽现已
- // 随合并形态取消,$指令 正文并入普通正文调用点。sessionReferences 按
- // sessionId / messageClientId 匹配、不依赖文本偏移,两处理应拿同一份。
- // 展开态传 handler;收起态传 undefined,但两个调用点都保留同一份引用元数据。
- expect(source).toMatch(
- /sessionReferences,\s*\n\s*longMessageCollapsed \? undefined : handlePastedTextChipClick,/,
- );
- expect(source).toMatch(/sessionReferences,\s*\n\s*handlePastedTextChipClick,/);
- });
-
it('S2 ToolPayloadLightbox 以只读 text 模式挂载', () => {
const lightboxStart = source.indexOf('{pastedTextPreview !== null && (');
expect(lightboxStart).toBeGreaterThan(-1);
diff --git a/apps/desktop/src/renderer/components/chat/MessageStream.tsx b/apps/desktop/src/renderer/components/chat/MessageStream.tsx
index ed8bd494fb..3ccdd1027b 100644
--- a/apps/desktop/src/renderer/components/chat/MessageStream.tsx
+++ b/apps/desktop/src/renderer/components/chat/MessageStream.tsx
@@ -6715,7 +6715,6 @@ const MessageItem = memo(function MessageItem({
sharedAuthorMemberId={message.sharedAuthorMemberId}
workingDir={workingDir}
content={message.content}
- sessionReferences={message.sessionReferences}
quotesEncoded={message.quotesEncoded}
agentReferences={message.agentReferences}
pastedTextRanges={message.pastedTextRanges}
diff --git a/apps/desktop/src/renderer/components/chat/SentAgentReferenceChip.tsx b/apps/desktop/src/renderer/components/chat/SentAgentReferenceChip.tsx
index f4a897e91b..15c435caab 100644
--- a/apps/desktop/src/renderer/components/chat/SentAgentReferenceChip.tsx
+++ b/apps/desktop/src/renderer/components/chat/SentAgentReferenceChip.tsx
@@ -1,5 +1,7 @@
import { Bot, CornerDownRight, FolderOpen, Globe2, Monitor, Plug } from 'lucide-react';
+import { i18n } from '@/i18n';
+
import type { AgentInputReference } from '../../../shared/agentInputQueue';
import { InlineReferenceChip } from './InlineReferenceChip';
import { ProjectLinkChip } from './ProjectLinkChip';
@@ -15,12 +17,15 @@ function oneLine(value: string): string {
/** The compact label shared by the rich chip and collapsed-message projection. */
export function sentAgentReferenceDisplayLabel(reference: AgentInputReference): string {
if (reference.kind === 'message') {
- const text = oneLine(reference.text ?? '') || reference.messageClientId;
+ const text =
+ oneLine(reference.text ?? '') || i18n.t('chat.userMessage.messageLinkFallback');
return text.length <= MESSAGE_REFERENCE_LABEL_MAX
? text
: `${text.slice(0, MESSAGE_REFERENCE_LABEL_MAX - 1)}…`;
}
- if (reference.kind === 'session') return oneLine(reference.title ?? '') || reference.sessionId;
+ if (reference.kind === 'session') {
+ return oneLine(reference.title ?? '') || i18n.t('chat.userMessage.sessionLinkFallback');
+ }
if (reference.kind === 'project') return oneLine(reference.name) || reference.workingDir;
if (reference.kind === 'browser-tab') return oneLine(reference.title ?? '') || reference.url;
if (reference.kind === 'desktop-window') {
diff --git a/apps/desktop/src/renderer/components/chat/SentInlineAtomBody.tsx b/apps/desktop/src/renderer/components/chat/SentInlineAtomBody.tsx
index 81d39c83ad..ead982638e 100644
--- a/apps/desktop/src/renderer/components/chat/SentInlineAtomBody.tsx
+++ b/apps/desktop/src/renderer/components/chat/SentInlineAtomBody.tsx
@@ -88,7 +88,6 @@ export function SentInlineAtomBody({
localPastedRanges,
localSlashRanges,
undefined,
- undefined,
localAgentReferences,
false,
)}
diff --git a/apps/desktop/src/renderer/components/chat/SessionLinkChip.tsx b/apps/desktop/src/renderer/components/chat/SessionLinkChip.tsx
index dca0f02617..4066c61535 100644
--- a/apps/desktop/src/renderer/components/chat/SessionLinkChip.tsx
+++ b/apps/desktop/src/renderer/components/chat/SessionLinkChip.tsx
@@ -7,8 +7,8 @@
* 标题解析三级降级:
* 1. 作者显式给的 label(`[自定义文案](cindy://…)`)——作者意图优先,不查库;
* 2. 异步查本地库(sessionService.get),miss 再查 device-link 远程会话镜像;
- * 3. 都查不到 → shortSessionId 短 ID(未知 / 离线设备的会话)。
- * 查询期间先显示短 ID,拿到标题后原地刷新——chip 宽度变化是行内文本流的自然
+ * 3. 都查不到 → 中性占位文字(未知 / 离线设备的会话),不露内部 ID。
+ * 查询期间先显示占位文字,拿到标题后原地刷新——chip 宽度变化是行内文本流的自然
* 重排,不产生视觉跳变(规则 7 的"先显示已有内容再增量刷新"口径)。
*
* 样式与 UserMessage 的 @file chip 同一套 token(--chat-input-chip-*),
@@ -25,7 +25,6 @@ import { projectDraftSessionTitle } from '@cindy/maker-shared/session-title';
import { cn } from '@/lib/utils';
import { parseSessionDeepLinkHref } from '@/lib/deepLink';
import { getSessionRouteOwnerId, resolveSessionRoute } from '@/lib/orcaSessionIdentity';
-import { shortSessionId } from '@/lib/sessionId';
import { resolveSessionMessageText } from '@/lib/sessionMessageText';
import * as sessionService from '@/lib/sessionService';
import { useRemoteProjectSessions } from '@/features/device-link/remoteProjectsStore';
@@ -35,7 +34,6 @@ import {
} from '@/features/cc-agent/embeddedSessionNavigation';
import { InlineReferenceChip } from './InlineReferenceChip';
import { QuoteChip } from './QuoteChip';
-import type { PersistedSessionReferenceMetadata } from '../../../shared/sessionReferenceMetadata';
const MESSAGE_LINK_LABEL_MAX = 240;
@@ -43,8 +41,6 @@ export interface SessionLinkChipProps {
href: string;
/** 作者显式链接文案(`[label](…)`,label ≠ href 时传入);有值则不查标题。 */
label?: string;
- /** Resolved, persisted range summary for this link. */
- referenceMetadata?: PersistedSessionReferenceMetadata;
}
function compactMessageLinkLabel(text: string): string {
@@ -53,7 +49,7 @@ function compactMessageLinkLabel(text: string): string {
return `${compact.slice(0, MESSAGE_LINK_LABEL_MAX - 1)}…`;
}
-export function SessionLinkChip({ href, label, referenceMetadata }: SessionLinkChipProps) {
+export function SessionLinkChip({ href, label }: SessionLinkChipProps) {
const { t } = useTranslation();
const navigate = useNavigate();
const navigationMode = useSessionNavigationMode();
@@ -148,60 +144,31 @@ export function SessionLinkChip({ href, label, referenceMetadata }: SessionLinkC
(resolvedTitle
? projectDraftSessionTitle(resolvedTitle, t('ccAgent.common.unnamedSession'))
: null) ??
- shortSessionId(sessionId);
- const referenceDetails = referenceMetadata
- ? [
- t(
- referenceMetadata.range === 'around-anchor'
- ? 'chat.userMessage.sessionReference.aroundAnchor'
- : 'chat.userMessage.sessionReference.recent',
- ),
- t('chat.userMessage.sessionReference.messageCount', {
- count: referenceMetadata.messageCount,
- }),
- ...(referenceMetadata.truncated ? [t('chat.userMessage.sessionReference.truncated')] : []),
- ]
- : [];
- const tooltip =
- referenceDetails.length > 0 ? `${display}\n${referenceDetails.join(' · ')}` : display;
+ t('chat.userMessage.sessionLinkFallback');
if (messageClientId) {
- const fullText = messageText ?? shortSessionId(messageClientId);
+ // 原文读不到(对端离线 / 已删除 / 尚未加载)时给中性文字,不露内部 ID。
+ const fullText = messageText ?? t('chat.userMessage.messageLinkFallback');
const messageLabel = compactMessageLinkLabel(fullText);
// An explicit markdown label is the author's chosen display text, even for
// anchored links; the resolved message remains the navigation target.
- // A Markdown label is explicit author intent and must survive anchored
- // links even when no persisted reference metadata is available yet.
const visibleMessageLabel = explicitLabel ?? messageLabel;
- // 宽度上限只能加在 pill 这一侧:pill 和 summary 是同一 flex 行的两个 item,
- // 把 240px 加在外层会让两者抢同一份宽度——summary 没有 nowrap,会被压到
- // min-content(中文逐字换行)竖成一列,再把 pill 沿 stretch 拉成大椭圆。
+ // 发给模型的上下文范围(条数 / 是否截断)不在气泡里展示:用户无从理解也无从操作。
const messageContent = (
<span className="inline-flex min-w-0 max-w-[min(240px,55vw)]">
<QuoteChip quote={{ text: visibleMessageLabel }} />
</span>
);
- // summary 单行截断:窄气泡里退化成省略号,完整内容仍在 title / aria-label。
- const referenceSummary =
- referenceDetails.length > 0 ? (
- <span
- data-session-reference-summary=""
- className="ml-1 min-w-0 truncate text-11 text-[var(--text-tertiary)]"
- >
- {referenceDetails.join(' · ')}
- </span>
- ) : null;
// items-center 保证 pill 保持自身高度(不被 align-items: stretch 撑成椭圆)。
const messageClass = 'inline-flex max-w-full items-center align-middle';
if (navigationMode === 'sidebar-embedded') {
return (
<span
data-session-message-link=""
- title={tooltip}
+ title={display}
className={cn(messageClass, 'cursor-default')}
>
{messageContent}
- {referenceSummary}
</span>
);
}
@@ -210,17 +177,12 @@ export function SessionLinkChip({ href, label, referenceMetadata }: SessionLinkC
type="button"
data-session-message-link=""
data-split-pane-route-action=""
- aria-label={
- referenceDetails.length > 0
- ? `${visibleMessageLabel} (${referenceDetails.join(' · ')})`
- : visibleMessageLabel
- }
- title={tooltip}
+ aria-label={visibleMessageLabel}
+ title={display}
onClick={handleClick}
className={cn(messageClass, 'cursor-pointer')}
>
{messageContent}
- {referenceSummary}
</button>
);
}
@@ -230,7 +192,7 @@ export function SessionLinkChip({ href, label, referenceMetadata }: SessionLinkC
<InlineReferenceChip
label={display}
icon={<CornerDownRight aria-hidden />}
- tooltip={tooltip}
+ tooltip={display}
ariaLabel={display}
className="relative top-[-1px] -my-[1px] max-w-[min(240px,55vw)] cursor-default align-middle"
/>
@@ -241,7 +203,7 @@ export function SessionLinkChip({ href, label, referenceMetadata }: SessionLinkC
<InlineReferenceChip
label={display}
icon={<CornerDownRight aria-hidden />}
- tooltip={tooltip}
+ tooltip={display}
ariaLabel={display}
onClick={handleClick}
splitPaneRouteAction
diff --git a/apps/desktop/src/renderer/components/chat/UserMessage.tsx b/apps/desktop/src/renderer/components/chat/UserMessage.tsx
index acefaecd1b..f708a5549d 100644
--- a/apps/desktop/src/renderer/components/chat/UserMessage.tsx
+++ b/apps/desktop/src/renderer/components/chat/UserMessage.tsx
@@ -56,7 +56,6 @@ import { isRealAutomationOrigin } from '@/lib/messageAutomationOrigin';
import { SHARE_SOURCE_ATTR } from '@/lib/shareConversationImage';
import type { PastedTextRange, SlashCommandRange } from '@/lib/imageRef';
import type { AgentInputReference } from '../../../shared/agentInputQueue';
-import type { PersistedSessionReferenceMetadata } from '../../../shared/sessionReferenceMetadata';
import {
buildRewindDraftAttachments,
startRewindSourceProbe,
@@ -105,7 +104,7 @@ import {
import { findLinkifyMatches } from './userMessageLinkify';
import { SessionLinkChip } from './SessionLinkChip';
import { ProjectLinkChip } from './ProjectLinkChip';
-import { buildSessionMessageDeepLink, parseSessionDeepLinkHref } from '@/lib/deepLink';
+import { buildSessionMessageDeepLink } from '@/lib/deepLink';
import { getStickySessionDeviceId } from '@/features/device-link/stickySessionOrigin';
import { insertSessionLinkIntoComposer } from '@/lib/composerActionsBus';
import { MENTION_TOKEN_SPLIT, parseMentionToken } from '@/lib/mentionRefFormat';
@@ -161,8 +160,6 @@ interface UserMessageProps {
*/
allowPrivilegedLinks?: boolean;
content: string;
- /** Resolved range summaries for session links in this user message. */
- sessionReferences?: PersistedSessionReferenceMetadata[];
/** chat-text-quote:content 开头 blockquote 为引用功能产出(胶囊化渲染判据)。 */
quotesEncoded?: boolean;
/** Hidden semantic reference ranges; preserved only while visible text is unchanged. */
@@ -286,7 +283,6 @@ function renderTextWithLinks(
keyPrefix: string,
onImageClick: ((xdtFileUrl: string) => void) | undefined,
sessionId?: string,
- sessionReferences?: readonly PersistedSessionReferenceMetadata[],
interactive = true,
): React.ReactNode[] {
if (!interactive) return [text];
@@ -309,14 +305,6 @@ function renderTextWithLinks(
/>,
);
} else if (match.kind === 'session') {
- const target = parseSessionDeepLinkHref(match.href);
- const referenceMetadata = target
- ? sessionReferences?.find(
- (reference) =>
- reference.sessionId === target.sessionId &&
- (reference.messageClientId ?? null) === target.messageClientId,
- )
- : undefined;
// 会话深链 → chip(显式 label / 标题 / 短 ID),点击跳会话、带锚点定位
// 消息。`[标题](深链)` markdown 形式(输入框粘贴 chip 化的序列化产物)
// 带显式 label,SessionLinkChip 优先展示、不查库。
@@ -325,7 +313,6 @@ function renderTextWithLinks(
key={`${keyPrefix}-session-${match.index}`}
href={match.href}
label={match.label}
- referenceMetadata={referenceMetadata}
/>,
);
} else if (match.kind === 'project') {
@@ -427,7 +414,6 @@ function renderContentWithoutPastedText(
/** remote 会话:@-chip 点击跳过本机 smart resolve,按 workdir 风格直接 join。 */
remoteJoin = false,
renderLegacySlashCommands = true,
- sessionReferences?: readonly PersistedSessionReferenceMetadata[],
interactive = true,
): React.ReactNode[] {
const nodes: React.ReactNode[] = [];
@@ -472,7 +458,6 @@ function renderContentWithoutPastedText(
`${li}-${pi}`,
onImageClick,
sessionId,
- sessionReferences,
interactive,
),
);
@@ -488,7 +473,6 @@ function renderContentWithoutPastedText(
`${li}-${pi}`,
onImageClick,
sessionId,
- sessionReferences,
interactive,
),
);
@@ -582,7 +566,6 @@ function renderContentWithoutPastedText(
`${li}-${pi}`,
onImageClick,
sessionId,
- sessionReferences,
interactive,
),
);
@@ -754,7 +737,6 @@ export function renderContent(
remoteJoin = false,
pastedTextRanges: readonly PastedTextRange[] = [],
slashCommandRanges?: readonly SlashCommandRange[],
- sessionReferences?: readonly PersistedSessionReferenceMetadata[],
/**
* 粘贴段胶囊的点击入口(issue #946)。不传时胶囊退回不可交互,只剩 hover
* tooltip —— 那正是"发出去就再也看不到全文"的旧行为,新调用点都应该传。
@@ -824,7 +806,6 @@ export function renderContent(
sessionId,
remoteJoin,
useLegacySlashHeuristic,
- sessionReferences,
interactive,
)}
</span>
@@ -842,7 +823,6 @@ export function UserMessage({
workingDir,
allowPrivilegedLinks = true,
content,
- sessionReferences,
quotesEncoded,
agentReferences,
pastedTextRanges,
@@ -1629,7 +1609,6 @@ export function UserMessage({
: ghostBodySourceStart + quoteTextSegmentStarts[index]!,
segment.text.length,
),
- sessionReferences,
longMessageCollapsed ? undefined : handlePastedTextChipClick,
projectSentRanges(
validAgentReferences,
@@ -1670,7 +1649,6 @@ export function UserMessage({
displayBubbleSourceStart,
displayBubbleBody.length,
),
- sessionReferences,
undefined,
bubbleAgentReferences,
false,
@@ -1703,7 +1681,6 @@ export function UserMessage({
displayBubbleSourceStart,
displayBubbleBody.length,
),
- sessionReferences,
handlePastedTextChipClick,
bubbleAgentReferences,
)}
diff --git a/apps/desktop/src/renderer/components/chat/__tests__/embeddedSessionNavigation.test.tsx b/apps/desktop/src/renderer/components/chat/__tests__/embeddedSessionNavigation.test.tsx
index 6835dad336..6c07a2f0af 100644
--- a/apps/desktop/src/renderer/components/chat/__tests__/embeddedSessionNavigation.test.tsx
+++ b/apps/desktop/src/renderer/components/chat/__tests__/embeddedSessionNavigation.test.tsx
@@ -190,64 +190,21 @@ describe('sidebar-embedded session navigation boundary', () => {
expect(mocks.navigate).not.toHaveBeenCalled();
});
- it('shows the persisted reference range summary without changing the link label', async () => {
- render(
- embedded(
- <SessionLinkChip
- href="cindy://session/session-a?message=message-1"
- label="Session A"
- referenceMetadata={{
- sessionId: 'session-a',
- messageClientId: 'message-1',
- range: 'around-anchor',
- messageCount: 7,
- truncated: true,
- }}
- />,
- ),
- );
- await act(async () => {
- await Promise.resolve();
- });
-
- expect(screen.getByText('Session A')).toBeTruthy();
- expect(
- screen.getByText(
- 'chat.userMessage.sessionReference.aroundAnchor · chat.userMessage.sessionReference.messageCount · chat.userMessage.sessionReference.truncated',
- ),
- ).toBeTruthy();
- });
-
- it('keeps the anchored pill and its range summary on a single line', async () => {
+ it('keeps the anchored pill on a single line without a context range summary', async () => {
const { container } = render(
- <SessionLinkChip
- href="cindy://session/session-a?message=message-1"
- label="Session A"
- referenceMetadata={{
- sessionId: 'session-a',
- messageClientId: 'message-1',
- range: 'around-anchor',
- messageCount: 11,
- truncated: true,
- }}
- />,
+ <SessionLinkChip href="cindy://session/session-a?message=message-1" label="Session A" />,
);
await act(async () => {
await Promise.resolve();
});
- // 宽度上限必须留在 pill 一侧:加回外层会让 pill 与 summary 抢同一份 240px,
- // summary 被压成逐字竖排、pill 被 stretch 拉成大椭圆。
+ expect(screen.getByText('Session A')).toBeTruthy();
const link = container.querySelector('button[data-session-message-link]');
expect(link?.className).toContain('items-center');
- expect(link?.className).not.toContain('max-w-[min(240px,55vw)]');
+ expect(link?.textContent).toBe('Session A');
expect(
container.querySelector('[data-inline-reference-chip]')?.parentElement?.className,
).toContain('max-w-[min(240px,55vw)]');
- // summary 单行截断,不参与换行。
- expect(container.querySelector('[data-session-reference-summary]')?.className).toContain(
- 'truncate',
- );
});
it('renders handoff cards as static content without resolving or navigating', () => {
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 2dd8868d26..eb5e31523d 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -10765,13 +10765,8 @@
},
"expandLongMessage": "Show full message",
"collapseLongMessage": "Collapse",
- "sessionReference": {
- "recent": "Recent",
- "aroundAnchor": "Around linked message",
- "messageCount_one": "{{count}} message",
- "messageCount_other": "{{count}} messages",
- "truncated": "truncated"
- },
+ "sessionLinkFallback": "A session",
+ "messageLinkFallback": "Quoted message",
"forkBusy": "Wait for the current response to finish before starting a new session from here",
"editStopTimeout": "Timed out waiting for the task to stop — please try again",
"editQueueNotEmpty": "This session has queued messages — send or remove them before editing",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index 0b1f0b839e..b04e2dfcb0 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -10742,13 +10742,8 @@
},
"expandLongMessage": "全文を表示",
"collapseLongMessage": "折りたたむ",
- "sessionReference": {
- "recent": "最近のメッセージ",
- "aroundAnchor": "リンクしたメッセージの前後",
- "messageCount_one": "{{count}} 件のメッセージ",
- "messageCount_other": "{{count}} 件のメッセージ",
- "truncated": "一部省略"
- },
+ "sessionLinkFallback": "セッション",
+ "messageLinkFallback": "引用したメッセージ",
"forkBusy": "現在の応答が終了してから、ここから新しいセッションを始めてください",
"editStopTimeout": "タスクの停止待ちがタイムアウトしました。もう一度お試しください",
"editQueueNotEmpty": "このセッションには送信待ちのメッセージがあります。先に送信または削除してから編集してください",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 9550500fb8..d906e9b663 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -10742,13 +10742,8 @@
},
"expandLongMessage": "전체 메시지 보기",
"collapseLongMessage": "접기",
- "sessionReference": {
- "recent": "최근 메시지",
- "aroundAnchor": "링크된 메시지 주변",
- "messageCount_one": "메시지 {{count}}개",
- "messageCount_other": "메시지 {{count}}개",
- "truncated": "일부 생략"
- },
+ "sessionLinkFallback": "세션",
+ "messageLinkFallback": "인용한 메시지",
"forkBusy": "현재 응답이 종료된 후 여기서 새 세션을 시작해 주세요",
"editStopTimeout": "작업 중지 대기 시간이 초과되었습니다. 다시 시도하세요",
"editQueueNotEmpty": "이 세션에 대기 중인 메시지가 있습니다. 먼저 전송하거나 제거한 후 편집하세요",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index 27cc4d0ac4..bec8b726fc 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -10742,13 +10742,8 @@
},
"expandLongMessage": "展开全文",
"collapseLongMessage": "收起",
- "sessionReference": {
- "recent": "最近消息",
- "aroundAnchor": "链接消息附近",
- "messageCount_one": "{{count}} 条消息",
- "messageCount_other": "{{count}} 条消息",
- "truncated": "已截断"
- },
+ "sessionLinkFallback": "某个任务",
+ "messageLinkFallback": "引用的消息",
"forkBusy": "当前任务正在运行,等结束后再从这里开启新任务",
"editStopTimeout": "等待任务停止超时,请稍后重试",
"editQueueNotEmpty": "任务有排队中的消息,先发送或移除队列内容后再编辑",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
index 07ab088c17..a03131b00f 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -10741,13 +10741,8 @@
},
"expandLongMessage": "展開全文",
"collapseLongMessage": "收起",
- "sessionReference": {
- "recent": "最近訊息",
- "aroundAnchor": "連結訊息附近",
- "messageCount_one": "{{count}} 條訊息",
- "messageCount_other": "{{count}} 條訊息",
- "truncated": "已截斷"
- },
+ "sessionLinkFallback": "某個任務",
+ "messageLinkFallback": "引用的訊息",
"forkBusy": "當前任務正在執行,等結束後再從這裡開啟新任務",
"editStopTimeout": "等待任務停止超時,請稍後重試",
"editQueueNotEmpty": "任務有排隊中的訊息,先傳送或移除佇列內容後再編輯",
diff --git a/apps/mobile/src/__tests__/selectableMarkdownHtml.test.ts b/apps/mobile/src/__tests__/selectableMarkdownHtml.test.ts
index 18264f1d2f..2d559f5da9 100644
--- a/apps/mobile/src/__tests__/selectableMarkdownHtml.test.ts
+++ b/apps/mobile/src/__tests__/selectableMarkdownHtml.test.ts
@@ -183,6 +183,13 @@ describe('buildSelectableMarkdownHtml 本地路径不出死链', () => {
expect(html).not.toContain('cindy://session/abc123');
expect(html).not.toMatch(/<a[^>]*xdt-session-chip/);
});
+
+ it('查不到标题的会话深链显示中性文字,不露内部任务 ID', () => {
+ const html = buildSelectableMarkdownHtml('cindy://session/03e0c22d-19db-4ac5-814f-1ea04040b471');
+ expect(html).toContain('xdt-session-chip');
+ expect(html).not.toContain('03e0c22d');
+ expect(html).not.toContain('b471');
+ });
});
describe('阅读器里「有下划线 = 可点」不得出现反例(DESIGN.md §14.5 规则 1)', () => {
diff --git a/apps/mobile/src/__tests__/sessionMessageText.test.ts b/apps/mobile/src/__tests__/sessionMessageText.test.ts
index 80f113c5a5..1f056821a5 100644
--- a/apps/mobile/src/__tests__/sessionMessageText.test.ts
+++ b/apps/mobile/src/__tests__/sessionMessageText.test.ts
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest';
import { formatQuoteForSend } from '@cindy/maker-shared/chat-quotes';
import {
+ compactSessionMessageLabel,
mobileSessionMessageDisplayText,
splitAnchoredSessionMessageLinks,
} from '@/session/sessionMessageText';
@@ -24,6 +25,16 @@ describe('mobile session message labels', () => {
expect(mobileSessionMessageDisplayText(message({ role: 'tool_use', content: { secret: true } }))).toBeNull();
});
+ it('shows anchored message labels as short plain text instead of raw Markdown', () => {
+ const label = compactSessionMessageLabel(
+ '**1. 深色·打开过程**:第一帧\n\n![深色-打开过程](cindy-media://blobs/0b12b71b6dcbf531eb89a2ed3b9ba7b1)',
+ );
+ expect(label).toBe('1. 深色·打开过程:第一帧 深色-打开过程');
+ expect(compactSessionMessageLabel('上次我用的是 Claude Code 自带的 `SendUserFile` 发文件,工具返回了已送达'))
+ .toBe('上次我用的是 Claude Code 自带的…');
+ expect(Array.from(compactSessionMessageLabel('😀'.repeat(40)))).toHaveLength(24);
+ });
+
it('splits message anchors while preserving adjacent punctuation and whole-session links', () => {
expect(splitAnchoredSessionMessageLinks(
'See cindy://session/s-1?message=m-2, then cindy://session/s-3.',
diff --git a/apps/mobile/src/__tests__/sessionReferences.test.ts b/apps/mobile/src/__tests__/sessionReferences.test.ts
index 3b5fc9b6ac..4812263298 100644
--- a/apps/mobile/src/__tests__/sessionReferences.test.ts
+++ b/apps/mobile/src/__tests__/sessionReferences.test.ts
@@ -9,7 +9,6 @@ import type { RemoteInvoke } from '@/device-link/mobileMakerTransport';
import {
estimateMobileReferenceTokens,
extractMobileSessionReferences,
- formatMobileSessionReferenceMetadata,
MAX_MOBILE_REFERENCE_MESSAGES,
MobileSessionReferenceError,
canFallbackToStoredMobileSessionReferenceSnapshot,
@@ -175,16 +174,6 @@ describe('mobile session-reference links', () => {
expect(invoke).not.toHaveBeenCalled();
});
- it('formats the persisted range summary without referenced message bodies', () => {
- expect(formatMobileSessionReferenceMetadata({
- sessionId: 'source',
- messageClientId: 'anchor',
- range: 'around-anchor',
- messageCount: 4,
- truncated: true,
- })).toBe('链接附近 · 4 条 · 已截断');
- });
-
it('falls back to raw link text when the target does not support references', async () => {
const invoke = vi.fn(async (deviceId: string, channel: string) => {
expect(deviceId).toBe('target-old');
diff --git a/apps/mobile/src/i18n/locales/en/message.json b/apps/mobile/src/i18n/locales/en/message.json
index 0b66fbb3b0..3fdc56c907 100644
--- a/apps/mobile/src/i18n/locales/en/message.json
+++ b/apps/mobile/src/i18n/locales/en/message.json
@@ -104,7 +104,8 @@
"handoffContentDesc": "Handoff — context summary sent to the new engine when switching (not part of the chat transcript; shown only here)",
"handoffContentDescEnglishSource": "Handoff — context summary sent to the new engine when switching (not part of the chat transcript; shown only here)",
"openDiagramDetail": "Open diagram detail",
- "sessionChipFallback": "Session {{id}}",
+ "sessionChipFallback": "A session",
+ "messageChipFallback": "Quoted message",
"imageFallbackTitle": "Image",
"mermaidExportFailedTitle": "Export failed",
"mermaidRenderIncompleteBody": "The diagram isn't fully rendered yet or the export failed. Try again later.",
diff --git a/apps/mobile/src/i18n/locales/en/session.json b/apps/mobile/src/i18n/locales/en/session.json
index a2707176f1..b07d430a14 100644
--- a/apps/mobile/src/i18n/locales/en/session.json
+++ b/apps/mobile/src/i18n/locales/en/session.json
@@ -530,10 +530,6 @@
"moreOptions": "More options",
"archiveConversation": "Archive session",
"closeActionMenu": "Close session actions menu",
- "referenceAroundAnchor": "Around the link",
- "referenceRecent": "Recent messages",
- "referenceCount": "{{num}} messages",
- "referenceTruncated": "Truncated",
"pinnedSection": "Pinned",
"extraDirsSummary": "{{num}} additional directories",
"noExtraDirsSummary": "No additional directories",
diff --git a/apps/mobile/src/i18n/locales/ja/message.json b/apps/mobile/src/i18n/locales/ja/message.json
index 82cd310872..fa69bd9d69 100644
--- a/apps/mobile/src/i18n/locales/ja/message.json
+++ b/apps/mobile/src/i18n/locales/ja/message.json
@@ -104,7 +104,8 @@
"handoffContentDesc": "引き継ぎ内容——切り替え時に新しいエンジンへ送るコンテキスト要約(チャット履歴には含まれず、ここでのみ表示)",
"handoffContentDescEnglishSource": "引き継ぎ内容——切り替え時に新しいエンジンへ送るコンテキスト要約。原文は英語(チャット履歴には含まれず、ここでのみ表示)",
"openDiagramDetail": "図の詳細を開く",
- "sessionChipFallback": "セッション {{id}}",
+ "sessionChipFallback": "セッション",
+ "messageChipFallback": "引用したメッセージ",
"imageFallbackTitle": "画像",
"mermaidExportFailedTitle": "エクスポート失敗",
"mermaidRenderIncompleteBody": "図の描画がまだ完了していないか、エクスポートに失敗しました。後でもう一度お試しください。",
diff --git a/apps/mobile/src/i18n/locales/ja/session.json b/apps/mobile/src/i18n/locales/ja/session.json
index bcdab9d524..3dc59d80cf 100644
--- a/apps/mobile/src/i18n/locales/ja/session.json
+++ b/apps/mobile/src/i18n/locales/ja/session.json
@@ -530,10 +530,6 @@
"moreOptions": "その他のオプション",
"archiveConversation": "セッションをアーカイブ",
"closeActionMenu": "セッション操作メニューを閉じる",
- "referenceAroundAnchor": "リンク付近",
- "referenceRecent": "最近のメッセージ",
- "referenceCount": "{{num}} 件",
- "referenceTruncated": "切り詰め済み",
"pinnedSection": "ピン留め",
"extraDirsSummary": "追加ディレクトリ {{num}} 件",
"noExtraDirsSummary": "追加ディレクトリはありません",
diff --git a/apps/mobile/src/i18n/locales/ko/message.json b/apps/mobile/src/i18n/locales/ko/message.json
index 2e4e1ab189..e3d25befb1 100644
--- a/apps/mobile/src/i18n/locales/ko/message.json
+++ b/apps/mobile/src/i18n/locales/ko/message.json
@@ -104,7 +104,8 @@
"handoffContentDesc": "인계 내용——전환 시 새 엔진에 전달되는 컨텍스트 요약(대화 기록에 포함되지 않으며 여기에서만 표시)",
"handoffContentDescEnglishSource": "인계 내용——전환 시 새 엔진에 전달되는 컨텍스트 요약. 원문은 영어(대화 기록에 포함되지 않으며 여기에서만 표시)",
"openDiagramDetail": "다이어그램 세부 정보 열기",
- "sessionChipFallback": "세션 {{id}}",
+ "sessionChipFallback": "세션",
+ "messageChipFallback": "인용한 메시지",
"imageFallbackTitle": "이미지",
"mermaidExportFailedTitle": "내보내기 실패",
"mermaidRenderIncompleteBody": "다이어그램이 아직 완전히 렌더링되지 않았거나 내보내기에 실패했습니다. 나중에 다시 시도하세요.",
diff --git a/apps/mobile/src/i18n/locales/ko/session.json b/apps/mobile/src/i18n/locales/ko/session.json
index bfb12726ab..96ee51d5e6 100644
--- a/apps/mobile/src/i18n/locales/ko/session.json
+++ b/apps/mobile/src/i18n/locales/ko/session.json
@@ -526,10 +526,6 @@
"moreOptions": "기타 옵션",
"archiveConversation": "세션 보관",
"closeActionMenu": "세션 작업 메뉴 닫기",
- "referenceAroundAnchor": "링크 부근",
- "referenceRecent": "최근 메시지",
- "referenceCount": "{{num}}건",
- "referenceTruncated": "잘림",
"pinnedSection": "고정됨",
"extraDirsSummary": "추가 디렉터리 {{num}}개",
"noExtraDirsSummary": "추가 디렉터리 없음",
diff --git a/apps/mobile/src/i18n/locales/zh-CN/message.json b/apps/mobile/src/i18n/locales/zh-CN/message.json
index 7d7df206f8..c166f59bb4 100644
--- a/apps/mobile/src/i18n/locales/zh-CN/message.json
+++ b/apps/mobile/src/i18n/locales/zh-CN/message.json
@@ -104,7 +104,8 @@
"handoffContentDesc": "交接内容——切换时发送给新引擎的上下文摘要(不计入对话记录,仅在此展示)",
"handoffContentDescEnglishSource": "交接内容——切换时发送给新引擎的上下文摘要,原文为英文(不计入对话记录,仅在此展示)",
"openDiagramDetail": "打开图表详情",
- "sessionChipFallback": "任务 {{id}}",
+ "sessionChipFallback": "某个任务",
+ "messageChipFallback": "引用的消息",
"imageFallbackTitle": "图片",
"mermaidExportFailedTitle": "导出失败",
"mermaidRenderIncompleteBody": "图表尚未渲染完成或导出出错,请稍后重试。",
diff --git a/apps/mobile/src/i18n/locales/zh-CN/session.json b/apps/mobile/src/i18n/locales/zh-CN/session.json
index cbf1525edb..3fcee1a986 100644
--- a/apps/mobile/src/i18n/locales/zh-CN/session.json
+++ b/apps/mobile/src/i18n/locales/zh-CN/session.json
@@ -526,10 +526,6 @@
"moreOptions": "更多选项",
"archiveConversation": "归档任务",
"closeActionMenu": "关闭任务操作菜单",
- "referenceAroundAnchor": "链接附近",
- "referenceRecent": "最近消息",
- "referenceCount": "{{num}} 条",
- "referenceTruncated": "已截断",
"pinnedSection": "置顶",
"extraDirsSummary": "当前 {{num}} 个附加目录",
"noExtraDirsSummary": "当前没有附加目录",
diff --git a/apps/mobile/src/i18n/locales/zh-TW/message.json b/apps/mobile/src/i18n/locales/zh-TW/message.json
index 1ed97cb059..dc41c667eb 100644
--- a/apps/mobile/src/i18n/locales/zh-TW/message.json
+++ b/apps/mobile/src/i18n/locales/zh-TW/message.json
@@ -104,7 +104,8 @@
"handoffContentDesc": "交接內容——切換時傳送給新引擎的上下文摘要(不計入對話記錄,僅在此展示)",
"handoffContentDescEnglishSource": "交接內容——切換時傳送給新引擎的上下文摘要,原文為英文(不計入對話記錄,僅在此展示)",
"openDiagramDetail": "開啟圖表詳情",
- "sessionChipFallback": "任務 {{id}}",
+ "sessionChipFallback": "某個任務",
+ "messageChipFallback": "引用的訊息",
"imageFallbackTitle": "圖片",
"mermaidExportFailedTitle": "匯出失敗",
"mermaidRenderIncompleteBody": "圖表尚未渲染完成或匯出出錯,請稍後重試。",
diff --git a/apps/mobile/src/i18n/locales/zh-TW/session.json b/apps/mobile/src/i18n/locales/zh-TW/session.json
index d1d2bb0a3b..8ee4ad4062 100644
--- a/apps/mobile/src/i18n/locales/zh-TW/session.json
+++ b/apps/mobile/src/i18n/locales/zh-TW/session.json
@@ -530,10 +530,6 @@
"moreOptions": "更多選項",
"archiveConversation": "歸檔任務",
"closeActionMenu": "關閉任務操作選單",
- "referenceAroundAnchor": "連結附近",
- "referenceRecent": "最近訊息",
- "referenceCount": "{{num}} 條",
- "referenceTruncated": "已截斷",
"pinnedSection": "置頂",
"extraDirsSummary": "當前 {{num}} 個附加目錄",
"noExtraDirsSummary": "當前沒有附加目錄",
diff --git a/apps/mobile/src/session/MessageRenderer.tsx b/apps/mobile/src/session/MessageRenderer.tsx
index bcff88a557..203efd418a 100644
--- a/apps/mobile/src/session/MessageRenderer.tsx
+++ b/apps/mobile/src/session/MessageRenderer.tsx
@@ -229,14 +229,8 @@ import {
parseProjectDeepLinkUrl,
parseSessionDeepLinkUrl,
projectDisplayName,
- shortSessionId,
type SessionDeepLinkTarget,
} from '@/session/sessionLinks';
-import {
- formatMobileSessionReferenceMetadata,
- mobileSessionReferenceMetadataKey,
- type MobilePersistedSessionReferenceMetadata,
-} from '@/session/sessionReferences';
import {
canOpenChatPathChip,
chatPathLabelReadsAsFileReference,
@@ -3797,7 +3791,6 @@ function MessageBubble({
onOpenSessionLink={actions.onOpenSessionLink}
pinContentWidth={!isUser}
selectable={canSelectVisibleText}
- sessionReferences={item.message.sessionReferences}
streaming={false}
text={text}
/>
@@ -3813,7 +3806,6 @@ function MessageBubble({
onOpenPayload={actions.onOpenPayload}
onOpenSessionLink={actions.onOpenSessionLink}
pinContentWidth={!isUser}
- sessionReferences={item.message.sessionReferences}
selectable={canSelectVisibleText}
streaming={isStreamingAssistant}
text={bubbleBody}
@@ -5596,7 +5588,6 @@ function MarkdownBody({
onOpenPayload,
onOpenSessionLink,
pinContentWidth = false,
- sessionReferences,
selectable,
streaming,
text,
@@ -5614,8 +5605,6 @@ function MarkdownBody({
* 气泡(长代码围栏横向裁切 + 纵向巨高空白)。
*/
pinContentWidth?: boolean;
- /** 当前落库消息里的展示安全引用摘要,按 sessionId + anchor 精确匹配链接。 */
- sessionReferences?: readonly MobilePersistedSessionReferenceMetadata[];
/** 完成态消息为 true:各块 Text 开原生选中(含内嵌图片 View 的块除外,Android 上有风险)。 */
selectable?: boolean;
/** 消息流式中:文件 chip 层跳过远端验证。 */
@@ -5731,15 +5720,6 @@ function MarkdownBody({
// changes; referenced task title changes still refresh every affected chip.
const remoteSessions = useRemoteSessions();
const sessionLinkTitles = useMarkdownSessionLinkTitles(text, remoteSessions);
- const sessionReferenceDetails = useMemo(() => {
- if (!sessionReferences?.length) return undefined;
- const details: Record<string, string> = {};
- for (const metadata of sessionReferences) {
- details[mobileSessionReferenceMetadataKey(metadata.sessionId, metadata.messageClientId)] =
- formatMobileSessionReferenceMetadata(metadata);
- }
- return details;
- }, [sessionReferences]);
const renderInlines = useCallback(
(
inlines: readonly MobileMarkdownInline[],
@@ -5754,7 +5734,6 @@ function MarkdownBody({
renderManagedImage,
onOpenMedia: openMarkdownMedia,
onOpenSessionLink,
- sessionReferenceDetails,
sessionLinkTitles,
SpanText,
streaming,
@@ -5762,7 +5741,7 @@ function MarkdownBody({
),
// renderInline also reads translated fallback labels. Invalidate completed
// memoized text blocks when useTranslation refreshes its bound translator.
- [onOpenSessionLink, openMarkdownImage, openMarkdownMedia, renderManagedImage, sessionLinkTitles, sessionReferenceDetails, streaming, styles, t],
+ [onOpenSessionLink, openMarkdownImage, openMarkdownMedia, renderManagedImage, sessionLinkTitles, streaming, styles, t],
);
const textRunGroupingOptions = useMemo(() => ({
...(Platform.OS === 'android' ? ANDROID_SELECTABLE_TEXT_RUN_GROUPING_OPTIONS : {}),
@@ -6308,7 +6287,6 @@ function renderInline(
onOpenMedia?: (url: string, title: string, kind: 'video') => void;
onOpenPayload?: (payload: MessagePayload) => void;
onOpenSessionLink?: (url: string) => void;
- sessionReferenceDetails?: Readonly<Record<string, string>>;
sessionLinkTitles?: Readonly<Record<string, string>>;
/** 块可选中且 iOS 时为 MarkdownSelectableSpan(嵌套进 UITextView 原生树);缺省 RN Text。 */
SpanText?: typeof Text;
@@ -6362,7 +6340,6 @@ function renderInline(
key={spanKey(`session-link:${index}:${inline.url}`)}
onOpenSessionLink={ctx.onOpenSessionLink}
session={session}
- sessionReferenceDetails={ctx.sessionReferenceDetails}
sessionLinkTitles={ctx.sessionLinkTitles}
SpanText={SpanText}
styles={styles}
@@ -6500,7 +6477,6 @@ function MarkdownSessionLinkSpan({
inline,
onOpenSessionLink,
session,
- sessionReferenceDetails,
sessionLinkTitles,
SpanText,
styles,
@@ -6509,7 +6485,6 @@ function MarkdownSessionLinkSpan({
inline: Extract<MobileMarkdownInline, { type: 'link' }>;
onOpenSessionLink?: (url: string) => void;
session: SessionDeepLinkTarget;
- sessionReferenceDetails?: Readonly<Record<string, string>>;
sessionLinkTitles?: Readonly<Record<string, string>>;
SpanText: typeof Text;
styles: ReturnType<typeof makeStyles>;
@@ -6524,22 +6499,20 @@ function MarkdownSessionLinkSpan({
: null;
const messageLabel = targetMessage ? mobileSessionMessageDisplayText(targetMessage) : null;
const title = session.messageClientId
- ? compactSessionMessageLabel(messageLabel ?? shortSessionId(session.messageClientId))
+ ? (messageLabel ? compactSessionMessageLabel(messageLabel) : i18n.t('message.renderer.messageChipFallback'))
: explicit
?? sessionLinkTitles?.[session.sessionId]
- ?? i18n.t('message.renderer.sessionChipFallback', { id: shortSessionId(session.sessionId) });
- const detail = sessionReferenceDetails?.[
- mobileSessionReferenceMetadataKey(session.sessionId, session.messageClientId)
- ];
+ ?? i18n.t('message.renderer.sessionChipFallback');
// handler 由上层可选注入 → 缺席时 chip 不可点,下划线也必须跟着不加
// (clickableInlineStyle 保证两者同源)。
const openSessionLink = onOpenSessionLink ? () => onOpenSessionLink(inline.url) : undefined;
+ // 发给模型的上下文范围(条数 / 是否截断)不在气泡里展示:用户无从理解也无从操作。
return (
<SpanText
onPress={openSessionLink}
style={clickableInlineStyle(styles, openSessionLink, baseStyle, styles.sessionLinkChipText)}
>
- {`${session.messageClientId ? '❝' : '↳'} ${title}${detail ? ` · ${detail}` : ''}`}
+ {`${session.messageClientId ? '❝' : '↳'} ${title}`}
</SpanText>
);
}
diff --git a/apps/mobile/src/session/selectableMarkdownHtml.ts b/apps/mobile/src/session/selectableMarkdownHtml.ts
index 59666f2d73..2497658299 100644
--- a/apps/mobile/src/session/selectableMarkdownHtml.ts
+++ b/apps/mobile/src/session/selectableMarkdownHtml.ts
@@ -6,7 +6,7 @@ import {
type MobileMarkdownInlineMark,
} from '@/session/messageMarkdown';
import { tokenizeCode } from '@/session/codeHighlight';
-import { parseSessionDeepLinkUrl, shortSessionId } from '@/session/sessionLinks';
+import { parseSessionDeepLinkUrl } from '@/session/sessionLinks';
import { buildKatexLoaderJs } from '@/session/mathWebViewHtml';
import { repairMermaidSource } from '@cindy/maker-shared/mermaid-autofix';
// lineHeight 取别名:本模块内 `lineHeight` 是正文行高的局部变量(来自 options)。
@@ -536,7 +536,7 @@ function renderInline(inline: MobileMarkdownInline, ctx: RenderContext = {}): st
const title =
explicit ??
ctx.sessionLinkTitles?.[session.sessionId] ??
- i18n.t('message.renderer.sessionChipFallback', { id: shortSessionId(session.sessionId) });
+ i18n.t('message.renderer.sessionChipFallback');
return `<span class="xdt-session-chip">›&nbsp;${escapeHtml(title)}</span>`;
}
// 本地路径(`[README.md](/abs/README.md:17)` 与正文裸写的路径)、mailto 等:
diff --git a/apps/mobile/src/session/sessionMessageText.ts b/apps/mobile/src/session/sessionMessageText.ts
index d70ee08cb4..4f227a94d3 100644
--- a/apps/mobile/src/session/sessionMessageText.ts
+++ b/apps/mobile/src/session/sessionMessageText.ts
@@ -1,4 +1,5 @@
import { joinChatQuoteTextSegments, parseChatQuoteSegments } from '@cindy/maker-shared/chat-quotes';
+import { parseMobileMarkdown, type MobileMarkdownInline } from '@/session/messageMarkdown';
import { normalizeRemoteMessages } from '@/session/messageNormalize';
import {
createSessionLinkPattern,
@@ -7,7 +8,9 @@ import {
} from '@/session/sessionLinks';
import type { RemoteMessage } from '@/session/types';
-const MESSAGE_LABEL_MAX_CHARS = 240;
+// 手机端消息锚点 chip 是正文里的行内 span,没法像桌面 pill 那样按宽度单行省略;
+// 按字数截到约一行气泡宽,完整正文仍可点进目标消息查看。
+const MESSAGE_LABEL_MAX_CHARS = 24;
/** Readable text only; never stringify tool/SDK metadata into a reference chip. */
export function mobileSessionMessageDisplayText(message: RemoteMessage): string | null {
@@ -27,10 +30,26 @@ export function mobileSessionMessageDisplayText(message: RemoteMessage): string
return text || null;
}
+function inlinesPlainText(inlines: readonly MobileMarkdownInline[]): string {
+ return inlines.map((inline) => (inline.type === 'image' ? inline.alt : inline.text)).join('');
+}
+
+/** 被引用消息常是带图片 / 强调的 Markdown;chip 只显示读得懂的单行摘要,不露 `**`、`![](…)`。 */
+function markdownPlainText(text: string): string {
+ return parseMobileMarkdown(text).map((block) => {
+ if (block.type === 'table') {
+ return [block.header, ...block.rows.map((row) => row.cells)]
+ .map((cells) => cells.map(inlinesPlainText).join(' ')).join(' ');
+ }
+ return 'inlines' in block ? inlinesPlainText(block.inlines) : block.text;
+ }).join(' ');
+}
+
export function compactSessionMessageLabel(text: string): string {
- const compact = text.replace(/\s+/g, ' ').trim();
- if (compact.length <= MESSAGE_LABEL_MAX_CHARS) return compact;
- return `${compact.slice(0, MESSAGE_LABEL_MAX_CHARS - 1)}…`;
+ const compact = markdownPlainText(text).replace(/\s+/g, ' ').trim() || text.replace(/\s+/g, ' ').trim();
+ const chars = Array.from(compact);
+ if (chars.length <= MESSAGE_LABEL_MAX_CHARS) return compact;
+ return `${chars.slice(0, MESSAGE_LABEL_MAX_CHARS - 1).join('').trimEnd()}…`;
}
export type AnchoredSessionMessageTextPart =
diff --git a/apps/mobile/src/session/sessionReferences.ts b/apps/mobile/src/session/sessionReferences.ts
index 24e1c3b037..c39c5fe948 100644
--- a/apps/mobile/src/session/sessionReferences.ts
+++ b/apps/mobile/src/session/sessionReferences.ts
@@ -2,7 +2,6 @@ import {
DL_HISTORY_MESSAGES_CHANNEL,
DL_SESSION_REFERENCE_CAPABILITY_CHANNEL,
} from '@cindy/device-link';
-import { i18n } from '@/i18n';
import type { RemoteInvoke } from '@/device-link/mobileMakerTransport';
import {
createSessionLinkPattern,
@@ -131,19 +130,6 @@ export function mobileSessionReferenceMetadataKey(
return `${sessionId}\u0000${messageClientId ?? ''}`;
}
-/** 格式化展示安全的范围摘要(文案经 i18n 本地化)。 */
-export function formatMobileSessionReferenceMetadata(
- metadata: MobilePersistedSessionReferenceMetadata,
-): string {
- return [
- metadata.range === 'around-anchor'
- ? i18n.t('session.row.referenceAroundAnchor')
- : i18n.t('session.row.referenceRecent'),
- i18n.t('session.row.referenceCount', { num: metadata.messageCount }),
- ...(metadata.truncated ? [i18n.t('session.row.referenceTruncated')] : []),
- ].join(' · ');
-}
-
/** Extract visible session links and bind each one to the mobile store's source device. */
export function extractMobileSessionReferences(
text: string,