@@ -4,6 +4,7 @@ import { SerializeAddon } from "@xterm/addon-serialize";
44import { WebLinksAddon } from "@xterm/addon-web-links" ;
55import { Terminal } from "@xterm/xterm" ;
66import "@xterm/xterm/css/xterm.css" ;
7+ import { useThemeStore } from "@stores/themeStore" ;
78import { useEffect , useRef } from "react" ;
89import { logger } from "@/renderer/lib/logger" ;
910import { useTerminalStore } from "../stores/terminalStore" ;
@@ -59,6 +60,7 @@ export function ShellTerminal({ cwd, stateKey }: ShellTerminalProps) {
5960 const restoredStateLengthRef = useRef < number > ( 0 ) ;
6061
6162 const terminalStore = useTerminalStore ( ) ;
63+ const isDarkMode = useThemeStore ( ( state ) => state . isDarkMode ) ;
6264 const persistenceKey = stateKey || cwd || "default" ;
6365
6466 useEffect ( ( ) => {
@@ -79,14 +81,23 @@ export function ShellTerminal({ cwd, stateKey }: ShellTerminalProps) {
7981 cursorBlink : true ,
8082 fontSize : 12 ,
8183 fontFamily : "monospace" ,
82- theme : {
83- background : "transparent" ,
84- foreground : "#ffffff" ,
85- cursor : "#BD6C3A" ,
86- cursorAccent : "#ffffff" ,
87- selectionBackground : "#532601" ,
88- selectionForeground : "#ffffff" ,
89- } ,
84+ theme : isDarkMode
85+ ? {
86+ background : "transparent" ,
87+ foreground : "#eeeeea" ,
88+ cursor : "#dc9300" ,
89+ cursorAccent : "#eeeeea" ,
90+ selectionBackground : "rgba(255, 203, 129, 0.3)" ,
91+ selectionForeground : "#eeeeea" ,
92+ }
93+ : {
94+ background : "transparent" ,
95+ foreground : "#1f1f1f" ,
96+ cursor : "#dc9300" ,
97+ cursorAccent : "#1f1f1f" ,
98+ selectionBackground : "rgba(255, 189, 87, 0.4)" ,
99+ selectionForeground : "#1f1f1f" ,
100+ } ,
90101 cursorStyle : "block" ,
91102 cursorWidth : 8 ,
92103 allowProposedApi : true ,
@@ -296,14 +307,38 @@ export function ShellTerminal({ cwd, stateKey }: ShellTerminalProps) {
296307 hasReceivedDataRef . current = false ;
297308 restoredStateLengthRef . current = 0 ;
298309 } ;
310+ // eslint-disable-next-line react-hooks/exhaustive-deps
299311 } , [
300312 cwd ,
301313 persistenceKey ,
302314 terminalStore . getTerminalState ,
303315 terminalStore . setSerializedState ,
304316 terminalStore . setSessionId ,
317+ isDarkMode ,
305318 ] ) ;
306319
320+ useEffect ( ( ) => {
321+ if ( terminal . current ) {
322+ terminal . current . options . theme = isDarkMode
323+ ? {
324+ background : "transparent" ,
325+ foreground : "#eeeeea" ,
326+ cursor : "#dc9300" ,
327+ cursorAccent : "#eeeeea" ,
328+ selectionBackground : "rgba(255, 203, 129, 0.3)" ,
329+ selectionForeground : "#eeeeea" ,
330+ }
331+ : {
332+ background : "transparent" ,
333+ foreground : "#1f1f1f" ,
334+ cursor : "#dc9300" ,
335+ cursorAccent : "#1f1f1f" ,
336+ selectionBackground : "rgba(255, 189, 87, 0.4)" ,
337+ selectionForeground : "#1f1f1f" ,
338+ } ;
339+ }
340+ } , [ isDarkMode ] ) ;
341+
307342 return (
308343 < Box
309344 style = { {
0 commit comments