Skip to content

Commit d180c80

Browse files
authored
🤖 fix: diff padding strip font alignment (#1159)
The PaddingStrip component used `ch` units in its `gutterWidth` calculation but lacked the `font-monospace` class. Since `ch` units are relative to the font's "0" character width, the padding strip was misaligned with the actual `DiffLineGutter` which uses `font-monospace`. ## Fix Add `font-monospace` to PaddingStrip so `ch` units match DiffLineGutter. ## Verification The `DiffPaddingColors` story demonstrates diffswith colored padding (additions at top, deletions at bottom). Before the fix, the colored padding strip edge was misaligned with the line number gutter. --- _Generated with `mux` • Model: `anthropic:claude-opus-4-5` • Thinking: `high`_
1 parent 456bd03 commit d180c80

File tree

2 files changed

+64
-1
lines changed

2 files changed

+64
-1
lines changed

src/browser/components/shared/DiffRenderer.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,9 @@ export const DiffContainer: React.FC<
285285
: "8px";
286286

287287
// Padding strip mirrors gutter/content background split of diff lines
288+
// Must use font-monospace so ch units match DiffLineGutter's character widths
288289
const PaddingStrip = ({ lineType }: { lineType?: DiffLineType }) => (
289-
<div className="flex h-1.5">
290+
<div className="font-monospace flex h-1.5">
290291
<div
291292
className="shrink-0"
292293
style={{

src/browser/stories/App.chat.stories.tsx

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,3 +848,65 @@ export const DiffPaddingColors: AppStory = {
848848
},
849849
},
850850
};
851+
852+
/**
853+
* Story to verify diff padding alignment with high line numbers.
854+
* The ch unit misalignment bug is more visible with 3-digit line numbers.
855+
* The colored padding strip should align perfectly with the gutter edge.
856+
*/
857+
export const DiffPaddingAlignment: AppStory = {
858+
render: () => (
859+
<AppWithMocks
860+
setup={() =>
861+
setupSimpleChatStory({
862+
workspaceId: "ws-diff-alignment",
863+
messages: [
864+
createUserMessage("msg-1", "Show me a diff with high line numbers", {
865+
historySequence: 1,
866+
timestamp: STABLE_TIMESTAMP - 100000,
867+
}),
868+
createAssistantMessage(
869+
"msg-2",
870+
"Here's a diff ending with deletions at high line numbers:",
871+
{
872+
historySequence: 2,
873+
timestamp: STABLE_TIMESTAMP - 90000,
874+
toolCalls: [
875+
// Diff with 3-digit line numbers ending in deletions
876+
// Replicates the alignment issue from code review diffs
877+
createFileEditTool(
878+
"call-1",
879+
"src/ppo/train/config.rs",
880+
[
881+
"--- src/ppo/train/config.rs",
882+
"+++ src/ppo/train/config.rs",
883+
"@@ -374,7 +374,3 @@",
884+
" adj = LR_INCREASE_ADJ;",
885+
" }",
886+
" ",
887+
"- // Slow down learning rate when we're too stale.",
888+
"- if last_metrics.stop_reason == metrics::StopReason::TooStale {",
889+
"- adj = LR_DECREASE_ADJ;",
890+
"- }",
891+
].join("\n")
892+
),
893+
],
894+
}
895+
),
896+
],
897+
})
898+
}
899+
/>
900+
),
901+
parameters: {
902+
docs: {
903+
description: {
904+
story:
905+
"Verifies diff padding alignment with 3-digit line numbers. " +
906+
"The bottom red padding strip should align exactly with the gutter/content boundary. " +
907+
"Before the fix, the padding strip used ch units without font-monospace, " +
908+
"causing misalignment that scaled with line number width.",
909+
},
910+
},
911+
},
912+
};

0 commit comments

Comments
 (0)