File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,13 +40,28 @@ export const LiveEditorServiceLayer = Layer.effect(
4040 const ActiveEditorRef = yield * Ref . make < unknown | null > ( null ) ;
4141 const VisibleEditorsRef = yield * Ref . make < readonly unknown [ ] > ( [ ] ) ;
4242
43- // Listen to Mountain editor-change events and update refs.
44- // Events are emitted via AppHandle.emit("editor:activeChanged", uri).
45- const _ = yield * Effect . fork (
43+ // Listen to Mountain editor-change events emitted by Mountain via
44+ // `AppHandle.emit("editor:activeChanged", { uri, viewColumn })`.
45+ // Update the ActiveEditorRef so GetActiveEditor returns the current uri.
46+ void Effect . runFork (
4647 Effect . gen ( function * ( ) {
47- const Events = IPCService . events ( "editor:activeChanged" ) ;
48- // Stream is consumed for its side effects (updating refs).
49- // If the stream errors, we ignore it - editor state is best-effort.
48+ // Subscribe to the Tauri event channel.
49+ const { listen } = yield * Effect . promise (
50+ ( ) => import ( "@tauri-apps/api/event" ) ,
51+ ) ;
52+ yield * Effect . promise (
53+ ( ) =>
54+ new Promise < void > ( ( Resolve ) => {
55+ void listen ( "editor:activeChanged" , ( Event ) => {
56+ void Effect . runFork (
57+ Ref . set (
58+ ActiveEditorRef ,
59+ Event . payload ?? null ,
60+ ) ,
61+ ) ;
62+ } ) . then ( ( ) => Resolve ( ) ) ;
63+ } ) ,
64+ ) ;
5065 } ) . pipe ( Effect . catchAll ( ( ) => Effect . void ) ) ,
5166 ) ;
5267
Original file line number Diff line number Diff line change @@ -76,15 +76,23 @@ export const LiveExtensionsServiceLayer = Layer.effect(
7676 Effect . mapError ( MakeExtensionsProblem ) ,
7777 ) ,
7878
79+ // `extensions:activate` sends an `activationEvent` gRPC
80+ // notification to Cocoon (`$activateByEvent`) via Mountain.
81+ // Mountain's handler triggers the extension host activation
82+ // machinery for the named extension ID.
7983 Activate : ( id ) =>
80- // TODO(Wave 3 follow-up): replace with a `commands:execute`
81- // of `workbench.extensions.activate` or a dedicated
82- // `extensions:activate` channel so Cocoon's `$activateByEvent`
83- // actually fires. Current implementation only verifies the
84- // extension exists, which matches the legacy stub behaviour.
85- IPCService . invoke ( Channel . ExtensionsGet ) ( [ id ] ) . pipe (
84+ IPCService . invoke ( Channel . ExtensionsActivate ) ( [ id ] ) . pipe (
8685 Effect . map ( ( ) => undefined as void ) ,
8786
87+ Effect . catchAll ( ( ) =>
88+ // Fallback: verify the extension exists even if
89+ // activation fails (e.g. extension host not yet up).
90+ IPCService . invoke ( Channel . ExtensionsGet ) ( [ id ] ) . pipe (
91+ Effect . map ( ( ) => undefined as void ) ,
92+ Effect . mapError ( MakeExtensionsProblem ) ,
93+ ) ,
94+ ) ,
95+
8896 Effect . mapError ( MakeExtensionsProblem ) ,
8997 ) ,
9098
Original file line number Diff line number Diff line change @@ -87,6 +87,8 @@ export default {
8787
8888 ExtensionsReinstall : "extensions:reinstall" ,
8989
90+ ExtensionsActivate : "extensions:activate" ,
91+
9092 ExtensionsScanSystemExtensions : "extensions:scanSystemExtensions" ,
9193
9294 ExtensionsScanUserExtensions : "extensions:scanUserExtensions" ,
You can’t perform that action at this time.
0 commit comments