@@ -44,8 +44,9 @@ function patchPrefs(request: MockGatewayRequest): Record<string, unknown> {
4444 return requireRecord ( ui . prefs , "config.patch ui.prefs" ) ;
4545}
4646
47- async function createContext ( ) : Promise < BrowserContext > {
47+ async function createContext ( colorScheme ?: "dark" | "light" ) : Promise < BrowserContext > {
4848 return suite . browser . newContext ( {
49+ ...( colorScheme ? { colorScheme } : { } ) ,
4950 locale : "en-US" ,
5051 serviceWorkers : "block" ,
5152 viewport : { height : 900 , width : 1440 } ,
@@ -135,6 +136,54 @@ function themeModeOption(page: Page, mode: "system" | "light" | "dark") {
135136}
136137
137138suite . define ( ( ) => {
139+ it ( "preserves a profile's explicit light theme while reconnecting" , async ( ) => {
140+ const context = await createContext ( "dark" ) ;
141+ const page = await context . newPage ( ) ;
142+ const initial = configResponse ( { } , "prefs-profile-light-1" ) ;
143+ const gateway = await installMockGateway ( page , {
144+ methodResponses : {
145+ "config.get" : initial ,
146+ "users.prefs.get" : {
147+ entries : { "ui.theme" : "claw" , "ui.themeMode" : "light" } ,
148+ status : "ok" ,
149+ } ,
150+ } ,
151+ presenceUsers : [ { id : "profile-theme-light" , self : true } ] ,
152+ } ) ;
153+
154+ try {
155+ const response = await page . goto ( `${ suite . server . baseUrl } chat` ) ;
156+ expect ( response ?. status ( ) ) . toBe ( 200 ) ;
157+ await gateway . waitForRequest ( "config.get" ) ;
158+ await gateway . waitForRequest ( "users.prefs.get" ) ;
159+ await gateway . waitForRequest ( "chat.startup" ) ;
160+ await expect . poll ( ( ) => page . locator ( "html" ) . getAttribute ( "data-theme-mode" ) ) . toBe ( "light" ) ;
161+ await expect
162+ . poll ( ( ) => page . locator ( "html" ) . getAttribute ( "data-theme-resolved" ) )
163+ . toBe ( "light" ) ;
164+ await expect
165+ . poll ( ( ) => readSettingsMirror ( page ) )
166+ . toMatchObject ( { theme : "claw" , themeMode : "light" } ) ;
167+
168+ await gateway . setOnline ( false ) ;
169+ await page . locator ( ".sidebar-footer-bar__status" ) . filter ( { hasText : "Offline" } ) . waitFor ( ) ;
170+ await page
171+ . locator ( ".agent-chat__composer-status-band" )
172+ . filter ( { hasText : "Offline" } )
173+ . waitFor ( ) ;
174+
175+ await expect . poll ( ( ) => page . locator ( "html" ) . getAttribute ( "data-theme-mode" ) ) . toBe ( "light" ) ;
176+ await expect
177+ . poll ( ( ) => page . locator ( "html" ) . getAttribute ( "data-theme-resolved" ) )
178+ . toBe ( "light" ) ;
179+ await expect
180+ . poll ( ( ) => readSettingsMirror ( page ) )
181+ . toMatchObject ( { theme : "claw" , themeMode : "light" } ) ;
182+ } finally {
183+ await context . close ( ) ;
184+ }
185+ } ) ;
186+
138187 it ( "replays an offline theme edit after a same-client reconnect" , async ( ) => {
139188 const context = await createContext ( ) ;
140189 const page = await context . newPage ( ) ;
0 commit comments