@@ -20,6 +20,7 @@ type Catalog = {
2020} ;
2121
2222type Options = {
23+ mode : "move" | "restart" ;
2324 sessionLabel : string ;
2425 activeRun : boolean ;
2526 deviceDisabledReason ?: string ;
@@ -29,7 +30,10 @@ type Options = {
2930
3031let active = false ;
3132
32- function targetKey ( target : SessionMoveTarget ) : string {
33+ function targetKey ( target : SessionMoveTarget | null ) : string {
34+ if ( ! target ) {
35+ return "" ;
36+ }
3337 switch ( target . kind ) {
3438 case "gateway" :
3539 return "gateway" ;
@@ -41,7 +45,7 @@ function targetKey(target: SessionMoveTarget): string {
4145 throw new Error ( "Unknown session placement move target" ) ;
4246}
4347
44- export function showSessionPlacementMoveDialog (
48+ export function showSessionPlacementTargetDialog (
4549 options : Options ,
4650) : Promise < SessionMoveTarget | null > {
4751 if ( active ) {
@@ -54,7 +58,7 @@ export function showSessionPlacementMoveDialog(
5458 let loading = true ;
5559 let loadError : string | null = null ;
5660 let catalog : Catalog = { profiles : [ ] , devices : [ ] } ;
57- let selected : SessionMoveTarget = { kind : "gateway" } ;
61+ let selected : SessionMoveTarget | null = options . mode === "move" ? { kind : "gateway" } : null ;
5862 const cloudMachines = new DraftCloudMachineState ( ) ;
5963
6064 const finish = ( result : SessionMoveTarget | null ) => {
@@ -71,6 +75,9 @@ export function showSessionPlacementMoveDialog(
7175
7276 const submit = ( event : Event ) => {
7377 event . preventDefault ( ) ;
78+ if ( ! selected ) {
79+ return ;
80+ }
7481 if ( selected . kind !== "profile" ) {
7582 finish ( selected ) ;
7683 return ;
@@ -84,40 +91,60 @@ export function showSessionPlacementMoveDialog(
8491
8592 function paint ( ) {
8693 const selectedKey = targetKey ( selected ) ;
94+ const restart = options . mode === "restart" ;
8795 render (
8896 html `
8997 < openclaw-modal-dialog
90- label =${ t ( "sessionsView.moveSessionTitle" ) }
98+ label =${ t (
99+ restart ? "sessionsView.restartSessionTitle" : "sessionsView.moveSessionTitle" ,
100+ ) }
91101 @modal-cancel =${ ( ) => finish ( null ) }
92102 >
93103 < form class ="exec-approval-card " @submit =${ submit } >
94104 < div class ="exec-approval-header ">
95- < div class ="exec-approval-title "> ${ t ( "sessionsView.moveSessionTitle" ) } </ div >
105+ < div class ="exec-approval-title ">
106+ ${ t (
107+ restart ? "sessionsView.restartSessionTitle" : "sessionsView.moveSessionTitle" ,
108+ ) }
109+ </ div >
96110 < div class ="muted ">
97- ${ t ( "sessionsView.moveSessionDescription" , { session : options . sessionLabel } ) }
111+ ${ t (
112+ restart
113+ ? "sessionsView.restartSessionDescription"
114+ : "sessionsView.moveSessionDescription" ,
115+ { session : options . sessionLabel } ,
116+ ) }
98117 </ div >
99118 </ div >
100- ${ options . activeRun
119+ ${ restart
101120 ? html `< div class ="exec-approval-error " role ="alert ">
102- ${ t ( "sessionsView.moveSessionActiveRunWarning " ) }
121+ ${ t ( "sessionsView.restartSessionWarning " ) }
103122 </ div > `
104- : html `< div class ="callout "> ${ t ( "sessionsView.moveSessionNoReplayWarning" ) } </ div > ` }
123+ : options . activeRun
124+ ? html `< div class ="exec-approval-error " role ="alert ">
125+ ${ t ( "sessionsView.moveSessionActiveRunWarning" ) }
126+ </ div > `
127+ : html `< div class ="callout ">
128+ ${ t ( "sessionsView.moveSessionNoReplayWarning" ) }
129+ </ div > ` }
105130 ${ loading
106131 ? html `< div class ="muted "> ${ t ( "common.loading" ) } </ div > `
107132 : loadError
108133 ? html `< div class ="exec-approval-error " role ="alert "> ${ loadError } </ div > `
109134 : html `
110135 < div class ="new-session-page__picker-root ">
111- ${ renderSessionMenuItem (
112- {
113- value : "gateway" ,
114- label : t ( "newSession.gateway" ) ,
115- icon : icons . monitor ,
116- checked : selectedKey === "gateway" ,
117- onSelect : ( ) => select ( { kind : "gateway" } ) ,
118- } ,
119- false ,
120- ) }
136+ ${ restart
137+ ? nothing
138+ : renderSessionMenuItem (
139+ {
140+ value : "gateway" ,
141+ label : t ( "newSession.gateway" ) ,
142+ icon : icons . monitor ,
143+ checked : selectedKey === "gateway" ,
144+ onSelect : ( ) => select ( { kind : "gateway" } ) ,
145+ } ,
146+ false ,
147+ ) }
121148 ${ catalog . devices . length > 0
122149 ? html `
123150 < div class ="new-session-page__menu-title ">
@@ -154,7 +181,7 @@ export function showSessionPlacementMoveDialog(
154181 </ div >
155182 ${ catalog . profiles . map ( ( profile ) => {
156183 const profileSelected =
157- selected . kind === "profile" && selected . profileId === profile . id ;
184+ selected ? .kind === "profile" && selected . profileId === profile . id ;
158185 const machines = profile . machines ?? [ ] ;
159186 const selectedMachineId =
160187 cloudMachines . resolve ( profile . id ) ||
@@ -199,9 +226,13 @@ export function showSessionPlacementMoveDialog(
199226 < button
200227 type ="submit "
201228 class ="btn primary "
202- ?disabled =${ loading || Boolean ( loadError ) }
229+ ?disabled =${ loading || Boolean ( loadError ) || ! selected }
203230 >
204- ${ t ( "sessionsView.moveSessionAction" ) }
231+ ${ t (
232+ restart
233+ ? "sessionsView.restartSessionAction"
234+ : "sessionsView.moveSessionAction" ,
235+ ) }
205236 </ button >
206237 < button type ="button " class ="btn " @click =${ ( ) => finish ( null ) } >
207238 ${ t ( "common.cancel" ) }
0 commit comments