From b42ad91fc2dc4e8b7a63de8f0ec2f0656dcf25a6 Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Fri, 4 Sep 2026 12:17:20 +0800 Subject: [PATCH] fix(completion): show column comments inline in SQL completions --- .../src/lib/__tests__/sql/semantic/completion.spec.ts | 9 +++++++++ apps/desktop/src/lib/sql/sqlCompletion.ts | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/apps/desktop/src/lib/__tests__/sql/semantic/completion.spec.ts b/apps/desktop/src/lib/__tests__/sql/semantic/completion.spec.ts index a5914fb92d..2bec0f86df 100644 --- a/apps/desktop/src/lib/__tests__/sql/semantic/completion.spec.ts +++ b/apps/desktop/src/lib/__tests__/sql/semantic/completion.spec.ts @@ -60,6 +60,15 @@ describe("semantic SQL completion candidates", () => { expect(items.filter((item) => item.type === "column").map((item) => item.label)).not.toContain("legacy_id"); }); + it("shows the column comment inline in the completion detail", () => { + const columnsByTable = new Map([["users", [{ name: "nickname", table: "users", schema: "public", dataType: "text", comment: "用户昵称" }]]]); + + const { items } = semanticCompletion("SELECT nick| FROM users", { columnsByTable }, { databaseType: "postgres", dialect: "postgres" }); + + const nickname = items.find((item) => item.type === "column" && item.label === "nickname"); + expect(nickname?.detail).toContain("-- 用户昵称"); + }); + it("ignores line-comment semicolons after a real statement boundary", () => { const columnsByTable = new Map([ ["codex_completion_a", [{ name: "legacy_id", table: "codex_completion_a", schema: "public" }]], diff --git a/apps/desktop/src/lib/sql/sqlCompletion.ts b/apps/desktop/src/lib/sql/sqlCompletion.ts index 4bb76847dc..63d497860c 100644 --- a/apps/desktop/src/lib/sql/sqlCompletion.ts +++ b/apps/desktop/src/lib/sql/sqlCompletion.ts @@ -4608,6 +4608,13 @@ function buildColumnDetail(column: SqlCompletionColumn): string { if (column.isNullable === false) { detail += " NOT NULL"; } + // Surface the column comment inline in the completion row (e.g. Chinese + // field notes) so it shows without opening the side info panel. This was + // dropped when qualified completion queries were optimized; keep it here. + const comment = column.comment?.trim(); + if (comment) { + detail += ` -- ${comment}`; + } return detail; }