@@ -37,8 +37,10 @@ const FILE_PATH_REGEX = new RegExp(
3737 'g' ,
3838)
3939
40- const SOLID_TERMINAL_BG = '#000000'
41- const SOLID_TERMINAL_FG = '#e5e7eb'
40+ const SOLID_TERMINAL_BG_DARK = '#000000'
41+ const SOLID_TERMINAL_BG_LIGHT = '#ffffff'
42+ const SOLID_TERMINAL_FG_DARK = '#e5e7eb'
43+ const SOLID_TERMINAL_FG_LIGHT = '#1a1a1a'
4244
4345function findFileLinksInLine (
4446 lineText : string ,
@@ -82,12 +84,11 @@ function buildXtermTheme(hasBgImage?: boolean, bgColor?: string | null) {
8284 const s = getComputedStyle ( document . documentElement )
8385 const v = ( name : string ) => s . getPropertyValue ( name ) . trim ( )
8486 const dark = document . documentElement . classList . contains ( 'dark' )
85- const solidBg = bgColor || SOLID_TERMINAL_BG
87+ const solidBg = bgColor || ( dark ? SOLID_TERMINAL_BG_DARK : SOLID_TERMINAL_BG_LIGHT )
88+ const solidFg = dark ? SOLID_TERMINAL_FG_DARK : SOLID_TERMINAL_FG_LIGHT
8689 return {
8790 background : hasBgImage ? 'transparent' : solidBg ,
88- foreground : hasBgImage
89- ? v ( '--text-primary' ) || ( dark ? '#e5e5e5' : '#171717' )
90- : SOLID_TERMINAL_FG ,
91+ foreground : hasBgImage ? v ( '--text-primary' ) || ( dark ? '#e5e5e5' : '#171717' ) : solidFg ,
9192 cursor : v ( '--brand' ) || '#a855f7' ,
9293 cursorAccent : hasBgImage ? 'transparent' : solidBg ,
9394 selectionBackground : ( v ( '--brand' ) || '#a855f7' ) + '40' ,
@@ -267,6 +268,7 @@ function TerminalPane({
267268 onChangeBgColor,
268269} : TerminalPaneProps ) {
269270 const hasBgImage = ! ! terminalBg
271+ const [ isDark , setIsDark ] = useState ( true )
270272 const [ showBgPicker , setShowBgPicker ] = useState ( false )
271273 const [ activeId , setActiveId ] = useState < number | null > ( session . terminalId )
272274 const [ terminalError , setTerminalError ] = useState < string | null > ( null )
@@ -275,6 +277,10 @@ function TerminalPane({
275277 const wasVisibleRef = useRef ( false )
276278 const refreshTokenRef = useRef < string | undefined > ( undefined )
277279
280+ useEffect ( ( ) => {
281+ setIsDark ( document . documentElement . classList . contains ( 'dark' ) )
282+ } , [ themeVersion ] )
283+
278284 useEffect ( ( ) => {
279285 onFileOpenRef . current = onFileOpen
280286 } , [ onFileOpen ] )
@@ -630,20 +636,36 @@ function TerminalPane({
630636 Background tint
631637 </ p >
632638 < div className = "grid grid-cols-6 gap-1.5 mb-2" >
633- { [
634- '#000000' ,
635- '#0a0a0a' ,
636- '#1a1a2e' ,
637- '#0d1117' ,
638- '#1e1e2e' ,
639- '#2d1b2e' ,
640- '#0b132b' ,
641- '#1b2a1b' ,
642- '#2a1a0b' ,
643- '#1a0a0a' ,
644- '#0a1a2a' ,
645- '#2a2a1a' ,
646- ] . map ( ( c ) => (
639+ { ( isDark
640+ ? [
641+ '#000000' ,
642+ '#0a0a0a' ,
643+ '#1a1a2e' ,
644+ '#0d1117' ,
645+ '#1e1e2e' ,
646+ '#2d1b2e' ,
647+ '#0b132b' ,
648+ '#1b2a1b' ,
649+ '#2a1a0b' ,
650+ '#1a0a0a' ,
651+ '#0a1a2a' ,
652+ '#2a2a1a' ,
653+ ]
654+ : [
655+ '#ffffff' ,
656+ '#fafafa' ,
657+ '#f5f5f5' ,
658+ '#f0f0f5' ,
659+ '#f5f0e8' ,
660+ '#f0f5f0' ,
661+ '#e8f0f5' ,
662+ '#f5e8f0' ,
663+ '#f0f0e0' ,
664+ '#e8e8f0' ,
665+ '#f0e8e0' ,
666+ '#e0f0f0' ,
667+ ]
668+ ) . map ( ( c ) => (
647669 < button
648670 key = { c }
649671 onClick = { ( ) => {
@@ -659,13 +681,17 @@ function TerminalPane({
659681 < div className = "flex items-center gap-2" >
660682 < input
661683 type = "color"
662- value = { terminalBgColor || '#000000' }
684+ value = {
685+ terminalBgColor ||
686+ ( isDark ? SOLID_TERMINAL_BG_DARK : SOLID_TERMINAL_BG_LIGHT )
687+ }
663688 onChange = { ( e ) => onChangeBgColor ( e . target . value ) }
664689 className = "w-6 h-6 rounded cursor-pointer border border-[var(--border)] bg-transparent p-0"
665690 title = "Custom color"
666691 />
667692 < span className = "text-[10px] text-[var(--text-disabled)] font-mono flex-1" >
668- { terminalBgColor || '#000000' }
693+ { terminalBgColor ||
694+ ( isDark ? SOLID_TERMINAL_BG_DARK : SOLID_TERMINAL_BG_LIGHT ) }
669695 </ span >
670696 { terminalBgColor && (
671697 < button
@@ -725,7 +751,11 @@ function TerminalPane({
725751 { /* Terminal viewport */ }
726752 < div
727753 className = "flex-1 overflow-hidden relative"
728- style = { { backgroundColor : hasBgImage ? undefined : terminalBgColor || '#000000' } }
754+ style = { {
755+ backgroundColor : hasBgImage
756+ ? undefined
757+ : terminalBgColor || ( isDark ? SOLID_TERMINAL_BG_DARK : SOLID_TERMINAL_BG_LIGHT ) ,
758+ } }
729759 >
730760 { hasBgImage && (
731761 < >
0 commit comments