@@ -16,6 +16,13 @@ export namespace HotReload {
1616 const log = Log . create ( { service : "project.hotreload" } )
1717
1818 export const Event = {
19+ Changed : BusEvent . define (
20+ "opencode.hotreload.changed" ,
21+ z . object ( {
22+ file : z . string ( ) ,
23+ event : z . enum ( [ "add" , "change" , "unlink" ] ) ,
24+ } ) ,
25+ ) ,
1926 Applied : BusEvent . define (
2027 "opencode.hotreload.applied" ,
2128 z . object ( {
@@ -113,6 +120,7 @@ export namespace HotReload {
113120
114121 const debounce = Flag . OPENCODE_EXPERIMENTAL_HOT_RELOAD_DEBOUNCE_MS ?? 700
115122 const cooldown = Flag . OPENCODE_EXPERIMENTAL_HOT_RELOAD_COOLDOWN_MS ?? 1500
123+ const mode = Flag . OPENCODE_EXPERIMENTAL_HOT_RELOAD_MODE === "manual" ? "manual" : "auto"
116124 let timer : ReturnType < typeof setTimeout > | undefined
117125 let busy = false
118126 let last = 0
@@ -200,13 +208,15 @@ export namespace HotReload {
200208 const unsubFile = Bus . subscribe ( FileWatcher . Event . Updated , ( event ) => {
201209 const rel = classify ( Instance . directory , event . properties . file )
202210 if ( ! rel ) return
203- void request (
204- {
205- file : rel ,
206- event : event . properties . event ,
207- } ,
208- "file" ,
209- )
211+
212+ const hit = {
213+ file : rel ,
214+ event : event . properties . event ,
215+ } as const
216+
217+ void Bus . publish ( Event . Changed , hit )
218+ if ( mode === "manual" ) return
219+ void request ( hit , "file" )
210220 } )
211221
212222 const unsubSession = Bus . subscribe ( SessionStatus . Event . Status , ( ) => {
@@ -215,7 +225,7 @@ export namespace HotReload {
215225 timer = setTimeout ( ( ) => flush ( "session" ) , 0 )
216226 } )
217227
218- log . info ( "hot reload enabled" , { debounce, cooldown } )
228+ log . info ( "hot reload enabled" , { debounce, cooldown, mode } )
219229 return {
220230 unsubFile,
221231 unsubSession,
0 commit comments