Skip to content

Commit c697d81

Browse files
authored
Merge pull request #224 from GCWing/gcwing/dev
Merge gcwing/dev to main
2 parents 5e0ff9a + 0152194 commit c697d81

11 files changed

Lines changed: 438 additions & 188 deletions

File tree

‎src/web-ui/src/app/components/NavPanel/NavPanel.scss‎

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,6 +1375,9 @@ $_section-header-height: 24px;
13751375
bottom: calc(100% + 8px);
13761376
left: 50%;
13771377
transform: translateX(-50%);
1378+
display: flex;
1379+
flex-direction: column;
1380+
gap: $size-gap-1;
13781381
min-width: 140px;
13791382
padding: $size-gap-1;
13801383
background: var(--color-bg-elevated, #1e1e22);
@@ -1393,7 +1396,7 @@ $_section-header-height: 24px;
13931396
gap: $size-gap-2;
13941397
width: 100%;
13951398
padding: 0 $size-gap-2;
1396-
height: 30px;
1399+
height: 24px;
13971400
border: none;
13981401
border-radius: $size-radius-sm;
13991402
background: transparent;
@@ -1449,27 +1452,6 @@ $_section-header-height: 24px;
14491452
white-space: nowrap;
14501453
}
14511454

1452-
.bitfun-nav-panel__footer-multimodal-item-dot {
1453-
width: 5px;
1454-
height: 5px;
1455-
border-radius: 50%;
1456-
background: var(--color-primary);
1457-
flex-shrink: 0;
1458-
margin-left: auto;
1459-
}
1460-
1461-
// Active dot badge on main Layers button
1462-
.bitfun-nav-panel__footer-multimodal-dot {
1463-
position: absolute;
1464-
bottom: 5px;
1465-
right: 5px;
1466-
width: 4px;
1467-
height: 4px;
1468-
border-radius: 50%;
1469-
background: var(--color-primary);
1470-
pointer-events: none;
1471-
}
1472-
14731455
// Hover-open subtle glow on the main button
14741456
.bitfun-nav-panel__footer-btn--icon.is-hover-open {
14751457
color: var(--color-text-primary);

‎src/web-ui/src/app/components/NavPanel/components/PersistentFooterActions.tsx‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,6 @@ const PersistentFooterActions: React.FC = () => {
270270
aria-haspopup="menu"
271271
>
272272
<Layers size={15} />
273-
{isAnyActive && (
274-
<span className="bitfun-nav-panel__footer-multimodal-dot" aria-hidden />
275-
)}
276273
</button>
277274
</Tooltip>
278275

@@ -291,7 +288,6 @@ const PersistentFooterActions: React.FC = () => {
291288
>
292289
<Globe size={13} className="bitfun-nav-panel__footer-multimodal-item-icon" />
293290
<span className="bitfun-nav-panel__footer-multimodal-item-label">{t('scenes.browser')}</span>
294-
{isBrowserActive && <span className="bitfun-nav-panel__footer-multimodal-item-dot" aria-hidden />}
295291
</button>
296292

297293
<button
@@ -303,7 +299,6 @@ const PersistentFooterActions: React.FC = () => {
303299
>
304300
<Network size={13} className="bitfun-nav-panel__footer-multimodal-item-icon" />
305301
<span className="bitfun-nav-panel__footer-multimodal-item-label">{t('scenes.mermaidEditor')}</span>
306-
{isMermaidActive && <span className="bitfun-nav-panel__footer-multimodal-item-dot" aria-hidden />}
307302
</button>
308303
</div>
309304
)}

‎src/web-ui/src/flow_chat/components/CodePreview.scss‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
@use '../../component-library/styles/_extended-mixins' as mixins;
77

88
.code-preview {
9+
--markdown-font-mono: "Fira Code", "JetBrains Mono", Consolas, "Courier New", monospace;
10+
911
position: relative;
1012
width: 100%;
1113
background: transparent;
@@ -29,6 +31,13 @@
2931
white-space: pre-wrap !important;
3032
word-break: break-word !important;
3133
cursor: text;
34+
font-family: var(--markdown-font-mono, "Fira Code", "JetBrains Mono", Consolas, "Courier New", monospace) !important;
35+
font-weight: 400 !important;
36+
37+
// Prism themes mark many tokens bold; match markdown body / code blocks (regular weight).
38+
span[style] {
39+
font-weight: 400 !important;
40+
}
3241

3342
> span[style] {
3443
&:hover {
@@ -113,5 +122,9 @@
113122
.linenumber {
114123
color: var(--color-text-muted, #94a3b8) !important;
115124
}
125+
126+
pre code > span[style]:hover {
127+
background-color: rgba(0, 0, 0, 0.06) !important;
128+
}
116129
}
117130
}

‎src/web-ui/src/flow_chat/components/CodePreview.tsx‎

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313

1414
import React, { useMemo, memo, useRef, useEffect, useState, useCallback } from 'react';
1515
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
16-
import { vscDarkPlus } from 'react-syntax-highlighter/dist/esm/styles/prism';
1716
import { getPrismLanguage } from '@/infrastructure/language-detection';
17+
import { useTheme } from '@/infrastructure/theme';
18+
import { buildCodePreviewPrismStyle, CODE_PREVIEW_FONT_FAMILY } from './codePreviewPrismTheme';
1819
import './CodePreview.scss';
1920

2021
export interface CodePreviewProps {
@@ -46,29 +47,6 @@ function detectLanguageFromPath(filePath: string): string {
4647
return getPrismLanguage(filePath);
4748
}
4849

49-
/**
50-
* Custom theme derived from vscDarkPlus with project-specific tweaks.
51-
*/
52-
const customStyle = {
53-
...vscDarkPlus,
54-
'pre[class*="language-"]': {
55-
...vscDarkPlus['pre[class*="language-"]'],
56-
margin: 0,
57-
padding: 0,
58-
background: 'transparent',
59-
fontSize: '12px',
60-
lineHeight: '1.6',
61-
fontFamily: "'JetBrains Mono', 'Fira Code', 'SF Mono', 'Consolas', 'Monaco', 'Courier New', monospace",
62-
},
63-
'code[class*="language-"]': {
64-
...vscDarkPlus['code[class*="language-"]'],
65-
background: 'transparent',
66-
fontSize: '12px',
67-
lineHeight: '1.6',
68-
fontFamily: "'JetBrains Mono', 'Fira Code', 'SF Mono', 'Consolas', 'Monaco', 'Courier New', monospace",
69-
},
70-
};
71-
7250
/**
7351
* CodePreview component with streaming-friendly syntax highlighting.
7452
*/
@@ -83,6 +61,9 @@ export const CodePreview: React.FC<CodePreviewProps> = memo(({
8361
maxHeight = 400,
8462
onLineClick,
8563
}) => {
64+
const { isLight } = useTheme();
65+
const prismStyle = useMemo(() => buildCodePreviewPrismStyle(isLight), [isLight]);
66+
8667
const containerRef = useRef<HTMLDivElement>(null);
8768
const prevContentLengthRef = useRef(0);
8869

@@ -151,7 +132,7 @@ export const CodePreview: React.FC<CodePreviewProps> = memo(({
151132
>
152133
<SyntaxHighlighter
153134
language={detectedLanguage}
154-
style={customStyle}
135+
style={prismStyle}
155136
showLineNumbers={showLineNumbers}
156137
wrapLines={true}
157138
wrapLongLines={true}
@@ -164,9 +145,10 @@ export const CodePreview: React.FC<CodePreviewProps> = memo(({
164145
}}
165146
codeTagProps={{
166147
style: {
167-
fontFamily: "'JetBrains Mono', 'Fira Code', 'SF Mono', 'Consolas', 'Monaco', 'Courier New', monospace",
148+
fontFamily: CODE_PREVIEW_FONT_FAMILY,
168149
fontSize: '12px',
169150
lineHeight: '1.6',
151+
fontWeight: 400,
170152
}
171153
}}
172154
lineNumberStyle={{
@@ -175,7 +157,7 @@ export const CodePreview: React.FC<CodePreviewProps> = memo(({
175157
textAlign: 'right',
176158
userSelect: 'none',
177159
color: 'var(--color-text-muted, #666)',
178-
opacity: 0.6,
160+
opacity: isLight ? 0.88 : 0.6,
179161
}}
180162
>
181163
{content}

‎src/web-ui/src/flow_chat/components/InlineDiffPreview.scss‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
*/
55

66
.inline-diff-preview {
7+
--markdown-font-mono: "Fira Code", "JetBrains Mono", Consolas, "Courier New", monospace;
8+
79
position: relative;
810
width: 100%;
911
background: transparent;
10-
font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Consolas', 'Monaco', 'Courier New', monospace;
12+
font-family: var(--markdown-font-mono, "Fira Code", "JetBrains Mono", Consolas, "Courier New", monospace);
1113
font-size: 12px;
14+
font-weight: 400;
1215

1316
&__content {
1417
overflow-y: auto;
@@ -200,6 +203,10 @@
200203
display: inline !important;
201204
font-size: inherit !important;
202205
}
206+
207+
code span[style] {
208+
font-weight: 400 !important;
209+
}
203210
}
204211
}
205212

‎src/web-ui/src/flow_chat/components/InlineDiffPreview.tsx‎

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212

1313
import React, { useMemo, memo, useRef, useCallback, useState } from 'react';
1414
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
15-
import { vscDarkPlus } from 'react-syntax-highlighter/dist/esm/styles/prism';
1615
import { diffLines, Change } from 'diff';
1716
import { getPrismLanguage } from '@/infrastructure/language-detection';
17+
import { useTheme } from '@/infrastructure/theme';
1818
import { createLogger } from '@/shared/utils/logger';
19+
import { buildCodePreviewPrismStyle, CODE_PREVIEW_FONT_FAMILY } from './codePreviewPrismTheme';
1920
import './InlineDiffPreview.scss';
2021

2122
const log = createLogger('InlineDiffPreview');
@@ -168,29 +169,6 @@ function applyContextCollapsing(diffLines: DiffLine[], contextLines: number): Di
168169
return result;
169170
}
170171

171-
/**
172-
* Custom theme styles (kept in sync with CodePreview).
173-
*/
174-
const customStyle = {
175-
...vscDarkPlus,
176-
'pre[class*="language-"]': {
177-
...vscDarkPlus['pre[class*="language-"]'],
178-
margin: 0,
179-
padding: 0,
180-
background: 'transparent',
181-
fontSize: '12px',
182-
lineHeight: '1.6',
183-
fontFamily: "'JetBrains Mono', 'Fira Code', 'SF Mono', 'Consolas', 'Monaco', 'Courier New', monospace",
184-
},
185-
'code[class*="language-"]': {
186-
...vscDarkPlus['code[class*="language-"]'],
187-
background: 'transparent',
188-
fontSize: '12px',
189-
lineHeight: '1.6',
190-
fontFamily: "'JetBrains Mono', 'Fira Code', 'SF Mono', 'Consolas', 'Monaco', 'Courier New', monospace",
191-
},
192-
};
193-
194172
/**
195173
* InlineDiffPreview component.
196174
*/
@@ -207,6 +185,9 @@ export const InlineDiffPreview: React.FC<InlineDiffPreviewProps> = memo(({
207185
contextLines = 3,
208186
onLineClick,
209187
}) => {
188+
const { isLight } = useTheme();
189+
const prismStyle = useMemo(() => buildCodePreviewPrismStyle(isLight), [isLight]);
190+
210191
const containerRef = useRef<HTMLDivElement>(null);
211192
const [highlightedLine, setHighlightedLine] = useState<number | null>(null);
212193

@@ -285,7 +266,7 @@ export const InlineDiffPreview: React.FC<InlineDiffPreviewProps> = memo(({
285266
<span className="diff-line__content">
286267
<SyntaxHighlighter
287268
language={detectedLanguage}
288-
style={customStyle}
269+
style={prismStyle}
289270
customStyle={{
290271
margin: 0,
291272
padding: 0,
@@ -294,8 +275,9 @@ export const InlineDiffPreview: React.FC<InlineDiffPreviewProps> = memo(({
294275
}}
295276
codeTagProps={{
296277
style: {
297-
fontFamily: "'JetBrains Mono', 'Fira Code', 'SF Mono', 'Consolas', 'Monaco', 'Courier New', monospace",
278+
fontFamily: CODE_PREVIEW_FONT_FAMILY,
298279
fontSize: '12px',
280+
fontWeight: 400,
299281
}
300282
}}
301283
PreTag="span"
@@ -305,7 +287,7 @@ export const InlineDiffPreview: React.FC<InlineDiffPreviewProps> = memo(({
305287
</span>
306288
</div>
307289
);
308-
}, [detectedLanguage, showLineNumbers, lineNumberMode, showPrefix, highlightedLine, handleLineClick]);
290+
}, [detectedLanguage, prismStyle, showLineNumbers, lineNumberMode, showPrefix, highlightedLine, handleLineClick]);
309291

310292
if (!originalContent && !modifiedContent) {
311293
return (
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Prism themes for Flow Chat embedded code previews.
3+
* vscDarkPlus is for dark surfaces; oneLight matches light card backgrounds.
4+
*/
5+
import type { CSSProperties } from 'react';
6+
import { oneLight, vscDarkPlus } from 'react-syntax-highlighter/dist/esm/styles/prism';
7+
8+
/** Match `.markdown-renderer` code blocks (`Markdown.scss` --markdown-font-mono). */
9+
export const CODE_PREVIEW_FONT_FAMILY =
10+
'var(--markdown-font-mono, "Fira Code", "JetBrains Mono", Consolas, "Courier New", monospace)';
11+
12+
const PRE_KEY = 'pre[class*="language-"]' as const;
13+
const CODE_KEY = 'code[class*="language-"]' as const;
14+
15+
export function buildCodePreviewPrismStyle(isLight: boolean): Record<string, CSSProperties> {
16+
const base = isLight ? oneLight : vscDarkPlus;
17+
return {
18+
...base,
19+
[PRE_KEY]: {
20+
...base[PRE_KEY],
21+
margin: 0,
22+
padding: 0,
23+
background: 'transparent',
24+
fontSize: '12px',
25+
lineHeight: '1.6',
26+
fontFamily: CODE_PREVIEW_FONT_FAMILY,
27+
fontWeight: 400,
28+
},
29+
[CODE_KEY]: {
30+
...base[CODE_KEY],
31+
background: 'transparent',
32+
fontSize: '12px',
33+
lineHeight: '1.6',
34+
fontFamily: CODE_PREVIEW_FONT_FAMILY,
35+
fontWeight: 400,
36+
},
37+
};
38+
}

0 commit comments

Comments
 (0)