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(chat): 文件失效后保留显式链接入口

Dash3d2e598d8e04
diff --git a/apps/desktop/scripts/fixtures/explicit-file-links/fixture.tsx b/apps/desktop/scripts/fixtures/explicit-file-links/fixture.tsx
new file mode 100644
index 0000000000..9ccf28782f
--- /dev/null
+++ b/apps/desktop/scripts/fixtures/explicit-file-links/fixture.tsx
@@ -0,0 +1,34 @@
+import { mountPage, forbid } from '../../ui-page/harness';
+import { MarkdownRenderer } from '../../../src/renderer/components/chat/MarkdownRenderer';
+import { ChatSessionFileProvider } from '../../../src/renderer/components/chat/ChatSessionFileContext';
+import { ToastContainer } from '../../../src/renderer/components/ui/toast/ToastContainer';
+
+// Exercise the real Markdown/render/click chain; only filesystem responses are
+// simulated. Restoring a file must work even with a cached negative result.
+let restored = false;
+const content = '[查看报告](/fixture/report.html)\n\n[下载 PDF](/fixture/report.pdf)\n\n自动识别:/fixture/missing.txt\n\n行内代码:`/fixture/missing.txt`';
+
+mountPage({
+ route: '/sessions/fixture',
+ host: ctx => ({
+ resolvePath: ctx.case === 'remote' ? forbid('resolvePath on remote file') : async ({ href }: { href: string }) => ({
+ status: restored && href.endsWith('.pdf') ? 'unique' : 'none',
+ candidates: restored && href.endsWith('.pdf') ? [href] : [],
+ kind: 'file',
+ }),
+ openPath: async (path: string) => {
+ document.documentElement.dataset.openedFile = path;
+ return { success: true };
+ },
+ fileBrowser: {
+ chatStat: async () => ({ verdict: 'nonfile' }),
+ },
+ }),
+ render: ctx => <main style={{ padding: '120px 24px 24px', maxWidth: 560, margin: '0 auto' }}>
+ <ChatSessionFileProvider value={{ sessionId: undefined, workingDir: '/fixture', origin: ctx.case === 'remote' ? { kind: 'device', deviceId: 'fixture-device' } : { kind: 'local' } }}>
+ <MarkdownRenderer content={content} workingDir="/fixture" allowPrivilegedLinks={ctx.case !== 'untrusted'} />
+ </ChatSessionFileProvider>
+ <button data-testid="restore-file" onClick={() => { restored = true; }}>恢复测试文件</button>
+ <ToastContainer />
+ </main>,
+});
diff --git a/apps/desktop/scripts/fixtures/explicit-file-links/ui-page.mjs b/apps/desktop/scripts/fixtures/explicit-file-links/ui-page.mjs
new file mode 100644
index 0000000000..6eb156af78
--- /dev/null
+++ b/apps/desktop/scripts/fixtures/explicit-file-links/ui-page.mjs
@@ -0,0 +1,34 @@
+import assert from 'node:assert/strict';
+
+export default {
+ name: 'explicit-file-links',
+ entry: './fixture.tsx',
+ viewport: { width: 560, height: 420 },
+ real: 'MarkdownRenderer, path classification, click-time resolution, link context menu and error toast',
+ notCovered: 'Real filesystem, remote transport and OS opening; mobile native rendering.',
+ cases: {
+ default: { about: 'Missing authored link remains clickable, explains failure, copies destination and retries after restoration' },
+ remote: { about: 'Missing remote link remains clickable without local filesystem access' },
+ untrusted: { about: 'Content without privileged file access stays inert' },
+ },
+ async check(page, ui) {
+ const report = page.getByRole('link', { name: '查看报告', exact: true });
+ if (ui.case === 'untrusted') {
+ assert.equal(await report.count(), 0);
+ return;
+ }
+ assert.equal(await page.locator('a[href="/fixture/missing.txt"]').count(), 0);
+ await report.click();
+ await page.getByText(await ui.t('chat.markdownRenderer.fileUnavailable'), { exact: true }).waitFor();
+ await ui.capture('missing-file');
+ assert.equal(await report.count(), 1);
+ await report.click({ button: 'right' });
+ await page.getByRole('menuitem', { name: await ui.t('chat.markdownRenderer.copyLink'), exact: true }).waitFor();
+ await page.keyboard.press('Escape');
+ if (ui.case === 'remote') return;
+ await page.getByTestId('restore-file').click();
+ await page.getByRole('link', { name: '下载 PDF', exact: true }).focus();
+ await page.keyboard.press('Enter');
+ await page.waitForFunction(() => document.documentElement.dataset.openedFile === '/fixture/report.pdf');
+ },
+};
diff --git a/apps/desktop/src/renderer/__tests__/chatClickabilitySignal.test.ts b/apps/desktop/src/renderer/__tests__/chatClickabilitySignal.test.ts
index 19795eef7c..4ccf75fe33 100644
--- a/apps/desktop/src/renderer/__tests__/chatClickabilitySignal.test.ts
+++ b/apps/desktop/src/renderer/__tests__/chatClickabilitySignal.test.ts
@@ -78,7 +78,13 @@ describe('聊天正文的可点性信号(DESIGN.md §14.5)', () => {
});
it('规则⑤:远程会话的点亮判据只有一处,且不在本文件里自己判', () => {
- const src = stripComments(read(CHAT_BODY_FILES[0]));
+ const renderer = stripComments(read(CHAT_BODY_FILES[0]));
+ // Authored links can recheck on click; the single-source rule applies to
+ // render-time auto-detection, not an explicit attempt to open a file.
+ const src = renderer.slice(
+ renderer.indexOf('function useResolvedMarkdownTarget('),
+ renderer.indexOf('async function activateResolvedLocalTarget('),
+ );
// 远程会话 fs:stat 回 unknown 时,歧义形状(裸名 `array.map`、分隔符无扩展
// `and/or`)不得乐观升级成 resolved-local —— 否则加了常显下划线后,普通行内 code
// 会被展示成可点文件、点了必失败(PR #1144 review 实捉桌面侧漏了这道门槛)。
diff --git a/apps/desktop/src/renderer/__tests__/markdownTargetRendererContract.test.ts b/apps/desktop/src/renderer/__tests__/markdownTargetRendererContract.test.ts
index e1937a6dd9..0712d78b5f 100644
--- a/apps/desktop/src/renderer/__tests__/markdownTargetRendererContract.test.ts
+++ b/apps/desktop/src/renderer/__tests__/markdownTargetRendererContract.test.ts
@@ -25,12 +25,9 @@ describe('Markdown target rendering contract', () => {
expect(markdownRenderer).toContain('<InlineCodeWithTarget');
});
- it('only renders a chip for uniquely-resolved local files — everything else is plain text', () => {
- // Design (chosen 2026-05-29 after follow-up review): the chip visual is
- // ONLY a confirmation that the path resolved to a single existing file
- // in workingDir. Unresolved / ambiguous / not-found / directory /
- // unsupported-scheme cases render as plain <span> or vanilla <code>, not
- // as a non-interactive chip. The chip is always interactive when shown.
+ it('only upgrades verified references to file chips, while authored links retain their action', () => {
+ // Auto-detected references need a uniquely resolved target. Explicit
+ // unresolved links keep an ordinary anchor, never a non-interactive chip.
expect(markdownRenderer).toContain('FileTargetChip');
expect(markdownRenderer).toContain("target.kind === 'resolved-local'");
expect(markdownRenderer).toContain('shouldRenderCodeReferenceLabel');
@@ -42,10 +39,10 @@ describe('Markdown target rendering contract', () => {
expect(markdownRenderer).not.toContain('cursor-default');
expect(markdownRenderer).not.toContain('interactive: boolean');
expect(markdownRenderer).not.toContain('interactive={interactive}');
- // Non-resolved local kinds fall through to plain text — assert MarkdownTargetLink
- // explicitly handles code-reference / local-candidate as <span>.
+ // Auto-detected unresolved paths remain plain text; authored links retain
+ // their click action (the UI fixture covers missing-file feedback/retry).
expect(markdownRenderer).toContain(
- "if (target.kind === 'code-reference' || target.kind === 'local-candidate')",
+ "if (target.kind === 'code-reference' || (target.kind === 'local-candidate' && fromBarePath))",
);
// InlineCodeWithTarget only chips on resolved-local; everything else is a
// vanilla <code>. The guard must use !== 'resolved-local'.
@@ -96,7 +93,13 @@ describe('Markdown target rendering contract', () => {
// misses through the de-duped cached wrapper — not call the raw resolver.
expect(markdownRenderer).toContain('peekResolveLocalPathSmart');
expect(markdownRenderer).toContain('resolveLocalPathSmartCached');
- expect(markdownRenderer).not.toContain('resolveLocalPathSmart(');
+ // Explicit clicks intentionally retry uncached resolution after a move or
+ // restoration; only render-time resolution must use the cache.
+ const hook = markdownRenderer.slice(
+ markdownRenderer.indexOf('function useResolvedMarkdownTarget('),
+ markdownRenderer.indexOf('async function activateResolvedLocalTarget('),
+ );
+ expect(hook).not.toContain('resolveLocalPathSmart(');
});
it('allows file:// through urlTransform so local file links can be classified safely', () => {
diff --git a/apps/desktop/src/renderer/components/chat/MarkdownRenderer.tsx b/apps/desktop/src/renderer/components/chat/MarkdownRenderer.tsx
index b37f9265d8..6308e3a673 100644
--- a/apps/desktop/src/renderer/components/chat/MarkdownRenderer.tsx
+++ b/apps/desktop/src/renderer/components/chat/MarkdownRenderer.tsx
@@ -66,6 +66,7 @@ import {
MODEL_EXT_RE,
normalizeMarkdownImageSrc,
resolveLocalPath,
+ resolveLocalPathSmart,
resolveLocalPathSmartCached,
peekResolveLocalPathSmart,
toLocalFileUrl,
@@ -1522,7 +1523,7 @@ function MarkdownTargetLink({
return allowPrivilegedLinks ? target : stripPrivilegedMarkdownTarget(target);
}, [href, localFileRefs, allowPrivilegedLinks]);
const target = useResolvedMarkdownTarget(initialTarget, workingDir, isStreaming);
- const openInlineTarget = () => {
+ const openInlineTarget = async () => {
if (target.kind === 'anchor') {
if (!target.id) return;
const element = document.getElementById(target.id);
@@ -1530,6 +1531,48 @@ function MarkdownTargetLink({
else toast.error(t('chat.markdownRenderer.anchorNotFound'));
} else if (target.kind === 'local-image-url') {
setLightboxSrc(rewriteToRemoteMediaOrigin(target.href, remoteMediaOrigin));
+ } else if (target.kind === 'local-candidate' && !fromBarePath) {
+ // An authored link keeps its destination even after the file moves. Retry
+ // resolution on click instead of trusting a cached "not found" result.
+ try {
+ let result: SmartResolveResult;
+ if (isRemoteFileOrigin(fileCtx.origin)) {
+ const absPath = resolveLocalPath(target.href, workingDir);
+ const { verdict } = await window.electronAPI.fileBrowser.chatStat({
+ origin: fileCtx.origin,
+ workdir: workingDir,
+ absPath,
+ });
+ if (verdict === 'nonfile') {
+ toast.error(t('chat.markdownRenderer.fileUnavailable'));
+ return;
+ }
+ // Unknown may mean offline: the existing preview can still serve a
+ // cached copy or explain the connection failure. Never open locally.
+ result = { status: 'unique', absPath, kind: verdict === 'directory' ? 'directory' : 'file' };
+ } else {
+ result = await resolveLocalPathSmart(target.href, workingDir);
+ }
+ if (result.status === 'multiple') {
+ toast.error(t('chat.markdownRenderer.duplicateFiles', { count: result.candidates.length }));
+ return;
+ }
+ const resolved = resolvedLocalFromResult(target, result);
+ if (!resolved) {
+ toast.error(t('chat.markdownRenderer.fileUnavailable'));
+ return;
+ }
+ if (resolved.localKind !== 'directory' && isHtmlFilePath(resolved.absPath) && sidebarTargetSessionId) {
+ await openHtmlFileByPreference(sidebarTargetSessionId, resolved.absPath, t, fileCtx);
+ } else {
+ await activateResolvedLocalTarget(
+ resolved, { ...fileCtx, sidebarTargetSessionId },
+ setLightboxSrc, setTextLightboxFile, setModelLightboxPath,
+ );
+ }
+ } catch {
+ toast.error(t('chat.markdownRenderer.openLinkFailed'));
+ }
}
};
const inlineMenu = useLinkContextMenu(href ?? '', [{
@@ -1550,11 +1593,8 @@ function MarkdownTargetLink({
// - resolved-local (path uniquely resolves to an existing file) → chip if
// the label reads as a file reference, underlined link if the label is
// freeform prose.
- // - local-candidate (not yet resolved, OR resolved to multiple, OR not
- // found) and code-reference (directory / unsupported scheme) → plain
- // <span>. We don't reserve a chip slot for paths that may never become
- // clickable; instead the chip only appears as a one-shot "lit up"
- // upgrade once unique resolution lands after streaming.
+ // - unresolved authored links remain underlined and resolve again on click.
+ // - automatically detected paths still require a verified target.
if (target.kind === 'resolved-local') {
const openResolvedTarget = () =>
activateResolvedLocalTarget(
@@ -1600,13 +1640,11 @@ function MarkdownTargetLink({
);
}
- if (target.kind === 'code-reference' || target.kind === 'local-candidate') {
+ if (target.kind === 'code-reference' || (target.kind === 'local-candidate' && fromBarePath)) {
return <span>{children}</span>;
}
- // Remaining: external / anchor / local-image-url — none of these flow
- // through the streaming → resolution transition, so the underlined-link
- // visual is stable from first paint. No jitter risk here.
+ // Explicit local candidates retain the same open/copy-link menu as links.
return (
<>
<a
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 768df0944c..9824dd5f26 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -12378,6 +12378,7 @@
"copy": "Copy",
"blockCopied": "Copied",
"duplicateFiles": "Found {{count}} files with the same name, please use an absolute path",
+ "fileUnavailable": "Can't find or access the file. It may have been moved or deleted.",
"copyFile": "Copy",
"copyFilePath": "Copy path",
"copyLocation": "Copy Location",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index e064bcd314..44ab1158a5 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -12333,6 +12333,7 @@
"copy": "コピー",
"blockCopied": "コピー済み",
"duplicateFiles": "同名のファイルが {{count}} 件見つかりました。絶対パスを使用してください",
+ "fileUnavailable": "ファイルが見つからないか、アクセスできません。移動または削除された可能性があります。",
"copyFile": "コピー",
"copyFilePath": "パスをコピー",
"copyLocation": "位置をコピー",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index d742704578..5248caa1dd 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -12333,6 +12333,7 @@
"copy": "복사",
"blockCopied": "복사됨",
"duplicateFiles": "동일한 이름의 파일 {{count}}개를 찾았습니다. 절대 경로를 사용해 주세요",
+ "fileUnavailable": "파일을 찾거나 접근할 수 없습니다. 이동되었거나 삭제되었을 수 있습니다.",
"copyFile": "복사",
"copyFilePath": "경로 복사",
"copyLocation": "위치 복사",
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 e594f1fffe..c772c18c57 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -12333,6 +12333,7 @@
"copy": "复制",
"blockCopied": "已复制",
"duplicateFiles": "找到 {{count}} 个同名文件,请改用绝对路径",
+ "fileUnavailable": "无法找到或访问文件,文件可能已移动或删除",
"copyFile": "复制",
"copyFilePath": "复制路径",
"copyLocation": "复制位置",
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 7d46206f6e..96ba43dca2 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -12332,6 +12332,7 @@
"copy": "複製",
"blockCopied": "已複製",
"duplicateFiles": "找到 {{count}} 個同名檔案,請改用絕對路徑",
+ "fileUnavailable": "無法找到或存取檔案,檔案可能已移動或刪除",
"copyFile": "複製",
"copyFilePath": "複製路徑",
"copyLocation": "複製位置",
diff --git a/apps/mobile/src/__tests__/InteractionPanelReceipt.test.tsx b/apps/mobile/src/__tests__/InteractionPanelReceipt.test.tsx
index db6397d75b..d01fc8bee5 100644
--- a/apps/mobile/src/__tests__/InteractionPanelReceipt.test.tsx
+++ b/apps/mobile/src/__tests__/InteractionPanelReceipt.test.tsx
@@ -11,6 +11,9 @@ import { clearAllInteractionDrafts, readAskUserDraft, readPlanReviewDraft } from
import { forwardNavigationLock } from '@/utils/navigationLock';
import { ChatFilePathContext, type ChatFilePathContextValue } from '@/session/chatFilePathContext';
import { QuestionReferenceText } from '@/session/QuestionReferenceText';
+import { ChatPathChipSpan } from '@/session/ChatPathChipSpan';
+import { classifyChatPathLinkTarget } from '@/session/chatPathCandidate';
+import { Text } from '@/components/AppText';
import { _clearRemotePathVerdictCache } from '@/session/remotePathVerdict';
import { i18n } from '@/i18n';
import { AskCardAuthContext } from '@/session/askCardAuth';
@@ -479,6 +482,37 @@ it('keeps a changed question reference unclickable until its own verification',
expect(onOpenPath).not.toHaveBeenCalled();
});
+// Unit regression: previous coverage only tested auto-detected references.
+// A missing authored file link must still reach the controlled device's preview
+// (which reports read failures), without lighting up the same bare reference.
+it.each([true, false])('keeps missing file links actionable only when authored: %s', async (explicitLink) => {
+ const onOpenPath = vi.fn();
+ const fileContext: ChatFilePathContextValue = {
+ deviceId: 'd1', sessionId: 's1', workdir: '/repo', onOpenPath,
+ statPath: vi.fn(async (absPath: string) => ({ kind: 'missing' as const, resolvedPath: absPath })),
+ };
+ await act(async () => root.render(
+ <ChatFilePathContext.Provider value={fileContext}>
+ <ChatPathChipSpan
+ candidate={classifyChatPathLinkTarget('/repo/missing.html')}
+ explicitLink={explicitLink}
+ display="查看报告" SpanText={Text} chipStyle={{ textDecorationLine: 'underline' }}
+ plainStyle={{}} usePathState={useState}
+ />
+ </ChatFilePathContext.Provider>,
+ ));
+ const link = host.querySelector<HTMLElement>('[data-testid="message.markdownPathChip"]');
+ expect(!!link).toBe(explicitLink);
+ if (link) {
+ await act(async () => link.click());
+ expect(onOpenPath).toHaveBeenCalledExactlyOnceWith({
+ kind: 'file', absPath: '/repo/missing.html', relPath: 'missing.html',
+ });
+ } else {
+ expect(onOpenPath).not.toHaveBeenCalled();
+ }
+});
+
it.each(['push-first', 'receipt-first', 'lost-receipt', 'other-client'] as const)(
'finalizes retained answers without stale snapshot resurrection: %s',
async (order) => {
diff --git a/apps/mobile/src/session/ChatPathChipSpan.tsx b/apps/mobile/src/session/ChatPathChipSpan.tsx
index 08d9e3de7d..fe2f355d03 100644
--- a/apps/mobile/src/session/ChatPathChipSpan.tsx
+++ b/apps/mobile/src/session/ChatPathChipSpan.tsx
@@ -11,11 +11,12 @@ type PathStateHook = <T>(initial: T | (() => T)) => readonly [T, Dispatch<SetSta
/**
* 文件/目录路径 chip 的共享执行体(远程会话文件交互,对齐桌面 #631 的 chip 点亮
* 语义)。inline code 与本地路径链接两种形态共用:候选先经被控端精确 stat 验证——
- * 文件/目录点亮可点(文件 → Quick Look 预览页;目录 → 文件浏览器定位),明确
- * 不存在保持纯文本,链路断等无法判定时乐观点亮(点击后预览页自己的错误 UX 兜底)。
+ * 文件/目录点亮可点(文件 → Quick Look 预览页;目录 → 文件浏览器定位)。
+ * 自动识别的不存在路径保持纯文本;作者显式写出的链接保留点击与长按菜单,
+ * 文件读取和失败反馈交给原有预览页。链路断等无法判定时按形状决定自动引用的点亮。
* workdir 外的绝对路径同样候选(对齐桌面):文件走被控端 absPath 取件通道预览,
* 目录因文件浏览器只认 workdir 内而保持纯文本(canOpenChatPathChip)。
- * 无会话上下文(context null)/ 流式中 → plainStyle 纯文本渲染。
+ * 无会话上下文(context null) → plainStyle 纯文本渲染;流式中不发起预检。
*/
export function ChatPathChipSpan({
candidate,
@@ -24,6 +25,7 @@ export function ChatPathChipSpan({
plainStyle,
SpanText,
streaming,
+ explicitLink = false,
usePathState = useRecyclingState,
}: {
candidate: ChatPathCandidate | null;
@@ -33,6 +35,8 @@ export function ChatPathChipSpan({
plainStyle: StyleProp<TextStyle>;
SpanText: typeof Text;
streaming?: boolean;
+ /** Authored Markdown links retain an open action even when the file is missing. */
+ explicitLink?: boolean;
/** Composer cards live outside LegendList, whose state setters require a list item. */
usePathState?: PathStateHook;
}) {
@@ -104,12 +108,12 @@ export function ChatPathChipSpan({
const verdictAllowsLit = candidate?.ambiguousShape
? verdict === 'file' || verdict === 'directory'
: verdict !== undefined && verdict !== 'nonfile';
- const lit = !!ctx && !!candidate && !!target && verdictAllowsLit;
+ const lit = !!ctx && !!candidate && !!target && (explicitLink || verdictAllowsLit);
if (!lit) {
return <SpanText style={plainStyle}>{display}</SpanText>;
}
const kind: 'file' | 'directory' =
- verdict === 'directory' || (verdict === 'unknown' && candidate.directoryShape) ? 'directory' : 'file';
+ verdict === 'directory' || (verdict !== 'file' && candidate.directoryShape) ? 'directory' : 'file';
if (!canOpenChatPathChip(kind, target.relPath)) {
return <SpanText style={plainStyle}>{display}</SpanText>;
}
diff --git a/apps/mobile/src/session/MessageRenderer.tsx b/apps/mobile/src/session/MessageRenderer.tsx
index 39a0a5bd24..2723b72582 100644
--- a/apps/mobile/src/session/MessageRenderer.tsx
+++ b/apps/mobile/src/session/MessageRenderer.tsx
@@ -6399,6 +6399,7 @@ function LinkPathChipSpan({
return (
<ChatPathChipSpan
candidate={candidate}
+ explicitLink={!bare}
chipStyle={
codeStyled
? [baseStyle, styles.markdownInlineCode, underlineDecoration(styles, baseStyle, styles.markdownPathChip)]
diff --git a/docs/design-rules/DESIGN.md b/docs/design-rules/DESIGN.md
index 8d5ba7261e..3a7fb9eb52 100644
--- a/docs/design-rules/DESIGN.md
+++ b/docs/design-rules/DESIGN.md
@@ -1434,7 +1434,12 @@ HTML 不提供复制文件、在文件列表中定位或选择应用。无侧边
4. **候选判定:反引号不等于路径。** 行内 code 只接受真正的路径形状——带分隔符 / 绝对路径,
或裸文件名;**不得**用「含斜杠或有个点后缀」兜底。显式 markdown 链接与正文裸路径不受此
限(前者作者已声明,后者词法本就要求带分隔符)。
-5. **无法判定时的点亮门槛按形态分级。** 适用于任何存在「无法判定」中间态的链路:移动端
+5. **自动识别路径的点亮门槛按形态分级。** 显式 Markdown 文件链接(`[查看报告](路径)`)
+ 在桌面和手机聊天中保留点击入口,不因尚未验证、文件缺失或断线退化为普通文字;点击时
+ 通过原有文件访问通道打开或说明失败,保留复制目标的操作,不绕过权限、不猜搬迁位置。
+ 已解析文件仍沿用原有预览与文件菜单。没有文件访问上下文或不允许特权链接的内容面不因此
+ 获得文件访问能力。以下形态门槛仅适用于正文自动识别路径和行内 code。
+ 适用于任何存在「无法判定」中间态的链路:移动端
全部会话、以及桌面的**远程会话**(两者的 `fs:stat` 都会回 `unknown`)。桌面**本机**
会话不适用 —— 那边走真实存在性检查,解析不到一律纯文本,没有中间态。
@@ -1548,12 +1553,13 @@ PR #1144 的两轮 review 各捉到一个**同族**缺陷:「有下划线却点
| ----------------------- | ------------------------------------------- | -------------------------------------- | ------------------------------------------- |
| 桌面聊天正文 | 外链 / anchor / 本地图片 URL | ✅ | ✅ `MARKDOWN_LINK_CLASS` |
| 桌面聊天正文 | 已解析本地文件(chip / 散文 label) | ✅ | ✅ |
-| 桌面聊天正文 | 未解析路径、行内 code | ❌ | ❌ |
+| 桌面聊天正文 | 未解析的显式文件链接 | ✅(点击重验,失败提示) | ✅ |
+| 桌面聊天正文 | 未解析的自动识别路径、行内 code | ❌ | ❌ |
| 桌面聊天正文 | **远程**会话里 stat 回 `unknown` 的引用 | 仅非歧义形状 | 由 `isAmbiguousPathShape` 门槛裁决 |
| 桌面聊天正文 / 用户气泡 | 会话 / 项目深链 chip(`InlineReferenceChip`) | 取决于是否注入 onClick | **与 `interactive` 同源** |
| 桌面用户气泡 | URL / 图片路径 | ✅ | ✅(改前只有 hover 下划线) |
| 手机聊天正文 | 外链 / 图片 chip / 会话 chip | 取决于 handler 是否注入 | **与 handler 同源**(`clickableInlineStyle`) |
-| 手机聊天正文 | 路径 chip | 取决于远端 verdict | 由 `ChatPathChipSpan.lit` 单点裁决 |
+| 手机聊天正文 | 路径 chip | 显式链接保留,其余取决于远端 verdict | 由 `ChatPathChipSpan.lit` 单点裁决 |
| 手机文件阅读器 | http(s) | ✅ | ✅ |
| 手机文件阅读器 | 会话 chip / 图片 chip / 本地路径 / mailto | ❌(无 bridge、只放行 http(s)) | ❌ |
@@ -1654,19 +1660,16 @@ peek 有值 → 调用方跳过重验 → 链路恢复后也不再问。两端
> 数组;两端都要有。(第 10 轮重构只做对了桌面那一半,第 11 轮 review 实捉;这类 bug 的形状
> 是「依赖数组漏了触发源」,没有类型保护,故两端各有源码级守卫。)
-> **不变量 B:点亮门槛(规则 5)对所有候选来源同口径。** 与候选门槛(规则 4)的来源豁免
-> **无关** —— 两者是两道独立的门,显式 markdown 链接只豁免前者。
+> **不变量 B(2026-10-27 更新):显式链接保留作者声明的点击入口,自动识别引用仍需验证。**
-作者写下 `[配置](package.json)` 只声明了「我想让它可点」,并不能让远端在链路断时知道它是否
-存在;点亮了却点不开正是规则 1 要防的反例。判据在两端各只有一份、且**逐字同形**:桌面
-`markdownTarget.isAmbiguousPathShape`、移动 `chatPathCandidate.isAmbiguousChatPathShape`;
-所有入口都调它,**不得按来源硬写 `true` / `false`**(移动端曾对链接入口恒 `false`,与桌面
-不对称,review 实捉)。
+`[配置](package.json)` 的下划线表示可以尝试打开,不承诺文件仍然存在。文件移动、删除或
+暂时不可达时,点击后给出可理解的反馈。正文路径与行内 code 仍按原有形态门槛判断,避免
+把 `array.map` 等普通文本变成假链接。两端以来源标记区分,不放宽路径分类或文件访问权限。
| 候选来源 | 桌面入口 | 移动入口 | 走门槛? |
| ------------------ | ----------------------------- | --------------------------------- | ------------------------------------------ |
| 行内 code | `classifyInlineCodeTarget` | `classifyInlineCodePathCandidate` | ✅ |
-| 显式 markdown 链接 | `classifyMarkdownLinkTarget` | `classifyChatPathLinkTarget` | ✅ |
+| 显式 markdown 链接 | `classifyMarkdownLinkTarget` | `classifyChatPathLinkTarget` | 不以存在性决定可点;实际访问仍校验 |
| 正文裸写路径 | `remarkLocalPathLinks` → 同上 | `matchBareFilePathLink` → 同上 | ✅(词法强制带扩展名 → 恒非歧义,实际无影响) |
| 尾斜杠目录 | 回看 `originalHref` → 非歧义 | 同左 | ✅ |
| `file://` 绝对路径 | 单列为非歧义 | 同左 | ✅ |