From 8559d1b422efc8c65d5893925a08d8f1042c4855 Mon Sep 17 00:00:00 2001 From: Yuliia Kovalova Date: Fri, 22 May 2026 13:54:02 +0200 Subject: [PATCH] Fix multi-binlog crashes in timeline, tree view, and diagnostics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Four call sites failed with 'requires explicit binlog_file' when the MCP server was started with multiple binlogs: 1. extension.ts callMcpTool — checked allBinlogPaths (sidebar) but not mcpClient.loadedBinlogs (server). After removing a binlog from the sidebar the two lists diverged, skipping binlog_file injection. 2. binlogTreeView.ts prefetch — called client.callTool directly, bypassing the mcpCall wrapper entirely. 3. binlogTreeView.ts mcpCall — mutated the args object in-place instead of making a copy, causing side effects on shared arg literals. 4. diagnostics.ts loadFromMcpClient — called callTool with no args at all, never injecting binlog_file. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- CHANGELOG.md | 5 +++++ package.json | 2 +- src/binlogTreeView.ts | 5 +++-- src/diagnostics.ts | 6 +++++- src/extension.ts | 5 ++++- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a813bc..5595e8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 0.10.22 (Preview) + +### Fixed +- **Multi-binlog timeline/tree crash** — fixed "requires explicit binlog_file" errors when the MCP server was started with multiple binlogs. The sidebar, tree prefetch, diagnostics, and timeline now correctly inject `binlog_file` even when the sidebar and MCP server binlog lists are out of sync. + ## 0.10.21 (Preview) ### Changed diff --git a/package.json b/package.json index 72f377d..f11cbba 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "binlog-analyzer", "displayName": "MSBuild Binlog Analyzer", "description": "Analyze MSBuild binary logs with Copilot Chat and MCP tools", - "version": "0.10.21", + "version": "0.10.22", "preview": true, "publisher": "dotutils", "license": "MIT", diff --git a/src/binlogTreeView.ts b/src/binlogTreeView.ts index 55c598c..4d8e18e 100644 --- a/src/binlogTreeView.ts +++ b/src/binlogTreeView.ts @@ -209,7 +209,7 @@ export class BinlogTreeDataProvider implements vscode.TreeDataProvider { try { - const result = await client.callTool(c.tool, c.args); + const result = await this.mcpCall(c.tool, c.args); const data = this.tryParseJson(result.text); if (c.cache === 'projects') { @@ -1668,7 +1668,8 @@ export class BinlogTreeDataProvider implements vscode.TreeDataProvider = {}): Promise<{ text: string }> { if (!this.mcpClient) { throw new Error('MCP server not connected'); } if (!args.binlog_file && this.binlogPaths.length >= 1) { - args.binlog_file = this.activeBinlogPath || this.binlogPaths[0]; + const copy = { ...args, binlog_file: this.activeBinlogPath || this.binlogPaths[0] }; + return this.mcpClient.callTool(tool, copy); } return this.mcpClient.callTool(tool, args); } diff --git a/src/diagnostics.ts b/src/diagnostics.ts index fb83b7b..f91bfde 100644 --- a/src/diagnostics.ts +++ b/src/diagnostics.ts @@ -53,7 +53,11 @@ export class BinlogDiagnosticsProvider implements vscode.Disposable { if (!this.mcpClient) { return; } try { - const result = await this.mcpClient.callTool('get_diagnostics'); + const args: Record = {}; + if (this.mcpClient.loadedBinlogs.length > 1) { + args.binlog_file = this.mcpClient.loadedBinlogs[0]; + } + const result = await this.mcpClient.callTool('get_diagnostics', args); const data = JSON.parse(result.text); const diagnostics = this.parseMcpDiagnostics(data); this.cachedDiagnostics = diagnostics; diff --git a/src/extension.ts b/src/extension.ts index ee478b3..02eb117 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -48,7 +48,10 @@ function escapeHtml(s: string): string { */ function callMcpTool(tool: string, args: Record = {}): Promise<{ text: string }> { if (!mcpClient) { throw new Error('MCP server not connected'); } - if (!args.binlog_file && allBinlogPaths.length > 1) { + // Always inject binlog_file when the MCP server was started with multiple + // binlogs — even if the user removed one from the sidebar, the server + // still requires an explicit path. + if (!args.binlog_file && (allBinlogPaths.length > 1 || (mcpClient.loadedBinlogs && mcpClient.loadedBinlogs.length > 1))) { const copy = { ...args, binlog_file: currentBinlogPath || allBinlogPaths[0] }; return mcpClient.callTool(tool, copy); }