Skip to content

feat(datasources): only auto-expand search matches in the data sources tree#9955

Merged
Light2Dark merged 3 commits into
mainfrom
feat/search-expand-matching
Jun 23, 2026
Merged

feat(datasources): only auto-expand search matches in the data sources tree#9955
Light2Dark merged 3 commits into
mainfrom
feat/search-expand-matching

Conversation

@Light2Dark

@Light2Dark Light2Dark commented Jun 22, 2026

Copy link
Copy Markdown
Member

Summary

Follow-up to #9845 (which superseded the closed #9874). No API or wire-protocol change — purely a frontend UX improvement on the existing Database.schemas model.

Previously, typing any text into the data sources search box ran setIsExpanded(hasSearch) on every database and schema, expanding the entire tree open regardless of whether a branch had any matching tables.

Now a database/schema row auto-expands during search only when its already-loaded subtree contains a table whose name matches the query. Crucially, deferred (not-yet-fetched) tables and child schemas are treated as non-matching, so searching never triggers a lazy catalog fetch — important for large/remote connections (Iceberg, etc.) where unconditional expansion would cause a fetch storm. Expansion is re-evaluated on each keystroke.

This is a reimplementation, against the merged Database.schemas model, of the matched-subtree search behavior from the closed #9874.

Changes

  • New helpers in datasources/utils.ts:
    • schemaSubtreeMatchesSearch(schema, query) — recurses over resolved tables/child schemas only.
    • shouldExpandDatabaseForSearch(database, query) — false when the schema list is deferred.
  • datasources.tsx: DatabaseItem and SchemaNode now drive auto-expansion via these helpers, tracking prevSearchValue so expansion follows the query. Removes the now-unused hasSearch plumbing through the tree.
Screen.Recording.2026-06-23.at.12.43.14.PM.mov

Testing

  • New unit tests for both helpers, including the deferred-bucket cases (search must not match unfetched data).
  • pnpm test src/components/datasources/ — 55 tests pass.

Pre-Review Checklist

  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • Video or media evidence is provided for any visual changes (optional).

Merge Checklist

  • I have read the contributor guidelines.
  • Tests have been added for the changes made.

Review in cubic

…s tree

Previously, typing any text in the data sources search box expanded every
database and every schema unconditionally, flooding the tree open even for
branches with no matching tables.

Now a database/schema row auto-expands during search only when its
already-loaded subtree contains a table whose name matches the query.
Deferred (not-yet-fetched) tables and child schemas are treated as
non-matching, so search never triggers a lazy catalog fetch on large or
remote connections. Expansion is re-evaluated on each keystroke.

Adds `schemaSubtreeMatchesSearch` / `shouldExpandDatabaseForSearch` helpers
with unit tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jun 23, 2026 4:58am

Request Review

@cubic-dev-ai cubic-dev-ai Bot 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.

1 issue found across 3 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread frontend/src/components/datasources/datasources.tsx
Auto-expansion was keyed only to search-text changes, so a matching table
arriving via lazily-resolved schemas/tables under an unchanged query left the
branch collapsed. Also track the computed expansion decision and re-sync when
it flips, so newly resolved matches expand without requiring the query to
change. Manual collapse/expand under a stable decision is preserved.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Light2Dark
Light2Dark requested a review from kirangadhave June 23, 2026 04:44
@Light2Dark
Light2Dark marked this pull request as ready for review June 23, 2026 04:44

@cubic-dev-ai cubic-dev-ai Bot 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.

2 issues found across 1 file (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread marimo/_smoke_tests/sql/catalog_children.py
Comment thread marimo/_smoke_tests/sql/catalog_children.py
@Light2Dark
Light2Dark merged commit ea00c85 into main Jun 23, 2026
44 checks passed
@Light2Dark
Light2Dark deleted the feat/search-expand-matching branch June 23, 2026 14:58
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.11-dev18

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants