Skip to content

Commit f0fe1dd

Browse files
1 parent 12caee8 commit f0fe1dd

1 file changed

Lines changed: 302 additions & 0 deletions

File tree

Source/Function/SkyBridge.ts

Lines changed: 302 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,308 @@ export async function InstallSkyBridge(): Promise<void> {
370370
);
371371
});
372372

373+
// BATCH-19 Part B: Mountain now fans terminal lifecycle events back
374+
// through the `sky://terminal/*` channel so the xterm panel can mount
375+
// without waiting for Cocoon to relay. Each event is re-dispatched as a
376+
// DOM `CustomEvent` so the terminal React/Astro components subscribe
377+
// through the same `document.addEventListener("cel:terminal:*")`
378+
// interface they use for resize.
379+
await Register(
380+
"sky://terminal/create",
381+
({ id, name, pid }: any) => {
382+
document.dispatchEvent(
383+
new CustomEvent("cel:terminal:create", {
384+
detail: { id, name, pid },
385+
}),
386+
);
387+
},
388+
);
389+
390+
await Register("sky://terminal/data", ({ id, data }: any) => {
391+
document.dispatchEvent(
392+
new CustomEvent("cel:terminal:data", {
393+
detail: { id, data },
394+
}),
395+
);
396+
});
397+
398+
await Register("sky://terminal/exit", ({ id }: any) => {
399+
document.dispatchEvent(
400+
new CustomEvent("cel:terminal:exit", {
401+
detail: { id },
402+
}),
403+
);
404+
});
405+
406+
// ---- Workspace folders ----
407+
// BATCH-14 follow-up: whenever Mountain mutates the workspace folder set
408+
// it emits `sky://workspaces/changed` with `{ added, removed, folders }`.
409+
// Sky re-dispatches it as a DOM event so the sidebar, breadcrumb, and
410+
// recent-folders list can refresh without polling `workspaces:getFolders`.
411+
await Register(
412+
"sky://workspaces/changed",
413+
({ added, removed, folders }: any) => {
414+
document.dispatchEvent(
415+
new CustomEvent("cel:workspaces:changed", {
416+
detail: { added, removed, folders },
417+
}),
418+
);
419+
},
420+
);
421+
422+
// ---- Notifications ----
423+
// Cocoon's `vscode.window.show{Information,Warning,Error}Message` routes
424+
// through Mountain's `Window.ShowMessage` effect which emits this event.
425+
// Sky re-dispatches it as `cel:notification:show` so any notification UI
426+
// (toast stack, status bar banner) can subscribe without needing a
427+
// direct Tauri listener.
428+
await Register("sky://notification/show", (Payload: any) => {
429+
document.dispatchEvent(
430+
new CustomEvent("cel:notification:show", {
431+
detail: Payload,
432+
}),
433+
);
434+
});
435+
await Register("sky://notification/progress-begin", (Payload: any) => {
436+
document.dispatchEvent(
437+
new CustomEvent("cel:notification:progress-begin", {
438+
detail: Payload,
439+
}),
440+
);
441+
});
442+
await Register(
443+
"sky://notification/progress-update",
444+
(Payload: any) => {
445+
document.dispatchEvent(
446+
new CustomEvent("cel:notification:progress-update", {
447+
detail: Payload,
448+
}),
449+
);
450+
},
451+
);
452+
await Register("sky://notification/progress-end", (Payload: any) => {
453+
document.dispatchEvent(
454+
new CustomEvent("cel:notification:progress-end", {
455+
detail: Payload,
456+
}),
457+
);
458+
});
459+
460+
// ---- Quick-pick / input / dialog prompts ----
461+
// Mountain's `Window.ShowQuickPick`/`ShowInputBox`/`ShowOpenDialog`/
462+
// `ShowSaveDialog` effects emit these events so Sky can render the
463+
// picker. Reply path (Sky → Mountain) is a downstream batch; re-
464+
// dispatching the event is enough for the current stub path.
465+
await Register("sky://quickpick/show", (Payload: any) => {
466+
document.dispatchEvent(
467+
new CustomEvent("cel:quickpick:show", { detail: Payload }),
468+
);
469+
});
470+
await Register("sky://input-box/show", (Payload: any) => {
471+
document.dispatchEvent(
472+
new CustomEvent("cel:input-box:show", { detail: Payload }),
473+
);
474+
});
475+
await Register("sky://dialog/open", (Payload: any) => {
476+
document.dispatchEvent(
477+
new CustomEvent("cel:dialog:open", { detail: Payload }),
478+
);
479+
});
480+
await Register("sky://dialog/save", (Payload: any) => {
481+
document.dispatchEvent(
482+
new CustomEvent("cel:dialog:save", { detail: Payload }),
483+
);
484+
});
485+
486+
// ---- Lifecycle ----
487+
// Mountain emits this on `ApplicationRunTime::Shutdown()` before the
488+
// recovery pass tears sockets down. Wind/Sky need to flush state and
489+
// dispose long-lived subscriptions.
490+
await Register("sky://lifecycle/willShutdown", (Payload: any) => {
491+
document.dispatchEvent(
492+
new CustomEvent("cel:lifecycle:willShutdown", {
493+
detail: Payload,
494+
}),
495+
);
496+
});
497+
498+
// ---- Status bar ----
499+
// Extensions that call `vscode.window.createStatusBarItem(...)` fan
500+
// `statusBar.update` through Mountain to `sky://status-bar/update`, and
501+
// `setStatusBarMessage` through `statusBar.message` →
502+
// `sky://status-bar/message`. Sky re-dispatches both as DOM events so
503+
// the workbench's status-bar component can subscribe in one place.
504+
await Register("sky://status-bar/update", (Payload: any) => {
505+
document.dispatchEvent(
506+
new CustomEvent("cel:status-bar:update", { detail: Payload }),
507+
);
508+
});
509+
await Register("sky://status-bar/dispose", (Payload: any) => {
510+
document.dispatchEvent(
511+
new CustomEvent("cel:status-bar:dispose", { detail: Payload }),
512+
);
513+
});
514+
await Register("sky://status-bar/message", (Payload: any) => {
515+
document.dispatchEvent(
516+
new CustomEvent("cel:status-bar:message", { detail: Payload }),
517+
);
518+
});
519+
520+
// ---- Languages ----
521+
// `vscode.languages.setTextDocumentLanguage(doc, languageId)` flows
522+
// through Mountain's `languages.setDocumentLanguage` notification.
523+
await Register(
524+
"sky://languages/setDocumentLanguage",
525+
(Payload: any) => {
526+
document.dispatchEvent(
527+
new CustomEvent("cel:languages:setDocumentLanguage", {
528+
detail: Payload,
529+
}),
530+
);
531+
},
532+
);
533+
// `setLanguageConfiguration` fires when an extension's activation
534+
// installs brackets, wordPattern, indentationRules, etc. Monaco
535+
// applies them via `monaco.languages.setLanguageConfiguration` in the
536+
// workbench layer; re-dispatch so that shim can pick them up.
537+
await Register("sky://language/configure", (Payload: any) => {
538+
document.dispatchEvent(
539+
new CustomEvent("cel:language:configure", { detail: Payload }),
540+
);
541+
});
542+
543+
// ---- Diagnostics / themes / SCM / docs / tests / native ----
544+
// Round up the remaining `sky://` channels Mountain already emits so
545+
// every event has a DOM listener downstream. Each arm re-dispatches
546+
// on `cel:<prefix>:<action>` so consumers never need a Tauri listener
547+
// of their own.
548+
for (const [Channel, DomEvent] of [
549+
["sky://diagnostics/changed", "cel:diagnostics:changed"],
550+
["sky://theme/change", "cel:theme:change"],
551+
["sky://tree-view/dispose", "cel:tree-view:dispose"],
552+
["sky://tree-view/create", "cel:tree-view:create"],
553+
["sky://test/registered", "cel:test:registered"],
554+
["sky://scm/provider/added", "cel:scm:provider-added"],
555+
["sky://scm/provider/removed", "cel:scm:provider-removed"],
556+
["sky://documents/open", "cel:documents:open"],
557+
["sky://documents/saved", "cel:documents:saved"],
558+
["sky://debug/stop", "cel:debug:stop"],
559+
["sky://debug/addBreakpoints", "cel:debug:addBreakpoints"],
560+
["sky://debug/removeBreakpoints", "cel:debug:removeBreakpoints"],
561+
["sky://debug/consoleAppend", "cel:debug:consoleAppend"],
562+
["sky://terminal/closed", "cel:terminal:closed"],
563+
["sky://terminal/opened", "cel:terminal:opened"],
564+
["sky://native/openExternal", "cel:native:openExternal"],
565+
["sky://task/terminate", "cel:task:terminate"],
566+
["sky://editor/applyEdits", "cel:editor:applyEdits"],
567+
["sky://editor/openDocument", "cel:editor:openDocument"],
568+
["sky://editor/saveAll", "cel:editor:saveAll"],
569+
["sky://output/replace", "cel:output:replace"],
570+
["sky://output/reveal", "cel:output:reveal"],
571+
["sky://statusbar/create", "cel:statusbar:create"],
572+
["sky://statusbar/dispose", "cel:statusbar:dispose"],
573+
["sky://statusbar/dispose-entry", "cel:statusbar:dispose-entry"],
574+
["sky://statusbar/set-entry", "cel:statusbar:set-entry"],
575+
["sky://webview/setHtml", "cel:webview:setHtml"],
576+
] as const) {
577+
await Register(Channel, (Payload: any) => {
578+
document.dispatchEvent(
579+
new CustomEvent(DomEvent, { detail: Payload }),
580+
);
581+
});
582+
}
583+
584+
// ---- Extension-host debug service ----
585+
// Workbench reload/close triggered from the extension host debug
586+
// service (`vscode.debug.onDidReceiveDebugSessionCustomEvent` flow).
587+
await Register("sky://exthost/debug-reload", (Payload: any) => {
588+
document.dispatchEvent(
589+
new CustomEvent("cel:exthost:debug-reload", { detail: Payload }),
590+
);
591+
});
592+
await Register("sky://exthost/debug-close", (Payload: any) => {
593+
document.dispatchEvent(
594+
new CustomEvent("cel:exthost:debug-close", { detail: Payload }),
595+
);
596+
});
597+
598+
// ---- Webview extensions ----
599+
// Extension-initiated webview metadata/content updates. Covers
600+
// setTitle, setIconPath, setHtml so every webview panel stays in sync.
601+
for (const Action of ["setTitle", "setIconPath", "setHtml"]) {
602+
await Register(`sky://webview/${Action}`, (Payload: any) => {
603+
document.dispatchEvent(
604+
new CustomEvent(`cel:webview:${Action}`, { detail: Payload }),
605+
);
606+
});
607+
}
608+
609+
// ---- Tasks ----
610+
// `vscode.tasks.executeTask(task)` flows through Mountain's
611+
// `Task.Execute` effect, which emits `sky://task/execute` so the
612+
// workbench's task-runner component can pick up the payload and drive
613+
// the underlying process.
614+
await Register("sky://task/execute", (Payload: any) => {
615+
document.dispatchEvent(
616+
new CustomEvent("cel:task:execute", { detail: Payload }),
617+
);
618+
});
619+
620+
// ---- Workspace edits / focus ----
621+
// Extensions' `workspace.applyEdit(edit)` / `window.showTextDocument(uri)`
622+
// round-trip through Mountain; Sky re-dispatches so the workbench can
623+
// drive its BulkEditService + EditorService.
624+
await Register("sky://workspace/applyEdit", (Payload: any) => {
625+
document.dispatchEvent(
626+
new CustomEvent("cel:workspace:applyEdit", { detail: Payload }),
627+
);
628+
});
629+
await Register("sky://window/showTextDocument", (Payload: any) => {
630+
document.dispatchEvent(
631+
new CustomEvent("cel:window:showTextDocument", { detail: Payload }),
632+
);
633+
});
634+
635+
// ---- Editor decorations ----
636+
await Register(
637+
"sky://decoration/createTextEditorDecorationType",
638+
(Payload: any) => {
639+
document.dispatchEvent(
640+
new CustomEvent("cel:decoration:create", { detail: Payload }),
641+
);
642+
},
643+
);
644+
await Register(
645+
"sky://decoration/disposeTextEditorDecorationType",
646+
(Payload: any) => {
647+
document.dispatchEvent(
648+
new CustomEvent("cel:decoration:dispose", { detail: Payload }),
649+
);
650+
},
651+
);
652+
653+
// ---- Output channels ----
654+
// `vscode.window.createOutputChannel(...)` runs entirely in the extension
655+
// host, but lifecycle events (create/append/clear/show/hide/dispose)
656+
// round-trip through Mountain as notifications so the workbench's
657+
// Output panel can mirror every write. Sky re-dispatches each arm.
658+
for (const Action of [
659+
"create",
660+
"append",
661+
"clear",
662+
"show",
663+
"hide",
664+
"dispose",
665+
]) {
666+
await Register(`sky://output-channel/${Action}`, (Payload: any) => {
667+
document.dispatchEvent(
668+
new CustomEvent(`cel:output-channel:${Action}`, {
669+
detail: Payload,
670+
}),
671+
);
672+
});
673+
}
674+
373675
// ---- Webview ----
374676
await Register(
375677
"sky://webview/message",

0 commit comments

Comments
 (0)