fix(app): lower threshold for diff hiding

This commit is contained in:
Adam
2026-02-18 08:40:01 -06:00
parent 00c238777a
commit 2611c35acc
17 changed files with 24 additions and 44 deletions

View File

@@ -17,25 +17,7 @@ import { PreloadMultiFileDiffResult } from "@pierre/diffs/ssr"
import { type SelectedLineRange } from "@pierre/diffs" import { type SelectedLineRange } from "@pierre/diffs"
import { Dynamic } from "solid-js/web" import { Dynamic } from "solid-js/web"
const MAX_DIFF_LINES = 20_000 const MAX_DIFF_CHANGED_LINES = 500
const MAX_DIFF_BYTES = 2_000_000
function linesOver(text: string, max: number) {
let lines = 1
for (let i = 0; i < text.length; i++) {
if (text.charCodeAt(i) !== 10) continue
lines++
if (lines > max) return true
}
return lines > max
}
function formatBytes(bytes: number) {
if (!Number.isFinite(bytes) || bytes <= 0) return "0 B"
if (bytes < 1024) return `${bytes} B`
if (bytes < 1024 * 1024) return `${Math.round((bytes / 1024) * 10) / 10} KB`
return `${Math.round((bytes / (1024 * 1024)) * 10) / 10} MB`
}
export type SessionReviewDiffStyle = "unified" | "split" export type SessionReviewDiffStyle = "unified" | "split"
@@ -354,18 +336,13 @@ export const SessionReview = (props: SessionReviewProps) => {
const beforeText = () => (typeof diff.before === "string" ? diff.before : "") const beforeText = () => (typeof diff.before === "string" ? diff.before : "")
const afterText = () => (typeof diff.after === "string" ? diff.after : "") const afterText = () => (typeof diff.after === "string" ? diff.after : "")
const changedLines = () => diff.additions + diff.deletions
const tooLarge = createMemo(() => { const tooLarge = createMemo(() => {
if (!expanded()) return false if (!expanded()) return false
if (force()) return false if (force()) return false
if (isImageFile(diff.file)) return false if (isImageFile(diff.file)) return false
return changedLines() > MAX_DIFF_CHANGED_LINES
const before = beforeText()
const after = afterText()
if (before.length > MAX_DIFF_BYTES || after.length > MAX_DIFF_BYTES) return true
if (linesOver(before, MAX_DIFF_LINES) || linesOver(after, MAX_DIFF_LINES)) return true
return false
}) })
const isAdded = () => diff.status === "added" || (beforeText().length === 0 && afterText().length > 0) const isAdded = () => diff.status === "added" || (beforeText().length === 0 && afterText().length > 0)
@@ -636,8 +613,10 @@ export const SessionReview = (props: SessionReviewProps) => {
{i18n.t("ui.sessionReview.largeDiff.title")} {i18n.t("ui.sessionReview.largeDiff.title")}
</div> </div>
<div data-slot="session-review-large-diff-meta"> <div data-slot="session-review-large-diff-meta">
Limit: {MAX_DIFF_LINES.toLocaleString()} lines / {formatBytes(MAX_DIFF_BYTES)}. {i18n.t("ui.sessionReview.largeDiff.meta", {
Current: {formatBytes(Math.max(beforeText().length, afterText().length))}. limit: MAX_DIFF_CHANGED_LINES.toLocaleString(),
current: changedLines().toLocaleString(),
})}
</div> </div>
<div data-slot="session-review-large-diff-actions"> <div data-slot="session-review-large-diff-actions">
<Button size="normal" variant="secondary" onClick={() => setForce(true)}> <Button size="normal" variant="secondary" onClick={() => setForce(true)}>

View File

@@ -11,7 +11,7 @@ export const dict = {
"ui.sessionReview.image.loading": "جار التحميل...", "ui.sessionReview.image.loading": "جار التحميل...",
"ui.sessionReview.image.placeholder": "صورة", "ui.sessionReview.image.placeholder": "صورة",
"ui.sessionReview.largeDiff.title": "Diff كبير جدا لعرضه", "ui.sessionReview.largeDiff.title": "Diff كبير جدا لعرضه",
"ui.sessionReview.largeDiff.meta": "الحد: {{lines}} سطر / {{limit}}. الحالي: {{current}}.", "ui.sessionReview.largeDiff.meta": "الحد: {{limit}} سطرًا متغيرًا. الحالي: {{current}} سطرًا متغيرًا.",
"ui.sessionReview.largeDiff.renderAnyway": "اعرض على أي حال", "ui.sessionReview.largeDiff.renderAnyway": "اعرض على أي حال",
"ui.lineComment.label.prefix": "تعليق على ", "ui.lineComment.label.prefix": "تعليق على ",

View File

@@ -11,7 +11,7 @@ export const dict = {
"ui.sessionReview.image.loading": "Carregando...", "ui.sessionReview.image.loading": "Carregando...",
"ui.sessionReview.image.placeholder": "Imagem", "ui.sessionReview.image.placeholder": "Imagem",
"ui.sessionReview.largeDiff.title": "Diff grande demais para renderizar", "ui.sessionReview.largeDiff.title": "Diff grande demais para renderizar",
"ui.sessionReview.largeDiff.meta": "Limite: {{lines}} linhas / {{limit}}. Atual: {{current}}.", "ui.sessionReview.largeDiff.meta": "Limite: {{limit}} linhas alteradas. Atual: {{current}} linhas alteradas.",
"ui.sessionReview.largeDiff.renderAnyway": "Renderizar mesmo assim", "ui.sessionReview.largeDiff.renderAnyway": "Renderizar mesmo assim",
"ui.lineComment.label.prefix": "Comentar em ", "ui.lineComment.label.prefix": "Comentar em ",

View File

@@ -15,7 +15,7 @@ export const dict = {
"ui.sessionReview.image.loading": "Učitavanje...", "ui.sessionReview.image.loading": "Učitavanje...",
"ui.sessionReview.image.placeholder": "Slika", "ui.sessionReview.image.placeholder": "Slika",
"ui.sessionReview.largeDiff.title": "Diff je prevelik za prikaz", "ui.sessionReview.largeDiff.title": "Diff je prevelik za prikaz",
"ui.sessionReview.largeDiff.meta": "Limit: {{lines}} linija / {{limit}}. Trenutno: {{current}}.", "ui.sessionReview.largeDiff.meta": "Limit: {{limit}} izmijenjenih linija. Trenutno: {{current}} izmijenjenih linija.",
"ui.sessionReview.largeDiff.renderAnyway": "Prikaži svejedno", "ui.sessionReview.largeDiff.renderAnyway": "Prikaži svejedno",
"ui.lineComment.label.prefix": "Komentar na ", "ui.lineComment.label.prefix": "Komentar na ",

View File

@@ -12,7 +12,7 @@ export const dict = {
"ui.sessionReview.image.loading": "Indlæser...", "ui.sessionReview.image.loading": "Indlæser...",
"ui.sessionReview.image.placeholder": "Billede", "ui.sessionReview.image.placeholder": "Billede",
"ui.sessionReview.largeDiff.title": "Diff er for stor til at blive vist", "ui.sessionReview.largeDiff.title": "Diff er for stor til at blive vist",
"ui.sessionReview.largeDiff.meta": "Grænse: {{lines}} linjer / {{limit}}. Nuværende: {{current}}.", "ui.sessionReview.largeDiff.meta": "Grænse: {{limit}} ændrede linjer. Nuværende: {{current}} ændrede linjer.",
"ui.sessionReview.largeDiff.renderAnyway": "Vis alligevel", "ui.sessionReview.largeDiff.renderAnyway": "Vis alligevel",
"ui.lineComment.label.prefix": "Kommenter på ", "ui.lineComment.label.prefix": "Kommenter på ",
"ui.lineComment.label.suffix": "", "ui.lineComment.label.suffix": "",

View File

@@ -16,7 +16,7 @@ export const dict = {
"ui.sessionReview.image.loading": "Wird geladen...", "ui.sessionReview.image.loading": "Wird geladen...",
"ui.sessionReview.image.placeholder": "Bild", "ui.sessionReview.image.placeholder": "Bild",
"ui.sessionReview.largeDiff.title": "Diff zu groß zum Rendern", "ui.sessionReview.largeDiff.title": "Diff zu groß zum Rendern",
"ui.sessionReview.largeDiff.meta": "Limit: {{lines}} Zeilen / {{limit}}. Aktuell: {{current}}.", "ui.sessionReview.largeDiff.meta": "Limit: {{limit}} geänderte Zeilen. Aktuell: {{current}} geänderte Zeilen.",
"ui.sessionReview.largeDiff.renderAnyway": "Trotzdem rendern", "ui.sessionReview.largeDiff.renderAnyway": "Trotzdem rendern",
"ui.lineComment.label.prefix": "Kommentar zu ", "ui.lineComment.label.prefix": "Kommentar zu ",
"ui.lineComment.label.suffix": "", "ui.lineComment.label.suffix": "",

View File

@@ -11,7 +11,7 @@ export const dict = {
"ui.sessionReview.image.loading": "Loading...", "ui.sessionReview.image.loading": "Loading...",
"ui.sessionReview.image.placeholder": "Image", "ui.sessionReview.image.placeholder": "Image",
"ui.sessionReview.largeDiff.title": "Diff too large to render", "ui.sessionReview.largeDiff.title": "Diff too large to render",
"ui.sessionReview.largeDiff.meta": "Limit: {{lines}} lines / {{limit}}. Current: {{current}}.", "ui.sessionReview.largeDiff.meta": "Limit: {{limit}} changed lines. Current: {{current}} changed lines.",
"ui.sessionReview.largeDiff.renderAnyway": "Render anyway", "ui.sessionReview.largeDiff.renderAnyway": "Render anyway",
"ui.lineComment.label.prefix": "Comment on ", "ui.lineComment.label.prefix": "Comment on ",

View File

@@ -11,7 +11,7 @@ export const dict = {
"ui.sessionReview.image.loading": "Cargando...", "ui.sessionReview.image.loading": "Cargando...",
"ui.sessionReview.image.placeholder": "Imagen", "ui.sessionReview.image.placeholder": "Imagen",
"ui.sessionReview.largeDiff.title": "Diff demasiado grande para renderizar", "ui.sessionReview.largeDiff.title": "Diff demasiado grande para renderizar",
"ui.sessionReview.largeDiff.meta": "Límite: {{lines}} líneas / {{limit}}. Actual: {{current}}.", "ui.sessionReview.largeDiff.meta": "Límite: {{limit}} líneas modificadas. Actual: {{current}} líneas modificadas.",
"ui.sessionReview.largeDiff.renderAnyway": "Renderizar de todos modos", "ui.sessionReview.largeDiff.renderAnyway": "Renderizar de todos modos",
"ui.lineComment.label.prefix": "Comentar en ", "ui.lineComment.label.prefix": "Comentar en ",

View File

@@ -11,7 +11,7 @@ export const dict = {
"ui.sessionReview.image.loading": "Chargement...", "ui.sessionReview.image.loading": "Chargement...",
"ui.sessionReview.image.placeholder": "Image", "ui.sessionReview.image.placeholder": "Image",
"ui.sessionReview.largeDiff.title": "Diff trop volumineux pour être affiché", "ui.sessionReview.largeDiff.title": "Diff trop volumineux pour être affiché",
"ui.sessionReview.largeDiff.meta": "Limite : {{lines}} lignes / {{limit}}. Actuel : {{current}}.", "ui.sessionReview.largeDiff.meta": "Limite : {{limit}} lignes modifiées. Actuel : {{current}} lignes modifiées.",
"ui.sessionReview.largeDiff.renderAnyway": "Afficher quand même", "ui.sessionReview.largeDiff.renderAnyway": "Afficher quand même",
"ui.lineComment.label.prefix": "Commenter sur ", "ui.lineComment.label.prefix": "Commenter sur ",

View File

@@ -12,7 +12,7 @@ export const dict = {
"ui.sessionReview.image.loading": "読み込み中...", "ui.sessionReview.image.loading": "読み込み中...",
"ui.sessionReview.image.placeholder": "画像", "ui.sessionReview.image.placeholder": "画像",
"ui.sessionReview.largeDiff.title": "差分が大きすぎて表示できません", "ui.sessionReview.largeDiff.title": "差分が大きすぎて表示できません",
"ui.sessionReview.largeDiff.meta": "上限: {{lines}} 行 / {{limit}}。現在: {{current}}。", "ui.sessionReview.largeDiff.meta": "上限: {{limit}} 変更行。現在: {{current}} 変更行。",
"ui.sessionReview.largeDiff.renderAnyway": "それでも表示する", "ui.sessionReview.largeDiff.renderAnyway": "それでも表示する",
"ui.lineComment.label.prefix": "", "ui.lineComment.label.prefix": "",
"ui.lineComment.label.suffix": "へのコメント", "ui.lineComment.label.suffix": "へのコメント",

View File

@@ -11,7 +11,7 @@ export const dict = {
"ui.sessionReview.image.loading": "로딩 중...", "ui.sessionReview.image.loading": "로딩 중...",
"ui.sessionReview.image.placeholder": "이미지", "ui.sessionReview.image.placeholder": "이미지",
"ui.sessionReview.largeDiff.title": "차이가 너무 커서 렌더링할 수 없습니다", "ui.sessionReview.largeDiff.title": "차이가 너무 커서 렌더링할 수 없습니다",
"ui.sessionReview.largeDiff.meta": "제한: {{lines}}줄 / {{limit}}. 현재: {{current}}.", "ui.sessionReview.largeDiff.meta": "제한: {{limit}} 변경 줄. 현재: {{current}} 변경 줄.",
"ui.sessionReview.largeDiff.renderAnyway": "그래도 렌더링", "ui.sessionReview.largeDiff.renderAnyway": "그래도 렌더링",
"ui.lineComment.label.prefix": "", "ui.lineComment.label.prefix": "",

View File

@@ -14,7 +14,7 @@ export const dict: Record<Keys, string> = {
"ui.sessionReview.image.loading": "Laster...", "ui.sessionReview.image.loading": "Laster...",
"ui.sessionReview.image.placeholder": "Bilde", "ui.sessionReview.image.placeholder": "Bilde",
"ui.sessionReview.largeDiff.title": "Diff er for stor til å gjengi", "ui.sessionReview.largeDiff.title": "Diff er for stor til å gjengi",
"ui.sessionReview.largeDiff.meta": "Grense: {{lines}} linjer / {{limit}}. Nåværende: {{current}}.", "ui.sessionReview.largeDiff.meta": "Grense: {{limit}} endrede linjer. Nåværende: {{current}} endrede linjer.",
"ui.sessionReview.largeDiff.renderAnyway": "Gjengi likevel", "ui.sessionReview.largeDiff.renderAnyway": "Gjengi likevel",
"ui.lineComment.label.prefix": "Kommenter på ", "ui.lineComment.label.prefix": "Kommenter på ",

View File

@@ -12,7 +12,7 @@ export const dict = {
"ui.sessionReview.image.loading": "Ładowanie...", "ui.sessionReview.image.loading": "Ładowanie...",
"ui.sessionReview.image.placeholder": "Obraz", "ui.sessionReview.image.placeholder": "Obraz",
"ui.sessionReview.largeDiff.title": "Diff jest zbyt duży, aby go wyrenderować", "ui.sessionReview.largeDiff.title": "Diff jest zbyt duży, aby go wyrenderować",
"ui.sessionReview.largeDiff.meta": "Limit: {{lines}} linii / {{limit}}. Obecnie: {{current}}.", "ui.sessionReview.largeDiff.meta": "Limit: {{limit}} zmienionych linii. Obecnie: {{current}} zmienionych linii.",
"ui.sessionReview.largeDiff.renderAnyway": "Renderuj mimo to", "ui.sessionReview.largeDiff.renderAnyway": "Renderuj mimo to",
"ui.lineComment.label.prefix": "Komentarz do ", "ui.lineComment.label.prefix": "Komentarz do ",
"ui.lineComment.label.suffix": "", "ui.lineComment.label.suffix": "",

View File

@@ -12,7 +12,7 @@ export const dict = {
"ui.sessionReview.image.loading": "Загрузка...", "ui.sessionReview.image.loading": "Загрузка...",
"ui.sessionReview.image.placeholder": "Изображение", "ui.sessionReview.image.placeholder": "Изображение",
"ui.sessionReview.largeDiff.title": "Diff слишком большой для отображения", "ui.sessionReview.largeDiff.title": "Diff слишком большой для отображения",
"ui.sessionReview.largeDiff.meta": "Лимит: {{lines}} строк / {{limit}}. Текущий: {{current}}.", "ui.sessionReview.largeDiff.meta": "Лимит: {{limit}} изменённых строк. Текущий: {{current}} изменённых строк.",
"ui.sessionReview.largeDiff.renderAnyway": "Отобразить всё равно", "ui.sessionReview.largeDiff.renderAnyway": "Отобразить всё равно",
"ui.lineComment.label.prefix": "Комментарий к ", "ui.lineComment.label.prefix": "Комментарий к ",
"ui.lineComment.label.suffix": "", "ui.lineComment.label.suffix": "",

View File

@@ -11,7 +11,8 @@ export const dict = {
"ui.sessionReview.image.loading": "กำลังโหลด...", "ui.sessionReview.image.loading": "กำลังโหลด...",
"ui.sessionReview.image.placeholder": "รูปภาพ", "ui.sessionReview.image.placeholder": "รูปภาพ",
"ui.sessionReview.largeDiff.title": "Diff มีขนาดใหญ่เกินไปจนไม่สามารถแสดงผลได้", "ui.sessionReview.largeDiff.title": "Diff มีขนาดใหญ่เกินไปจนไม่สามารถแสดงผลได้",
"ui.sessionReview.largeDiff.meta": "ขีดจำกัด: {{lines}} บรรทัด / {{limit}}. ปัจจุบัน: {{current}}.", "ui.sessionReview.largeDiff.meta":
"ขีดจำกัด: {{limit}} บรรทัดที่เปลี่ยนแปลง. ปัจจุบัน: {{current}} บรรทัดที่เปลี่ยนแปลง.",
"ui.sessionReview.largeDiff.renderAnyway": "แสดงผลต่อไป", "ui.sessionReview.largeDiff.renderAnyway": "แสดงผลต่อไป",
"ui.lineComment.label.prefix": "แสดงความคิดเห็นบน ", "ui.lineComment.label.prefix": "แสดงความคิดเห็นบน ",

View File

@@ -15,7 +15,7 @@ export const dict = {
"ui.sessionReview.image.loading": "加载中...", "ui.sessionReview.image.loading": "加载中...",
"ui.sessionReview.image.placeholder": "图片", "ui.sessionReview.image.placeholder": "图片",
"ui.sessionReview.largeDiff.title": "差异过大,无法渲染", "ui.sessionReview.largeDiff.title": "差异过大,无法渲染",
"ui.sessionReview.largeDiff.meta": "限制:{{lines}} 行 / {{limit}}。当前:{{current}}。", "ui.sessionReview.largeDiff.meta": "限制:{{limit}} 行变更。当前:{{current}} 行变更。",
"ui.sessionReview.largeDiff.renderAnyway": "仍然渲染", "ui.sessionReview.largeDiff.renderAnyway": "仍然渲染",
"ui.lineComment.label.prefix": "评论 ", "ui.lineComment.label.prefix": "评论 ",

View File

@@ -15,7 +15,7 @@ export const dict = {
"ui.sessionReview.image.loading": "載入中...", "ui.sessionReview.image.loading": "載入中...",
"ui.sessionReview.image.placeholder": "圖片", "ui.sessionReview.image.placeholder": "圖片",
"ui.sessionReview.largeDiff.title": "差異過大,無法渲染", "ui.sessionReview.largeDiff.title": "差異過大,無法渲染",
"ui.sessionReview.largeDiff.meta": "限制:{{lines}} 行 / {{limit}}。目前:{{current}}。", "ui.sessionReview.largeDiff.meta": "限制:{{limit}} 行變更。目前:{{current}} 行變更。",
"ui.sessionReview.largeDiff.renderAnyway": "仍然渲染", "ui.sessionReview.largeDiff.renderAnyway": "仍然渲染",
"ui.lineComment.label.prefix": "評論 ", "ui.lineComment.label.prefix": "評論 ",