Skip to content

feat(resources): add sort and filter to all resource list pages#3834

Merged
waleedlatif1 merged 30 commits intostagingfrom
feat/table-filtering
Mar 29, 2026
Merged

feat(resources): add sort and filter to all resource list pages#3834
waleedlatif1 merged 30 commits intostagingfrom
feat/table-filtering

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

@waleedlatif1 waleedlatif1 commented Mar 29, 2026

Summary

  • Add sort and multi-select filter to KB list, Files, Tables, and Scheduled Tasks list pages
  • Add sort to Logs page (client-side over paginated data)
  • Add sort to Recently Deleted page
  • Upgrade all filter panels to Combobox-based UI (consistent with logs) supporting multi-select
  • Add member-based "Uploaded by" / "Owner" filter to Files and Tables using workspace member data with avatars
  • Add additional filter dimensions: file type, size, schedule type, health, row count, column type
  • Upgrade KB Documents and Document Chunks filter panels to Combobox style
  • Fix filter popover inheriting anchor min-width (added `w-fit` to Radix popover content)
  • Fix build: add missing `Combobox` and `SortConfig` imports in `files.tsx` and `document.tsx`
  • Fix stale `logs` refs in sort-related callbacks and dependency arrays
  • Wrap `sortConfig`, `filterTags`, `enabledFilterParam` in `useMemo` consistently across all pages
  • Fix missing `uploadFile`/`uploadCsv` in useCallback dependency arrays

Type of Change

  • New feature

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

- Replace popover filter with persistent inline panel below toolbar
- Add AND/OR toggle between filter rules (shown in Where label slot)
- Sync filter panel state from applied filter on open
- Show filter button active state when filter is applied or panel is open
- Use readable operator labels matching dropdown options
- Add Clear filters button (shown only when filter is active)
- Close filter panel when last rule is removed via X
- Fix empty gap rows appearing in filtered results by skipping position gap rendering when filter is active
- Add toggle mode to ResourceOptionsBar for inline panel pattern
- Memoize FilterRuleRow for perf, fix filterTags key collision, remove dead filterActiveCount prop
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 29, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Mar 29, 2026 6:04am

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Mar 29, 2026

PR Summary

Medium Risk
Touches multiple core workspace list UIs and introduces new client/server sorting/filtering paths (including new API query params), which could impact list correctness and performance if edge cases aren’t covered.

Overview
Adds consistent sort + multi-select filter UX across workspace resource list pages (Knowledge Bases, KB documents/chunks, Files, Tables, Scheduled Tasks) and client-side sorting for Logs/Recently Deleted, using Combobox-based filter panels and removable filter tags.

Updates ResourceOptionsBar to support a highlighted sort state, truncated filter tags, a w-fit filter popover, and an optional onFilterToggle mode (used by Tables to render an inline filter bar). Multiple lists now debounce search via useDebounce, apply new filter dimensions (e.g., type/size/owner/uploaded-by/status/health), and compute sorting locally or via new backend params.

Extends the knowledge chunks API (GET .../chunks) to accept sortBy/sortOrder, wires chunk/document list pages to pass these, and includes a markdown preview refactor to make task-list checkboxes reliably toggleable. Also centralizes auth CTA button styling via new CSS variables and shared AUTH_PRIMARY_CTA_BASE/AUTH_SUBMIT_BTN, plus small UX fixes (paste accepts any file type, sidebar tooltip wrapper, column drag handle + drop indicator, and tighter callback deps).

Written by Cursor Bugbot for commit f8a26a3. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 29, 2026

Greptile Summary

This PR consistently upgrades all resource list pages (Files, Tables, Knowledge Bases, Scheduled Tasks, Logs, Recently Deleted, KB Documents, Doc Chunks) with a sort control and Combobox-based multi-select filter panel. It also brings along several quality fixes: replacing ad-hoc debounce timers with useDebounce, removing the now-redundant sortValues pattern from ResourceRow, fixing stale closure deps (uploadFile, uploadCsv, logssortedLogs), and correctly wrapping sortConfig/filterTags in useMemo.

Key changes:

  • Sort: all list pages now pass a SortConfig to ResourceOptionsBar; client-side for Files/Tables/KB/Scheduled Tasks/Logs/Recently Deleted, server-side for KB Documents and Doc Chunks (new sortBy/sortOrder params propagated through the API route → Zod schema → service → Drizzle query).
  • Filters: upgraded from bespoke radio-button panels to uniform Combobox multiSelect dropdowns; member avatars added for "Uploaded by" / "Owner" filters in Files and Tables.
  • useAutoScroll gains a scrollOnMount opt-in (default false), preventing the preview panel from hijacking scroll position on open while preserving the chat's scroll-to-bottom on mount.
  • Whitelabeling: new auth-button CSS vars in globals.css are overridden at runtime by inject-theme.ts using NEXT_PUBLIC_BRAND_PRIMARY_COLOR/NEXT_PUBLIC_BRAND_PRIMARY_HOVER_COLOR.
  • Sidebar: SidebarTooltip extracted and shared between sidebar.tsx and settings-sidebar.tsx, removing repeated Tooltip.Root/Trigger/Content boilerplate.

The only meaningful limitation is that the Logs sort is client-side over already-fetched paginated data, which the author explicitly acknowledges in the PR description.

Confidence Score: 5/5

Safe to merge — all remaining findings are P2 style suggestions with no correctness or data-integrity impact.

No P0/P1 issues found. The sort and filter logic is implemented consistently and correctly across all pages. Server-side sort for chunks is correctly plumbed through the API route, Zod schema, and Drizzle query. The known client-side-only sort on paginated Logs is an intentional, documented trade-off. All bug fixes in the PR (stale deps, missing uploadFile/uploadCsv in callbacks) are correct. Only three P2 style observations remain: the globals.css addition (justified by whitelabeling needs), the log-sort UX note (already documented), and the minor placement of SidebarTooltip in the main sidebar file.

No files require special attention. The globals.css addition warrants a brief discussion but is technically justified.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/files/files.tsx Adds client-side sort + multi-select filter (file type, size, owner) using useDebounce hook and replaces manual debounce timer; removes the Last Updated column and its sortValues; fixes missing uploadFile in useCallback dep array.
apps/sim/app/workspace/[workspaceId]/tables/tables.tsx Adds debounced search, sort config, and row-count/owner multi-select filters; replaces sortValues pattern with direct useMemo sort; fixes missing uploadCsv in useCallback dep array.
apps/sim/app/workspace/[workspaceId]/knowledge/knowledge.tsx Adds sort and connector/content/owner multi-select filters to the knowledge-base list; replaces manual debounce with useDebounce and removes sortValues pattern.
apps/sim/app/workspace/[workspaceId]/logs/logs.tsx Adds client-side sort (date, duration, cost, status) applied over the currently-fetched paginated pages; fixes stale logs refs in sort callbacks and dep arrays.
apps/sim/app/workspace/[workspaceId]/scheduled-tasks/scheduled-tasks.tsx Adds sort and schedule-type/status/health multi-select filters; removes sortValues pattern in favour of useMemo sort.
apps/sim/app/workspace/[workspaceId]/knowledge/[id]/base.tsx Upgrades the documents enabled-filter from a single-value string to a string[] multiselect Combobox; wraps sortConfig in useMemo and adds onClear; no logic regressions.
apps/sim/app/workspace/[workspaceId]/knowledge/[id]/[documentId]/document.tsx Adds server-side sort for document chunks (index/tokens/status); upgrades enabledFilter to string[] multi-select; maps sort column IDs to API-level field names correctly.
apps/sim/lib/knowledge/chunks/service.ts Adds sortBy/sortOrder support to queryChunks with an IIFE-based column selector; defaults remain chunkIndex/asc.
apps/sim/app/_styles/globals.css Six CSS custom properties for auth button theming added to :root; needed for the whitelabeling override system but technically violates the project rule to avoid editing globals.css.
apps/sim/hooks/use-auto-scroll.ts Adds scrollOnMount option (defaults false); preview-panel intentionally no longer scrolls to bottom on mount, while mothership-chat explicitly opts in with scrollOnMount:true.
apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-filter/table-filter.tsx Incorporates the previously-reviewed rulesRef fix; adds filterToRules for initialising state from existing filter, logical operator toggle, and a clear handler that auto-closes.
apps/sim/ee/whitelabeling/inject-theme.ts Generates overriding CSS vars for auth button colours from NEXT_PUBLIC_BRAND_PRIMARY/HOVER env vars with automatic contrast-text calculation.
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/sidebar.tsx Extracts SidebarTooltip helper and uses it throughout the sidebar and settings-sidebar; simplifies repeated Tooltip.Root/Trigger/Content boilerplate.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User Input] --> B{Input Type}
    B -->|Search text| C[setInputValue / setSearchTerm]
    B -->|Filter selection| D[setTypeFilter / setSizeFilter / setOwnerFilter]
    B -->|Sort selection| E[setActiveSort]

    C --> F[useDebounce 200-300ms]
    F --> G[debouncedSearchTerm]

    G --> H[processedItems / filteredFiles useMemo]
    D --> H
    E --> H

    H --> I{Sort Strategy}
    I -->|Files / Tables / KB / Scheduled| J[Client-side filter + sort over full local dataset]
    I -->|Logs| K[Client-side sort over currently loaded pages]
    I -->|KB Documents| L[Server-side sort + filter via API query params]
    I -->|Doc Chunks| M[Server-side sort + filter via API query params]

    J --> N[rows ResourceRow array]
    K --> N
    L --> N
    M --> N

    N --> O[Resource component renders list]
    O --> P[SortConfig to ResourceOptionsBar]
    O --> Q[filterContent JSX to Popover]
    O --> R[filterTags as chip row]
Loading

Reviews (6): Last reviewed commit: "pr fixes" | Re-trigger Greptile

…backs

Reading rules via ref instead of closure eliminates rules from useCallback
dependency arrays, keeping callbacks stable across rule edits and preserving
the memo() benefit on FilterRuleRow.
…width

- Remove non-TSDoc comment from table-filter (rulesRef pattern is self-evident)
- Simplify SearchSection: remove setState-during-render anti-pattern; controlled
  input binds directly to search.value/onChange (simpler and correct)
- Reduce KB filter popover from w-[320px] to w-[200px]; tag filter uses vertical
  layout so narrow width works; Status-only case is now appropriately compact
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Sort dropdown: name, documents, tokens, created, last updated — pre-sorted
externally before passing rows to Resource. Active sort highlights the Sort
button; clear resets to default (created desc).

Filter popover: filter by connector status (All / With connectors /
Without connectors). Active filter shown as a removable tag in the toolbar.
…e hook and use type guards for file filtering
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

Chunk sort was previously done client-side on a single page of
server-paginated data, which only reordered the current page.
Now sort params (sortBy, sortOrder) flow through the full stack:
types → service → API route → query hook → useDocumentChunks → document.tsx.
Resource is wrapped in React.memo, so an unstable filterContent reference
on every parent re-render defeats the memo. Wrap filterContent in useMemo
with correct deps in all 6 pages (files, tables, scheduled-tasks, knowledge,
base, document).
Every column visible in a resource table should be sortable. Three pages
had visible columns with no sort support:
- files.tsx: add 'owner' sort (member name lookup)
- scheduled-tasks.tsx: add 'schedule' sort (localeCompare on description)
- knowledge.tsx: add 'connectors' (count) and 'owner' (member name) sorts

Also add 'members' to processedKBs deps in knowledge.tsx since owner
sort now reads member names inside the memo.
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@waleedlatif1 waleedlatif1 merged commit b371364 into staging Mar 29, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the feat/table-filtering branch March 29, 2026 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant