Skip to content

add a toggle to filter empty schemas and db#9712

Draft
Light2Dark wants to merge 1 commit into
mainfrom
sham/hide-empty-schemas-db
Draft

add a toggle to filter empty schemas and db#9712
Light2Dark wants to merge 1 commit into
mainfrom
sham/hide-empty-schemas-db

Conversation

@Light2Dark
Copy link
Copy Markdown
Collaborator

@Light2Dark Light2Dark commented May 28, 2026

📝 Summary

Closes #6807.

This toggles empty db and schemas. By default all are shown, this config is stored in local storage.

Screen.Recording.2026-05-28.at.5.35.47.PM.mov

📋 Pre-Review Checklist

  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • 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.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Tests have been added for the changes made.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 28, 2026

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

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment May 28, 2026 9:36am

Request Review

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

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

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="frontend/src/components/datasources/datasources.tsx">

<violation number="1" location="frontend/src/components/datasources/datasources.tsx:156">
P1: The new empty-schema filter treats `tables.length === 0` as definitively empty, but `0` is also the lazy-loading state. This can hide schemas/databases before table fetches run, preventing users from ever loading their tables.</violation>
</file>
Architecture diagram
sequenceDiagram
    participant UI as DataSources Panel
    participant Store as Jotai Store (localStorage)
    participant Backend as Backend API
    participant Cache as React useMemo

    Note over UI,Cache: Initial Load
    
    UI->>Store: NEW: read hideEmptyDatasourcesAtom (from localStorage key "marimo:datasources:hideEmpty")
    Store-->>UI: false (default)

    UI->>Backend: fetch databases & schemas
    Backend-->>UI: rawConnections with all databases & schemas

    Note over UI,Cache: Toggle Filter
    
    UI->>UI: user clicks Eye/EyeOff button
    UI->>Store: NEW: setHideEmpty(!hideEmpty)
    Store-->>UI: confirm toggle

    Note over UI,Cache: Re-render with filter applied
    
    UI->>Cache: NEW: useMemo recomputes dataConnections
    Cache->>Cache: NEW: filterEmptyDatabases() applied per connection
    
    alt hideEmpty === false
        Cache-->>UI: return rawConnections unchanged
    else hideEmpty === true
        Note over Cache: For each connection.databases:
        Cache->>Cache: filter schemas with 0 tables
        Cache->>Cache: filter databases where all schemas are empty
        alt database.schemas.length === 0
            Note over Cache: preserve - lazy state
        end
        Cache-->>UI: filteredConnections
    end

    alt filteredConnections changed
        UI->>UI: re-render tree with filtered data
    else no change (immuatable check)
        UI->>UI: return previous reference
    end

    Note over UI,Backend: Unchanged Backend Behavior
    
    Note over Backend: CHANGED: get_schemas() no longer filters empty schemas server-side
    Note over Backend: now returns ALL schemas regardless of table count
Loading

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

Re-trigger cubic

continue;
}
const nonEmptySchemas = database.schemas.filter(
(schema) => schema.tables.length > 0,
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.

P1: The new empty-schema filter treats tables.length === 0 as definitively empty, but 0 is also the lazy-loading state. This can hide schemas/databases before table fetches run, preventing users from ever loading their tables.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At frontend/src/components/datasources/datasources.tsx, line 156:

<comment>The new empty-schema filter treats `tables.length === 0` as definitively empty, but `0` is also the lazy-loading state. This can hide schemas/databases before table fetches run, preventing users from ever loading their tables.</comment>

<file context>
@@ -116,6 +124,51 @@ const sortedTablesAtom = atom((get) => {
+      continue;
+    }
+    const nonEmptySchemas = database.schemas.filter(
+      (schema) => schema.tables.length > 0,
+    );
+    if (nonEmptySchemas.length === 0) {
</file context>

@Light2Dark Light2Dark added the enhancement New feature or request label May 28, 2026
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.

Datasource panel with IbisEngine shows empty database and schema

1 participant