diff --git a/static/i18n.js b/static/i18n.js index 1b0a23cf..a5e46cab 100644 --- a/static/i18n.js +++ b/static/i18n.js @@ -27,6 +27,8 @@ const LOCALES = { copy_failed: 'Copy failed', diff_loading: 'Loading diff', + diff_error: 'Could not load patch file', + diff_too_large: 'Patch file too large to display inline', you: 'You', thinking: 'Thinking', expand_all: 'Expand all', @@ -719,6 +721,8 @@ const LOCALES = { copy_failed: '\u041e\u0448\u0438\u0431\u043a\u0430 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f', diff_loading: 'Загрузка diff', + diff_error: 'Не удалось загрузить файл патча', + diff_too_large: 'Файл патча слишком большой для отображения', you: 'Вы', thinking: 'Думаю', expand_all: 'Развернуть всё', @@ -1360,6 +1364,8 @@ const LOCALES = { copy_failed: 'Error al copiar', diff_loading: 'Cargando diff', + diff_error: 'No se pudo cargar el archivo de parche', + diff_too_large: 'Archivo de parche demasiado grande para mostrar', you: 'Tú', thinking: 'Pensando', expand_all: 'Expandir todo', @@ -1993,6 +1999,8 @@ const LOCALES = { copy_failed: 'Kopieren fehlgeschlagen', diff_loading: 'Lade Diff', + diff_error: 'Patch-Datei konnte nicht geladen werden', + diff_too_large: 'Patch-Datei zu groß für Inline-Anzeige', you: 'Du', thinking: 'Nachdenken', expand_all: 'Alle ausklappen', @@ -2401,6 +2409,8 @@ const LOCALES = { copy_failed: '\u590d\u5236\u5931\u8d25', diff_loading: '加载 diff', + diff_error: '无法加载 patch 文件', + diff_too_large: 'Patch 文件过大,无法内联显示', you: '\u4f60', thinking: '\u601d\u8003\u8fc7\u7a0b', expand_all: '\u5168\u90e8\u5c55\u5f00', @@ -3032,6 +3042,8 @@ const LOCALES = { copy_failed: '\u8907\u88fd\u5931\u6557', diff_loading: '載入 diff', + diff_error: '無法載入 patch 檔案', + diff_too_large: 'Patch 檔案過大,無法內聯顯示', you: '\u4f60', thinking: '\u601d\u8003\u904e\u7a0b', expand_all: '\u5168\u90e8\u5c55\u958b', @@ -3712,6 +3724,8 @@ const LOCALES = { copy_failed: '복사 실패', diff_loading: 'diff 불러오는 중', + diff_error: '패치 파일을 로드할 수 없습니다', + diff_too_large: '패치 파일이 너무 커서 인라인으로 표시할 수 없습니다', you: '나', thinking: '생각 중', expand_all: '모두 펼치기', diff --git a/static/ui.js b/static/ui.js index c62fccde..ca6652a6 100644 --- a/static/ui.js +++ b/static/ui.js @@ -3151,12 +3151,17 @@ let _mermaidLoading=false; let _mermaidReady=false; function loadDiffInline(){ + const DIFF_MAX_SIZE=512*1024; // 512 KB cap for inline diff rendering document.querySelectorAll('.diff-inline-load:not([data-loaded])').forEach(el=>{ el.setAttribute('data-loaded','1'); const path=el.dataset.path; fetch('api/media?path='+encodeURIComponent(path)) .then(r=>{if(!r.ok) throw new Error(r.status);return r.text();}) .then(text=>{ + if(text.length>DIFF_MAX_SIZE){ + el.outerHTML=`
${esc(path.split('/').pop())}
${t('diff_too_large')}
`; + return; + } const lines=text.split('\n').map(line=>{ const e=esc(line); if(e.startsWith('@@')) return `${e}`; @@ -3167,7 +3172,7 @@ function loadDiffInline(){ el.outerHTML=`
${esc(path.split('/').pop())}
${lines}
`; }) .catch(()=>{ - el.outerHTML=`
${esc(path.split('/').pop())}
`; + el.outerHTML=`
${esc(path.split('/').pop())}
${t('diff_error')}
`; }); }); }