3333import { invoke } from "@tauri-apps/api/core" ;
3434import { listen } from "@tauri-apps/api/event" ;
3535
36+ // Single source of truth for Mountain → Sky event URIs. Importing from
37+ // the Wind package avoids maintaining a parallel string table here and
38+ // catches drift against Mountain's Rust `SkyEvent` enum at type-check
39+ // time (Wind's TS table is the TS mirror of Common/IPC/SkyEvent.rs).
40+ import SkyEvent from "@codeeditorland/wind/Target/IPC/SkyEvent.js" ;
41+
3642// ============================================================================
3743// VS Code workbench accessor
3844// ============================================================================
@@ -599,23 +605,26 @@ export async function InstallSkyBridge(): Promise<void> {
599605
600606 // ---- Status bar ----
601607 // Extensions that call `vscode.window.createStatusBarItem(...)` fan
602- // `statusBar.update` through Mountain to `sky://status-bar /update`, and
608+ // `statusBar.update` through Mountain to `sky://statusbar /update`, and
603609 // `setStatusBarMessage` through `statusBar.message` →
604- // `sky://status-bar/message`. Sky re-dispatches both as DOM events so
605- // the workbench's status-bar component can subscribe in one place.
606- await Register ( "sky://status-bar/update" , ( Payload : any ) => {
610+ // `sky://statusbar/set-message`. Sky re-dispatches both as DOM events
611+ // so the workbench's status-bar component can subscribe in one place.
612+ // The canonical wire prefix is `sky://statusbar/` (no hyphen); the
613+ // earlier `sky://status-bar/…` fork was a listener-only mismatch with
614+ // no Mountain emitter and has been retired.
615+ await Register ( "sky://statusbar/update" , ( Payload : any ) => {
607616 document . dispatchEvent (
608- new CustomEvent ( "cel:status-bar :update" , { detail : Payload } ) ,
617+ new CustomEvent ( "cel:statusbar :update" , { detail : Payload } ) ,
609618 ) ;
610619 } ) ;
611- await Register ( "sky://status-bar /dispose" , ( Payload : any ) => {
620+ await Register ( "sky://statusbar /dispose" , ( Payload : any ) => {
612621 document . dispatchEvent (
613- new CustomEvent ( "cel:status-bar :dispose" , { detail : Payload } ) ,
622+ new CustomEvent ( "cel:statusbar :dispose" , { detail : Payload } ) ,
614623 ) ;
615624 } ) ;
616- await Register ( "sky://status-bar/ message" , ( Payload : any ) => {
625+ await Register ( "sky://statusbar/set- message" , ( Payload : any ) => {
617626 document . dispatchEvent (
618- new CustomEvent ( "cel:status-bar: message" , { detail : Payload } ) ,
627+ new CustomEvent ( "cel:statusbar:set- message" , { detail : Payload } ) ,
619628 ) ;
620629 } ) ;
621630
@@ -646,39 +655,42 @@ export async function InstallSkyBridge(): Promise<void> {
646655 // Round up the remaining `sky://` channels Mountain already emits so
647656 // every event has a DOM listener downstream. Each arm re-dispatches
648657 // on `cel:<prefix>:<action>` so consumers never need a Tauri listener
649- // of their own.
650- for ( const [ Channel , DomEvent ] of [
651- [ "sky://diagnostics/changed" , "cel:diagnostics:changed" ] ,
652- [ "sky://theme/change" , "cel:theme:change" ] ,
653- [ "sky://tree-view/dispose" , "cel:tree-view:dispose" ] ,
654- [ "sky://tree-view/create" , "cel:tree-view:create" ] ,
655- [ "sky://test/registered" , "cel:test:registered" ] ,
656- [ "sky://scm/provider/added" , "cel:scm:provider-added" ] ,
657- [ "sky://scm/provider/removed" , "cel:scm:provider-removed" ] ,
658- [ "sky://documents/open" , "cel:documents:open" ] ,
659- [ "sky://documents/saved" , "cel:documents:saved" ] ,
660- [ "sky://debug/stop" , "cel:debug:stop" ] ,
661- [ "sky://debug/addBreakpoints" , "cel:debug:addBreakpoints" ] ,
662- [ "sky://debug/removeBreakpoints" , "cel:debug:removeBreakpoints" ] ,
663- [ "sky://debug/consoleAppend" , "cel:debug:consoleAppend" ] ,
664- [ "sky://terminal/closed" , "cel:terminal:closed" ] ,
665- [ "sky://terminal/opened" , "cel:terminal:opened" ] ,
666- [ "sky://native/openExternal" , "cel:native:openExternal" ] ,
667- [ "sky://task/terminate" , "cel:task:terminate" ] ,
668- [ "sky://editor/applyEdits" , "cel:editor:applyEdits" ] ,
669- [ "sky://editor/openDocument" , "cel:editor:openDocument" ] ,
670- [ "sky://editor/saveAll" , "cel:editor:saveAll" ] ,
671- [ "sky://output/replace" , "cel:output:replace" ] ,
672- [ "sky://output/reveal" , "cel:output:reveal" ] ,
673- [ "sky://statusbar/create" , "cel:statusbar:create" ] ,
674- [ "sky://statusbar/dispose" , "cel:statusbar:dispose" ] ,
675- [ "sky://statusbar/dispose-entry" , "cel:statusbar:dispose-entry" ] ,
676- [ "sky://statusbar/set-entry" , "cel:statusbar:set-entry" ] ,
677- [ "sky://webview/setHtml" , "cel:webview:setHtml" ] ,
678- ] as const ) {
658+ // of their own. Channels are sourced from the Wind `SkyEvent` table -
659+ // the single source of truth that mirrors Mountain's Rust enum - so a
660+ // renamed variant either compiles or breaks type-check, never silently
661+ // fails at runtime.
662+ const ChannelToDomEvent = ( Channel : string ) : string =>
663+ Channel . replace ( / ^ s k y : \/ \/ / , "cel:" ) . replace ( / \/ / g, ":" ) ;
664+ const FanOut = [
665+ SkyEvent . DiagnosticsChanged ,
666+ SkyEvent . ThemeChange ,
667+ SkyEvent . TreeViewDispose ,
668+ SkyEvent . TreeViewCreate ,
669+ SkyEvent . TestRegistered ,
670+ SkyEvent . SCMProviderAdded ,
671+ SkyEvent . SCMProviderRemoved ,
672+ SkyEvent . DocumentsOpen ,
673+ SkyEvent . DocumentsSaved ,
674+ SkyEvent . DebugStop ,
675+ SkyEvent . TerminalClosed ,
676+ SkyEvent . TerminalOpened ,
677+ SkyEvent . NativeOpenExternal ,
678+ SkyEvent . TaskTerminate ,
679+ SkyEvent . EditorApplyEdits ,
680+ SkyEvent . EditorOpenDocument ,
681+ SkyEvent . EditorSaveAll ,
682+ SkyEvent . OutputReplace ,
683+ SkyEvent . OutputReveal ,
684+ SkyEvent . StatusBarCreate ,
685+ SkyEvent . StatusBarDispose ,
686+ SkyEvent . StatusBarDisposeEntry ,
687+ SkyEvent . StatusBarSetEntry ,
688+ SkyEvent . WebviewSetHTML ,
689+ ] as const ;
690+ for ( const Channel of FanOut ) {
679691 await Register ( Channel , ( Payload : any ) => {
680692 document . dispatchEvent (
681- new CustomEvent ( DomEvent , { detail : Payload } ) ,
693+ new CustomEvent ( ChannelToDomEvent ( Channel ) , { detail : Payload } ) ,
682694 ) ;
683695 } ) ;
684696 }
@@ -698,15 +710,12 @@ export async function InstallSkyBridge(): Promise<void> {
698710 } ) ;
699711
700712 // ---- Webview extensions ----
701- // Extension-initiated webview metadata/content updates. Covers
702- // setTitle, setIconPath, setHtml so every webview panel stays in sync.
703- for ( const Action of [ "setTitle" , "setIconPath" , "setHtml" ] ) {
704- await Register ( `sky://webview/${ Action } ` , ( Payload : any ) => {
705- document . dispatchEvent (
706- new CustomEvent ( `cel:webview:${ Action } ` , { detail : Payload } ) ,
707- ) ;
708- } ) ;
709- }
713+ // Extension-initiated webview content updates. The canonical channel
714+ // is the kebab-case `sky://webview/set-html` (see `SkyEvent.ts` for
715+ // the single source of truth). The earlier camelCase fan-out over
716+ // `setTitle`/`setIconPath`/`setHtml` had no matching Mountain emitter
717+ // for the first two and the third is now covered by the main bulk
718+ // loop via `SkyEvent.WebviewSetHTML`.
710719
711720 // ---- Tasks ----
712721 // `vscode.tasks.executeTask(task)` flows through Mountain's
0 commit comments