Skip to content

Commit 84c9eaf

Browse files
committed
fix: tool streaming preview visible during active tool use
- Delay adding ai-tool-done class by 1.5s so the streaming preview remains visible while the tool is active and briefly after completion - Add final flush of aiToolStream on content_block_stop to ensure browser receives latest preview data before tool completes - Update get_browser_console_logs MCP tool description to mention PhNode logs are included
1 parent cd2797a commit 84c9eaf

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

phoenix-builder-mcp/mcp-tools.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ export function registerTools(server, processManager, wsControlServer, phoenixDe
161161
server.tool(
162162
"get_browser_console_logs",
163163
"Get console logs from the Phoenix browser runtime. Returns last 50 entries by default. " +
164+
"This includes both browser-side console logs and Node.js (PhNode) logs, which are prefixed with 'PhNode:'. " +
164165
"USAGE: Start with default tail=50. Use filter (regex) to narrow results (e.g. filter='error|warn'). " +
165166
"Use before=N (from previous totalEntries) to page back. Avoid tail=0 unless necessary — " +
166167
"prefer filter + small tail to keep responses compact.",

src-node/claude-code-agent.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,19 @@ async function _runQuery(requestId, prompt, projectPath, model, signal) {
381381
}
382382
}
383383

384-
// Tool block complete — parse input and send details
384+
// Tool block complete — flush final stream preview and send details
385385
if (event.type === "content_block_stop" &&
386386
event.index === activeToolIndex &&
387387
activeToolName) {
388+
// Final flush of tool stream (bypasses throttle)
389+
if (activeToolInputJson) {
390+
nodeConnector.triggerPeer("aiToolStream", {
391+
requestId: requestId,
392+
toolId: toolCounter,
393+
toolName: activeToolName,
394+
partialJson: activeToolInputJson
395+
});
396+
}
388397
let toolInput = {};
389398
try {
390399
toolInput = JSON.parse(activeToolInputJson);

src/core-ai/AIChatPanel.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,7 @@ define(function (require, exports, module) {
557557
const config = TOOL_CONFIG[toolName] || { icon: "fa-solid fa-gear", color: "#adb9bd", label: toolName };
558558
const detail = _getToolDetail(toolName, toolInput);
559559

560-
// Mark as done: replace spinner with colored icon
561-
$tool.addClass("ai-tool-done");
560+
// Replace spinner with colored icon immediately
562561
$tool.find(".ai-tool-spinner").replaceWith(
563562
'<span class="ai-tool-icon" style="color:' + config.color + '">' +
564563
'<i class="' + config.icon + '"></i>' +
@@ -593,6 +592,14 @@ define(function (require, exports, module) {
593592
}).css("cursor", "pointer").addClass("ai-tool-label-clickable");
594593
}
595594

595+
// Delay marking as done so the streaming preview stays visible briefly.
596+
// The ai-tool-done class hides the preview via CSS; deferring it lets the
597+
// browser paint the preview before it disappears.
598+
setTimeout(function () {
599+
$tool.addClass("ai-tool-done");
600+
$tool.find(".ai-tool-preview").text("");
601+
}, 1500);
602+
596603
_scrollToBottom();
597604
}
598605

0 commit comments

Comments
 (0)