From e1d240e502f14c75d8720dd86e5a6141363e5db7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E4=B8=AB=E8=AE=B2=E6=A2=B5?= Date: Thu, 30 Jul 2026 00:10:04 +0800 Subject: [PATCH] fix(editor): wrap dangerous SQL previews by default --- .../components/editor/DangerConfirmDialog.vue | 12 +++++----- .../__tests__/DangerConfirmDialog.spec.ts | 22 +++++++++++++++++++ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/apps/desktop/src/components/editor/DangerConfirmDialog.vue b/apps/desktop/src/components/editor/DangerConfirmDialog.vue index 76cb8e4648..cabe1fa7f9 100644 --- a/apps/desktop/src/components/editor/DangerConfirmDialog.vue +++ b/apps/desktop/src/components/editor/DangerConfirmDialog.vue @@ -18,7 +18,7 @@ const { highlight } = useSqlHighlighter(); const open = defineModel("open", { default: false }); const suppressFuturePrompts = defineModel("suppressFuturePrompts", { default: false }); -const wrap = ref(false); +const wrap = ref(true); const copied = ref(false); const props = withDefaults( @@ -94,8 +94,8 @@ async function copyFullCode() {

{{ message || t("dangerDialog.message") }}

{{ detailsText }}

-
-
+
+
-
-
+          
+
             
{{ t("dangerDialog.previewTruncated", { lines: preview.omittedLines.toLocaleString(), characters: preview.omittedCharacters.toLocaleString() }) }}
-
+            
           
diff --git a/apps/desktop/src/components/editor/__tests__/DangerConfirmDialog.spec.ts b/apps/desktop/src/components/editor/__tests__/DangerConfirmDialog.spec.ts index 8ada137468..373bd13af6 100644 --- a/apps/desktop/src/components/editor/__tests__/DangerConfirmDialog.spec.ts +++ b/apps/desktop/src/components/editor/__tests__/DangerConfirmDialog.spec.ts @@ -51,6 +51,28 @@ afterEach(() => { }); describe("DangerConfirmDialog SQL preview", () => { + it("wraps SQL by default, including long unbroken identifiers", async () => { + await mountDialog(`UPDATE ${"very_long_identifier_".repeat(20)} SET value = 1;`); + + const container = document.body.querySelector('[data-testid="danger-code-container"]'); + const preview = container?.querySelector('[data-testid="danger-code-preview"]'); + const code = preview?.querySelector("pre"); + expect(code?.classList).toContain("whitespace-pre-wrap"); + expect(code?.classList).toContain("break-all"); + expect(preview?.classList).toContain("overflow-auto"); + const actions = container?.querySelector('[data-testid="danger-code-actions"]'); + expect(actions?.classList).toContain("justify-end"); + expect(actions?.nextElementSibling).toBe(preview); + expect(actions?.classList).not.toContain("absolute"); + + actions?.querySelectorAll("button")[1]?.click(); + await nextTick(); + + expect(code?.classList).toContain("whitespace-pre"); + expect(code?.classList).toContain("w-max"); + expect(code?.classList).toContain("min-w-full"); + }); + it("fully highlights short SQL without a truncation notice", async () => { const sql = "DROP TABLE IF EXISTS users;";