Skip to content

Commit b7b239f

Browse files
committed
🤖 fix: use resolved theme for visual rendering
1 parent a3e1d4f commit b7b239f

5 files changed

Lines changed: 22 additions & 15 deletions

File tree

src/browser/components/Messages/MarkdownComponents.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ interface CodeBlockProps {
4242
*/
4343
const CodeBlock: React.FC<CodeBlockProps> = ({ code, language }) => {
4444
const [highlightedLines, setHighlightedLines] = useState<string[] | null>(null);
45-
const { theme: themeMode } = useTheme();
45+
const { resolvedTheme } = useTheme();
4646

4747
// Split code into lines, removing trailing empty line
4848
const plainLines = code
@@ -51,7 +51,7 @@ const CodeBlock: React.FC<CodeBlockProps> = ({ code, language }) => {
5151

5252
useEffect(() => {
5353
let cancelled = false;
54-
const isLight = themeMode === "light" || themeMode.endsWith("-light");
54+
const isLight = resolvedTheme === "light" || resolvedTheme.endsWith("-light");
5555
const theme = isLight ? "light" : "dark";
5656

5757
setHighlightedLines(null);
@@ -78,7 +78,7 @@ const CodeBlock: React.FC<CodeBlockProps> = ({ code, language }) => {
7878
return () => {
7979
cancelled = true;
8080
};
81-
}, [code, language, themeMode]);
81+
}, [code, language, resolvedTheme]);
8282

8383
const lines = highlightedLines ?? plainLines;
8484
const isSingleLine = lines.length === 1;

src/browser/components/ProjectSidebar.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,9 @@ const ProjectSidebarInner: React.FC<ProjectSidebarProps> = ({
245245
} = useProjectContext();
246246

247247
// Theme for logo variant
248-
const { theme } = useTheme();
249-
const MuxLogo = theme === "dark" || theme.endsWith("-dark") ? MuxLogoDark : MuxLogoLight;
248+
const { resolvedTheme } = useTheme();
249+
const MuxLogo =
250+
resolvedTheme === "dark" || resolvedTheme.endsWith("-dark") ? MuxLogoDark : MuxLogoLight;
250251

251252
// Mobile breakpoint for auto-closing sidebar
252253
const MOBILE_BREAKPOINT = 768;

src/browser/components/RightSidebar/FileViewer/TextFileViewer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function buildUnifiedView(content: string, diffText: string): UnifiedLine[] | nu
137137
}
138138

139139
export const TextFileViewer: React.FC<TextFileViewerProps> = (props) => {
140-
const { theme: themeMode } = useTheme();
140+
const { resolvedTheme } = useTheme();
141141
const language = getLanguageFromPath(props.filePath);
142142
const languageDisplayName = getLanguageDisplayName(language);
143143

@@ -160,7 +160,7 @@ export const TextFileViewer: React.FC<TextFileViewerProps> = (props) => {
160160
? unifiedLines.map((l) => l.content)
161161
: fileLines.filter((l, i, arr) => i < arr.length - 1 || l !== "");
162162

163-
const theme = themeMode === "light" || themeMode.endsWith("-light") ? "light" : "dark";
163+
const theme = resolvedTheme === "light" || resolvedTheme.endsWith("-light") ? "light" : "dark";
164164

165165
let cancelled = false;
166166

@@ -181,7 +181,7 @@ export const TextFileViewer: React.FC<TextFileViewerProps> = (props) => {
181181
return () => {
182182
cancelled = true;
183183
};
184-
}, [unifiedLines, fileLines, language, themeMode]);
184+
}, [unifiedLines, fileLines, language, resolvedTheme]);
185185

186186
const addedCount = unifiedLines?.filter((l) => l.type === "added").length ?? 0;
187187
const removedCount = unifiedLines?.filter((l) => l.type === "removed").length ?? 0;

src/browser/components/shared/DiffRenderer.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -500,13 +500,19 @@ export const DiffRenderer: React.FC<DiffRendererProps> = ({
500500
className,
501501
}) => {
502502
// Detect language for syntax highlighting (memoized to prevent repeated detection)
503-
const { theme } = useTheme();
503+
const { resolvedTheme } = useTheme();
504504
const language = React.useMemo(
505505
() => (filePath ? getLanguageFromPath(filePath) : "text"),
506506
[filePath]
507507
);
508508

509-
const highlightedChunks = useHighlightedDiff(content, language, oldStart, newStart, theme);
509+
const highlightedChunks = useHighlightedDiff(
510+
content,
511+
language,
512+
oldStart,
513+
newStart,
514+
resolvedTheme
515+
);
510516

511517
const lineNumberWidths = React.useMemo(() => {
512518
if (!showLineNumbers || !highlightedChunks) {
@@ -866,7 +872,7 @@ export const SelectableDiffRenderer = React.memo<SelectableDiffRendererProps>(
866872
window.removeEventListener("blur", stopDragging);
867873
};
868874
}, []);
869-
const { theme } = useTheme();
875+
const { resolvedTheme } = useTheme();
870876
const [selection, setSelection] = React.useState<LineSelection | null>(null);
871877

872878
// Notify parent when composition state changes
@@ -895,7 +901,7 @@ export const SelectableDiffRenderer = React.memo<SelectableDiffRendererProps>(
895901
enableHighlighting ? language : "text",
896902
oldStart,
897903
newStart,
898-
theme
904+
resolvedTheme
899905
);
900906

901907
// Parse raw lines once for use in lineData

src/browser/components/tools/shared/HighlightedCode.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ export const HighlightedCode: React.FC<HighlightedCodeProps> = ({
2525
startLineNumber = 1,
2626
}) => {
2727
const [highlightedLines, setHighlightedLines] = useState<string[] | null>(null);
28-
const { theme: themeMode } = useTheme();
28+
const { resolvedTheme } = useTheme();
2929

3030
const plainLines = code.split("\n").filter((line, i, arr) => i < arr.length - 1 || line !== "");
3131

3232
useEffect(() => {
3333
let cancelled = false;
34-
const theme = themeMode === "light" || themeMode.endsWith("-light") ? "light" : "dark";
34+
const theme = resolvedTheme === "light" || resolvedTheme.endsWith("-light") ? "light" : "dark";
3535

3636
setHighlightedLines(null);
3737

@@ -53,7 +53,7 @@ export const HighlightedCode: React.FC<HighlightedCodeProps> = ({
5353
return () => {
5454
cancelled = true;
5555
};
56-
}, [code, language, themeMode]);
56+
}, [code, language, resolvedTheme]);
5757

5858
const lines = highlightedLines ?? plainLines;
5959

0 commit comments

Comments
 (0)