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(quick-open): scope object search to a selected connection (#12871)
Jefferyc18a1b599d7c
diff --git a/apps/desktop/src/components/quick-open/QuickOpenDialog.vue b/apps/desktop/src/components/quick-open/QuickOpenDialog.vueindex 53a94f81db..043ad77fa4 100644--- a/apps/desktop/src/components/quick-open/QuickOpenDialog.vue+++ b/apps/desktop/src/components/quick-open/QuickOpenDialog.vue@@ -4,9 +4,11 @@ import { useI18n } from "vue-i18n";import { Command, FileCode, FileText, Search, FolderPlus, SlidersHorizontal, X } from "@lucide/vue";import { Dialog, DialogContent } from "@/components/ui/dialog";import { Input } from "@/components/ui/input";+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";import PluginIcon from "@/components/plugins/PluginIcon.vue";import { useQuickOpen, type QuickOpenItem } from "@/composables/useQuickOpen";import { usePluginCommandPalette } from "@/lib/plugins/pluginCommandPalette";+import { useConnectionStore } from "@/stores/connectionStore";import { useToast } from "@/composables/useToast";import { useSettingsStore } from "@/stores/settingsStore";import { formatShortcutDisplay } from "@/lib/editor/shortcutDisplay";@@ -45,6 +47,9 @@ const {contentSelectedItem,contentSearching,setContentMode: setSearchContentMode,+ scopeConnectionIds,+ scopeActive,+ setScopeConnectionIds,} = useQuickOpen({ extraItems: pluginPalette.items });const previewEditing = ref(false);const pinnedPreviewItem = ref<QuickOpenItem | null>(null);@@ -75,6 +80,19 @@ const searchSettingsOpen = ref(false);const searchRoots = ref<string[]>([]);const extensionsInput = ref("");+// Connection scope: empty selection = all connections.+const connectionStore = useConnectionStore();+const scopeConnections = computed(() => connectionStore.connections);+/** Select value for "all connections"; a real connection id never uses this sentinel. */+const SCOPE_ALL_VALUE = "__all_connections__";++const scopeSelection = computed<string>({+ get: () => (scopeActive.value && scopeConnectionIds.value.length === 1 ? scopeConnectionIds.value[0] : SCOPE_ALL_VALUE),+ set: (value) => {+ setScopeConnectionIds(value === SCOPE_ALL_VALUE ? [] : [value]);+ },+});+function refreshSearchSettings(): void {searchRoots.value = getGlobalSearchRoots();extensionsInput.value = getGlobalSearchExtensions().join(", ");@@ -348,6 +366,16 @@ watch(selectedIndex, async () => {<Search class="h-4 w-4" /></button></div>+ <!-- Connection scope: file-content search ignores connections, so the picker only shows in object mode. -->+ <Select v-if="!contentMode" v-model="scopeSelection" :disabled="previewEditing">+ <SelectTrigger class="h-7 w-[132px] gap-1 px-2 text-xs" :title="t('quickOpen.scope')">+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ <SelectItem :value="SCOPE_ALL_VALUE">{{ t("quickOpen.scopeAll") }}</SelectItem>+ <SelectItem v-for="conn in scopeConnections" :key="conn.id" :value="conn.id">{{ conn.name }}</SelectItem>+ </SelectContent>+ </Select><!-- Search settings (roots & extensions) --><button:disabled="previewEditing"diff --git a/apps/desktop/src/components/quick-open/__tests__/QuickOpenDialog.preview.spec.ts b/apps/desktop/src/components/quick-open/__tests__/QuickOpenDialog.preview.spec.tsindex a1aaeda224..9700ade02d 100644--- a/apps/desktop/src/components/quick-open/__tests__/QuickOpenDialog.preview.spec.ts+++ b/apps/desktop/src/components/quick-open/__tests__/QuickOpenDialog.preview.spec.ts@@ -221,6 +221,22 @@ describe("content search preview navigation", () => {expect(host.querySelector(".cm-editor")).toBeNull();});+ // File-content search is not connection-scoped, so offering the picker there would be a+ // control that silently does nothing.+ it("shows the connection scope picker only in object mode", async () => {+ const { props } = await mountSearch();+ const scopeTitle = i18n.global.t("quickOpen.scope");+ expect([...host.querySelectorAll<HTMLElement>(`[title="${scopeTitle}"]`)]).toHaveLength(0);++ props.initialContentMode = false;+ await nextTick();+ expect([...host.querySelectorAll<HTMLElement>(`[title="${scopeTitle}"]`)]).toHaveLength(1);++ props.initialContentMode = true;+ await nextTick();+ expect([...host.querySelectorAll<HTMLElement>(`[title="${scopeTitle}"]`)]).toHaveLength(0);+ });+it("preserves single-click opening a search result", async () => {const { rows } = await mountSearch();rows[1]!.click();diff --git a/apps/desktop/src/composables/__tests__/useQuickOpen.spec.ts b/apps/desktop/src/composables/__tests__/useQuickOpen.spec.tsindex b12913796b..9c34750993 100644--- a/apps/desktop/src/composables/__tests__/useQuickOpen.spec.ts+++ b/apps/desktop/src/composables/__tests__/useQuickOpen.spec.ts@@ -3,6 +3,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { matchQuickOpenText, useQuickOpen } from "@/composables/useQuickOpen";import * as api from "@/lib/backend/api";import { getSqlFileFilter, getSqlFileFolderPaths, sqlFileFoldersVersion } from "@/lib/sqlFile/sqlFileFolders";+import { setQuickOpenScopeIds } from "@/lib/quickOpen/quickOpenScope";import { useConnectionStore } from "@/stores/connectionStore";import { useSavedSqlStore } from "@/stores/savedSqlStore";@@ -58,6 +59,13 @@ describe("useQuickOpen", () => {vi.mocked(getSqlFileFolderPaths).mockReturnValue([]);});+ afterEach(() => {+ // The scope is module-level state and every useQuickOpen() instance leaves live+ // watchers behind, so a leaked scope or mock would make later tests order-dependent.+ setQuickOpenScopeIds([]);+ vi.clearAllMocks();+ });+describe("external SQL files", () => {it("reloads when folders change during an in-flight scan", async () => {vi.mocked(useConnectionStore).mockReturnValue({ connections: [], treeNodes: [] } as any);@@ -995,6 +1003,142 @@ describe("useQuickOpen", () => {});});+ describe("connection scope", () => {+ // Scope: no selection searches every connection, picking some narrows both+ // the local tree entries and the remote search pool to those connections.+ function scopeStore() {+ return {+ connections: [+ { id: "conn1", name: "Alpha", db_type: "mysql", database: "shop" },+ { id: "conn2", name: "Beta", db_type: "postgres", database: "public_db" },+ { id: "conn3", name: "Gamma", db_type: "mysql", database: "crm" },+ ],+ activeConnectionId: "conn1",+ connectedIds: new Set(["conn1", "conn2", "conn3"]),+ treeNodes: [+ { connectionId: "conn1", type: "database", database: "shop", label: "shop" },+ { connectionId: "conn2", type: "database", database: "public_db", label: "public_db" },+ { connectionId: "conn3", type: "database", database: "crm", label: "crm" },+ ],+ listCompletionTables: vi.fn().mockResolvedValue([]),+ };+ }++ it("searches every connection by default", () => {+ vi.mocked(useConnectionStore).mockReturnValue(scopeStore() as any);++ const { filteredItems, setQuery } = useQuickOpen();+ setQuery("");++ const databases = filteredItems.value.filter((item) => item.type === "database").map((item) => item.label);+ expect(databases).toEqual(["shop", "public_db", "crm"]);+ });++ it("hides unselected connections and their objects from the local pool", () => {+ vi.mocked(useConnectionStore).mockReturnValue(scopeStore() as any);++ const { filteredItems, setQuery, setScopeConnectionIds } = useQuickOpen();+ setScopeConnectionIds(["conn2"]);+ setQuery("");++ const labels = filteredItems.value.map((item) => item.label);+ expect(labels).toContain("Beta");+ expect(labels).not.toContain("Alpha");+ expect(labels).not.toContain("Gamma");+ expect(labels.filter((label) => ["shop", "public_db", "crm"].includes(label))).toEqual(["public_db"]);+ });++ it("only queries the selected connections remotely", async () => {+ vi.useFakeTimers();+ try {+ const store = scopeStore();+ vi.mocked(useConnectionStore).mockReturnValue(store as any);++ const { setQuery, setScopeConnectionIds } = useQuickOpen();+ setScopeConnectionIds(["conn3"]);+ setQuery("customer");++ await vi.advanceTimersByTimeAsync(400);+ await flushAsyncWork();++ expect(store.listCompletionTables).toHaveBeenCalledTimes(1);+ expect(store.listCompletionTables.mock.calls[0][0]).toBe("conn3");+ } finally {+ vi.useRealTimers();+ }+ });++ it("treats an empty selection as all connections", () => {+ vi.mocked(useConnectionStore).mockReturnValue(scopeStore() as any);++ const { scopeActive, setScopeConnectionIds } = useQuickOpen();+ setScopeConnectionIds(["conn1"]);+ expect(scopeActive.value).toBe(true);+ setScopeConnectionIds([]);+ expect(scopeActive.value).toBe(false);+ });++ // Switching the scope must re-issue the query without retyping: the user picks a+ // connection and expects the list to change on the spot.+ it("re-runs the current query against the new connection when the scope changes", async () => {+ vi.useFakeTimers();+ try {+ const store = scopeStore();+ vi.mocked(useConnectionStore).mockReturnValue(store as any);++ const { setQuery, setScopeConnectionIds } = useQuickOpen();+ setScopeConnectionIds(["conn1"]);+ setQuery("customer");+ await vi.advanceTimersByTimeAsync(400);+ await flushAsyncWork();+ expect(store.listCompletionTables).toHaveBeenCalledTimes(1);+ expect(store.listCompletionTables.mock.calls[0][0]).toBe("conn1");++ // Switching to conn2 re-queries that connection without touching the query text.+ setScopeConnectionIds(["conn2"]);+ await vi.advanceTimersByTimeAsync(400);+ await flushAsyncWork();++ expect(store.listCompletionTables).toHaveBeenCalledTimes(2);+ expect(store.listCompletionTables.mock.calls[1][0]).toBe("conn2");+ } finally {+ vi.useRealTimers();+ }+ });++ it("drops results from the previous scope instead of merging them", async () => {+ vi.useFakeTimers();+ try {+ let resolveAlpha!: (value: any[]) => void;+ const store = scopeStore();+ store.listCompletionTables = vi.fn().mockImplementation((connectionId: string) => {+ if (connectionId === "conn1") return new Promise((resolve) => (resolveAlpha = resolve));+ return Promise.resolve([{ name: "beta_orders", schema: "", type: "table" }]);+ });+ vi.mocked(useConnectionStore).mockReturnValue(store as any);++ const { filteredItems, setQuery, setScopeConnectionIds } = useQuickOpen();+ setScopeConnectionIds(["conn1"]);+ setQuery("orders");+ await vi.advanceTimersByTimeAsync(400);++ // The scope changes while conn1's request is still in flight.+ setScopeConnectionIds(["conn2"]);+ await vi.advanceTimersByTimeAsync(400);+ await flushAsyncWork();+ expect(filteredItems.value.map((item) => item.label)).toContain("beta_orders");++ // The stale conn1 response lands late and must not surface under the new scope.+ resolveAlpha([{ name: "alpha_orders", schema: "", type: "table" }]);+ await flushAsyncWork();+ expect(filteredItems.value.map((item) => item.label)).toContain("beta_orders");+ expect(filteredItems.value.map((item) => item.label)).not.toContain("alpha_orders");+ } finally {+ vi.useRealTimers();+ }+ });+ });+describe("SQL library files", () => {function savedSqlStoreWithFiles(files: any[]) {const fileMap = new Map(files.map((f) => [f.id, f]));diff --git a/apps/desktop/src/composables/useQuickOpen.ts b/apps/desktop/src/composables/useQuickOpen.tsindex 0641da711f..673dbcfb66 100644--- a/apps/desktop/src/composables/useQuickOpen.ts+++ b/apps/desktop/src/composables/useQuickOpen.ts@@ -8,6 +8,7 @@ import * as api from "@/lib/backend/api";import type { SqlFileEntry } from "@/lib/backend/api";import { getSqlFileFilter, getSqlFileFolderPaths, sqlFileFoldersVersion } from "@/lib/sqlFile/sqlFileFolders";import { composeGlobalSearchRoots, getGlobalSearchExtensions, globalSearchSettingsVersion } from "@/lib/globalSearch/globalSearchSettings";+import { isQuickOpenScopeActive, pruneQuickOpenScope, quickOpenScopeIds, quickOpenScopeIncludes, setQuickOpenScopeIds } from "@/lib/quickOpen/quickOpenScope";import { containsHan, pinyinFirstLetters } from "@/lib/common/pinyin";import { createFrontendPluginRegistry } from "@/lib/plugins/frontendPlugin";import i18n, { currentLocale } from "@/i18n";@@ -439,16 +440,19 @@ export function useQuickOpen(options: UseQuickOpenOptions = {}) {}const sqlLibraryAllItems = computed<QuickOpenItem[]>(() => {- return savedSqlStore.allFiles.map((file) => ({- id: `sqllib-${file.id}`,- type: "sql_library_file" as const,- label: file.name,- description: getConnectionLabel(file.connectionId),- connectionId: file.connectionId,- connectionName: getConnectionLabel(file.connectionId),- sqlFileId: file.id,- searchText: `${file.name} ${getConnectionLabel(file.connectionId)}`,- }));+ // Files bound to a connection outside the scope are hidden with it; unbound files stay visible.+ return savedSqlStore.allFiles+ .filter((file) => !file.connectionId || quickOpenScopeIncludes(file.connectionId))+ .map((file) => ({+ id: `sqllib-${file.id}`,+ type: "sql_library_file" as const,+ label: file.name,+ description: getConnectionLabel(file.connectionId),+ connectionId: file.connectionId,+ connectionName: getConnectionLabel(file.connectionId),+ sqlFileId: file.id,+ searchText: `${file.name} ${getConnectionLabel(file.connectionId)}`,+ }));});const sqlLibraryRecentItems = computed<QuickOpenItem[]>(() => {@@ -569,7 +573,9 @@ export function useQuickOpen(options: UseQuickOpenOptions = {}) {const allItems = computed((): QuickOpenItem[] => {const items: QuickOpenItem[] = [];- const connections = connectionStore.connections;+ // A narrowed scope hides unselected connections and everything beneath them,+ // keeping local tree entries in sync with the remote search pool.+ const connections = connectionStore.connections.filter((conn) => quickOpenScopeIncludes(conn.id));const treeNodes = connectionStore.treeNodes;// Add connections@@ -837,6 +843,8 @@ export function useQuickOpen(options: UseQuickOpenOptions = {}) {return priority(left) - priority(right);});for (const conn of orderedConnections) {+ // Connection scope: unselected connections contribute neither results nor on-demand connects.+ if (!quickOpenScopeIncludes(conn.id)) continue;// listCompletionTables connects on demand. Keeping disconnected connections// out here makes quick-open blind to unloaded tables after a cold start.if (REMOTE_SEARCH_UNSUPPORTED_TYPES.has(conn.db_type)) continue;@@ -930,15 +938,33 @@ export function useQuickOpen(options: UseQuickOpenOptions = {}) {void loadExternalSqlFiles();});+ /**+ * Invalidate in-flight remote work and schedule a fresh search for `rawQuery`.+ * Both the query watcher and the scope watcher funnel through here: bumping the+ * generation keeps stale responses from landing, and the debounce coalesces bursts.+ */+ function scheduleRemoteSearch(rawQuery: string): void {+ selectedIndex.value = 0;+ const generation = ++remoteSearchGeneration;+ cancelStaleRemoteRequestWaiters(generation);+ if (remoteSearchTimer) clearTimeout(remoteSearchTimer);+ remoteSearchTimer = undefined;+ remoteItems.value = [];++ const normalizedQuery = rawQuery.trim();+ if (normalizedQuery.length < REMOTE_SEARCH_MIN_QUERY_LENGTH) return;+ const contexts = remoteSearchContexts();+ if (contexts.length === 0) return;++ remoteSearchTimer = setTimeout(() => {+ remoteSearchTimer = undefined;+ void runRemoteSearch(normalizedQuery, generation, contexts);+ }, REMOTE_SEARCH_DEBOUNCE_MS);+ }+watch(searchQuery,(query) => {- selectedIndex.value = 0;- const generation = ++remoteSearchGeneration;- cancelStaleRemoteRequestWaiters(generation);- if (remoteSearchTimer) clearTimeout(remoteSearchTimer);- remoteItems.value = [];-const normalizedQuery = query.trim();// Ensure external SQL files are loaded when the user starts searching@@ -949,18 +975,22 @@ export function useQuickOpen(options: UseQuickOpenOptions = {}) {void loadPluginWorkbenches();}- if (normalizedQuery.length < REMOTE_SEARCH_MIN_QUERY_LENGTH) return;- const contexts = remoteSearchContexts();- if (contexts.length === 0) return;-- remoteSearchTimer = setTimeout(() => {- remoteSearchTimer = undefined;- void runRemoteSearch(normalizedQuery, generation, contexts);- }, REMOTE_SEARCH_DEBOUNCE_MS);+ scheduleRemoteSearch(query);},{ flush: "sync" },);+ // Changing the connection scope re-runs the current query immediately, without retyping.+ watch(quickOpenScopeIds, () => {+ scheduleRemoteSearch(searchQuery.value);+ });++ // Drop a selected connection that no longer exists, so the picker never points at it.+ watch(+ () => connectionStore.connections.map((conn) => conn.id).join("\n"),+ () => pruneQuickOpenScope(connectionStore.connections.map((conn) => conn.id)),+ );+const filteredItems = computed((): MatchedItem[] => {if (!searchQuery.value.trim()) {// Show all tree items plus a limited set of recent SQL library files and external SQL files@@ -1116,5 +1146,9 @@ export function useQuickOpen(options: UseQuickOpenOptions = {}) {setQuery,loadExternalSqlFiles,loadPluginWorkbenches,+ // Connection scope: empty = all connections.+ scopeConnectionIds: quickOpenScopeIds,+ scopeActive: computed(() => isQuickOpenScopeActive()),+ setScopeConnectionIds: setQuickOpenScopeIds,};}diff --git a/apps/desktop/src/i18n/locales/az.ts b/apps/desktop/src/i18n/locales/az.tsindex b9d1a72c9d..0d20ada20c 100644--- a/apps/desktop/src/i18n/locales/az.ts+++ b/apps/desktop/src/i18n/locales/az.ts@@ -2877,6 +2877,8 @@ export default withEnglishFallback({searchExtensions: "Fayl uzantıları",extensionsPlaceholder: "məs. sql, txt, md",apply: "Tətbiq et",+ scope: "Axtarış əhatəsi",+ scopeAll: "Bütün bağlantılar",},explain: {copyRaw: "{format} kopyala",diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.tsindex f172c00e6f..0e7afebf6c 100644--- a/apps/desktop/src/i18n/locales/en.ts+++ b/apps/desktop/src/i18n/locales/en.ts@@ -3777,6 +3777,8 @@ export default {searchExtensions: "File extensions",extensionsPlaceholder: "e.g. sql, txt, md",apply: "Apply",+ scope: "Search scope",+ scopeAll: "All connections",},explain: {copyRaw: "Copy {format}",diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.tsindex 2780cc731a..e4d470d119 100644--- a/apps/desktop/src/i18n/locales/es.ts+++ b/apps/desktop/src/i18n/locales/es.ts@@ -3535,6 +3535,8 @@ export default withEnglishFallback({searchExtensions: "Extensiones de archivo",extensionsPlaceholder: "p. ej. sql, txt, md",apply: "Aplicar",+ scope: "Ámbito de búsqueda",+ scopeAll: "Todas las conexiones",},explain: {copyRaw: "Copiar {format}",diff --git a/apps/desktop/src/i18n/locales/id.ts b/apps/desktop/src/i18n/locales/id.tsindex 84dfb2f85c..9145c12661 100644--- a/apps/desktop/src/i18n/locales/id.ts+++ b/apps/desktop/src/i18n/locales/id.ts@@ -3207,6 +3207,8 @@ export default withEnglishFallback({searchExtensions: "Ekstensi file",extensionsPlaceholder: "mis. sql, txt, md",apply: "Terapkan",+ scope: "Ruang lingkup pencarian",+ scopeAll: "Semua koneksi",},explain: {copyRaw: "Salin {format}",diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.tsindex 957f805cd9..699ed8a766 100644--- a/apps/desktop/src/i18n/locales/it.ts+++ b/apps/desktop/src/i18n/locales/it.ts@@ -3387,6 +3387,8 @@ export default withEnglishFallback({searchExtensions: "Estensioni file",extensionsPlaceholder: "es. sql, txt, md",apply: "Applica",+ scope: "Ambito di ricerca",+ scopeAll: "Tutte le connessioni",},explain: {copyRaw: "Copia {format}",diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.tsindex 3fbd31e486..03ef6cee29 100644--- a/apps/desktop/src/i18n/locales/ja.ts+++ b/apps/desktop/src/i18n/locales/ja.ts@@ -3411,6 +3411,8 @@ export default withEnglishFallback({searchExtensions: "拡張子",extensionsPlaceholder: "例: sql, txt, md",apply: "適用",+ scope: "検索範囲",+ scopeAll: "すべての接続",},explain: {copyRaw: "{format} をコピー",diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.tsindex 1d261917f6..ad7984c8f0 100644--- a/apps/desktop/src/i18n/locales/ko.ts+++ b/apps/desktop/src/i18n/locales/ko.ts@@ -3336,6 +3336,8 @@ export default withEnglishFallback({searchExtensions: "확장자",extensionsPlaceholder: "예: sql, txt, md",apply: "적용",+ scope: "검색 범위",+ scopeAll: "모든 연결",},explain: {copyRaw: "{format} 복사",diff --git a/apps/desktop/src/i18n/locales/pl.ts b/apps/desktop/src/i18n/locales/pl.tsindex 907aec0602..fa886de24c 100644--- a/apps/desktop/src/i18n/locales/pl.ts+++ b/apps/desktop/src/i18n/locales/pl.ts@@ -3275,6 +3275,8 @@ export default withEnglishFallback({searchExtensions: "Rozszerzenia plików",extensionsPlaceholder: "np. sql, txt, md",apply: "Zastosuj",+ scope: "Zakres wyszukiwania",+ scopeAll: "Wszystkie połączenia",},explain: {copyRaw: "Kopiuj jako {format}",diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.tsindex 3653fa763c..f1875bc3ff 100644--- a/apps/desktop/src/i18n/locales/pt-BR.ts+++ b/apps/desktop/src/i18n/locales/pt-BR.ts@@ -3387,6 +3387,8 @@ export default withEnglishFallback({searchExtensions: "Extensões de arquivo",extensionsPlaceholder: "ex.: sql, txt, md",apply: "Aplicar",+ scope: "Escopo da pesquisa",+ scopeAll: "Todas as conexões",},explain: {copyRaw: "Copiar {format}",diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.tsindex feec70b85f..9a54aaa722 100644--- a/apps/desktop/src/i18n/locales/ru.ts+++ b/apps/desktop/src/i18n/locales/ru.ts@@ -3488,6 +3488,8 @@ export default withEnglishFallback({searchExtensions: "Расширения файлов",extensionsPlaceholder: "например, sql, txt, md",apply: "Применить",+ scope: "Область поиска",+ scopeAll: "Все подключения",},explain: {copyRaw: "Копировать {format}",diff --git a/apps/desktop/src/i18n/locales/th.ts b/apps/desktop/src/i18n/locales/th.tsindex a82d74a210..3eafbcbb22 100644--- a/apps/desktop/src/i18n/locales/th.ts+++ b/apps/desktop/src/i18n/locales/th.ts@@ -3721,6 +3721,8 @@ export default withEnglishFallback({searchExtensions: "นามสกุลไฟล์",extensionsPlaceholder: "เช่น sql, txt, md",apply: "ใช้",+ scope: "ขอบเขตการค้นหา",+ scopeAll: "การเชื่อมต่อทั้งหมด",},explain: {copyRaw: "คัดลอก {format}",diff --git a/apps/desktop/src/i18n/locales/tr.ts b/apps/desktop/src/i18n/locales/tr.tsindex daaec6c786..eeec07b3da 100644--- a/apps/desktop/src/i18n/locales/tr.ts+++ b/apps/desktop/src/i18n/locales/tr.ts@@ -2852,6 +2852,8 @@ export default withEnglishFallback({searchExtensions: "Dosya uzantıları",extensionsPlaceholder: "örn. sql, txt, md",apply: "Uygula",+ scope: "Arama kapsamı",+ scopeAll: "Tüm bağlantılar",},explain: {copyRaw: "{format} kopyala",diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.tsindex 239cfec3a6..daac22b1cc 100644--- a/apps/desktop/src/i18n/locales/zh-CN.ts+++ b/apps/desktop/src/i18n/locales/zh-CN.ts@@ -3708,6 +3708,8 @@ export default withEnglishFallback({searchExtensions: "扩展名",extensionsPlaceholder: "例如 sql, txt, md",apply: "应用",+ scope: "搜索范围",+ scopeAll: "全部连接",},explain: {copyRaw: "复制 {format}",diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.tsindex d00c77ed02..50d258b113 100644--- a/apps/desktop/src/i18n/locales/zh-TW.ts+++ b/apps/desktop/src/i18n/locales/zh-TW.ts@@ -3390,6 +3390,8 @@ export default withEnglishFallback({searchExtensions: "副檔名",extensionsPlaceholder: "例如 sql, txt, md",apply: "套用",+ scope: "搜尋範圍",+ scopeAll: "全部連線",},explain: {copyRaw: "複製 {format}",diff --git a/apps/desktop/src/lib/quickOpen/quickOpenScope.ts b/apps/desktop/src/lib/quickOpen/quickOpenScope.tsnew file mode 100644index 0000000000..9c191ab84c--- /dev/null+++ b/apps/desktop/src/lib/quickOpen/quickOpenScope.ts@@ -0,0 +1,32 @@+import { ref } from "vue";++/**+ * Quick-open connection scope: the set of connection ids included in a search.+ * An empty set means "search every connection", which is the default.+ *+ * Deliberately in-memory only: the choice survives closing and reopening the search dialog,+ * but a fresh app launch starts from "all connections" again.+ */+export const quickOpenScopeIds = ref<string[]>([]);++/** True when the user narrowed the search to specific connections. */+export function isQuickOpenScopeActive(ids: readonly string[] = quickOpenScopeIds.value): boolean {+ return ids.length > 0;+}++/** Whether `connectionId` passes the active scope (everything passes when no scope is set). */+export function quickOpenScopeIncludes(connectionId: string, ids: readonly string[] = quickOpenScopeIds.value): boolean {+ return ids.length === 0 || ids.includes(connectionId);+}++export function setQuickOpenScopeIds(ids: string[]): void {+ quickOpenScopeIds.value = [...new Set(ids.filter((id) => typeof id === "string" && id.trim().length > 0))];+}++/** Drop stored ids whose connection no longer exists, so a stale scope cannot hide everything. */+export function pruneQuickOpenScope(knownConnectionIds: readonly string[]): void {+ if (!isQuickOpenScopeActive()) return;+ const known = new Set(knownConnectionIds);+ const next = quickOpenScopeIds.value.filter((id) => known.has(id));+ if (next.length !== quickOpenScopeIds.value.length) setQuickOpenScopeIds(next);+}