Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(ai): wrap long tokens in user chat messages

zipg8dab02245281
diff --git a/apps/desktop/src/components/editor/AiAssistant.vue b/apps/desktop/src/components/editor/AiAssistant.vue
index a2e8a29c30..85990a6279 100644
--- a/apps/desktop/src/components/editor/AiAssistant.vue
+++ b/apps/desktop/src/components/editor/AiAssistant.vue
@@ -4780,7 +4780,7 @@ async function openExternalUrl(url: string) {
<span class="truncate">{{ mention.kind === "table" ? [mention.schema, mention.table].filter(Boolean).join(".") : mention.name }}</span>
</button>
</div>
- <div v-if="msg.content" class="whitespace-pre-wrap">{{ msg.content }}</div>
+ <div v-if="msg.content" data-ai-user-message-content class="whitespace-pre-wrap">{{ msg.content }}</div>
</div>
<div v-if="canCopyMessage(msg)" class="mt-1 flex justify-end">
<button
@@ -4888,7 +4888,7 @@ async function openExternalUrl(url: string) {
</button>
</div>
</div>
- <pre class="ai-code-block whitespace-pre-wrap break-words p-3 text-xs leading-relaxed text-zinc-900 dark:text-zinc-100"><code v-html="seg.html"></code></pre>
+ <pre class="ai-code-block whitespace-pre-wrap break-words [overflow-wrap:anywhere] p-3 text-xs leading-relaxed text-zinc-900 dark:text-zinc-100"><code v-html="seg.html"></code></pre>
</div>
</template>
<div v-if="msg === proposalConfirmMessage" class="mt-2 flex gap-2" :title="t('ai.proposalConfirmTitle')">
@@ -5716,6 +5716,10 @@ html.dbx-legacy-webview.dark .ai-markdown :deep(.ai-markdown-table-wrap:hover::-
overflow-anchor: none;
}
+.ai-message-scroll :deep([data-ai-user-message-content]) {
+ overflow-wrap: anywhere;
+}
+
.resize-handle {
position: absolute;
top: -4px;
diff --git a/apps/desktop/src/components/editor/__tests__/AiAssistant.messageWrap.spec.ts b/apps/desktop/src/components/editor/__tests__/AiAssistant.messageWrap.spec.ts
new file mode 100644
index 0000000000..fce498305a
--- /dev/null
+++ b/apps/desktop/src/components/editor/__tests__/AiAssistant.messageWrap.spec.ts
@@ -0,0 +1,16 @@
+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 message wrapping", () => {
+ it("allows long unbroken user text such as comma-separated SQL arrays to wrap", () => {
+ expect(source).toContain('data-ai-user-message-content class="whitespace-pre-wrap">{{ msg.content }}</div>');
+ expect(source).toContain(".ai-message-scroll :deep([data-ai-user-message-content])");
+ expect(source).toContain("overflow-wrap: anywhere;");
+ });
+
+ it("allows long unbroken fenced code to wrap inside the message bubble", () => {
+ expect(source).toContain('class="ai-code-block whitespace-pre-wrap break-words [overflow-wrap:anywhere]');
+ });
+});