feat(mcp): apply review fixes for auto-visualization widget (P1/P2/P3) (#2081)

Applies all review fixes from PR #2080 onto current main (which already
has the base feature from #2076):

P1 — pendingHash guard: data changing mid-flight no longer caches stale
HTML under the new hash. autoVisualize now receives startHash and only
writes cachedWidgetHtml / renders when pendingHash === lastJsonHash.

P1 — Stream-end flush: panel no longer gets stuck on loading if stream
closes before a 'done' event. After the read loop, if !rendered and
resultHtml exists (html_complete fired), render it. If !rendered and no
HTML, show error and reset hashes.

P1 — extractJsonData fallback gated on content wrapper absence: was
returning the whole result object (including isError etc.) when content
array had no JSON text. Now only falls back when result.content is not
an array.

P2 — Hash extended to 8192 chars (was 1000).

P2 — destroyController: AbortController on the class; destroy() calls
abort() to cancel any in-flight fetch. AbortError silently returns.

P2 — Dead CSS removed: .mcp-panel-widget .wm-widget-shell and
.wm-widget-body / .wm-widget-generated only apply to basic-tier widgets;
MCP always uses the pro iframe path.

P3 — toolName sliced to 100 chars before LLM prompt injection.
This commit is contained in:
Elie Habib
2026-03-23 01:05:51 +04:00
committed by GitHub
parent 03e3e80b33
commit 32ab184027
2 changed files with 47 additions and 26 deletions

View File

@@ -20394,20 +20394,6 @@ body.has-breaking-alert .panels-grid {
flex-direction: column;
}
.mcp-panel-widget .wm-widget-shell {
flex: 1;
display: flex;
flex-direction: column;
min-height: 240px;
}
.mcp-panel-widget .wm-widget-body,
.mcp-panel-widget .wm-widget-generated {
flex: 1;
overflow-y: auto;
padding: 8px 10px;
}
.mcp-panel-widget iframe {
width: 100%;
min-height: 260px;