MCPcopy Create free account
hub / github.com/codag-megalith/codag-visualizer / showFilePicker

Method showFilePicker

frontend/src/webview.ts:360–415  ·  view source on GitHub ↗

* Show file picker in webview and wait for user selection

(tree: FileTreeNode, totalFiles: number)

Source from the content-addressed store, hash-verified

358 * Show file picker in webview and wait for user selection
359 */
360 async showFilePicker(tree: FileTreeNode, totalFiles: number): Promise<string[] | null> {
361 // Ensure panel is created
362 if (!this.panel) {
363 this.panel = vscode.window.createWebviewPanel(
364 'codag',
365 'LLM Architecture',
366 vscode.ViewColumn.Two,
367 {
368 enableScripts: true,
369 retainContextWhenHidden: true,
370 localResourceRoots: [
371 vscode.Uri.joinPath(this.context.extensionUri, 'media'),
372 vscode.Uri.joinPath(this.context.extensionUri, 'out')
373 ]
374 }
375 );
376
377 this.panel.iconPath = this.getIconPath();
378
379 this.panel.onDidDispose(() => {
380 this.panel = undefined;
381 // If file picker was open, resolve with null
382 if (this.filePickerResolver) {
383 this.filePickerResolver(null);
384 this.filePickerResolver = null;
385 }
386 });
387
388 this.setupMessageHandlers();
389
390 // Show empty graph initially - reset ready state since HTML is replaced
391 this.resetWebviewState();
392 this.panel.webview.html = this.getHtml({ nodes: [], edges: [], llms_detected: [], workflows: [] });
393
394 } else {
395 this.panel.reveal();
396 }
397
398 // Send file picker message to webview (queued until ready)
399 // Include pricing for cost estimation in file picker
400 this.postMessage({
401 command: 'showFilePicker',
402 tree,
403 totalFiles,
404 pricing: {
405 inputPer1M: 0.075, // Gemini 2.5 Flash input cost
406 outputPer1M: 0.30, // Gemini 2.5 Flash output cost
407 outputPerFile: 2000 // Estimated output tokens per file
408 }
409 });
410
411 // Wait for result
412 return new Promise((resolve) => {
413 this.filePickerResolver = resolve;
414 });
415 }
416
417 showLoading(message: string) {

Callers 2

activateFunction · 0.95
analyzeWorkspaceFunction · 0.80

Calls 5

getIconPathMethod · 0.95
setupMessageHandlersMethod · 0.95
resetWebviewStateMethod · 0.95
getHtmlMethod · 0.95
postMessageMethod · 0.95

Tested by

no test coverage detected