-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix(web): keep oversized diff lines from locking the UI #2338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,8 +29,7 @@ import { readLocalApi } from "../localApi"; | |
| import { resolvePathLinkTarget } from "../terminal-links"; | ||
| import { parseDiffRouteSearch, stripDiffSearchParams } from "../diffRouteSearch"; | ||
| import { useTheme } from "../hooks/useTheme"; | ||
| import { buildPatchCacheKey } from "../lib/diffRendering"; | ||
| import { resolveDiffThemeName } from "../lib/diffRendering"; | ||
| import { buildPatchCacheKey, canRenderFileDiff, resolveDiffThemeName } from "../lib/diffRendering"; | ||
| import { useTurnDiffSummaries } from "../hooks/useTurnDiffSummaries"; | ||
| import { selectProjectByRef, useStore } from "../store"; | ||
| import { createThreadSelectorByRef } from "../storeSelectors"; | ||
|
|
@@ -328,12 +327,22 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) { | |
| if (!renderablePatch || renderablePatch.kind !== "files") { | ||
| return []; | ||
| } | ||
| return renderablePatch.files.toSorted((left, right) => | ||
| resolveFileDiffPath(left).localeCompare(resolveFileDiffPath(right), undefined, { | ||
| numeric: true, | ||
| sensitivity: "base", | ||
| }), | ||
| ); | ||
| return renderablePatch.files | ||
| .map((fileDiff) => ({ | ||
| canRender: canRenderFileDiff(fileDiff), | ||
| fileDiff, | ||
| filePath: resolveFileDiffPath(fileDiff), | ||
| })) | ||
| .toSorted((left, right) => { | ||
| const renderOrder = Number(!left.canRender) - Number(!right.canRender); | ||
| if (renderOrder !== 0) { | ||
| return renderOrder; | ||
| } | ||
| return left.filePath.localeCompare(right.filePath, undefined, { | ||
| numeric: true, | ||
| sensitivity: "base", | ||
| }); | ||
| }); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrong key in visibility effectMedium Severity After Reviewed by Cursor Bugbot for commit 57d9293. Configure here. |
||
| }, [renderablePatch]); | ||
|
|
||
| useEffect(() => { | ||
|
|
@@ -659,8 +668,7 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) { | |
| intersectionObserverMargin: 1200, | ||
| }} | ||
| > | ||
| {renderableFiles.map((fileDiff) => { | ||
| const filePath = resolveFileDiffPath(fileDiff); | ||
| {renderableFiles.map(({ canRender, fileDiff, filePath }) => { | ||
| const fileKey = buildFileDiffRenderKey(fileDiff); | ||
| const themedFileKey = `${fileKey}:${resolvedTheme}`; | ||
| const collapsed = collapsedDiffFileKeys.has(fileKey); | ||
|
|
@@ -712,8 +720,17 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) { | |
| theme: resolveDiffThemeName(resolvedTheme), | ||
| themeType: resolvedTheme as DiffThemeType, | ||
| unsafeCSS: DIFF_PANEL_UNSAFE_CSS, | ||
| collapsed: !canRender, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate collapsed option keyMedium Severity The Reviewed by Cursor Bugbot for commit 57d9293. Configure here. |
||
| }} | ||
| /> | ||
|
|
||
| {!canRender && ( | ||
| <div className="px-3 py-3 text-[11px] leading-relaxed text-muted-foreground"> | ||
| <p> | ||
| This file is too large to display. Open the file to inspect the change. | ||
| </p> | ||
| </div> | ||
| )} | ||
| </div> | ||
| ); | ||
| })} | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this, but everything else looks good