-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
ref(issues): improve similar issues stacktrace diff #97645
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5b4d319
to
8310f11
Compare
scttcper
reviewed
Aug 14, 2025
static/app/components/splitDiff.tsx
Outdated
Comment on lines
70
to
86
? (() => { | ||
const leftText = line.reduce( | ||
(acc, result) => (result.added ? acc : acc + result.value), | ||
'' | ||
); | ||
const rightText = line.reduce( | ||
(acc, result) => (result.removed ? acc : acc + result.value), | ||
'' | ||
); | ||
|
||
// Handle edge cases where text might be empty | ||
if (!leftText && !rightText) { | ||
return line; // Return original line if both texts are empty | ||
} | ||
|
||
return diffWords(leftText, rightText); | ||
})() |
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.
don't use iife, make a small named function somewhere
scttcper
approved these changes
Aug 14, 2025
static/app/components/splitDiff.tsx
Outdated
Comment on lines
58
to
82
const processResults = (): Change[][] => { | ||
let currentLine: Change[] = []; | ||
const processedLines: Change[][] = []; | ||
for (const change of results) { | ||
const lines = change.value.split('\n'); | ||
for (let i = 0; i < lines.length; i++) { | ||
const lineValue = lines[i]; | ||
if (lineValue !== undefined && lineValue !== '') { | ||
currentLine.push({ | ||
value: lineValue, | ||
added: change.added, | ||
removed: change.removed, | ||
}); | ||
} | ||
if (i < lines.length - 1) { | ||
processedLines.push(currentLine); | ||
currentLine = []; | ||
} | ||
} | ||
} | ||
if (currentLine.length > 0) { | ||
processedLines.push(currentLine); | ||
} | ||
return processedLines; | ||
}; |
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.
lets wrap this in useMemo
priscilawebdev
pushed a commit
that referenced
this pull request
Aug 25, 2025
andrewshie-sentry
pushed a commit
that referenced
this pull request
Aug 26, 2025
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Improve similar issues stacktrace diff by changing diff
type
tolines
, and then diffing those lines byword
.Before/After
Change to
lines
The diff library does not know how to split stacktraces into words effectively, leading to weird formatting like file names and function calls being split up.

Changing the diff type to
lines
preserves the structure of the stack trace when diffing. Then, diffing those split lines bywords
keeps the structure made withlines
but gives a more accurate diff.processChange
diffFn()
returns a list ofChange
objects whos values have to be put back together to form the stack trace in the UI. To preserve formatting, each change has to only contain one line, or you get multi line highlights like this.Additionally, including newlines can cause spacing issues(below) in the

<SplitBody>
component so generally they are removed, and lines are broken up instead by the<Line>
component.