= {
+ pptx: "PowerPoint",
+ ppt: "PowerPoint",
+ docx: "Word",
+ doc: "Word",
+ xlsx: "Excel",
+ xls: "Excel",
+};
+
function getExtension(path: string): string {
const idx = path.lastIndexOf(".");
return idx === -1 ? "" : path.slice(idx + 1).toLowerCase();
}
+/**
+ * Fallback shown when a file's bytes aren't previewable. Office documents
+ * (.pptx / .docx / .xlsx …) get a clear, format-named message; every other
+ * binary keeps the generic "binary file" string so the pane is never blank.
+ */
+function UnpreviewableFallback({ path }: { path: string }) {
+ const { t } = useTranslation("openhands");
+ const documentLabel = OFFICE_DOCUMENT_LABELS[getExtension(path)];
+ return (
+
+ {documentLabel
+ ? t(I18nKey.FILES$UNSUPPORTED_DOCUMENT, { type: documentLabel })
+ : t(I18nKey.FILES$BINARY_FALLBACK)}
+
+ );
+}
+
/**
* Renders the contents of a single workspace file. In `rich` mode we point
* an iframe /
straight at the agent server's static workspace
@@ -82,14 +118,7 @@ export function FileContentViewer({ path, viewMode }: FileContentViewerProps) {
/>
);
}
- return (
-
- {t(I18nKey.FILES$BINARY_FALLBACK)}
-
- );
+ return ;
}
// ----- Rich mode: render HTML, markdown, images, PDFs from staticUrl. ----
@@ -129,14 +158,7 @@ export function FileContentViewer({ path, viewMode }: FileContentViewerProps) {
}
if (kind === "binary") {
- return (
-
- {t(I18nKey.FILES$BINARY_FALLBACK)}
-
- );
+ return ;
}
// Text-like content.
@@ -202,12 +224,5 @@ export function FileContentViewer({ path, viewMode }: FileContentViewerProps) {
// Truly unknown / empty payload — show a fallback so the pane is never
// blank.
- return (
-
- {t(I18nKey.FILES$BINARY_FALLBACK)}
-
- );
+ return ;
}
diff --git a/src/i18n/translation.json b/src/i18n/translation.json
index 9d8de6c0e..05701c383 100644
--- a/src/i18n/translation.json
+++ b/src/i18n/translation.json
@@ -21640,6 +21640,23 @@
"uk": "Двійковий файл – попередній перегляд недоступний",
"ca": "Fitxer binari – previsualització no disponible"
},
+ "FILES$UNSUPPORTED_DOCUMENT": {
+ "en": "Preview isn't available for {{type}} files.",
+ "ja": "{{type}} ファイルのプレビューは利用できません。",
+ "zh-CN": "{{type}} 文件无法预览。",
+ "zh-TW": "{{type}} 檔案無法預覽。",
+ "ko-KR": "{{type}} 파일은 미리 보기를 사용할 수 없습니다.",
+ "no": "Forhåndsvisning er ikke tilgjengelig for {{type}}-filer.",
+ "it": "L'anteprima non è disponibile per i file {{type}}.",
+ "pt": "A visualização não está disponível para arquivos {{type}}.",
+ "es": "La vista previa no está disponible para archivos {{type}}.",
+ "ar": "المعاينة غير متاحة لملفات {{type}}.",
+ "fr": "L'aperçu n'est pas disponible pour les fichiers {{type}}.",
+ "tr": "{{type}} dosyaları için önizleme kullanılamıyor.",
+ "de": "Für {{type}}-Dateien ist keine Vorschau verfügbar.",
+ "uk": "Попередній перегляд недоступний для файлів {{type}}.",
+ "ca": "La previsualització no està disponible per als fitxers {{type}}."
+ },
"FILES$LOADING_FILES": {
"en": "Loading files…",
"ja": "ファイルを読み込んでいます…",