@@ -39,6 +39,19 @@ export default function ServerDetailPage({
3939 } ,
4040 } )
4141
42+ const deployMutation = useMutation ( {
43+ mutationFn : async ( ) => {
44+ const res = await fetch ( `/api/servers/${ serverId } /deploy-daemon` , { method : 'POST' } )
45+ if ( ! res . ok ) {
46+ const data = await res . json ( ) . catch ( ( ) => ( { error : 'Deploy failed' } ) ) as { error : string }
47+ throw new Error ( data . error )
48+ }
49+ } ,
50+ onSuccess : ( ) => {
51+ queryClient . invalidateQueries ( { queryKey : [ 'server' , serverId ] } )
52+ } ,
53+ } )
54+
4255 const actionMutation = useMutation ( {
4356 mutationFn : async ( action : string ) => {
4457 if ( ! server ?. node_id ) throw new Error ( 'No node linked' )
@@ -104,9 +117,34 @@ export default function ServerDetailPage({
104117 View Progress
105118 </ Link >
106119 ) }
120+ { server . provision_status === 'completed' && ! server . node_id && (
121+ < button
122+ className = "btn btn-primary btn-sm"
123+ onClick = { ( ) => deployMutation . mutate ( ) }
124+ disabled = { deployMutation . isPending }
125+ >
126+ { deployMutation . isPending ? < > < span className = "spinner" style = { { width : '0.75rem' , height : '0.75rem' , marginRight : '0.375rem' } } /> Deploying…</ > : 'Deploy Daemon' }
127+ </ button >
128+ ) }
107129 </ div >
108130 </ div >
109131
132+ { /* Deploy feedback */ }
133+ { deployMutation . isError && (
134+ < div className = "card" style = { { marginBottom : '1rem' , borderColor : 'var(--color-danger)' , background : 'color-mix(in srgb, var(--color-danger), transparent 92%)' } } >
135+ < div style = { { fontSize : '0.8125rem' , color : 'var(--color-danger)' } } >
136+ Deploy failed: { deployMutation . error . message }
137+ </ div >
138+ </ div >
139+ ) }
140+ { deployMutation . isSuccess && (
141+ < div className = "card" style = { { marginBottom : '1rem' , borderColor : 'var(--color-success)' , background : 'color-mix(in srgb, var(--color-success), transparent 92%)' } } >
142+ < div style = { { fontSize : '0.8125rem' , color : 'var(--color-success)' } } >
143+ Daemon deployed successfully. Waiting for heartbeat…
144+ </ div >
145+ </ div >
146+ ) }
147+
110148 { /* System Info */ }
111149 { server . system_info && (
112150 < div className = "card" style = { { marginBottom : '1rem' } } >
0 commit comments