@@ -14,7 +14,7 @@ import { EventTable } from './components/event-table';
1414import { ReactECharts , collectChartData , createOptions } from './components/react-echart' ;
1515import { ViewHeader } from './components/view-header' ;
1616import type { DevtoolsComponentState } from './utilities/view-state' ;
17- import { restoreState , storeState , vsCodeApi } from './utilities/view-state' ;
17+ import { restoreState , storeState , vsCodeApi , getVSCodeTheme } from './utilities/view-state' ;
1818
1919type DataEvent = {
2020 extension : string ;
@@ -53,6 +53,7 @@ class DevtoolsComponent extends React.Component<Record<string, any>, DevtoolsCom
5353
5454 messenger : Messenger ;
5555 eventTable : EventTable ;
56+ private themeObserver : MutationObserver | null = null ;
5657
5758 constructor ( ) {
5859 super ( { } ) ;
@@ -61,7 +62,8 @@ class DevtoolsComponent extends React.Component<Record<string, any>, DevtoolsCom
6162 selectedExtension : storedState ?. selectedExtension ?? '' ,
6263 datasetSrc : storedState ?. datasetSrc ? new Map ( ) : new Map ( ) ,
6364 chartsShown : storedState ?. chartsShown ?? false ,
64- diagramShown : storedState ?. diagramShown ?? false
65+ diagramShown : storedState ?. diagramShown ?? false ,
66+ theme : storedState ?. theme ?? getVSCodeTheme ( )
6567 } ;
6668 this . eventTable = new EventTable ( { gridRowSelected : ( e ) => this . gridRowSelected ( e ) } ) ;
6769 this . messenger = new Messenger ( vsCodeApi , { debugLog : true } ) ;
@@ -83,13 +85,46 @@ class DevtoolsComponent extends React.Component<Record<string, any>, DevtoolsCom
8385 return ;
8486 } ) . catch ( err => console . error ( err ) ) ;
8587
88+ // Set up theme change observer
89+ this . setupThemeObserver ( ) ;
8690 }
8791
88- render ( ) {
92+ componentWillUnmount ( ) {
93+ // Clean up theme observer
94+ if ( this . themeObserver ) {
95+ this . themeObserver . disconnect ( ) ;
96+ this . themeObserver = null ;
97+ }
98+ }
8999
100+ private setupThemeObserver ( ) {
101+ // Watch for changes to the data-vscode-theme-kind attribute
102+ this . themeObserver = new MutationObserver ( ( mutations ) => {
103+ mutations . forEach ( ( mutation ) => {
104+ if ( mutation . type === 'attributes' && mutation . attributeName === 'data-vscode-theme-kind' ) {
105+ const newTheme = getVSCodeTheme ( ) ;
106+ if ( newTheme !== this . state . theme ) {
107+ // Update state with new theme - this will trigger chart re-render
108+ // and table will automatically pick up new CSS theme class
109+ this . updateState ( { ...this . state , theme : newTheme } , true ) ;
110+ }
111+ }
112+ } ) ;
113+ } ) ;
114+
115+ // Start observing
116+ this . themeObserver . observe ( document . body , {
117+ attributes : true ,
118+ attributeFilter : [ 'data-vscode-theme-kind' ]
119+ } ) ;
120+
121+ }
122+
123+ render ( ) {
124+ const theme = this . state . theme ;
90125 const charSeries = collectChartData ( this . selectedExtensionData ( ) ?. events ?? [ ] ) ;
91- const optionSize = createOptions ( charSeries . series [ 0 ] , charSeries . senderY , ' (chars)' ) ;
92- const optionCount = createOptions ( charSeries . series [ 1 ] , charSeries . senderY ) ;
126+ const optionSize = createOptions ( charSeries . series [ 0 ] , charSeries . senderY , ' (chars)' , theme ) ;
127+ const optionCount = createOptions ( charSeries . series [ 1 ] , charSeries . senderY , '' , theme ) ;
93128
94129 const selectedExt = this . selectedExtensionData ( ) ;
95130 const updateState = ( selectedId : string ) => {
@@ -360,7 +395,8 @@ class DevtoolsComponent extends React.Component<Record<string, any>, DevtoolsCom
360395 if ( typeof value === 'object' ) {
361396 try {
362397 stringValue = JSON . stringify ( value ) ;
363- } catch ( error ) {
398+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
399+ } catch ( _error ) {
364400 stringValue = String ( value ) ;
365401 }
366402 } else {
0 commit comments