@@ -23,11 +23,7 @@ import {
2323} from "../lib/sessions/session-key.ts" ;
2424import { OpenClawLightDomElement } from "../lit/openclaw-element.ts" ;
2525import { getSafeLocalStorage } from "../local-storage.ts" ;
26- import {
27- buildHomeWorkContext ,
28- subscribeChatWorkContext ,
29- type ChatWorkContext ,
30- } from "../pages/chat/chat-work-context.ts" ;
26+ import { buildHomeWorkContext , subscribeChatWorkContext } from "../pages/chat/chat-work-context.ts" ;
3127import {
3228 custodianSessionStore ,
3329 type CustodianSessionStore ,
@@ -52,6 +48,8 @@ type AssistantDestination = "home" | "custodian";
5248type AssistantDock = Exclude < DockPanelSide , "left" > ;
5349
5450const panelLayout = createDockPanelLayout ( {
51+ // Shipped key: operators' saved dock size and placement live here, so the
52+ // legacy custodian spelling stays even though the dock is now shared.
5553 storageKey : "openclaw.custodian.panel.v1" ,
5654 minHeight : 240 ,
5755 minWidth : 320 ,
@@ -71,15 +69,16 @@ export class OpenClawAssistantPanel extends OpenClawLightDomElement {
7169 @property ( { type : Boolean } ) sessionPage = false ;
7270 @property ( ) pageSessionKey = "" ;
7371 @property ( ) pageAgentId = "" ;
74- @property ( { attribute : false } ) workContext : ChatWorkContext | undefined ;
72+ /** Route id of the page being worked on; the dock derives its own snapshot from it. */
73+ @property ( ) workPage = "" ;
7574 @state ( ) private destination : AssistantDestination = "custodian" ;
7675 private readonly homeLoader = new LazyCustomElementRequestController ( this ) ;
7776 @property ( { type : Number } ) minimizeRequestId = 0 ;
7877 @property ( { attribute : false } ) store : CustodianSessionStore = custodianSessionStore ;
7978
8079 private readonly dockLayout = new DockLayoutController ( this , {
8180 layout : panelLayout ,
82- reservationPrefix : "custodian " ,
81+ reservationPrefix : "assistant " ,
8382 isAvailable : ( ) => this . available ,
8483 } ) ;
8584 private readonly onToggleRequest = ( event : Event ) => this . handleToggleRequest ( event ) ;
@@ -99,9 +98,7 @@ export class OpenClawAssistantPanel extends OpenClawLightDomElement {
9998 window . addEventListener ( CUSTODIAN_PANEL_TOGGLE_EVENT , this . onToggleRequest ) ;
10099 window . addEventListener ( HOME_PANEL_TOGGLE_EVENT , this . onToggleRequest ) ;
101100 this . dockLayout . setSuppressed ( this . suppressed ) ;
102- if ( this . dockLayout . open && this . destination === "custodian" ) {
103- void this . store . refreshTranscriptIfIdle ( ) ;
104- }
101+ this . refreshCustodianTranscript ( this . dockLayout . open ) ;
105102 }
106103
107104 override disconnectedCallback ( ) : void {
@@ -169,9 +166,7 @@ export class OpenClawAssistantPanel extends OpenClawLightDomElement {
169166 } else {
170167 this . dockLayout . restoreOpenState ( ) ;
171168 }
172- if ( ! wasOpen && this . dockLayout . open && this . destination === "custodian" ) {
173- void this . store . refreshTranscriptIfIdle ( ) ;
174- }
169+ this . refreshCustodianTranscript ( ! wasOpen && this . dockLayout . open ) ;
175170 if ( wasOpen && ! this . dockLayout . open ) {
176171 this . claimInput ( "page" ) ;
177172 }
@@ -218,8 +213,19 @@ export class OpenClawAssistantPanel extends OpenClawLightDomElement {
218213 } ;
219214 }
220215
216+ /** Ask OpenClaw hydrates lazily; only refresh when it actually becomes visible. */
217+ private refreshCustodianTranscript ( becameVisible : boolean ) : void {
218+ if ( becameVisible && this . destination === "custodian" ) {
219+ void this . store . refreshTranscriptIfIdle ( ) ;
220+ }
221+ }
222+
223+ private availableFor ( destination : AssistantDestination ) : boolean {
224+ return destination === "home" ? this . homeAvailable : this . custodianAvailable ;
225+ }
226+
221227 private get available ( ) : boolean {
222- return this . destination === "home" ? this . homeAvailable : this . custodianAvailable ;
228+ return this . availableFor ( this . destination ) ;
223229 }
224230
225231 private get suppressed ( ) : boolean {
@@ -292,9 +298,7 @@ export class OpenClawAssistantPanel extends OpenClawLightDomElement {
292298 this . persistTarget ( ) ;
293299 this . dockLayout . setOpen ( open ) ;
294300 this . claimInput ( open ? "dock" : "page" ) ;
295- if ( open && this . destination === "custodian" ) {
296- void this . store . refreshTranscriptIfIdle ( ) ;
297- }
301+ this . refreshCustodianTranscript ( open ) ;
298302 }
299303
300304 toggle ( ) : void {
@@ -312,7 +316,7 @@ export class OpenClawAssistantPanel extends OpenClawLightDomElement {
312316
313317 handleToggleRequest ( event : Event ) : void {
314318 const destination = event . type === HOME_PANEL_TOGGLE_EVENT ? "home" : "custodian" ;
315- if ( destination === "home" ? ! this . homeAvailable : ! this . custodianAvailable ) {
319+ if ( ! this . availableFor ( destination ) ) {
316320 return ;
317321 }
318322 const detail = asNullableRecord ( event instanceof CustomEvent ? event . detail : null ) ;
@@ -342,23 +346,24 @@ export class OpenClawAssistantPanel extends OpenClawLightDomElement {
342346 const dock = this . dockLayout . dock ;
343347 const home = this . homeTarget ;
344348 const homeState = this . homeLoader . visibleState ;
345- const workContext =
346- this . context && this . workContext
347- ? buildHomeWorkContext ( this . context , this . workContext . page , this . workContext . sessionKey )
348- : this . workContext ;
349+ // Built here, not by the shell: the dock re-derives on its own work-context
350+ // and agent-selection subscriptions without waiting for a shell render.
351+ const workContext = this . context
352+ ? buildHomeWorkContext ( this . context , this . workPage , this . pageSessionKey )
353+ : undefined ;
349354 const style =
350355 dock === "bottom" ? `height:${ this . dockLayout . height } px` : `width:${ this . dockLayout . width } px` ;
351356 return html `
352357 < section
353- class ="cp cp --${ dock } "
358+ class ="assistant-panel assistant-panel --${ dock } "
354359 style =${ style }
355360 aria-label =${ t ( "assistantPanel.title" ) }
356361 @pointerdown=${ ( ) => this . claimInput ( "dock" ) }
357362 @focusin=${ ( ) => this . claimInput ( "dock" ) }
358363 >
359- ${ this . dockLayout . renderResizer ( "cp " , t ( "assistantPanel.resize" ) ) }
360- < header class ="rail-header cp -header " @mousedown =${ beginNativeWindowDrag } >
361- < div class ="cp -title ">
364+ ${ this . dockLayout . renderResizer ( "assistant-panel " , t ( "assistantPanel.resize" ) ) }
365+ < header class ="rail-header assistant-panel -header " @mousedown =${ beginNativeWindowDrag } >
366+ < div class ="assistant-panel -title ">
362367 < openclaw-mascot
363368 .mood =${ this . destination === "custodian" && this . store . sending ? "thinking" : "idle" }
364369 .size =${ 16 }
@@ -367,7 +372,7 @@ export class OpenClawAssistantPanel extends OpenClawLightDomElement {
367372 ( destination === "home" ? this . homeAvailable : this . custodianAvailable )
368373 ? html `< button
369374 type ="button "
370- class ="cp -tab "
375+ class ="assistant-panel -tab "
371376 aria-pressed =${ this . destination === destination }
372377 @click =${ ( ) => this . openDestination ( destination ) }
373378 >
@@ -376,10 +381,10 @@ export class OpenClawAssistantPanel extends OpenClawLightDomElement {
376381 : nothing ,
377382 ) }
378383 </ div >
379- < div class ="rail-header__actions cp -actions ">
384+ < div class ="rail-header__actions assistant-panel -actions ">
380385 ${ this . destination === "home"
381386 ? html `< button
382- class ="rail-header__action cp -icon "
387+ class ="rail-header__action assistant-panel -icon "
383388 type ="button "
384389 aria-label =${ t ( "assistantPanel.openHome" ) }
385390 @click =${ ( ) => this . openHomePage ( ) }
@@ -388,7 +393,7 @@ export class OpenClawAssistantPanel extends OpenClawLightDomElement {
388393 </ button > `
389394 : nothing }
390395 < button
391- class ="rail-header__action cp -icon "
396+ class ="rail-header__action assistant-panel -icon "
392397 type ="button "
393398 aria-label =${ dock === "bottom"
394399 ? t ( "assistantPanel.dockRight" )
@@ -398,7 +403,7 @@ export class OpenClawAssistantPanel extends OpenClawLightDomElement {
398403 ${ dock === "bottom" ? icons . panelRightOpen : icons . panelBottomOpen }
399404 </ button >
400405 < button
401- class ="rail-header__action cp -icon "
406+ class ="rail-header__action assistant-panel -icon "
402407 type ="button "
403408 aria-label =${ t ( "assistantPanel.close" ) }
404409 @click =${ ( ) => this . setOpen ( false ) }
0 commit comments