Skip to content

Commit 662248a

Browse files
committed
fix: compact diff preview and apply palette to review comments
1 parent 830b061 commit 662248a

5 files changed

Lines changed: 27 additions & 10 deletions

File tree

‎apps/mobile/src/features/files/SourceFileSurface.tsx‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function NativeSourceFileSurface(
153153
) {
154154
const { NativeView, onRefresh } = props;
155155
const { codeSurface, codeWordBreak, nativeSourceStyle } = useAppearanceCodeSurface();
156-
const { themeAppearance, themeId } = useAppearancePreferences();
156+
const { themeAppearance, themeId, diffColorScheme } = useAppearancePreferences();
157157
const appTheme = useUniwindTheme();
158158
const { width: viewportWidth } = useWindowDimensions();
159159
const { rowsJson, status, targetIndex, tokens } = useSourceFileModel(props);
@@ -175,8 +175,11 @@ function NativeSourceFileSurface(
175175
[targetIndex],
176176
);
177177
const themeJson = useMemo(
178-
() => JSON.stringify(createNativeReviewDiffTheme(themeAppearance, themeId, appTheme)),
179-
[appTheme, themeAppearance, themeId],
178+
() =>
179+
JSON.stringify(
180+
createNativeReviewDiffTheme(themeAppearance, themeId, appTheme, diffColorScheme),
181+
),
182+
[appTheme, themeAppearance, themeId, diffColorScheme],
180183
);
181184
const styleJson = useMemo(() => JSON.stringify(nativeSourceStyle), [nativeSourceStyle]);
182185
const contentWidth = codeWordBreak

‎apps/mobile/src/features/review/nativeReviewDiffAdapter.test.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ describe("createNativeReviewDiffTheme", () => {
198198
appearance,
199199
themeId,
200200
appTheme(themeId, appearance),
201+
"red-green",
201202
);
202203
for (const color of Object.values(theme)) {
203204
expect(color, `${themeId}/${appearance}`).toMatch(/^#[\da-f]{6}$/i);
@@ -207,8 +208,13 @@ describe("createNativeReviewDiffTheme", () => {
207208
});
208209

209210
it("uses the selected app palette for native code surfaces", () => {
210-
const standard = createNativeReviewDiffTheme("dark", "t3-code", appTheme("t3-code", "dark"));
211-
const iris = createNativeReviewDiffTheme("dark", "iris", appTheme("iris", "dark"));
211+
const standard = createNativeReviewDiffTheme(
212+
"dark",
213+
"t3-code",
214+
appTheme("t3-code", "dark"),
215+
"red-green",
216+
);
217+
const iris = createNativeReviewDiffTheme("dark", "iris", appTheme("iris", "dark"), "red-green");
212218

213219
expect(iris.background).not.toBe(standard.background);
214220
expect(iris.hunkText).not.toBe(standard.hunkText);

‎apps/mobile/src/features/review/nativeReviewDiffAdapter.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export function createNativeReviewDiffTheme(
145145
scheme: TerminalAppearanceScheme,
146146
themeId: MobileThemeId,
147147
appTheme: MobileThemeVariables,
148-
diffColorScheme: DiffColorScheme = "red-green",
148+
diffColorScheme: DiffColorScheme,
149149
): NativeReviewDiffTheme {
150150
const terminalTheme = getMobileTerminalTheme(themeId, scheme);
151151
const [, terminalRed] = terminalTheme.palette;

‎apps/mobile/src/features/threads/ThreadFeed.tsx‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,7 +1753,11 @@ const ReviewCommentCard = memo(function ReviewCommentCard(props: {
17531753
readonly colors: ReviewCommentColors;
17541754
}) {
17551755
const { codeSurface, nativeReviewDiffStyle } = useAppearanceCodeSurface();
1756-
const { themeAppearance: appearanceScheme, themeId } = useAppearancePreferences();
1756+
const {
1757+
themeAppearance: appearanceScheme,
1758+
themeId,
1759+
diffColorScheme,
1760+
} = useAppearancePreferences();
17571761
const appTheme = useUniwindTheme();
17581762
const NativeReviewDiffView = resolveNativeReviewDiffView();
17591763
const patch = useMemo(() => buildReviewCommentPatch(props.comment), [props.comment]);
@@ -1767,8 +1771,8 @@ const ReviewCommentCard = memo(function ReviewCommentCard(props: {
17671771
[nativeReviewDiffData.rows],
17681772
);
17691773
const nativeReviewDiffTheme = useMemo(
1770-
() => createNativeReviewDiffTheme(appearanceScheme, themeId, appTheme),
1771-
[appearanceScheme, appTheme, themeId],
1774+
() => createNativeReviewDiffTheme(appearanceScheme, themeId, appTheme, diffColorScheme),
1775+
[appearanceScheme, appTheme, themeId, diffColorScheme],
17721776
);
17731777
const nativeRowsJson = useMemo(() => JSON.stringify(compactNativeRows), [compactNativeRows]);
17741778
const nativeThemeJson = useMemo(

‎apps/web/src/components/settings/SettingsFontPreviews.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,14 @@ export function DiffColorsPreview() {
4141
return (
4242
<StyledDiffCodeView
4343
aria-label="Diff color preview"
44-
className="h-24 w-full overflow-hidden rounded-md border border-border/60"
44+
// This two-row sample stays still; CodeView's sticky offsets otherwise clip the last row.
45+
className="h-10 w-full overflow-hidden rounded-md ring-1 ring-border/60 [--diffs-gap-block:0px] [&_div:has(>diffs-container)]:static!"
4546
items={colorPreviewItems}
4647
options={{
4748
diffStyle: "unified",
49+
disableFileHeader: true,
50+
stickyHeaders: false,
51+
overflow: "wrap",
4852
theme: resolveDiffThemeName(resolvedTheme),
4953
preferredHighlighter: PREFERRED_HIGHLIGHTER,
5054
}}

0 commit comments

Comments
 (0)