MCPcopy
hub / github.com/coder/mux / onWebviewMessage

Method onWebviewMessage

vscode/src/extension.ts:1293–1381  ·  view source on GitHub ↗
(raw: unknown)

Source from the content-addressed store, hash-verified

1291 }
1292
1293 private async onWebviewMessage(raw: unknown): Promise<void> {
1294 const msg = parseWebviewToExtensionMessage(raw);
1295 if (!msg) {
1296 return;
1297 }
1298
1299 switch (msg.type) {
1300 case "debugLog":
1301 muxLogDebug(`mux.chatView(webview): ${msg.message}`, msg.data);
1302 return;
1303
1304 case "copyDebugLog": {
1305 const text = msg.text;
1306 muxLogInfo("mux.chatView: copyDebugLog requested", {
1307 traceId: this.traceId,
1308 length: text.length,
1309 });
1310
1311 await vscode.env.clipboard.writeText(text);
1312 this.postMessage({
1313 type: "uiNotice",
1314 level: "info",
1315 message: "Copied mux debug log to clipboard.",
1316 });
1317 return;
1318 }
1319
1320 case "orpcCall": {
1321 if (this.pendingOrpcCalls.has(msg.requestId)) {
1322 this.postMessage({
1323 type: "orpcResponse",
1324 requestId: msg.requestId,
1325 ok: false,
1326 error: "Duplicate ORPC requestId",
1327 });
1328 return;
1329 }
1330
1331 const controller = new AbortController();
1332 this.pendingOrpcCalls.set(msg.requestId, controller);
1333
1334 await this.handleOrpcCall({
1335 requestId: msg.requestId,
1336 path: msg.path,
1337 input: msg.input,
1338 lastEventId: msg.lastEventId,
1339 controller,
1340 });
1341 return;
1342 }
1343
1344 case "orpcCancel":
1345 this.handleOrpcCancel(msg.requestId);
1346 return;
1347
1348 case "orpcStreamCancel":
1349 this.handleOrpcStreamCancel(msg.streamId);
1350 return;

Callers 1

resolveWebviewViewMethod · 0.95

Calls 14

postMessageMethod · 0.95
handleOrpcCallMethod · 0.95
handleOrpcCancelMethod · 0.95
refreshWorkspacesMethod · 0.95
openWorkspaceFromViewMethod · 0.95
muxLogDebugFunction · 0.85
muxLogInfoFunction · 0.85

Tested by

no test coverage detected