ADR-015: Built-In Search/Filter Bar for List Views¶
Status: Accepted Date: 2026-08
Context¶
Every tree list view had no search or filtering affordance beyond whatever a module manually wired one-off. The ask: a search bar every list view gets automatically — the same "structural chrome the engine always provides" posture CreateBar and the List/Kanban/Calendar/Graph mode switcher already take — filtering entirely server-side, respecting field-level group gating (ADR-014), with a group-by section reflecting a field's actual distinct values, plus named filter combinations a user can save privately or share tenant-wide.
This also closes a gap ADR-014 deliberately deferred: filter[col]=/search[col]= were not group-aware, letting a caller lacking a field's group infer values from which rows matched.
Decision¶
Repository.checkColumncloses the group-gating gap, and every new filter kind below reuses this one function — gating a field viaWithFieldGroupsmakes it invisible to filtering/searching/grouping automatically, no separate opt-in.- Structured filters extend
ListFilterwith parallel maps, not a generic operator DSL:In map[string][]string(col::text = ANY($1)) andGT/GTE/LT/LTE map[string]string(range comparisons, type-aware cast tonumericortimestamptzviaFieldMeta.GoType— lexicographic::textcomparison would be wrong for numbers). A "between" is just aGTEplus anLTEon the same column. OR-composition andis_empty/is_setare explicitly out of scope for v1. - Group-by rides the existing list endpoint via
?distinct=<column>, not a new route — a literal new route would derive its own auto-permission no existing role has; folding it intoGET /api/v1/{table}?distinct=colreuses the already-grantedtable:table:readpermission and the samecheckColumngating.Repository.DistinctValuesreturns each value plus its row count in one query, capped at 500 distinct values. - Saved filters get a dedicated Go package (
internal/savedfilter), mirroringinternal/notebook— "private OR shared" visibility is an OR-composed WHERE the generic repository's AND-only chain can't express, and rename/delete need an owner check a bare column-whitelist handler doesn't do. Two hand-written partial unique indexes give private and shared names independent uniqueness scopes. - Per-module customization is a descriptor field, not a new registry:
ViewDescriptor.search?: SearchDescriptor(liveFields,filterableFields,groupableFields) is plain RSC-safe data, validated at registration. A module overriding another's search bar uses the existing view extensionsetDescriptorop, widened to includesearch. - The bar lives inside
TreeRenderer, in the same slot as the mode switcher, driving the sameliveRecordsstate Kanban/Calendar already share. Live-typing does up to 3 sequential debounced single-columnsearch[col]=calls (name, then id, then module-specified fields), merged client-side — every match is still a real server-computedILIKEresult.
Consequences¶
- The live-search leg costs up to 3 sequential round-trips per keystroke (debounced). If that proves laggy, the upgrade path is a real backend OR-search endpoint.
- Saved filters are owner-only to rename/delete, even when shared — no admin-override in v1.
SavedFilter.Configis opaque JSON the backend never validates semantically; the frontend re-validates against the live descriptor when a saved filter is applied, degrading gracefully if a field was since removed or regated.distinct=<column>sharestable:table:readrather than deriving its own permission.
Reference Implementation¶
core/orm/internal/crud/repository.go (checkColumn, filterConditions, DistinctValues), core/internal/savedfilter/, core/modules/savedfilter/, core-front/packages/core-front/src/ views/search-bar.tsx (SearchBar), views/descriptor.ts (SearchDescriptor).