@@ -66,9 +66,8 @@ export type SessionWorkspaceProps = {
6666 onToggleTerminal ?: ( ) => void ;
6767 onToggleBrowser ?: ( ) => void ;
6868 onToggleCustodian ?: ( ) => void ;
69- /** Opens the session diff panel; absent when the gateway lacks sessions.diff . */
69+ /** Opens the session diff panel; absent until a usable checkout is known . */
7070 onOpenDiff ?: ( ) => void ;
71- diffNotGit ?: boolean ;
7271} ;
7372
7473type SessionWorkspaceState = {
@@ -375,14 +374,27 @@ function loadWorkspace(
375374 const reload = current . pendingReload ;
376375 current . pendingReload = false ;
377376 if ( reload ) {
378- loadWorkspace ( state , current , true ) ;
377+ loadWorkspace ( state , current ) ;
379378 }
380379 }
381380 requestUpdate ( state ) ;
382381 }
383382 } ) ( ) ;
384383}
385384
385+ /** Refresh workspace facts after a run, which may have created a git checkout. */
386+ export function refreshSessionWorkspace ( state : SessionWorkspaceHost ) {
387+ const workspace = state . sessionWorkspaceState ;
388+ if ( ! workspace || workspace . sessionKey !== state . sessionKey ) {
389+ return ;
390+ }
391+ if ( workspace . loading ) {
392+ workspace . pendingReload = true ;
393+ } else {
394+ loadWorkspace ( state , workspace ) ;
395+ }
396+ }
397+
386398function beginOpenRequest (
387399 state : SessionWorkspaceHost ,
388400 workspace : SessionWorkspaceState ,
@@ -755,6 +767,11 @@ export function createSessionWorkspaceProps(
755767 ) {
756768 loadWorkspace ( state , workspace ) ;
757769 }
770+ const canOpenDiff =
771+ isGatewayMethodAdvertised ( state , "sessions.diff" ) === true &&
772+ Boolean ( state . client ) &&
773+ workspace . list ?. sessionKey === state . sessionKey &&
774+ workspace . list . gitCheckout !== false ;
758775 return {
759776 collapsed : workspace . collapsed ,
760777 sessionKey : state . sessionKey ,
@@ -815,11 +832,9 @@ export function createSessionWorkspaceProps(
815832 state . connected && isGatewayMethodAdvertised ( state , "openclaw.chat" ) === true
816833 ? ( ) => window . dispatchEvent ( new CustomEvent ( CUSTODIAN_PANEL_TOGGLE_EVENT ) )
817834 : undefined ,
818- diffNotGit : workspace . list ?. gitCheckout === false ,
819- onOpenDiff :
820- isGatewayMethodAdvertised ( state , "sessions.diff" ) === true && state . client
821- ? ( ) => state . handleOpenSidebar ( buildSessionDiffSidebarContent ( state ) )
822- : undefined ,
835+ onOpenDiff : canOpenDiff
836+ ? ( ) => state . handleOpenSidebar ( buildSessionDiffSidebarContent ( state ) )
837+ : undefined ,
823838 } ;
824839}
825840
@@ -913,23 +928,20 @@ export function renderSessionWorkspaceToggle(
913928 ` ;
914929}
915930
916- /** Session diff button shown beside the workspace toggle; hidden when the
917- * gateway does not advertise sessions.diff. */
931+ /** Session diff button shown beside the workspace toggle when available. */
918932export function renderSessionDiffToggle (
919933 sessionWorkspace : SessionWorkspaceProps | undefined ,
920934) : TemplateResult | typeof nothing {
921935 if ( ! sessionWorkspace ?. onOpenDiff ) {
922936 return nothing ;
923937 }
924938 const label = t ( "chat.sessionDiff.show" ) ;
925- const tooltip = sessionWorkspace . diffNotGit ? t ( "chat.sessionDiff.notGit" ) : label ;
926939 return html `
927- < openclaw-tooltip .content =${ tooltip } >
940+ < openclaw-tooltip .content =${ label } >
928941 < button
929942 class ="btn btn--ghost btn--icon chat-icon-btn chat-session-diff-toggle "
930943 type ="button "
931944 aria-label =${ label }
932- ?disabled =${ sessionWorkspace . diffNotGit === true }
933945 @click =${ sessionWorkspace . onOpenDiff }
934946 >
935947 ${ icons . fileDiff }
@@ -993,16 +1005,11 @@ export function renderSessionWorkspaceRail(
9931005 : nothing ;
9941006 const diffButton = sessionWorkspace . onOpenDiff
9951007 ? html `
996- < openclaw-tooltip
997- .content =${ sessionWorkspace . diffNotGit
998- ? t ( "chat.sessionDiff.notGit" )
999- : t ( "chat.sessionDiff.show" ) }
1000- >
1008+ < openclaw-tooltip .content =${ t ( "chat.sessionDiff.show" ) } >
10011009 < button
10021010 type ="button "
10031011 class ="chat-workspace-rail__terminal chat-session-diff-toggle "
10041012 aria-label =${ t ( "chat.sessionDiff.show" ) }
1005- ?disabled =${ sessionWorkspace . diffNotGit === true }
10061013 @click =${ sessionWorkspace . onOpenDiff }
10071014 >
10081015 ${ icons . fileDiff }
0 commit comments