@@ -281,9 +281,16 @@ async function _runQuery(requestId, prompt, projectPath, model, signal, locale)
281281 toolId : myToolId ,
282282 edit : edit
283283 } ) ;
284- const reason = ( editResult && editResult . applied === false )
285- ? "Edit FAILED: " + ( editResult . error || "unknown error" )
286- : "Edit applied successfully via Phoenix editor." ;
284+ let reason ;
285+ if ( editResult && editResult . applied === false ) {
286+ reason = "Edit FAILED: " + ( editResult . error || "unknown error" ) ;
287+ } else {
288+ reason = "Edit applied successfully via Phoenix editor." ;
289+ if ( editResult && editResult . isLivePreviewRelated ) {
290+ reason += " The edited file is part of the active live preview." +
291+ " Reload when ready with execJsInLivePreview: `location.reload()`" ;
292+ }
293+ }
287294 return {
288295 hookSpecificOutput : {
289296 hookEventName : "PreToolUse" ,
@@ -347,21 +354,33 @@ async function _runQuery(requestId, prompt, projectPath, model, signal, locale)
347354 newText : input . tool_input . content
348355 } ;
349356 editCount ++ ;
357+ let writeResult ;
350358 try {
351- await nodeConnector . execPeer ( "applyEditToBuffer" , edit ) ;
359+ writeResult = await nodeConnector . execPeer ( "applyEditToBuffer" , edit ) ;
352360 } catch ( err ) {
353361 console . warn ( "[Phoenix AI] Failed to apply write to buffer:" , err . message ) ;
362+ writeResult = { applied : false , error : err . message } ;
354363 }
355364 nodeConnector . triggerPeer ( "aiToolEdit" , {
356365 requestId : requestId ,
357366 toolId : myToolId ,
358367 edit : edit
359368 } ) ;
369+ let reason ;
370+ if ( writeResult && writeResult . applied === false ) {
371+ reason = "Write FAILED: " + ( writeResult . error || "unknown error" ) ;
372+ } else {
373+ reason = "Write applied successfully via Phoenix editor." ;
374+ if ( writeResult && writeResult . isLivePreviewRelated ) {
375+ reason += " The written file is part of the active live preview." +
376+ " Reload when ready with execJsInLivePreview: `location.reload()`" ;
377+ }
378+ }
360379 return {
361380 hookSpecificOutput : {
362381 hookEventName : "PreToolUse" ,
363382 permissionDecision : "deny" ,
364- permissionDecisionReason : "Write applied successfully via Phoenix editor."
383+ permissionDecisionReason : reason
365384 }
366385 } ;
367386 }
0 commit comments