Skip to content

feat(connections): expand matching folders in search and add the visible-folders filter COMPASS-11308 - #8691

Open
KareBearIsBoss8 wants to merge 5 commits into
mainfrom
COMPASS-11308
Open

KareBearIsBoss8 wants to merge 5 commits into
mainfrom
COMPASS-11308

Conversation

@KareBearIsBoss8

@KareBearIsBoss8 KareBearIsBoss8 commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Search results now keep matches reachable:

  • Matching folders show all their connections and expand automatically.
  • Matching connections keep their parent folder visible and expanded.
  • Search-driven expansion is temporary and preserves the user's own expanded state.
  • Empty folders are hidden while search or “show only active connections” narrows the list; newly created empty folders remain visible when unfiltered.

Add a visible-folders multi-select filter for folders and Uncategorized, with an All connections option.

Screenshot 2026-11-17 at 4 19 42 PM

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added
  • If this change updates the UI, screenshots/videos are added and a design review is requested
  • If this change could impact the load on the MongoDB cluster, please describe the expected and worst case impact
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

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

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@KareBearIsBoss8 KareBearIsBoss8 added the feature flagged PRs labeled with this label will not be included in the release notes of the next release label Nov 12, 2026
@github-actions github-actions Bot added the feat label Nov 12, 2026
@KareBearIsBoss8
KareBearIsBoss8 changed the base branch from main to COMPASS-11306 November 17, 2026 21:04
@KareBearIsBoss8
KareBearIsBoss8 marked this pull request as ready for review November 17, 2026 21:20
@KareBearIsBoss8
KareBearIsBoss8 requested a review from a team as a code owner November 17, 2026 21:20
@KareBearIsBoss8
KareBearIsBoss8 requested review from Anemy, kmruiz and paula-stacho and removed request for a team November 17, 2026 21:20
const EMPTY_HIDDEN_FOLDER_IDS: string[] = [];

// Stands in for connections that aren't filed in any folder.
const UNCATEGORIZED_ITEM_ID = 'uncategorized';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 😊

Base automatically changed from COMPASS-11306 to main November 18, 2026 17:24
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.
@paula-stacho

paula-stacho commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

The hiddenFolderIds are updated when the filter changes, but not when a folder is deleted - result is a bit confusing (especially if someone has the filter active for a while and they might not even remember activating a filter). On the other hand, we do allow for selecting "none" in the filter - which would make sense if "uncategorized" wasn't a separate option. What do you think? We can also just document these considerations and discuss this with @misbamongo

Screen.Recording.2026-11-19.at.10.48.58.mov

@paula-stacho

paula-stacho commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

For connections and databases, we only enter the temporary auto-expand state when the child is the match - not when the parent itself is the match (see screenshots). For consistency, we should make folders follow the same pattern.

Connection - parent match and child match

Screenshot 2026-11-19 at 10 57 33 Screenshot 2026-11-19 at 10 57 06

Database - parent match and child match

Screenshot 2026-11-19 at 11 01 34 Screenshot 2026-11-19 at 11 01 27

}): 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('');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2026-11-19 at 11 24 04

const excludeInactiveCheckboxId = useId();
const allConnectionsCheckboxId = useId();

const hiddenFolderIds = filter.hiddenFolderIds ?? EMPTY_HIDDEN_FOLDER_IDS;

@paula-stacho paula-stacho Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

@paula-stacho paula-stacho Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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}
Comment on lines +153 to +165
// 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)
)
) {
Comment on lines +621 to +623
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;

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat feature flagged PRs labeled with this label will not be included in the release notes of the next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants