fix(ai): constrain explain plan canvas overflow

This commit is contained in:
Melody Ruch authored and GitHub committed 2026-08-19 20:22:15 +08:00
1 parent 4c38b389ce
commit 11903c6dfd
4 files changed
+47 -9

No files matched your search

@@ -2614,8 +2614,8 @@ async function openExternalUrl(url: string) {
<GitBranch class="h-3 w-3" />
{{ t("explain.title") }}
</Button>
<div v-if="step.toolName === 'explain_query' && step.explainData && connection?.db_type" class="mb-1">
<ExplainPlanViewer :plan="parseExplainFromData(step.explainData, connection.db_type)" class="max-h-64" />
<div v-if="step.toolName === 'explain_query' && step.explainData && connection?.db_type" class="mb-1 h-64 overflow-hidden rounded border">
<ExplainPlanViewer :plan="parseExplainFromData(step.explainData, connection.db_type)" />
</div>
<div v-else-if="step.isError && step.toolResult" class="text-[10px] text-red-600 dark:text-red-400">{{ step.toolResult }}</div>
<div v-else-if="step.toolResult" class="max-h-48 overflow-auto text-[10px] text-muted-foreground whitespace-pre-wrap">{{ step.toolResult }}</div>
@@ -0,0 +1,18 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
const source = readFileSync(new URL("../AiAssistant.vue", import.meta.url), "utf8");
describe("AI assistant explain_query canvas containment", () => {
it("bounds the embedded ExplainPlanViewer to a fixed, clipped height", () => {
const match = source.match(/<div v-if="step\.toolName === 'explain_query' && step\.explainData[^>]*class="([^"]*)"/);
expect(match, "explain_query wrapper div not found").not.toBeNull();
const wrapperClass = match![1];
expect(wrapperClass).toContain("h-64");
expect(wrapperClass).toContain("overflow-hidden");
});
it("does not rely on an unresolvable max-height alone to contain the canvas", () => {
expect(source).not.toContain('<ExplainPlanViewer :plan="parseExplainFromData(step.explainData, connection.db_type)" class="max-h-64" />');
});
});