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(sql-file): locate query tab files from the context menu
二丫讲梵933d78e8e9f4
diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vueindex 622b556d4c..717878109e 100644--- a/apps/desktop/src/App.vue+++ b/apps/desktop/src/App.vue@@ -114,7 +114,7 @@ import { getPlatform, isMacOS, isWindows } from "@/lib/backend/platform";import { isTauriRuntime } from "@/lib/backend/tauriRuntime";import { openQueryResultArchiveFile } from "@/lib/query/queryResultArchiveFile";import { activeTabExternalSqlFileTarget, rememberExternalSqlFileTarget, resolveExternalSqlFileTarget, resolveExternalSqlFileTargetForActiveTab, unassociatedExternalSqlFileTarget, type ExternalSqlFileTarget } from "@/lib/sql/externalSqlFileTarget";-import { defaultSavedQueryFileName, externalSqlFileOpenErrorMessage, externalSqlEditorMaxBytes, isSqlFilePath, queryEditorOpenFileAccept, queryEditorOpenFileFilters, readBrowserSqlFile, sqlFileTitleFromPath } from "@/lib/sql/sqlFileOpen";+import { defaultSavedQueryFileName, externalSqlFileOpenErrorMessage, externalSqlEditorMaxBytes, isSqlFilePath, queryEditorOpenFileAccept, queryEditorOpenFileFilters, queryTabExternalFilePath, readBrowserSqlFile, sqlFileTitleFromPath } from "@/lib/sql/sqlFileOpen";import type { ConnectionConfig, DatabaseType, ObjectBrowserFilter, ObjectSourceKind, QueryTab, TableInfoTab, TabOutputView, TreeNode } from "@/types/database";import { OPEN_PLUGIN_SETTINGS, type PluginCenterFocus } from "@/lib/plugins/pluginCenterNavigation";import { parsePluginInstallDeepLink } from "@/lib/plugins/pluginInstallDeepLink";@@ -484,7 +484,16 @@ const isAiPanelMaximized = ref(false);const isHistoryPanelMaximized = ref(false);const isZenMode = ref(false);const showSqlLibraryPanel = ref(safeLocalStorageGet("dbx-sql-library-open") === "true");+const sqlFileLocateRequest = ref<{ id: number; path: string } | null>(null);+let sqlFileLocateRequestId = 0;const showSqlFilePanel = ref(safeLocalStorageGet("dbx-sql-file-panel-open") === "true");+watch(+ showSqlFilePanel,+ (open) => {+ if (!open) sqlFileLocateRequest.value = null;+ },+ { flush: "sync" },+);const rightSidebarPanelRefs: Record<RightSidebarPanelId, typeof showAiPanel> = {ai: showAiPanel,history: showHistory,@@ -3662,6 +3671,18 @@ function setSidebarOpen(open: boolean) {safeLocalStorageSet("dbx-sidebar-open", open ? "true" : "false");}+function locateSqlFile(tab: QueryTab) {+ const path = queryTabExternalFilePath(tab);+ if (!path || isDetachedWindowContext) return;+ isZenMode.value = false;+ openRightSidebarPanel("sqlFile");+ sqlFileLocateRequest.value = { id: ++sqlFileLocateRequestId, path };+}++function finishSqlFileLocate(requestId: number) {+ if (sqlFileLocateRequest.value?.id === requestId) sqlFileLocateRequest.value = null;+}+async function locateTabInSidebar(tab: QueryTab) {setSidebarOpen(true);await nextTick();@@ -5488,6 +5509,7 @@ onUnmounted(() => {ref="contentAreaRef":content-suppressed="activeTab?.mode === 'plugin-workbench'"@locate-tab="locateTabInSidebar"+ @locate-sql-file="locateSqlFile"@close-tab="(tabId: string) => {if (tabId === queryStore.activeTabId) void closeActiveSurface();@@ -5734,7 +5756,7 @@ onUnmounted(() => {><div class="panel-resize-handle panel-resize-handle--left" @pointerdown="startSqlFilePanelResize" /><div class="h-full min-h-0 overflow-hidden rounded-[inherit]">- <SqlFilePanel @close="closeRightSidebarPanel('sqlFile')" />+ <SqlFilePanel :locate-request="sqlFileLocateRequest" @locate-handled="finishSqlFileLocate" @close="closeRightSidebarPanel('sqlFile')" /></div></div><PluginShortcutBar v-if="!isDetachedWindowContext && !isZenMode && settingsStore.editorSettings.pluginShortcuts.enabled && settingsStore.editorSettings.pluginShortcuts.position.startsWith('right-')" :position="settingsStore.editorSettings.pluginShortcuts.position" />diff --git a/apps/desktop/src/components/layout/EditorGroup.vue b/apps/desktop/src/components/layout/EditorGroup.vueindex ca6a2a4c8a..83f2ef7ebf 100644--- a/apps/desktop/src/components/layout/EditorGroup.vue+++ b/apps/desktop/src/components/layout/EditorGroup.vue@@ -191,6 +191,7 @@ const groupExecutableSql = computed(() => {:special-page-tabs="toolbar.specialPageTabs.value"@activate-tab="$emit('activate-tab', $event)"@locate-tab="$emit('locate-tab', $event)"+ @locate-sql-file="$emit('locate-sql-file', $event)"@toggle-zen-mode="$emit('toggle-zen-mode')"@start-resize="$emit('start-resize', $event)"@toggle-collapse="$emit('toggle-collapse')"diff --git a/apps/desktop/src/components/layout/EditorGroupTabBar.vue b/apps/desktop/src/components/layout/EditorGroupTabBar.vueindex ac4678b9b7..85436e2553 100644--- a/apps/desktop/src/components/layout/EditorGroupTabBar.vue+++ b/apps/desktop/src/components/layout/EditorGroupTabBar.vue@@ -41,6 +41,7 @@ import {ChevronsUpDown,Clock3,Copy,+ Crosshair,Database,FoldHorizontal,ListFilter,@@ -118,6 +119,7 @@ import {tabIconClass,tabTooltipLines,} from "@/lib/tabs/tabPresentation";+import { queryTabExternalFilePath } from "@/lib/sql/sqlFileOpen";import { activeTabSidebarTarget } from "@/lib/sidebar/sidebarActiveTabTarget";import "./appTabBar.css";import type { QueryTab } from "@/types/database";@@ -142,6 +144,7 @@ const props = defineProps<{const emit = defineEmits<{"activate-tab": [tabId: string];"locate-tab": [tab: QueryTab];+ "locate-sql-file": [tab: QueryTab];"toggle-zen-mode": [];"start-resize": [event: PointerEvent];"toggle-collapse": [];@@ -1687,6 +1690,12 @@ function getTabMenuItems(tab: QueryTab): ContextMenuItem[] {visible: !!activeTabSidebarTarget(tab),onLocate: () => emit("locate-tab", tab),}),+ {+ label: t("sidebar.locateSqlFile"),+ icon: Crosshair,+ visible: !!queryTabExternalFilePath(tab),+ action: () => emit("locate-sql-file", tab),+ },{ label: "", separator: true },createPinTabMenuItem({label: tab.pinned ? t("contextMenu.unpinTab") : t("contextMenu.pinTab"),diff --git a/apps/desktop/src/components/layout/SqlFilePanel.vue b/apps/desktop/src/components/layout/SqlFilePanel.vueindex 596cf09eb6..40b61f5ac1 100644--- a/apps/desktop/src/components/layout/SqlFilePanel.vue+++ b/apps/desktop/src/components/layout/SqlFilePanel.vue@@ -1,5 +1,5 @@<script setup lang="ts">-import { ref, computed, nextTick, onMounted, onUnmounted, watch, useId } from "vue";+import { ref, computed, nextTick, onMounted, onBeforeUnmount, onUnmounted, watch, useId } from "vue";import { useI18n } from "vue-i18n";import { FolderOpen, FolderClosed, FileCode, FolderPlus, ChevronRight, ChevronDown, X, Trash2, RefreshCw, FolderSearch, Copy, Play, ChevronsUpDown, ChevronsDownUp, Settings, FilePlus, Pencil, Search, ArrowDownAZ, ArrowUpAZ, Loader2, GripVertical, Check } from "@lucide/vue";import { Button } from "@/components/ui/button";@@ -19,7 +19,7 @@ import { isTauriRuntime } from "@/lib/backend/tauriRuntime";import { translateBackendError } from "@/i18n/backend-errors";import { copyToClipboard } from "@/lib/common/clipboard";import { forgetExternalSqlFileTarget, forgetExternalSqlFolderTargets, moveExternalSqlFileTarget, moveExternalSqlFolderTargets, resolveExternalSqlFileTargetForActiveTab } from "@/lib/sql/externalSqlFileTarget";-import { externalSqlFileOpenErrorMessage, externalSqlEditorMaxBytes, formatSqlFileSize, isExternalSqlFileTooLargeError, isSqlFilePath, normalizeExternalSqlPath, relocateExternalSqlPathWithinFolder } from "@/lib/sql/sqlFileOpen";+import { externalSqlFileOpenErrorMessage, externalSqlEditorMaxBytes, formatSqlFileSize, isExternalSqlFileTooLargeError, isSqlFilePath, normalizeExternalSqlPath, queryTabExternalFilePath, relocateExternalSqlPathWithinFolder } from "@/lib/sql/sqlFileOpen";import type { SavedSqlLineMatch } from "@/lib/savedSql/savedSqlSearch";import * as api from "@/lib/backend/api";import type { SqlFileEntry } from "@/lib/backend/api";@@ -32,7 +32,10 @@ import { getSqlFileOpenMode, saveSqlFileOpenMode, type SqlFileOpenMode } from "@import { getSqlFileOrder, saveSqlFileOrder, reorderSqlFiles, remapSqlFileOrder, sqlFileParentPath, type SqlFileOrder } from "@/lib/sqlFile/sqlFileOrder";import { useSqlFileReorder } from "@/composables/useSqlFileReorder";+const props = defineProps<{ locateRequest?: { id: number; path: string } | null }>();+const emit = defineEmits<{+ "locate-handled": [id: number];close: [];}>();@@ -59,7 +62,7 @@ const fileTree = ref<HTMLElement | null>(null);const locatingFile = ref(false);const currentFilePath = computed(() => {const tab = queryStore.tabs.find((tab) => tab.id === queryStore.activeTabId);- return tab?.mode === "query" ? tab.externalSqlPath : undefined;+ return queryTabExternalFilePath(tab);});const filterSettingsOpen = ref(false);const fileFilterDraft = ref(getSqlFileFilter());@@ -317,20 +320,19 @@ function findFileAncestors(entries: SqlFileEntry[], path: string): string[] | nureturn null;}-const activeFileTarget = computed(() => {- const tab = queryStore.tabs.find((tab) => tab.id === queryStore.activeTabId);- if (!tab?.externalSqlPath) return null;- const path = normalizeExternalSqlPath(tab.externalSqlPath);+function findFileTarget(filePath: string) {+ const path = normalizeExternalSqlPath(filePath);for (const folder of folders.value) {if (folder.loading) continue;const ancestors = findFileAncestors(folder.entries, path);if (ancestors) return { folder, path, ancestors };}return null;-});+}-async function locateActiveFile() {- const target = activeFileTarget.value;+async function locateFileTarget(path: string) {+ if (disposed) return;+ const target = findFileTarget(path);if (!target) return;if (searchText.value) {const isVisibleNow = visibleItems.value.some((item) => item.folder === target.folder && item.type === "file" && normalizeExternalSqlPath(item.path) === target.path);@@ -427,9 +429,13 @@ async function addFolder(folderPath: string) {async function locateCurrentFile() {const path = currentFilePath.value;- if (!path || locatingFile.value) return;- if (activeFileTarget.value) {- await locateActiveFile();+ if (path) await enqueueFileLocate(path);+}++async function locateFile(path: string) {+ if (disposed) return;+ if (findFileTarget(path)) {+ await locateFileTarget(path);return;}if (!isTauriRuntime()) {@@ -448,11 +454,12 @@ async function locateCurrentFile() {if (!parentPath) return;if (await addFolder(parentPath)) return;}- if (!activeFileTarget.value) {+ if (disposed) return;+ if (!findFileTarget(path)) {toast(t("sqlFileTree.activeFileNotFound"), 5000);return;}- await locateActiveFile();+ await locateFileTarget(path);} finally {locatingFile.value = false;}@@ -747,11 +754,40 @@ function folderName(path: string): string {return parts.pop() || path;}+let disposed = false;+const foldersInitialized = ref(false);+let locateQueue: Promise<void> = Promise.resolve();++function enqueueFileLocate(path: string): Promise<void> {+ // Keep scans serialized, while retaining the requested path across focus changes.+ locateQueue = locateQueue+ .then(() => locateFile(path))+ .catch((error) => {+ if (!disposed) toast(t("sqlFileTree.loadFailed", { message: translateBackendError(t, error) }), 5000);+ });+ return locateQueue;+}++watch([foldersInitialized, () => props.locateRequest], async ([initialized, request]) => {+ if (!initialized || !request) return;+ await enqueueFileLocate(request.path);+ if (!disposed) emit("locate-handled", request.id);+});++onBeforeUnmount(() => {+ disposed = true;+});+onMounted(async () => {+ // Restoring folders must not persist a partially loaded list. Register all+ // roots before scanning so closing the panel cannot discard saved roots.const saved = loadSavedFolders();+ folders.value = saved.map((path) => ({ path, entries: [], expanded: new Set<string>(), loading: true, refreshing: false, collapsed: false }));for (const path of saved) {- await addFolder(path);+ if (disposed) return;+ await loadFolderEntries(path);}+ if (!disposed) foldersInitialized.value = true;});type TreeEntry = { entry: SqlFileEntry; depth: number };diff --git a/apps/desktop/src/components/layout/__tests__/SqlFilePanel.locate.spec.ts b/apps/desktop/src/components/layout/__tests__/SqlFilePanel.locate.spec.tsindex e5a6a54dc5..6ac308c278 100644--- a/apps/desktop/src/components/layout/__tests__/SqlFilePanel.locate.spec.ts+++ b/apps/desktop/src/components/layout/__tests__/SqlFilePanel.locate.spec.ts@@ -8,7 +8,7 @@ import { useQueryStore } from "@/stores/queryStore";vi.mock("@/lib/sqlFile/sqlFileFolders", () => ({getSqlFileFilter: () => "*.sql",- getSqlFileFolderPaths: () => ["/sql"],+ getSqlFileFolderPaths: vi.fn(() => ["/sql"]),saveSqlFileFilter: vi.fn(),saveSqlFileFolderPaths: vi.fn(),notifySqlFileFoldersChanged: vi.fn(),@@ -23,29 +23,33 @@ vi.mock("@/lib/backend/api", async (importOriginal) => ({}));import SqlFilePanel from "../SqlFilePanel.vue";+import { getSqlFileFolderPaths, saveSqlFileFolderPaths } from "@/lib/sqlFile/sqlFileFolders";+import { listSqlFilesInFolder, type SqlFileEntry } from "@/lib/backend/api";const mounted: Array<{ app: App; host: HTMLElement }> = [];const scrollIntoView = vi.fn();-async function mountPanel(path?: string) {+async function mountPanel(path?: string, options: { waitForLoad?: boolean; locateRequest?: { id: number; path: string } } = {}) {const pinia = createPinia();setActivePinia(pinia);const queryStore = useQueryStore();if (path) queryStore.openExternalSqlFile("", "", path, "SELECT 1");const host = document.createElement("div");document.body.appendChild(host);- const app = createApp(SqlFilePanel);+ const app = createApp(SqlFilePanel, { locateRequest: options.locateRequest });app.use(pinia);app.use(i18n);app.mount(host);mounted.push({ app, host });- await vi.waitFor(() => expect(host.textContent).toContain("other.sql"));+ if (options.waitForLoad !== false) await vi.waitFor(() => expect(host.textContent).toContain("other.sql"));const button = host.querySelector<HTMLButtonElement>(`button[aria-label="${i18n.global.t("sqlFileTree.locateActiveFile")}"]`);expect(button).not.toBeNull();- return { host, button: button!, queryStore };+ return { app, host, button: button!, queryStore };}beforeEach(() => {+ vi.mocked(getSqlFileFolderPaths).mockReturnValue(["/sql"]);+ vi.mocked(saveSqlFileFolderPaths).mockClear();vi.spyOn(HTMLElement.prototype, "scrollIntoView").mockImplementation(scrollIntoView);});@@ -59,6 +63,44 @@ afterEach(() => {});describe("SQL file panel locate active file", () => {+ it("preserves every saved root when closed during the first scan", async () => {+ vi.mocked(getSqlFileFolderPaths).mockReturnValue(["/sql", "/second"]);+ let finishScan!: (entries: SqlFileEntry[]) => void;+ vi.mocked(listSqlFilesInFolder).mockImplementationOnce(+ () =>+ new Promise((resolve) => {+ finishScan = resolve;+ }),+ );+ const { app, host } = await mountPanel(undefined, { waitForLoad: false });+ expect(host.textContent).toContain("second");+ app.unmount();+ host.remove();+ mounted.splice(+ mounted.findIndex((item) => item.app === app),+ 1,+ );+ finishScan([]);+ await nextTick();+ await nextTick();+ expect(saveSqlFileFolderPaths).not.toHaveBeenCalled();+ const reopened = await mountPanel();+ expect(reopened.host.textContent).toContain("second");+ expect(saveSqlFileFolderPaths).not.toHaveBeenCalled();+ });++ it("locates a requested DDL file after loading without switching the active query", async () => {+ vi.mocked(listSqlFilesInFolder).mockResolvedValueOnce([+ { name: "target.ddl", path: "/sql/target.ddl", is_dir: false, children: [] },+ { name: "other.sql", path: "/sql/other.sql", is_dir: false, children: [] },+ ]);+ const { host, queryStore } = await mountPanel("/sql/other.sql", { locateRequest: { id: 1, path: "/sql/target.ddl" } });+ const activeTabId = queryStore.activeTabId;+ await vi.waitFor(() => expect(host.querySelector('[data-sql-file-path="/sql/target.ddl"]')?.classList.contains("bg-accent")).toBe(true));+ expect(queryStore.activeTabId).toBe(activeTabId);+ expect(queryStore.tabs.find((tab) => tab.id === activeTabId)?.externalSqlPath).toBe("/sql/other.sql");+ });+it("expands collapsed parents, highlights and scrolls without reopening the file", async () => {const { host, button, queryStore } = await mountPanel("/sql/nested/deep/current.sql");const openFile = vi.spyOn(queryStore, "openExternalSqlFile");@@ -77,7 +119,8 @@ describe("SQL file panel locate active file", () => {expect(row!.classList.contains("bg-accent")).toBe(true);expect(row!.parentElement!.parentElement!.style.display).not.toBe("none");expect(scrollIntoView).toHaveBeenCalledWith({ block: "center", inline: "nearest" });- expect(scrollIntoView.mock.contexts[0]).toBe(row);+ const locateScrollIndex = scrollIntoView.mock.calls.findIndex(([options]) => options.block === "center");+ expect(scrollIntoView.mock.contexts[locateScrollIndex]).toBe(row);expect(openFile).not.toHaveBeenCalled();expect(queryStore.activeTabId).toBe(tabId);});@@ -90,7 +133,7 @@ describe("SQL file panel locate active file", () => {await nextTick();button.click();await nextTick();- expect(host.querySelector('[data-sql-file-path="/sql/other.sql"]')!.classList.contains("bg-accent")).toBe(true);+ await vi.waitFor(() => expect(host.querySelector('[data-sql-file-path="/sql/other.sql"]')!.classList.contains("bg-accent")).toBe(true));expect(host.querySelector('[data-sql-file-path="/sql/nested/deep/current.sql"]')!.classList.contains("bg-accent")).toBe(false);});@@ -107,7 +150,7 @@ describe("SQL file panel locate active file", () => {expect(button.disabled).toBe(false);button.click();await nextTick();- expect(host.querySelector('[data-sql-file-path="/sql/nested/deep/current.sql"]')!.classList.contains("bg-accent")).toBe(true);+ await vi.waitFor(() => expect(host.querySelector('[data-sql-file-path="/sql/nested/deep/current.sql"]')?.classList.contains("bg-accent")).toBe(true));});it("disables locating after switching to an unsaved query", async () => {diff --git a/apps/desktop/src/components/layout/__tests__/SqlFilePanel.locateExtended.spec.ts b/apps/desktop/src/components/layout/__tests__/SqlFilePanel.locateExtended.spec.tsindex 584ced673e..5f0b0e7eb5 100644--- a/apps/desktop/src/components/layout/__tests__/SqlFilePanel.locateExtended.spec.ts+++ b/apps/desktop/src/components/layout/__tests__/SqlFilePanel.locateExtended.spec.ts@@ -125,9 +125,11 @@ describe("SQL file panel current file location", () => {expect(mocks.list).toHaveBeenCalledWith("C:/outside/", DEFAULT_SQL_FILE_FILTER, true);expect(getSqlFileFolderPaths()).toEqual(["C:/outside/"]);- const row = fileRow(host, scanPath)!;- expect(row.getAttribute("aria-current")).toBe("true");- expect(scroll.mock.contexts.at(-1)).toBe(row);+ await vi.waitFor(() => {+ const row = fileRow(host, scanPath)!;+ expect(row.getAttribute("aria-current")).toBe("true");+ expect(scroll.mock.contexts.at(-1)).toBe(row);+ });});it("refreshes a known folder to locate a newly added file without adding another root", async () => {@@ -137,8 +139,10 @@ describe("SQL file panel current file location", () => {expect(mocks.list).toHaveBeenCalledTimes(2);expect(getSqlFileFolderPaths()).toEqual(["C:/repo"]);- expect(fileRow(host)?.getAttribute("aria-current")).toBe("true");- expect(scroll.mock.contexts.at(-1)).toBe(fileRow(host));+ await vi.waitFor(() => {+ expect(fileRow(host)?.getAttribute("aria-current")).toBe("true");+ expect(scroll.mock.contexts.at(-1)).toBe(fileRow(host));+ });});it("keeps the file filter and reports hidden or missing files", async () => {diff --git a/apps/desktop/src/components/layout/__tests__/SqlFilePanel.searchAndSort.spec.ts b/apps/desktop/src/components/layout/__tests__/SqlFilePanel.searchAndSort.spec.tsindex fd250118d6..5c64e3c56f 100644--- a/apps/desktop/src/components/layout/__tests__/SqlFilePanel.searchAndSort.spec.ts+++ b/apps/desktop/src/components/layout/__tests__/SqlFilePanel.searchAndSort.spec.ts@@ -209,6 +209,6 @@ describe("SqlFilePanel search and sort", () => {expect(host.textContent).toContain("zebra.sql");const zebraRow = host.querySelector<HTMLElement>('[data-sql-file-path="/sql/zebra.sql"]');expect(zebraRow).not.toBeNull();- expect(zebraRow!.classList.contains("bg-accent")).toBe(true);+ await vi.waitFor(() => expect(zebraRow!.classList.contains("bg-accent")).toBe(true));});});diff --git a/apps/desktop/src/components/layout/querySurfaces.ts b/apps/desktop/src/components/layout/querySurfaces.tsindex f31ca878f8..39fd9d49bd 100644--- a/apps/desktop/src/components/layout/querySurfaces.ts+++ b/apps/desktop/src/components/layout/querySurfaces.ts@@ -84,6 +84,7 @@ export interface ContentAreaSurfaceProps {export interface ContentAreaSurfaceEmits {closeTab: [tabId: string];"locate-tab": [tab: QueryTab];+ "locate-sql-file": [tab: QueryTab];"update:activeOutputView": [tabId: string, value: TabOutputView];fixWithAi: [tabId: string, errorMessage: string];sendSelectionToAi: [tabId: string, sql: string];diff --git a/apps/desktop/src/i18n/locales/az.ts b/apps/desktop/src/i18n/locales/az.tsindex e5e905aee2..a1c6b38bd2 100644--- a/apps/desktop/src/i18n/locales/az.ts+++ b/apps/desktop/src/i18n/locales/az.ts@@ -504,6 +504,7 @@ export default withEnglishFallback({regexSearchTooltip: "Yan paneldəki adları, şərhləri və ləqəbləri JavaScript müntəzəm ifadələri ilə uyğunlaşdırın.",clearFilter: "Süzgəci təmizlə",locateTargetNotFound: "Element yan paneldə mövcud deyil. O, silinmiş və ya gizlədilmiş ola bilər.",+ locateSqlFile: "SQL fayl siyahısında tap",locateActiveTab: "Yan paneldə tap",},savedSql: {diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.tsindex 04d8396c7e..b54c37ae47 100644--- a/apps/desktop/src/i18n/locales/en.ts+++ b/apps/desktop/src/i18n/locales/en.ts@@ -1139,6 +1139,7 @@ export default {regexSearchTooltip: "Match sidebar names, comments, and aliases with JavaScript regular expressions.",clearFilter: "Clear filter",locateTargetNotFound: "The item is not available in the sidebar. It may have been removed or hidden.",+ locateSqlFile: "Locate in SQL file list",locateActiveTab: "Locate in sidebar",},savedSql: {diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.tsindex d0c3037ff4..16ce71600d 100644--- a/apps/desktop/src/i18n/locales/es.ts+++ b/apps/desktop/src/i18n/locales/es.ts@@ -989,6 +989,7 @@ export default withEnglishFallback({regexSearchTooltip: "Coincide con nombres, comentarios y alias mediante expresiones regulares de JavaScript.",clearFilter: "Limpiar filtro",locateTargetNotFound: "El elemento no está disponible en la barra lateral. Puede que se haya eliminado u ocultado.",+ locateSqlFile: "Localizar en la lista de archivos SQL",locateActiveTab: "Localizar en la barra lateral",},savedSql: {diff --git a/apps/desktop/src/i18n/locales/id.ts b/apps/desktop/src/i18n/locales/id.tsindex 9bbaf826fa..b1072a0683 100644--- a/apps/desktop/src/i18n/locales/id.ts+++ b/apps/desktop/src/i18n/locales/id.ts@@ -709,6 +709,7 @@ export default withEnglishFallback({regexSearchTooltip: "Cocokkan nama, komentar, dan alias di bilah sisi dengan ekspresi reguler JavaScript.",clearFilter: "Bersihkan filter",locateTargetNotFound: "Item tidak tersedia di bilah sisi. Item mungkin telah dihapus atau disembunyikan.",+ locateSqlFile: "Temukan dalam daftar file SQL",locateActiveTab: "Cari di bilah sisi",},savedSql: {diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.tsindex 5646afcbc8..3288e53908 100644--- a/apps/desktop/src/i18n/locales/it.ts+++ b/apps/desktop/src/i18n/locales/it.ts@@ -978,6 +978,7 @@ export default withEnglishFallback({regexSearchTooltip: "Trova nomi, commenti e alias con espressioni regolari JavaScript.",clearFilter: "Cancella filtro",locateTargetNotFound: "L’elemento non è disponibile nella barra laterale. Potrebbe essere stato rimosso o nascosto.",+ locateSqlFile: "Individua nell’elenco dei file SQL",locateActiveTab: "Trova nella barra laterale",},savedSql: {diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.tsindex e3568f7428..fe8012ecc2 100644--- a/apps/desktop/src/i18n/locales/ja.ts+++ b/apps/desktop/src/i18n/locales/ja.ts@@ -979,6 +979,7 @@ export default withEnglishFallback({regexSearchTooltip: "JavaScript 正規表現でサイドバーの名前、コメント、エイリアスを照合します。",clearFilter: "フィルターをクリア",locateTargetNotFound: "サイドバーに該当する項目が見つかりません。削除または非表示にされている可能性があります。",+ locateSqlFile: "SQL ファイル一覧で表示",locateActiveTab: "サイドバーで表示",},savedSql: {diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.tsindex 1caaeeac32..0be76c2cba 100644--- a/apps/desktop/src/i18n/locales/ko.ts+++ b/apps/desktop/src/i18n/locales/ko.ts@@ -985,6 +985,7 @@ export default withEnglishFallback({regexSearchTooltip: "JavaScript 정규식으로 사이드바 이름, 주석, 별칭을 검색합니다.",clearFilter: "필터 지우기",locateTargetNotFound: "사이드바에서 해당 항목을 찾을 수 없습니다. 삭제되었거나 숨겨져 있을 수 있습니다.",+ locateSqlFile: "SQL 파일 목록에서 찾기",locateActiveTab: "사이드바에서 찾기",},savedSql: {diff --git a/apps/desktop/src/i18n/locales/pl.ts b/apps/desktop/src/i18n/locales/pl.tsindex d0f97aa1ef..b0629b4a6e 100644--- a/apps/desktop/src/i18n/locales/pl.ts+++ b/apps/desktop/src/i18n/locales/pl.ts@@ -773,6 +773,7 @@ export default withEnglishFallback({regexSearchTooltip: "Dopasowuj nazwy, komentarze i aliasy w panelu bocznym przy użyciu wyrażeń regularnych JavaScript.",clearFilter: "Wyczyść filtr",locateTargetNotFound: "Pozycja nie jest dostępna w panelu bocznym. Mogła zostać usunięta lub ukryta.",+ locateSqlFile: "Znajdź na liście plików SQL",locateActiveTab: "Znajdź na pasku bocznym",},savedSql: {diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.tsindex 2fc26f9499..5b373b5426 100644--- a/apps/desktop/src/i18n/locales/pt-BR.ts+++ b/apps/desktop/src/i18n/locales/pt-BR.ts@@ -979,6 +979,7 @@ export default withEnglishFallback({regexSearchTooltip: "Correspondência de nomes, comentários e aliases com expressões regulares JavaScript.",clearFilter: "Limpar filtro",locateTargetNotFound: "O item não está disponível na barra lateral. Ele pode ter sido removido ou ocultado.",+ locateSqlFile: "Localizar na lista de arquivos SQL",locateActiveTab: "Localizar na barra lateral",},savedSql: {diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.tsindex 1c58eb4a5e..5aa2eefb6f 100644--- a/apps/desktop/src/i18n/locales/ru.ts+++ b/apps/desktop/src/i18n/locales/ru.ts@@ -959,6 +959,7 @@ export default withEnglishFallback({regexSearchTooltip: "Сопоставлять имена, комментарии и псевдонимы в боковой панели с помощью регулярных выражений JavaScript.",clearFilter: "Очистить фильтр",locateTargetNotFound: "Элемент недоступен на боковой панели. Возможно, он был удалён или скрыт.",+ locateSqlFile: "Найти в списке SQL-файлов",locateActiveTab: "Найти в боковой панели",},savedSql: {diff --git a/apps/desktop/src/i18n/locales/th.ts b/apps/desktop/src/i18n/locales/th.tsindex a3bd02e874..1b186d29c5 100644--- a/apps/desktop/src/i18n/locales/th.ts+++ b/apps/desktop/src/i18n/locales/th.ts@@ -1069,6 +1069,7 @@ export default withEnglishFallback({regexSearchTooltip: "จับคู่ชื่อ คอมเมนต์ และ Alias ในแถบด้านข้างด้วย Regular Expression ของ JavaScript",clearFilter: "ล้างตัวกรอง",locateTargetNotFound: "รายการนี้ไม่พร้อมใช้งานในแถบด้านข้าง อาจถูกลบหรือซ่อนไว้",+ locateSqlFile: "ค้นหาในรายการไฟล์ SQL",locateActiveTab: "ค้นหาในแถบด้านข้าง",},savedSql: {diff --git a/apps/desktop/src/i18n/locales/tr.ts b/apps/desktop/src/i18n/locales/tr.tsindex dd9b1cdfe7..0174df292b 100644--- a/apps/desktop/src/i18n/locales/tr.ts+++ b/apps/desktop/src/i18n/locales/tr.ts@@ -504,6 +504,7 @@ export default withEnglishFallback({regexSearchTooltip: "Kenar çubuğu adlarını, açıklamaları ve takma adları JavaScript düzenli ifadeleriyle eşleştirin.",clearFilter: "Filtreyi temizle",locateTargetNotFound: "Öğe kenar çubuğunda bulunamıyor. Silinmiş veya gizlenmiş olabilir.",+ locateSqlFile: "SQL dosya listesinde bul",locateActiveTab: "Kenar çubuğunda bul",},savedSql: {diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.tsindex 97888461af..70b2e5623f 100644--- a/apps/desktop/src/i18n/locales/zh-CN.ts+++ b/apps/desktop/src/i18n/locales/zh-CN.ts@@ -1075,6 +1075,7 @@ export default withEnglishFallback({regexSearchTooltip: "使用 JavaScript 正则表达式匹配侧边栏名称、备注和别名。",clearFilter: "清除筛选",locateTargetNotFound: "左侧导航中未找到对应项目,该项目可能已被删除或隐藏。",+ locateSqlFile: "在 SQL 文件列表中定位",locateActiveTab: "在侧边栏中定位",},savedSql: {diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.tsindex e8e3636408..2681bfd0b2 100644--- a/apps/desktop/src/i18n/locales/zh-TW.ts+++ b/apps/desktop/src/i18n/locales/zh-TW.ts@@ -983,6 +983,7 @@ export default withEnglishFallback({regexSearchTooltip: "使用 JavaScript 正規表示式比對側邊欄名稱、備註與別名。",clearFilter: "清除篩選",locateTargetNotFound: "側邊欄中找不到對應項目,該項目可能已被刪除或隱藏。",+ locateSqlFile: "在 SQL 檔案清單中定位",locateActiveTab: "在側邊欄中定位",},savedSql: {diff --git a/apps/desktop/src/lib/sql/sqlFileOpen.ts b/apps/desktop/src/lib/sql/sqlFileOpen.tsindex 9032303c54..b3063bf189 100644--- a/apps/desktop/src/lib/sql/sqlFileOpen.ts+++ b/apps/desktop/src/lib/sql/sqlFileOpen.ts@@ -1,3 +1,10 @@+import type { QueryTab } from "@/types/database";++/** File identity comes from the query tab, never its editable display title. */+export function queryTabExternalFilePath(tab: QueryTab | undefined | null): string | undefined {+ return tab?.mode === "query" && tab.externalSqlPath?.trim() ? tab.externalSqlPath : undefined;+}+export function isSqlFilePath(path: string): boolean {return /\.sql$/i.test(path.trim());}diff --git a/apps/desktop/src/lib/tabs/contentSurfaceEvents.ts b/apps/desktop/src/lib/tabs/contentSurfaceEvents.tsindex 40b6d9af2e..a062765edd 100644--- a/apps/desktop/src/lib/tabs/contentSurfaceEvents.ts+++ b/apps/desktop/src/lib/tabs/contentSurfaceEvents.ts@@ -9,6 +9,7 @@ import type { ContentAreaSurfaceEmits } from "@/components/layout/querySurfaces"export const contentSurfaceEventNames = ["closeTab","locate-tab",+ "locate-sql-file","update:activeOutputView","fixWithAi","sendSelectionToAi",