fix(ui): preserve upstream sidebar and selection behavior

This commit is contained in:
c_w_xiaohei
2026-08-26 02:36:07 +08:00
parent f329a22cf3
commit ceee7f350e
4 changed files with 60 additions and 1 deletions
@@ -55,4 +55,14 @@ describe('selectFolderIdsForProjection', () => {
expect([...selectFolderIdsForProjection(folders, { archivedBucket: true, searchQuery: 'matching' })])
.toEqual(['root', 'child']);
});
test('keeps a fuzzy folder match and its ancestor', () => {
const folders = [
{ id: 'root', name: 'Root', parentId: null, nodeCount: 0 },
{ id: 'child', name: 'Release Notes', parentId: 'root', nodeCount: 0 },
];
expect([...selectFolderIdsForProjection(folders, { archivedBucket: false, searchQuery: 'release-notes' })])
.toEqual(['root', 'child']);
});
});
@@ -1,4 +1,5 @@
import { getRuntimeKey } from '@/lib/runtime-switch';
import { matchesRankQuery } from '@/lib/search/fuzzySearch';
import { normalizePath } from '@/lib/pathNormalization';
import { resolveGlobalSessionDirectory } from '@/stores/useGlobalSessionsStore';
import { getPinnedSessionKey } from '@/stores/useSessionPinnedStore';
@@ -227,7 +228,7 @@ export const selectFolderIdsForProjection = (
keep = (childIdsByParentId.get(folderId) ?? []).some(shouldKeep);
} else {
if (!keep && !options.searchQuery) keep = true;
if (!keep && (entry.nodeCount > 0 || entry.name.toLowerCase().includes(options.searchQuery))) keep = true;
if (!keep && (entry.nodeCount > 0 || matchesRankQuery([entry.name], options.searchQuery))) keep = true;
if (!keep) keep = (childIdsByParentId.get(folderId) ?? []).some(shouldKeep);
}