@@ -132,21 +132,40 @@ function queueSharedGatewayAuthGenerationRefresh(
132132 } ) ;
133133}
134134
135- function shouldScheduleDirectConfigRestart ( params : {
135+ function isNoopConfigReloadPlan ( plan : ReturnType < typeof buildGatewayReloadPlan > ) : boolean {
136+ return (
137+ ! plan . restartGateway &&
138+ plan . hotReasons . length === 0 &&
139+ ! plan . reloadHooks &&
140+ ! plan . restartGmailWatcher &&
141+ ! plan . restartCron &&
142+ ! plan . restartHeartbeat &&
143+ ! plan . restartHealthMonitor &&
144+ ! plan . reloadPlugins &&
145+ ! plan . disposeMcpRuntimes &&
146+ plan . restartChannels . size === 0
147+ ) ;
148+ }
149+
150+ function resolveConfigRestartRequirement ( params : {
136151 changedPaths : string [ ] ;
137152 nextConfig : OpenClawConfig ;
138- } ) : boolean {
153+ } ) : { requiresRestart : boolean ; scheduleDirectRestart : boolean } {
139154 const reloadSettings = resolveGatewayReloadSettings ( params . nextConfig ) ;
155+ const plan = buildGatewayReloadPlan ( params . changedPaths ) ;
156+ if ( isNoopConfigReloadPlan ( plan ) ) {
157+ return { requiresRestart : false , scheduleDirectRestart : false } ;
158+ }
140159 if ( reloadSettings . mode === "off" ) {
141- return true ;
160+ return { requiresRestart : true , scheduleDirectRestart : true } ;
142161 }
143- // Hybrid mode lets hot-reload own non-gateway restarts; only paths the reload
144- // plan marks as gateway-owned get a direct process restart here.
145- const plan = buildGatewayReloadPlan ( params . changedPaths ) ;
146- if ( reloadSettings . mode === "hot" && plan . restartGateway ) {
147- return true ;
162+ if ( reloadSettings . mode === "restart" ) {
163+ return { requiresRestart : true , scheduleDirectRestart : false } ;
164+ }
165+ if ( plan . restartGateway ) {
166+ return { requiresRestart : true , scheduleDirectRestart : reloadSettings . mode === "hot" } ;
148167 }
149- return false ;
168+ return { requiresRestart : false , scheduleDirectRestart : false } ;
150169}
151170
152171function resolveConfigRestartRequest ( params : unknown ) : {
@@ -182,6 +201,7 @@ function buildConfigRestartSentinelPayload(params: {
182201 kind : RestartSentinelPayload [ "kind" ] ;
183202 mode : string ;
184203 configPath : string ;
204+ requiresRestart : boolean ;
185205 sessionKey : string | undefined ;
186206 deliveryContext : ReturnType < typeof extractDeliveryInfo > [ "deliveryContext" ] ;
187207 threadId : ReturnType < typeof extractDeliveryInfo > [ "threadId" ] ;
@@ -199,6 +219,7 @@ function buildConfigRestartSentinelPayload(params: {
199219 stats : {
200220 mode : params . mode ,
201221 root : params . configPath ,
222+ requiresRestart : params . requiresRestart ,
202223 } ,
203224 } ;
204225}
@@ -260,20 +281,22 @@ export async function resolveGatewayConfigRestartWriteResult(params: {
260281} > {
261282 const { sessionKey, note, restartDelayMs, deliveryContext, threadId } =
262283 resolveConfigRestartRequest ( params . requestParams ) ;
284+ const restartRequirement = resolveConfigRestartRequirement ( {
285+ changedPaths : params . changedPaths ,
286+ nextConfig : params . nextConfig ,
287+ } ) ;
263288 const payload = buildConfigRestartSentinelPayload ( {
264289 kind : params . kind ,
265290 mode : params . mode ,
266291 configPath : params . configPath ,
292+ requiresRestart : restartRequirement . requiresRestart ,
267293 sessionKey,
268294 deliveryContext,
269295 threadId,
270296 note,
271297 } ) ;
272298 const sentinelPersisted = await tryWriteRestartSentinelPayload ( payload ) ;
273- const restart = shouldScheduleDirectConfigRestart ( {
274- changedPaths : params . changedPaths ,
275- nextConfig : params . nextConfig ,
276- } )
299+ const restart = restartRequirement . scheduleDirectRestart
277300 ? scheduleGatewaySigusr1Restart ( {
278301 delayMs : restartDelayMs ,
279302 reason : params . mode ,
0 commit comments