Skip to content

Commit 4d9fb69

Browse files
feat(Sky): Add tree-view data bridge for cel: events
Add a document listener for `cel:tree-view:create` that bridges tree view data between Mountain and the Sky frontend. When triggered, the listener invokes Mountain's `tree:getChildren` method and re-dispatches the returned items as `cel:tree-view:items` for any downstream renderer shim. This completes the F1.1 handoff contract: Mountain emits `cel:tree-view:create` but nothing was listening, resulting in `consumer-present=false` in the cel-dispatch logs. The listener now primes the viewer by requesting root children and broadcasting them, eliminating the orphan event pattern. Dev logging via `RenderDevLog` tracks both successful item retrieval (`bridge-items`) and failures (`bridge-error`) for debugging. Also removes obsolete Step 13 comment from astro.config.ts regarding the built-in extension copy workaround.
1 parent 8da853e commit 4d9fb69

2 files changed

Lines changed: 55 additions & 5 deletions

File tree

Source/Function/SkyBridge.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,61 @@ export async function InstallSkyBridge(): Promise<void> {
771771
});
772772
}
773773

774+
// ---- Tree-view data bridge ----
775+
// Consumer for `cel:tree-view:create` - without this listener the fan-out
776+
// above re-dispatches the event but nothing downstream listens, so every
777+
// registered view logs `consumer-present=false` (F1.1 in HANDOFF §-10).
778+
// The listener primes the viewer by requesting the root children through
779+
// Mountain's `tree:getChildren` invoke - Mountain forwards to Cocoon's
780+
// `$provideTreeChildren` and returns `{ items: [...] }`. We re-dispatch
781+
// the children on `cel:tree-view:items` so any renderer shim can pick
782+
// them up without an extra round-trip.
783+
if (typeof document !== "undefined") {
784+
document.addEventListener("cel:tree-view:create", (Event: Event) => {
785+
const Detail = (Event as CustomEvent).detail as
786+
| { viewId?: string; extensionId?: string }
787+
| undefined;
788+
const ViewId = Detail?.viewId ?? "";
789+
if (!ViewId) return;
790+
invoke<{ items?: unknown[] }>("MountainIPCInvoke", {
791+
method: "tree:getChildren",
792+
params: [{ viewId: ViewId, treeItemHandle: "" }],
793+
})
794+
.then((Response) => {
795+
const Items = Array.isArray(Response?.items)
796+
? Response.items
797+
: [];
798+
document.dispatchEvent(
799+
new CustomEvent("cel:tree-view:items", {
800+
detail: {
801+
viewId: ViewId,
802+
parent: "",
803+
items: Items,
804+
},
805+
}),
806+
);
807+
try {
808+
invoke<void>("RenderDevLog", {
809+
Tag: "tree-view",
810+
Message: `[TreeView] bridge-items view=${ViewId} count=${Items.length}`,
811+
tag: "tree-view",
812+
message: `[TreeView] bridge-items view=${ViewId} count=${Items.length}`,
813+
}).catch(() => {});
814+
} catch {}
815+
})
816+
.catch((Error) => {
817+
try {
818+
invoke<void>("RenderDevLog", {
819+
Tag: "tree-view",
820+
Message: `[TreeView] bridge-error view=${ViewId} err=${String(Error)}`,
821+
tag: "tree-view",
822+
message: `[TreeView] bridge-error view=${ViewId} err=${String(Error)}`,
823+
}).catch(() => {});
824+
} catch {}
825+
});
826+
});
827+
}
828+
774829
// ---- Extension-host debug service ----
775830
// Workbench reload/close triggered from the extension host debug
776831
// service (`vscode.debug.onDidReceiveDebugSessionCustomEvent` flow).

astro.config.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,6 @@ export default defineConfig({
334334
// Step 13 - built-in extension copy + `npm install`
335335
// spawn - esbuild plugins have no post-
336336
// build external-command hook.
337-
//
338-
// Follow-up work is tracked in
339-
// `.claude/plans/unified-juggling-squirrel.md` under
340-
// the "Out of scope for this pass" section.
341-
342337
// Step 8: When Electron=true, patch workbench.js to surface
343338
// errors from the async IIFE. The original code does NOT await
344339
// result.main(configuration) and has no unhandledrejection

0 commit comments

Comments
 (0)