Fix inconsistent path normalization in diff handler and remove dead showParentheses prop
- Normalize file path passed from 'View diff' button via normalizeFilePath() to match the normalized paths used by tree node click handlers - Export normalizeFilePath from turnDiffTree for reuse - Remove unused showParentheses prop from DiffStatLabel (dead code) Co-authored-by: Julius Marminge <[email protected]>
This commit is contained in:
1 parent
c45ea6d6f9
commit
74d445af4d
2 files changed
+13
-7
No files matched your search
@@ -71,6 +71,7 @@ import { useTheme } from "../hooks/useTheme";
|
||||
import { useTurnDiffSummaries } from "../hooks/useTurnDiffSummaries";
|
||||
import {
|
||||
buildTurnDiffTree,
|
||||
normalizeFilePath,
|
||||
summarizeTurnDiffStats,
|
||||
type TurnDiffTreeNode,
|
||||
} from "../lib/turnDiffTree";
|
||||
@@ -3141,16 +3142,13 @@ function hasNonZeroStat(stat: { additions: number; deletions: number }): boolean
|
||||
const DiffStatLabel = memo(function DiffStatLabel(props: {
|
||||
additions: number;
|
||||
deletions: number;
|
||||
showParentheses?: boolean;
|
||||
}) {
|
||||
const { additions, deletions, showParentheses = false } = props;
|
||||
const { additions, deletions } = props;
|
||||
return (
|
||||
<>
|
||||
{showParentheses && <span className="text-muted-foreground/70">(</span>}
|
||||
<span className="text-success">+{additions}</span>
|
||||
<span className="mx-0.5 text-muted-foreground/70">/</span>
|
||||
<span className="text-destructive">-{deletions}</span>
|
||||
{showParentheses && <span className="text-muted-foreground/70">)</span>}
|
||||
</>
|
||||
);
|
||||
});
|
||||
@@ -3708,9 +3706,13 @@ const MessagesTimeline = memo(function MessagesTimeline({
|
||||
type="button"
|
||||
size="xs"
|
||||
variant="outline"
|
||||
onClick={() =>
|
||||
onOpenTurnDiff(turnSummary.turnId, checkpointFiles[0]?.path)
|
||||
}
|
||||
onClick={() => {
|
||||
const rawPath = checkpointFiles[0]?.path;
|
||||
onOpenTurnDiff(
|
||||
turnSummary.turnId,
|
||||
rawPath ? normalizeFilePath(rawPath) : undefined,
|
||||
);
|
||||
}}
|
||||
>
|
||||
View diff
|
||||
</Button>
|
||||
|
||||
@@ -39,6 +39,10 @@ function normalizePathSegments(pathValue: string): string[] {
|
||||
.filter((segment) => segment.length > 0);
|
||||
}
|
||||
|
||||
export function normalizeFilePath(pathValue: string): string {
|
||||
return normalizePathSegments(pathValue).join("/");
|
||||
}
|
||||
|
||||
function compareByName(a: { name: string }, b: { name: string }): number {
|
||||
return a.name.localeCompare(b.name, undefined, SORT_LOCALE_OPTIONS);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user