Skip to content

Commit 4c6573d

Browse files
committed
docs(vscode-extension): add comments for clarity in sendToExtension and onMessage functions
1 parent 4fc938c commit 4c6573d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

apps/web/src/core/vscode/vscode-bridge.helpers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ const handlers = new Map<string, Set<AnyHandler>>();
1515

1616
export const sendToExtension = (msg: AppMessage): void => {
1717
if (!isVSCodeEnv()) return;
18+
// In VS Code webviews the parent origin is not a stable app URL.
19+
// We post to parent and rely on origin/source checks in the bridge listeners.
1820
window.parent.postMessage(msg, '*');
1921
};
2022

2123
export const onMessage = <T extends HostMessage['type']>(
2224
type: T,
2325
handler: HandlerFor<T>
2426
): (() => void) => {
25-
if (!isVSCodeEnv()) return () => {};
27+
if (!isVSCodeEnv()) return () => { };
2628

2729
const existing = handlers.get(type) ?? new Set<AnyHandler>();
2830
existing.add(handler as AnyHandler);

0 commit comments

Comments
 (0)