fix(sidebar): preserve results when enabling regex search

This commit is contained in:
OOMEcho authored and GitHub committed 2026-09-29 11:56:31 +08:00
1 parent 77c542248d
commit 03b3f4c4fa
3 files changed
+22 -3

No files matched your search

+7 -1
View File
@@ -1,6 +1,6 @@
import { strict as assert } from "node:assert";
import { test, vi } from "vitest";
import { collectSidebarRegexIndexScopes, regexTableSearchParents, resolveSidebarRemoteSearchQuery, resolveSidebarSearchDispatchMode } from "../../apps/desktop/src/lib/sidebar/sidebarRegexSearchIndex.ts";
import { collectSidebarRegexIndexScopes, regexTableSearchParents, resolveSidebarRemoteSearchQuery, resolveSidebarSearchDispatchMode, shouldRestoreTrackedSidebarSearchTargetsInRegexMode } from "../../apps/desktop/src/lib/sidebar/sidebarRegexSearchIndex.ts";
import type { SidebarRegexIndexScope } from "../../apps/desktop/src/lib/sidebar/sidebarSearchTree.ts";
import type { TableInfo, TreeNode } from "../../apps/desktop/src/types/database.ts";
@@ -40,6 +40,12 @@ test("local search on keeps ordinary queries local and local search off enables
assert.equal(resolveSidebarSearchDispatchMode({ query: "", regexMode: false, wasRegexMode: false }, { localSearchEnabled: false }), "ordinary");
});
test("keeps ordinary search results available until the regex query is cleared", () => {
assert.equal(shouldRestoreTrackedSidebarSearchTargetsInRegexMode("user"), false);
assert.equal(shouldRestoreTrackedSidebarSearchTargetsInRegexMode("user|role"), false);
assert.equal(shouldRestoreTrackedSidebarSearchTargetsInRegexMode(""), true);
});
test("collects manifest scopes and live-tree backfill scopes through the read-only reader", async () => {
const manifestScope = scope("conn-1:app:public:__tables", { path: [{ id: "conn-1", label: "c", type: "connection", connectionId: "conn-1" }] });
const live: TreeNode[] = [