Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Merge pull request #6464 from AdityaUmale/fix/mail-1a1ec7e0-cjk-html-preview

milind-soni24c5530da405
diff --cc src/components/ChatMarkdown.tsx
index 71a2d067e9,7d813e9271..1ee823865c
--- a/src/components/ChatMarkdown.tsx
+++ b/src/components/ChatMarkdown.tsx
@@@ -339,9 -339,9 +339,9 @@@ export function MermaidDiagram({ code }
// Security: no href at all, since an <a href="file://…"> reaches setWindowOpenHandler on a middle or modifier click,
// which calls shell.openExternal without main's containment check.
// source: the original a delivered copy came from, offered on right-click (Show in Finder) like in the gallery.
- function LocalFileLink({ filePath, shownPath, name, source, children, message }: { filePath: string; shownPath: string; name?: string; source?: string; children?: ReactNode; message?: MessageAttachmentContext }) {
-function LocalFileLink({ filePath, shownName, name, source, children, message }: { filePath: string; shownName: string; name?: string; source?: string; children?: ReactNode; message?: MessageAttachmentContext }) {
++function LocalFileLink({ filePath, shownPath, shownName, name, source, children, message }: { filePath: string; shownPath: string; shownName: string; name?: string; source?: string; children?: ReactNode; message?: MessageAttachmentContext }) {
const save = useLocalFileSave(filePath, name, message);
- const preview = useHtmlPreview(filePath, name ?? fileName(filePath), message);
+ const preview = useHtmlPreview(filePath, shownName, message);
const revealMenu = useRevealOriginalMenu();
if (!message) {
return <span title={t("chat.file.legacy")} className="break-words text-ink-secondary">{children}</span>;
@@@ -659,9 -659,9 +659,11 @@@ function MarkdownLink({ href, children
if (localPath) {
const copy = delivered && Object.hasOwn(delivered, fileName(localPath)) ? delivered[fileName(localPath)] : undefined;
const source = copy && originals && Object.hasOwn(originals, copy) ? originals[copy] : undefined;
- // A delivered copy keeps its literal name; localFilePath already decodes a file:// URL; a plain path link is still encoded and gets the server's single decode.
- const shownName = copy || /^file:\/\//i.test(href) ? fileName(localPath) : fileName(decodedLinkPath(localPath));
- return <LocalFileLink filePath={copy ?? localPath} shownName={shownName} name={copy ? fileName(localPath) : undefined} source={source} message={message}>{children}</LocalFileLink>;
+ // localFilePath already decodes a file:// URL; a plain path link is still encoded and gets the server's single decode.
++ // A delivered copy keeps its literal name.
+ const shownPath = copy ?? (/^file:\/\//i.test(href) ? localPath : decodedLinkPath(localPath));
- return <LocalFileLink filePath={copy ?? localPath} shownPath={shownPath} name={copy ? fileName(localPath) : undefined} source={source} message={message}>{children}</LocalFileLink>;
++ const shownName = copy ? fileName(localPath) : fileName(shownPath);
++ return <LocalFileLink filePath={copy ?? localPath} shownPath={shownPath} shownName={shownName} name={copy ? fileName(localPath) : undefined} source={source} message={message}>{children}</LocalFileLink>;
}
if (!/^https?:\/\//i.test(href)) {
return (