fix(ai): wrap long tokens in user chat messages
This commit is contained in:
2 files changed
+22
-2
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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]');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user