(view: vscode.WebviewView)
| 1029 | } |
| 1030 | |
| 1031 | resolveWebviewView(view: vscode.WebviewView): void { |
| 1032 | muxLogDebug("mux.chatView: resolveWebviewView", { visible: view.visible }); |
| 1033 | |
| 1034 | // New view instance; clear any previous timers. |
| 1035 | this.clearReadyProbeInterval(); |
| 1036 | |
| 1037 | this.traceId = randomBytes(8).toString("hex"); |
| 1038 | muxLogDebug("mux.chatView: traceId assigned", { traceId: this.traceId }); |
| 1039 | |
| 1040 | this.view = view; |
| 1041 | this.isWebviewReady = false; |
| 1042 | |
| 1043 | const viewDisposables: vscode.Disposable[] = []; |
| 1044 | |
| 1045 | try { |
| 1046 | view.webview.options = { |
| 1047 | enableScripts: true, |
| 1048 | localResourceRoots: [ |
| 1049 | vscode.Uri.joinPath(this.context.extensionUri, "out"), |
| 1050 | vscode.Uri.joinPath(this.context.extensionUri, "media"), |
| 1051 | ], |
| 1052 | }; |
| 1053 | |
| 1054 | muxLogDebug("mux.chatView: webview.options set", { |
| 1055 | enableScripts: view.webview.options.enableScripts ?? false, |
| 1056 | localResourceRoots: (view.webview.options.localResourceRoots ?? []).map((uri) => |
| 1057 | uri.toString() |
| 1058 | ), |
| 1059 | }); |
| 1060 | |
| 1061 | const visibilityDisposable = view.onDidChangeVisibility(async () => { |
| 1062 | muxLogDebug("mux.chatView: view visibility changed", { visible: view.visible }); |
| 1063 | |
| 1064 | if (!view.visible) { |
| 1065 | return; |
| 1066 | } |
| 1067 | |
| 1068 | if (!this.isWebviewReady) { |
| 1069 | return; |
| 1070 | } |
| 1071 | |
| 1072 | await this.refreshWorkspaces(); |
| 1073 | }); |
| 1074 | viewDisposables.push(visibilityDisposable); |
| 1075 | |
| 1076 | // Register the message handler before setting HTML to avoid losing the initial |
| 1077 | // "ready" handshake due to a race. |
| 1078 | const messageDisposable = view.webview.onDidReceiveMessage((msg: unknown) => { |
| 1079 | const msgType = |
| 1080 | typeof msg === "object" && |
| 1081 | msg !== null && |
| 1082 | "type" in msg && |
| 1083 | typeof (msg as { type?: unknown }).type === "string" |
| 1084 | ? (msg as { type: string }).type |
| 1085 | : undefined; |
| 1086 | |
| 1087 | const meta = |
| 1088 | typeof msg === "object" && msg !== null && "__muxMeta" in msg |
nothing calls this directly
no test coverage detected