Skip to content

Scope filter-by-values top-K to exclude the filter being edited#9376

Merged
kirangadhave merged 1 commit into
mainfrom
kg/filter-by-values-topk-scope
Apr 27, 2026
Merged

Scope filter-by-values top-K to exclude the filter being edited#9376
kirangadhave merged 1 commit into
mainfrom
kg/filter-by-values-topk-scope

Conversation

@kirangadhave

Copy link
Copy Markdown
Member

Summary

  • Re-opening a "filter by values" pill re-computed the picker's top-K list against the already-filtered rows, so values excluded by the current filter vanished from the picker. Narrowing role to [admin, user] hid guest entirely — the user could no longer broaden the filter back out without clearing it.
  • _calculate_top_k_rows now strips conditions targeting the requested column before computing top-K. Filters on other columns and the active search query still narrow the result, so cross-column filter context is preserved.
  • Fast path: when no active filter targets the requested column, the cached _searched_manager is reused — zero extra cost for the common case.

Before

Screen.Recording.2026-04-24.at.1.10.28.PM.mov

After

Screen.Recording.2026-04-24.at.1.11.05.PM.mov
Re-opening a filter pill computed top-K against the already-filtered rows,
so values the filter excluded disappeared from the picker and users couldn't
broaden the filter back out. Strip conditions targeting the requested column
before computing top-K; other filters and the search query still apply.
@kirangadhave kirangadhave requested a review from mscolnick April 24, 2026 20:12
@vercel

vercel Bot commented Apr 24, 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 Apr 24, 2026 8:12pm

Request Review

@kirangadhave kirangadhave added the bug Something isn't working label Apr 24, 2026
@kirangadhave

Copy link
Copy Markdown
Member Author
@cubic-dev-ai

cubic-dev-ai Bot commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

@cubic

@kirangadhave I have started the AI code review. It will take a few minutes to complete.

@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.

No issues found across 2 files

Architecture diagram
sequenceDiagram
    participant FE as Frontend (UI)
    participant T as Table Component (Python)
    participant TM as Table Manager (Data Backend)

    Note over FE, TM: State Synchronization
    FE->>T: _search(filters, query)
    T->>T: NEW: Store _current_filters & _current_query
    T->>TM: Apply all filters & query
    TM-->>T: Return filtered results
    T-->>FE: Update Table View

    Note over FE, TM: Filter Picker Interaction (Top-K)
    FE->>T: _calculate_top_k_rows(column, k)
    
    alt NEW: Column is targeted by active filters
        T->>T: NEW: _strip_filters_for_column(target_column)
        Note right of T: Removes conditions on this column<br/>but keeps other column filters and query
        T->>TM: CHANGED: _apply_filters_query_sort(stripped_filters, query)
        TM-->>T: Return temporary "rescoped" manager
        T->>TM: calculate_top_k_rows(column, k)
    else Fast Path: No active filters on this column
        T->>TM: calculate_top_k_rows(column, k) (using cached searched_manager)
    end

    TM-->>T: Return list of (value, count)
    T-->>FE: CalculateTopKRowsResponse
Loading
@kirangadhave kirangadhave requested a review from Light2Dark April 26, 2026 20:46
@kirangadhave kirangadhave merged commit a50b846 into main Apr 27, 2026
45 of 46 checks passed
@kirangadhave kirangadhave deleted the kg/filter-by-values-topk-scope branch April 27, 2026 16:01
@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.4-dev9

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

Labels

bug Something isn't working

2 participants