Repository navigation
feat(datagrid): restore a table's saved filter without running it - #3026
Merged
Merged
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
This was referenced Sep 20, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3006
Reopening a table now brings its filter rows back without necessarily running them, and rows typed into the filter bar and never applied survive closing the tab.
Root cause
TabFilterState.commitwas answering three different questions with one bit:appliedFilters/hasAppliedFilters/executedFilters: query building, pagination, refresh, the status bar, tab reuse.persistedStateopened withguard commit != nil, andFilterSettingsStorage.saveLastFilterstreats an empty array as a delete. So a filter that was not running did not merely fail to save, it deleted the table's saved filter.resolvedRestoredStatesetcommit = .allunconditionally so the rows would show.Nothing in
TabFilterStateorPersistedFilterStatecould say "these rows exist and are not running", so the request was not expressible, and the same conflation was already producing four defects on its own.What changed
commitkeeps meaning (1) and only (1). Persistence and restore each get their own answer.PersistedFilterStatecarriesisApplied. A plain flag rather than theFilterCommit:persistedStatedrops invalid rows, and nothing clears a.solocommit whose row became invalid, so that id could reach disk pointing at a row no longer in the file and restore to nothing applied over a panel full of rows. An applied set restores as.allover the rows that survived, each keeping its own enabled flag. A file with no flag decodes as applied, which is what every file written so far means.persistedStatesaves the rows whether or not they are running. An empty row list still saves nothing, which the storage reads as a delete, and Remove All Filters is the gesture that produces one.resolvedRestoredStatenever fabricates a commit.FilterPanelDefaultStatesplit into the two axes it was conflating. Saved Filters (Restore and apply / Restore without applying / Don't save) decides what happens to the rows; Always Show Filter Bar decides whether the bar opens on a table that has no filter. Both stay in the filter bar's own popover: the HIG's Settings guidance names filtering a list as its example of an option that belongs in the screen it affects.FilterSettings.init(from:)rather than behind a one-shot UserDefaults flag. The flag version rewrote a storedalwaysHideonce and stranded anyone who set it again afterwards; that block is removed.Don't savestops reading and stops writing, and never deletes. Falling through to an empty write would delete the file, so the option could never be turned back on.Pre-existing defects fixed with it
Each one makes the new behaviour wrong or unsafe, so they could not be left for later.
A filter row typed and never applied already counted as applied.
resolvedRestoredStatesetcommit = .alleven when nothing was saved, so every table tab opened in that state. Typing a valid row then resolved throughappliedFiltersimmediately: the status bar read "1 filters applied", its icon filled, and the next page turn orCmd+Rran the filter, landing on an offset taken in the unfiltered set.Only the selected tab restored its filters.
applyRestoredGrouprestored fortabManager.selectedTabalone, andPersistedTabcarries no filter state, so every other restored table tab came back empty. The next tab switch then calledsaveLastFilterson it, which wrote an empty set over the filters on disk and deleted them. This is the reporter's own sentence, and it failed for every tab but one.Apply committed and wrote to disk before the unsaved-changes guard.
applyAllFilterssetcommitand persisted, and only then didonApplytake the guard. Cancelling left the filter marked applied and saved over rows it had never run.Clear deleted the table's saved rows. The one gesture that produces "rows kept, nothing running" was also the one that destroyed the saved state. It now saves them unapplied, which is the whole point of the issue.
Closing a tab never saved its filters.
closeTabsByUserremoves the tab before the selection moves, so the tab-switch save never sees it. An applied filter was written when it was applied; rows that were never applied had no save point at all, which is the reporter's second sentence.Restore never dropped a stale WHERE. A tab reopened from the recently closed history carries the last filtered SQL it ran in its persisted query. Bringing the filter back unapplied without rebuilding would keep running that WHERE while the panel reported nothing applied. Restore now rebuilds for the selected tab, and
prepareTableTabFirstLoadrebuilds unconditionally. Session restore was already safe, becausehandleRestoreOrDefaultrewrites every table tab's query to a base query first.A tab that is not selected gets its filter state and nothing else. Its schema columns are not loaded (
prepareTableTabFirstLoadgates that on selection) so a query built then would type its values by guessing at their text, andrebuildTableQuerywritesexecutedFilters, which foreign-key navigation trusts as the record of what the rows on screen were fetched with. That tab has no rows.Tests
103 cases pass across
FilterRestoreTests,FilterSettingsStorageTests,TabFilterStateTests,MainContentCoordinatorTabSwitchTestsand the newFilterPersistenceRoundTripTests.New coverage: each restore option end to end; a typed-and-never-applied row surviving a reopen; a background tab restoring its own filters; a closed tab saving the rows left in its bar; a stale WHERE dropped on an unapplied restore;
Don't saveleaving the file on disk; the legacypanelStatefile mapping onto both axes, read twice for idempotence; a filter file with noisAppliedkey decoding as applied.TableProUITests/FilterPersistenceUITestscovers the flow: apply a filter, press Clear, browse to another table and back, and the rows are in the bar with Clear dimmed. Clear is the observable state on both counts, since it exists only inside the filter bar and is enabled only while a filter is running. The Saved Filters picker itself is not driven from a UI test: reaching it means a menu and a popover, and the scrolling-menu click lands unreliably on the runner. Its three options are covered by unit tests overresolvedRestoredStateand by the round-trip suite.Two existing tests changed because the specification changed, not to match new output.
TabFilterStateTests.persistedStateIsEmptyWithNothingCommittedasserted that an unapplied set saves nothing, which is defect 2 above.MainContentCoordinatorTabSwitchTests.tabSwitchAfterClearKeepsSavedFiltersClearedasserted that Clear leaves nothing on disk, which is what this issue asks to change.Verification
verify.sh build: PASSverify.sh test(the five suites above): PASS, 103 executed, 103 passedbuild-for-testingoverTableProUITests: TEST BUILD SUCCEEDEDverify.sh lintover every changed Swift file: PASSdocs/scripts/check-writing-style.shandcheck-docs-against-source.py: both passReview
Codex was unavailable (the workspace is out of credits until 22 September), so the second-model pass was
Skill(code-review)at high effort. It raised five findings. Three are fixed here:FilterSettings.encode(to:)droppedpanelState, so a rollback to an older build would throwkeyNotFoundand reset Default Column and Default Operator along with the restore behaviour; the restore loop ran before the hidden-columns restore, inverting the previous order; and the loop's!content.query.isEmptygate left open the hole its own comment describes. It also caught thatrestoreFiltersForTable(_:)no longer used its parameter, nowrestoreFiltersForSelectedTab().Two were declined. Remove All Filters cannot delete while Saved Filters is Don't save, which is that option's contract and what its footer states: nothing is written in either direction, which is what makes turning it off reversible. Reaching through to delete a file the setting says is being left alone is the more surprising behaviour, so the doc comment was corrected instead. And
isAppliedfollowscommit, so Restore without applying leaves the flag false, which is what the flag means: whether the rows were running when they were saved. Pressing Apply setscommitand savestrue.It also caught a factual error in two comments:
handleRestoreOrDefaultrewrites every restored table tab's query to a base query, so the stale WHERE is the Reopen-Closed-Tab path and not session restore. Both are corrected.Not in this change
FilterSettingsPopoveris unreachable on a browse-search connection, which swaps inKeyPatternSearchBarinstead, andBrowseSearchStatehas no draft-versus-applied distinction: its pattern is the query.CatalogEditAdoptionhas no hook intoTableScopedSettingsRegistryfor a drop. Reported separately.