1- import { Bus } from "@/bus"
21import { Config } from "@/config/config"
32import { AppRuntime } from "@/effect/app-runtime"
43import { Flag } from "@opencode-ai/core/flag/flag"
54import { Installation } from "@/installation"
65import { InstallationVersion } from "@opencode-ai/core/installation/version"
6+ import { GlobalBus } from "@/bus/global"
77
88export async function upgrade ( ) {
99 const config = await AppRuntime . runPromise ( Config . Service . use ( ( cfg ) => cfg . getGlobal ( ) ) )
@@ -13,7 +13,13 @@ export async function upgrade() {
1313 if ( ! latest ) return
1414
1515 if ( Flag . OPENCODE_ALWAYS_NOTIFY_UPDATE ) {
16- await Bus . publish ( Installation . Event . UpdateAvailable , { version : latest } )
16+ GlobalBus . emit ( "event" , {
17+ directory : "global" ,
18+ payload : {
19+ type : Installation . Event . UpdateAvailable . type ,
20+ properties : { version : latest } ,
21+ } ,
22+ } )
1723 return
1824 }
1925
@@ -22,12 +28,26 @@ export async function upgrade() {
2228 const kind = Installation . getReleaseType ( InstallationVersion , latest )
2329
2430 if ( config . autoupdate === "notify" || kind !== "patch" ) {
25- await Bus . publish ( Installation . Event . UpdateAvailable , { version : latest } )
31+ GlobalBus . emit ( "event" , {
32+ directory : "global" ,
33+ payload : {
34+ type : Installation . Event . UpdateAvailable . type ,
35+ properties : { version : latest } ,
36+ } ,
37+ } )
2638 return
2739 }
2840
2941 if ( method === "unknown" ) return
3042 await Installation . upgrade ( method , latest )
31- . then ( ( ) => Bus . publish ( Installation . Event . Updated , { version : latest } ) )
43+ . then ( ( ) =>
44+ GlobalBus . emit ( "event" , {
45+ directory : "global" ,
46+ payload : {
47+ type : Installation . Event . Updated . type ,
48+ properties : { version : latest } ,
49+ } ,
50+ } ) ,
51+ )
3252 . catch ( ( ) => { } )
3353}
0 commit comments