feat(datagrid): apply filters individually (enable, disable, solo) (#1561)#1562
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f4785f30d7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| var appliedFilters: [TableFilter] { | ||
| guard let commit else { return [] } | ||
| return Self.resolve(commit, in: filters) |
There was a problem hiding this comment.
Preserve the applied filter snapshot until Apply
Because appliedFilters is now derived from the editable filters array, editing an already-applied row changes what the app considers applied before the user clicks Apply. For example, after applying name = 'Alice', changing the value to Bob without applying leaves the displayed query at Alice, but any later rebuild path that reads tab.filterState.appliedFilters (pagination/sort/refresh via rebuildTableQuery) will silently query Bob. The Apply button no longer represents the boundary between draft and applied filters, so keep a snapshot of applied values or otherwise separate draft edits from committed filters.
Useful? React with 👍 / 👎.
| FilterSettingsStorage.shared.saveLastFilters( | ||
| tab.filterState.appliedFilters, | ||
| tab.filterState.filters.filter(\.isValid), | ||
| for: tableName, |
There was a problem hiding this comment.
Keep disabled filters saved when switching tabs
This path saves all valid rows so disabled filters can be restored, but switching away from the tab still calls FilterSettingsStorage.saveLastFilters(tabManager.tabs[oldIndex].filterState.appliedFilters, ...) in MainContentCoordinator+TabSwitch.swift, which resolves .all to enabled filters only. In the common flow of disabling a valid row, clicking Apply, and then switching tabs, that tab-switch save overwrites the file written here and drops the disabled row before the table is reopened. Update the tab-switch persistence to use the same full valid filter list.
Useful? React with 👍 / 👎.
…-comments, cover solo edge cases)
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c53dd634a3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| state.commit = .solo(filter.id) | ||
| } | ||
| saveLastFiltersForActiveTable() |
There was a problem hiding this comment.
Preserve solo commits when saving last filters
When the last action is a per-row Apply, this saves through saveLastFiltersForActiveTable(), which persists tab.filterState.filters.filter(\.isValid) without the .solo(filter.id) commit. On a later table restore, restoreLastFilters rebuilds the state with commit = .all, so a table that was last queried by only one soloed row reopens/apply-rebuilds with every enabled valid row instead. Persist the commit separately or save a last-applied snapshot for solo restores while keeping the full draft panel rows elsewhere.
Useful? React with 👍 / 👎.
Closes #1561.
What this adds
Apply filters individually instead of all-or-nothing.
Cmd+Returnapplies all active filters.Refactor (no behavior regressions)
The model already carried
isEnabled; this surfaces it and cleans up the surrounding state model.TabFilterState.appliedFiltersis now a computed property derived fromfilters+ acommit: FilterCommit?(.all/.solo(id)). The two arrays can no longer drift apart, and every apply path goes throughcommitinstead of assigningappliedFiltersdirectly.Return.sqlDialect(for:) != nilinstead of matching the language display string.isSelectedfield andTabFilterState.hasChanges.Native macOS / HIG
Tests
TabFilterStateTestsfor thecommittoappliedFiltersderivation, solo behavior, and Codable round-trip.col = NULL); the correctIS NULLtest already exists.Deferred
TableFilterwith the iOS (TableProModels) copy is a separate cross-platform task; this PR is macOS-only and does not touch the iOS app.FilterValueTextFieldstays a customNSViewRepresentable: it bridges async, schema-aware autocomplete that native sync completion cannot provide.Verification
Build, filter test suites, and
swiftlint --stricton the changed files all pass.