Repository navigation
feat(connections): expand matching folders in search and add the visible-folders filter COMPASS-11308 - #8691
KareBearIsBoss8 wants to merge 5 commits into
Conversation
bf8ccbd to
a760f4c
Compare
| const EMPTY_HIDDEN_FOLDER_IDS: string[] = []; | ||
|
|
||
| // Stands in for connections that aren't filed in any folder. | ||
| const UNCATEGORIZED_ITEM_ID = 'uncategorized'; |
There was a problem hiding this comment.
now this is another example of a comment that is harmless now - but say the code changes and we'll start to use it for other items. there is no need to rename the const, because it already says "item", not "connection", so noone will touch this. even later, someone reads this comment not knowing that it's no longer true.
it's a nit now, just trying to explain the problem with relying on comments 😊
The hook took `folders` as input and returned `folders` as output with a different meaning, so the call site destructured it into `visibleFolders` to disambiguate. Renaming the return values to `filteredConnections` and `filteredFolders` removes the ambiguity at the source. Also drops a comment on UNCATEGORIZED_ITEM_ID: the const name already says "item", so the comment can only go stale.
909aeae to
8025c76
Compare
|
The Screen.Recording.2026-11-19.at.10.48.58.mov |
| }): React.ReactElement { | ||
| // The filter only holds the compiled regex, so the text the user typed is | ||
| // kept here — it is what the input renders and what Reset has to clear. | ||
| const [searchText, setSearchText] = useState(''); |
There was a problem hiding this comment.
I understand where you're coming from, working around the search only being passed to the store if it's valid. The decision back then was most likely intentional (if we can't parse the regex then just show everything). We can double check this with design, but either way -
we could move the searchText to the store, so that it's treated like any other filter - single onFilterChange then clears all filters, and is available to clear the input even if its in invalid state
(optional, pre-existing) - when the search isn't a valid regex, the input could become visibly invalid
| const excludeInactiveCheckboxId = useId(); | ||
| const allConnectionsCheckboxId = useId(); | ||
|
|
||
| const hiddenFolderIds = filter.hiddenFolderIds ?? EMPTY_HIDDEN_FOLDER_IDS; |
There was a problem hiding this comment.
I see the default initial value is defined in two separate places, could we instead have an initial filter coming from the store? that way they don't diverge, and we could also use this for example to test the reset (expect it to result in the same initial value - for all filters)
|
|
||
| // Expanded during search only; the user's own state returns when cleared. | ||
| if (regex) { | ||
| temporarilyExpandedFolderIds.push(folder.id); |
There was a problem hiding this comment.
the temporary expand of connections is handled elsewhere, this could be why you didn't notice the difference in behaviour. let's align the two
…SS-11308 - Keep the search text in the filter itself, with a single initial filter the store starts from and Reset returns to - Only temp-expand a folder when a child matches, as with connections and databases, including matches deeper in a connection's subtree - Land every unmatchable search (unparseable regex or a folder-name restricted character) on the empty state instead of showing everything - Prune deleted folder ids from the filter so the caption does not linger - Show the filter caption and Reset only for the popover filters
There was a problem hiding this comment.
🟡 Changes recommended
Active issues leave matching connections collapsed, reject valid regex searches, remove hidden folders from move destinations, and trigger unnecessary collection metadata fetching on visibility-only changes.
4 open issues
What changed in this PR
This PR extends the sidebar’s connection-folder support with folder-aware search and visibility filters. The added integration coverage is useful, though search correctness and unnecessary metadata loading still need attention.
Changes:
- Adds folder-aware filtering and temporary expansion state.
- Adds folder visibility controls, a filter indicator, and Reset.
- Extends hook and sidebar tests for filtering and expansion behavior.
| File | Description |
|---|---|
packages/compass-sidebar/src/components/use-filtered-connections.ts |
Implements folder filtering, search compilation, and temporary expansion. |
packages/compass-sidebar/src/components/use-filtered-connections.spec.ts |
Covers folder visibility and search expansion behavior. |
packages/compass-sidebar/src/components/navigation-items-filter.tsx |
Adds controlled search input, filter caption, and Reset. |
packages/compass-sidebar/src/components/multiple-connections/sidebar.tsx |
Initializes shared filter defaults and removes deleted folder IDs. |
packages/compass-sidebar/src/components/multiple-connections/sidebar.spec.tsx |
Adds integrated filtering, reset, and empty-state coverage. |
packages/compass-sidebar/src/components/multiple-connections/connections-navigation.tsx |
Connects filtered folders to navigation and updates empty results. |
packages/compass-sidebar/src/components/connections-filter-popover.tsx |
Adds folder, Uncategorized, and All connections checkboxes. |
Review effort: Balanced
| ) | ||
| <ConnectionsNavigationTree | ||
| connections={filteredConnections || connections} | ||
| folders={filteredFolders} |
| // Matches connections and databases: only a child match opens the parent, | ||
| // a folder that matched by its own name stays closed. A connection can be | ||
| // the match through its own children, so its subtree counts too. Expanded | ||
| // during search only; the user's own state returns when cleared. | ||
| if ( | ||
| regex && | ||
| !nameMatches && | ||
| connectionsToShow.some( | ||
| (c) => | ||
| c.isMatch || | ||
| (c.connectionStatus === 'connected' && c.databases.length > 0) | ||
| ) | ||
| ) { |
| if (RESTRICTED_CHARACTERS_REGEX.test(search)) { | ||
| return NEVER_MATCHING_REGEX; | ||
| } |
| // so we use this conditional dependency to avoid too many calls | ||
| const connectionsWhenFiltering = | ||
| (filter.regex || filter.excludeInactive) && connections; | ||
| const connectionsWhenFiltering = isFilterActive && connections; |






Description
Search results now keep matches reachable:
Add a visible-folders multi-select filter for folders and Uncategorized, with an All connections option.
Checklist
Motivation and Context
Open Questions
Dependents
Stacked on COMPASS-11306 — this branch is based on it. It builds on the folder foundation from COMPASS-11304 (folder store/actions), COMPASS-11305 (tree rendering) and COMPASS-11306 (folder management menus).
Types of changes