diff --git a/packages/ui/src/components/session-review.tsx b/packages/ui/src/components/session-review.tsx
index 5f1e6b1ab..6ab922262 100644
--- a/packages/ui/src/components/session-review.tsx
+++ b/packages/ui/src/components/session-review.tsx
@@ -17,25 +17,7 @@ import { PreloadMultiFileDiffResult } from "@pierre/diffs/ssr"
import { type SelectedLineRange } from "@pierre/diffs"
import { Dynamic } from "solid-js/web"
-const MAX_DIFF_LINES = 20_000
-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`
-}
+const MAX_DIFF_CHANGED_LINES = 500
export type SessionReviewDiffStyle = "unified" | "split"
@@ -354,18 +336,13 @@ export const SessionReview = (props: SessionReviewProps) => {
const beforeText = () => (typeof diff.before === "string" ? diff.before : "")
const afterText = () => (typeof diff.after === "string" ? diff.after : "")
+ const changedLines = () => diff.additions + diff.deletions
const tooLarge = createMemo(() => {
if (!expanded()) return false
if (force()) return false
if (isImageFile(diff.file)) return false
-
- 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
+ return changedLines() > MAX_DIFF_CHANGED_LINES
})
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")}
- Limit: {MAX_DIFF_LINES.toLocaleString()} lines / {formatBytes(MAX_DIFF_BYTES)}.
- Current: {formatBytes(Math.max(beforeText().length, afterText().length))}.
+ {i18n.t("ui.sessionReview.largeDiff.meta", {
+ limit: MAX_DIFF_CHANGED_LINES.toLocaleString(),
+ current: changedLines().toLocaleString(),
+ })}