@@ -37,6 +37,7 @@ export const Workspace = forwardRef(function Workspace(
3737 const wsRef = useRef ( null ) ;
3838 const [ layouts , setLayouts ] = useState ( { } ) ;
3939 const [ activeLayoutName , setActiveLayoutName ] = useState ( null ) ;
40+ const [ restoreCount , setRestoreCount ] = useState ( 0 ) ;
4041 const initializedRef = useRef ( false ) ;
4142
4243 // ── Imperative handle for Header and other consumers ──────────────
@@ -46,7 +47,10 @@ export const Workspace = forwardRef(function Workspace(
4647 getLayouts : ( ) => layouts ,
4748 getActiveLayout : ( ) => activeLayoutName ,
4849 setActiveLayout : ( name ) => {
49- if ( layouts [ name ] ) setActiveLayoutName ( name ) ;
50+ if ( layouts [ name ] ) {
51+ setActiveLayoutName ( name ) ;
52+ setRestoreCount ( ( c ) => c + 1 ) ;
53+ }
5054 } ,
5155 saveLayout : async ( ) => {
5256 const ws = wsRef . current ;
@@ -166,7 +170,7 @@ export const Workspace = forwardRef(function Workspace(
166170 if ( ! ws ) return ;
167171
168172 ws . restore ( applyThemeToLayout ( layouts [ activeLayoutName ] ) ) ;
169- } , [ activeLayoutName ] ) ;
173+ } , [ activeLayoutName , restoreCount ] ) ;
170174
171175 // ── Apply theme to newly added viewers (right-click → add table) ──
172176 // Only fires AFTER initial restore is complete (guarded by initializedRef)
0 commit comments