diff --git a/locales/en.json b/locales/en.json index 73bc12f40..7dba4f568 100644 --- a/locales/en.json +++ b/locales/en.json @@ -1961,6 +1961,7 @@ "sessions.imageStoredAsLocalFile": "Image upload is offline; added as a pending file attachment.", "sessions.fileDownload": "Download", "sessions.fileDownloadFull": "Download full file", + "sessions.openLivePreview": "Open live preview", "sessions.filePreviewRendered": "Rendered", "sessions.filePreviewRaw": "Raw", "sessions.filePreviewTruncated": "Preview shows only the start of this file. Download the full file to see everything.", diff --git a/locales/zh_CN.json b/locales/zh_CN.json index 8eb5cc241..c1b215ad1 100644 --- a/locales/zh_CN.json +++ b/locales/zh_CN.json @@ -1961,6 +1961,7 @@ "sessions.imageStoredAsLocalFile": "图片上传处于离线状态,已作为待同步文件附件添加。", "sessions.fileDownload": "下载", "sessions.fileDownloadFull": "下载完整文件", + "sessions.openLivePreview": "打开实时预览", "sessions.filePreviewRendered": "渲染", "sessions.filePreviewRaw": "原文", "sessions.filePreviewTruncated": "预览仅显示文件开头部分。下载完整文件以查看全部内容。", diff --git a/packages/components/src/components/ai-gui/index.tsx b/packages/components/src/components/ai-gui/index.tsx index 1cdf37e9c..2bf512c52 100644 --- a/packages/components/src/components/ai-gui/index.tsx +++ b/packages/components/src/components/ai-gui/index.tsx @@ -89,6 +89,8 @@ export interface SessionChatStreamProps { onFilePathClick?: (filePath: string) => void; /** Routes HTML attachment clicks to a live file or Browser surface. */ onOpenHtmlFile?: (file: SessionFilePayload) => boolean; + /** Whether an HTML attachment can be routed to a live file or Browser surface. */ + canOpenHtmlFile?: (file: SessionFilePayload) => boolean; messageFileDiffEntriesByTurn?: MessageFileDiffEntriesByTurn; assistantActions?: AssistantMessageAction[]; assistantActionsMessageId?: string | null; @@ -171,6 +173,7 @@ const SessionChatStreamImpl = forwardRef void; isDownloading?: boolean; + onOpenLivePreview?: (file: SessionFilePayload) => void; }; /** @@ -38,6 +39,7 @@ export function SessionFilePreviewPanel({ status, onDownload, isDownloading = false, + onOpenLivePreview, }: SessionFilePreviewPanelProps) { const { t } = useTranslation(); const markdown = isMarkdownFile(file.fileName); @@ -123,7 +125,20 @@ export function SessionFilePreviewPanel({ )} - {/* Divider separates content actions (copy/download) from the window + {onOpenLivePreview ? ( + + ) : null} + {/* Divider separates content actions (copy/download/live-preview) from the window action (close), and the close sits inline in the same row instead of floating in the corner over the buttons. */}