@@ -20,6 +20,7 @@ import { previewElectronApi } from "./preview-electron-api";
2020// is purely FE-based (registered via WPS on the frontend)
2121// - rpc.GetMetaCommand -- reads .meta from the mock WOS atom for the given oref
2222// - rpc.SetMetaCommand -- writes .meta to the mock WOS atom (null values delete keys)
23+ // - rpc.SetConfigCommand -- merges settings into fullConfigAtom (null values delete keys)
2324// - rpc.UpdateTabNameCommand -- updates .name on the Tab WaveObj in the mock WOS
2425// - rpc.UpdateWorkspaceTabIdsCommand -- updates .tabids on the Workspace WaveObj in the mock WOS
2526//
@@ -173,6 +174,7 @@ function makeMockGlobalAtoms(
173174type MockWosFns = {
174175 getWaveObjectAtom : < T extends WaveObj > ( oref : string ) => PrimitiveAtom < T > ;
175176 mockSetWaveObj : < T extends WaveObj > ( oref : string , obj : T ) => void ;
177+ fullConfigAtom : PrimitiveAtom < FullConfigType > ;
176178} ;
177179
178180export function makeMockRpc ( overrides : RpcOverrides , wos : MockWosFns ) : RpcApiType {
@@ -211,6 +213,19 @@ export function makeMockRpc(overrides: RpcOverrides, wos: MockWosFns): RpcApiTyp
211213 wos . mockSetWaveObj ( tabORef , updated ) ;
212214 return null ;
213215 } ) ;
216+ dispatchMap . set ( "setconfig" , async ( _client , data : SettingsType ) => {
217+ const current = globalStore . get ( wos . fullConfigAtom ) ;
218+ const updatedSettings = { ...( current ?. settings ?? { } ) } ;
219+ for ( const [ key , value ] of Object . entries ( data ) ) {
220+ if ( value === null ) {
221+ delete ( updatedSettings as any ) [ key ] ;
222+ } else {
223+ ( updatedSettings as any ) [ key ] = value ;
224+ }
225+ }
226+ globalStore . set ( wos . fullConfigAtom , { ...current , settings : updatedSettings as SettingsType } ) ;
227+ return null ;
228+ } ) ;
214229 dispatchMap . set ( "updateworkspacetabids" , async ( _client , data : { args : [ string , string [ ] ] } ) => {
215230 const [ workspaceId , tabIds ] = data . args ;
216231 const wsORef = "workspace:" + workspaceId ;
@@ -280,6 +295,7 @@ export function makeMockWaveEnv(mockEnv?: MockEnv): MockWaveEnv {
280295 } ) ;
281296 const mockWosFns : MockWosFns = {
282297 getWaveObjectAtom,
298+ fullConfigAtom : atoms . fullConfigAtom ,
283299 mockSetWaveObj : < T extends WaveObj > ( oref : string , obj : T ) => {
284300 if ( ! waveObjectValueAtomCache . has ( oref ) ) {
285301 waveObjectValueAtomCache . set ( oref , atom ( null as WaveObj ) ) ;
0 commit comments