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): preserve question text layout and uppercase URLs

Lizia5892234c3ed
diff --git a/apps/desktop/src/renderer/components/chat/MarkdownRenderer.tsx b/apps/desktop/src/renderer/components/chat/MarkdownRenderer.tsx
index e67cb58663..dc37fb5726 100644
--- a/apps/desktop/src/renderer/components/chat/MarkdownRenderer.tsx
+++ b/apps/desktop/src/renderer/components/chat/MarkdownRenderer.tsx
@@ -1120,6 +1120,7 @@ function ResolvedLocalLink({
anchorProps,
children,
sessionId,
+ showFileIcon = true,
}: {
resolvedAbsPath: string;
localKind: MarkdownLocalKind;
@@ -1131,6 +1132,7 @@ function ResolvedLocalLink({
children: ReactNode;
/** 当前会话 id;就位时 html 文件左键弹"打开方式"菜单(同 FileTargetChip)。 */
sessionId?: string;
+ showFileIcon?: boolean;
}) {
const { t } = useTranslation();
// 同 FileTargetChip:html + 有会话上下文时左键按偏好直开,「查看源文件」
@@ -1168,7 +1170,7 @@ function ResolvedLocalLink({
onContextMenu={ctxMenu.onContextMenu}
{...anchorProps}
>
- {localKind !== 'directory' && nodeToText(children).trim() && (
+ {showFileIcon && localKind !== 'directory' && nodeToText(children).trim() && (
<FileTypeIcon name={resolvedAbsPath} size={14} className="mr-1 inline-block align-[-0.125em]" />
)}
{children}
@@ -1457,6 +1459,7 @@ export function QuestionReferenceText({ text, onPreviewOpenChange }: { text: str
isStreaming={false}
allowPrivilegedLinks
fromBarePath
+ showFileIcon={false}
anchorProps={{}}
setLightboxSrc={setImage}
setTextLightboxFile={setFile}
@@ -1483,6 +1486,7 @@ function MarkdownTargetLink({
fromBarePath,
remoteMediaOrigin,
sessionId,
+ showFileIcon,
}: {
href?: string;
children: ReactNode;
@@ -1500,6 +1504,8 @@ function MarkdownTargetLink({
* shouldRenderCodeReferenceLabel 的调用点与 DESIGN.md §14.5。
*/
fromBarePath?: boolean;
+ /** Plain question text preserves its layout when a file becomes clickable. */
+ showFileIcon?: boolean;
/** 远程会话媒体来源:把 xdt-audio:// 等链接改写到 cindy-remote-media://;本地 undefined。 */
remoteMediaOrigin?: RemoteMediaOrigin;
/** 当前会话 id;就位时外链 / html 文件左键弹"打开方式"菜单。 */
@@ -1573,6 +1579,7 @@ function MarkdownTargetLink({
onOpen={openResolvedTarget}
anchorProps={anchorProps}
sessionId={sessionId}
+ showFileIcon={showFileIcon}
>
{children}
</ResolvedLocalLink>
diff --git a/packages/maker-shared/src/__tests__/interaction.test.ts b/packages/maker-shared/src/__tests__/interaction.test.ts
index 7537289d8e..fb6cb41e16 100644
--- a/packages/maker-shared/src/__tests__/interaction.test.ts
+++ b/packages/maker-shared/src/__tests__/interaction.test.ts
@@ -90,6 +90,11 @@ describe('interaction shared model', () => {
{ text: windowsHosts, href: windowsHosts }, { text: ' 与 ' },
{ text: 'hosts', href: '/etc/hosts' },
]);
+ expect(splitQuestionReferences('请查看 HTTPS://en.wikipedia.org/wiki/Foo_(bar)。')).toEqual([
+ { text: '请查看 ' },
+ { text: 'HTTPS://en.wikipedia.org/wiki/Foo_(bar)', href: 'HTTPS://en.wikipedia.org/wiki/Foo_(bar)' },
+ { text: '。' },
+ ]);
});
it('keeps original questions attached to late answers without including skipped questions', () => {
expect(formatAsyncQuestionSupplement([{ question: 'Scope?\nDetails?', header: 'Scope' }, { question: 'Skipped?' }],
diff --git a/packages/maker-shared/src/questionReferences.ts b/packages/maker-shared/src/questionReferences.ts
index f45863d5bb..4a9263130e 100644
--- a/packages/maker-shared/src/questionReferences.ts
+++ b/packages/maker-shared/src/questionReferences.ts
@@ -36,7 +36,7 @@ export function splitQuestionReferences(text: string): QuestionReferencePart[] {
BARE_HTTP_URL_RE_SOURCE,
/(?<![^\s((【「"',、;;])[^\s,。!?;:()【】「」、()"'<>\[\]\u0060]+/.source,
].join('|'),
- 'g',
+ 'gi',
);
let from = 0;
let unquotedAbsolutePath = false;