"use client"; import { SymlinkIndicator } from "@/components/shared/symlink-indicator"; import { memo } from "react"; import { IconBrowser, IconCode, IconRefresh } from "@tabler/icons-react"; import { Button } from "@kandev/ui/button"; import { Tooltip, TooltipContent, TooltipTrigger } from "@kandev/ui/tooltip"; import { PanelHeaderBarSplit } from "@/components/task/panel-primitives"; import { FileViewerDownloadButton } from "@/components/task/file-viewer-header"; import { ExternalVcsFileLink, useExternalVcsFileStatus, } from "@/components/editors/external-vcs-file-link"; import { getHtmlPreviewPublishErrorKey, type HtmlPreviewPublishErrorCode, } from "@/hooks/use-html-preview-publisher"; import { toRelativePath } from "@/lib/utils"; import { useTranslation } from "react-i18next"; type HtmlPreviewContentProps = { path: string; isSymlink?: boolean; previewUrl?: string | null; isLoading?: boolean; error?: HtmlPreviewPublishErrorCode | null; worktreePath?: string; sessionId?: string; taskId?: string | null; repositoryId?: string | null; repositoryName?: string; showExternalVcsLink?: boolean; onDownload?: () => void; onRefresh?: () => void; onOpenInBrowser?: () => void; onRetry?: () => void; onTogglePreview: () => void; }; function HtmlPreviewContentToolbar({ path, isSymlink, worktreePath, sessionId, taskId, repositoryId, repositoryName, showExternalVcsLink, isLoading, onDownload, onRefresh, onOpenInBrowser, onTogglePreview, }: Omit) { const { t } = useTranslation(); const fileStatus = useExternalVcsFileStatus(path, sessionId, repositoryName); const trustWarning = t("task:htmlPreviewTrustedCode"); return ( {toRelativePath(path, worktreePath)} {t("task:htmlPreview")} } right={
{showExternalVcsLink && ( )} {onRefresh && ( )} {onOpenInBrowser && ( )}

{t("task:showCode")}

{trustWarning}

} /> ); } export const HtmlPreviewContent = memo(function HtmlPreviewContent({ path, isSymlink, previewUrl, isLoading = false, error = null, worktreePath, sessionId, taskId, repositoryId, repositoryName, showExternalVcsLink = true, onDownload, onRefresh, onOpenInBrowser, onRetry, onTogglePreview, }: HtmlPreviewContentProps) { const { t } = useTranslation(); const errorKey = error ? getHtmlPreviewPublishErrorKey(error) : null; return (

{t("task:htmlPreviewTrustedCode")}

{isLoading && (
{t("task:htmlPreviewLoading")}
)} {!isLoading && errorKey && (

{t(errorKey)}

{onRetry && ( )}
)} {!isLoading && !errorKey && previewUrl && (