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。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
feat(sidebar): highlight current login user schema
jearhe0c8b796c8c59
diff --git a/apps/desktop/src/components/sidebar/TreeItem.vue b/apps/desktop/src/components/sidebar/TreeItem.vueindex 595c8d31c5..3ca0375e44 100644--- a/apps/desktop/src/components/sidebar/TreeItem.vue+++ b/apps/desktop/src/components/sidebar/TreeItem.vue@@ -68,6 +68,7 @@ import { filterSidebarModifierSelectionIds, supportsSidebarModifierSelection, trimport { applyConnectionMultiSelection, applyTreeNodeSelection, connectionMultiSelectionAfterToggle } from "@/lib/sidebar/sidebarConnectionMultiSelect";import { connectionBearingGroupIdsUnder, connectionIdsUnderGroup } from "@/lib/sidebar/sidebarLayout";import { isSidebarDatabaseOpenForVisual } from "@/lib/sidebar/sidebarDatabaseOpenState";+import { isLoginUserSchemaNode } from "@/lib/sidebar/loginUserNode";import { sidebarTreeContextKey } from "@/lib/sidebar/sidebarTreeContext";import { connectionCanConfigureSidebarVisibleDatabases } from "@/lib/sidebar/sidebarVisibleFilterMenu";import { supportsSidebarObjectNameFilter } from "@/lib/sidebar/sidebarObjectNameFilter";@@ -771,6 +772,14 @@ function isNodeDefaultSchema(): boolean {return activeNode.value.type === "schema" && !!activeNode.value.connectionId && !!activeNode.value.schema && connectionStore.isDefaultSchema(activeNode.value.connectionId, activeNode.value.schema);}+// #7490: on Oracle-family connections whose schemas are database users, bold the+// schema node matching the login user so it stands out among many user schemas.+// Kept as a plain function call (not a computed) so TreeItem stays within the+// top-level computed budget asserted by sidebarRuntimeDecomposition.+function isLoginUserNode(): boolean {+ return isLoginUserSchemaNode(activeNode.value, activeNode.value.connectionId ? connectionStore.getConfig(activeNode.value.connectionId) : undefined);+}+const trailingComment = computed(() => {if (!settingsStore.editorSettings.sidebarObjectInfoMode.startsWith("comment-")) return null;return sidebarTreeNodeComment(activeNode.value, settingsStore.editorSettings.sidebarShowConnectionNotes);@@ -1469,7 +1478,7 @@ function onKeydown(event: KeyboardEvent) {@keydown.escape.prevent="cancelRename"@click.stop/>- <span v-else ref="labelRef" :class="[labelWidthClass, { 'flex-1': node.type === 'connection' && !trailingComment }]">{{ visibleLabel(node) }}</span>+ <span v-else ref="labelRef" :class="[labelWidthClass, { 'flex-1': node.type === 'connection' && !trailingComment, 'font-semibold': isLoginUserNode }]">{{ visibleLabel(node) }}</span><span v-if="treeNodeSecondaryValue(node)" class="min-w-0 max-w-[55%] shrink truncate text-xs text-muted-foreground" :title="treeNodeSecondaryValue(node)">{{ treeNodeSecondaryValue(node) }}</span><buttonv-if="canDragPinnedOrder()"diff --git a/apps/desktop/src/lib/__tests__/sidebar/loginUserNode.spec.ts b/apps/desktop/src/lib/__tests__/sidebar/loginUserNode.spec.tsnew file mode 100644index 0000000000..1164220991--- /dev/null+++ b/apps/desktop/src/lib/__tests__/sidebar/loginUserNode.spec.ts@@ -0,0 +1,80 @@+import { describe, expect, it } from "vitest";+import type { ConnectionConfig, TreeNode } from "@/types/database";+import { isLoginUserSchemaNode } from "@/lib/sidebar/loginUserNode";++function config(overrides: Partial<ConnectionConfig>): ConnectionConfig {+ return {+ id: "conn-1",+ name: "conn",+ db_type: "dameng",+ host: "localhost",+ port: 5236,+ username: "TEST01",+ password: "",+ ...overrides,+ } as ConnectionConfig;+}++function schemaNode(overrides: Partial<TreeNode>): TreeNode {+ return {+ id: "conn-1:TEST01:TEST01",+ label: "TEST01",+ type: "schema",+ connectionId: "conn-1",+ database: "TEST01",+ schema: "TEST01",+ ...overrides,+ };+}++describe("isLoginUserSchemaNode", () => {+ it("marks the schema node matching the login user (Case 1)", () => {+ expect(isLoginUserSchemaNode(schemaNode({}), config({ username: "TEST01" }))).toBe(true);+ });++ it("does not mark other user schemas (Case 2)", () => {+ expect(isLoginUserSchemaNode(schemaNode({ schema: "TEST02", label: "TEST02" }), config({ username: "TEST01" }))).toBe(false);+ expect(isLoginUserSchemaNode(schemaNode({ schema: "SYSDBA", label: "SYSDBA" }), config({ username: "TEST01" }))).toBe(false);+ });++ it("isolates by the caller-provided connection config (Case 3)", () => {+ // A same-named schema on a different connection is checked against that+ // connection's own config, whose login user is different, so it stays plain.+ const otherConnectionConfig = config({ id: "conn-2", username: "OTHER" });+ expect(isLoginUserSchemaNode(schemaNode({ connectionId: "conn-2" }), otherConnectionConfig)).toBe(false);+ });++ it("matches Dameng's upper-cased schema against a lower-case login (Case 4)", () => {+ expect(isLoginUserSchemaNode(schemaNode({ schema: "TEST01", label: "TEST01" }), config({ username: "test01" }))).toBe(true);+ });++ it("never highlights engines whose schema is not a user (Case 5)", () => {+ // PostgreSQL: a `postgres` schema that coincidentally matches the login name+ // is a plain schema, not the login user, and must stay unbolded.+ const pgNode = schemaNode({ schema: "postgres", label: "postgres", database: "app" });+ expect(isLoginUserSchemaNode(pgNode, config({ db_type: "postgres", username: "postgres" }))).toBe(false);+ // MySQL has no schema tree level, but guard the type boundary regardless.+ expect(isLoginUserSchemaNode(pgNode, config({ db_type: "mysql", username: "postgres" }))).toBe(false);+ });++ it("is safe when config, username, or schema is missing (Case 6)", () => {+ expect(isLoginUserSchemaNode(schemaNode({}), undefined)).toBe(false);+ expect(isLoginUserSchemaNode(schemaNode({}), config({ username: "" }))).toBe(false);+ expect(isLoginUserSchemaNode(schemaNode({}), config({ username: " " }))).toBe(false);+ expect(isLoginUserSchemaNode(schemaNode({ schema: undefined, label: "" }), config({ username: "TEST01" }))).toBe(false);+ });++ it("only applies to schema nodes, not tables or other user schemas' children", () => {+ expect(isLoginUserSchemaNode(schemaNode({ type: "table" }), config({ username: "TEST01" }))).toBe(false);+ expect(isLoginUserSchemaNode(schemaNode({ type: "connection" }), config({ username: "TEST01" }))).toBe(false);+ });++ it("falls back to the label when the schema field is absent", () => {+ expect(isLoginUserSchemaNode(schemaNode({ schema: undefined, label: "TEST01" }), config({ username: "test01" }))).toBe(true);+ });++ it("also covers Oracle and OceanBase (Oracle mode) connections", () => {+ expect(isLoginUserSchemaNode(schemaNode({ schema: "SCOTT", label: "SCOTT" }), config({ db_type: "oracle", username: "scott" }))).toBe(true);+ expect(isLoginUserSchemaNode(schemaNode({ schema: "APP", label: "APP" }), config({ db_type: "oceanbase-oracle", username: "app" }))).toBe(true);+ });+});diff --git a/apps/desktop/src/lib/sidebar/loginUserNode.ts b/apps/desktop/src/lib/sidebar/loginUserNode.tsnew file mode 100644index 0000000000..ce05c05ebf--- /dev/null+++ b/apps/desktop/src/lib/sidebar/loginUserNode.ts@@ -0,0 +1,32 @@+import type { ConnectionConfig, TreeNode } from "@/types/database";+import { connectionUsesConnectionRootSchemaMode } from "@/lib/database/jdbcDialect";++/**+ * Whether a sidebar tree node represents the connection's own login user.+ *+ * This is only meaningful for the Oracle-family engines whose connection-root+ * schemas *are* database users (Oracle, Dameng, OceanBase in Oracle mode). For+ * those connections the schema tree is a flat list of user schemas, one of+ * which is the account the connection logged in as. Highlighting it lets a user+ * with many schemas immediately see "which one is me" (issue #7490).+ *+ * The comparison mirrors `filterSchemaNamesForVisiblePicker` in+ * `visibleDatabases.ts`, which already equates `connection.username` with the+ * current user schema case-insensitively. Oracle/Dameng fold unquoted+ * identifiers to upper case, so a `test01` login surfaces as a `TEST01` schema+ * node; the lower-cased compare keeps those matched without inventing a new+ * identifier-normalization framework.+ *+ * Databases where a schema is not a user (PostgreSQL's `public`, a MySQL+ * database that happens to share the login name, every `treeSchema` engine)+ * never reach the connection-root-schema branch, so a coincidental name clash+ * is not mistaken for the login user.+ */+export function isLoginUserSchemaNode(node: Pick<TreeNode, "type" | "schema" | "label">, config: Pick<ConnectionConfig, "db_type" | "driver_profile" | "username"> | undefined): boolean {+ if (node.type !== "schema") return false;+ if (!connectionUsesConnectionRootSchemaMode(config)) return false;+ const username = config?.username?.trim().toLowerCase();+ if (!username) return false;+ const schemaName = (node.schema ?? node.label ?? "").trim().toLowerCase();+ return schemaName.length > 0 && schemaName === username;+}