Skip to content

Replace the JSON query editor with a structured filter builder (#1920) - #2000

Merged
mstomar125 merged 2 commits into
mainfrom
issue-1920-filter-builder
Aug 7, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
issue-1920-filter-builder

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Closes #1920. Builds on #1919 (default-query model).

Replaces the raw-JSON Edit Query textarea with a structured filter builder driven by the target type's schema.

What

  • Filter rows: Property (select over the schema's fields — no free-typed names) · Operator (narrowed to the field's type) · Value (typed control: enum select with labels, number, boolean, or text; exists = no value, in = comma-separated list).
  • targetType inherited — a read-only chip, never an input (can't create a type/column mismatch).
  • Results stay visible while the builder is open.
  • Preview count fixed — handleQueryPreview now applies the definition's filters via executeQueryDefinition instead of reporting the whole-type count.
  • Pure logic in a new query-editor-model.ts, 24 unit tests.

Live-validated

Ran the app here (isolated daemon → dev-proxy → vite → Chromium): the builder renders on the Task view, the status enum populates (Open/In Progress/Done/Cancelled), Preview reports a filtered count — zero console errors.

Adversarial review → addressed

An independent review found real defects, all fixed in the follow-up commit:

  • [data-loss] content/relationship/metadata filters (and property filters on now-missing fields) were dropped on save → partitionFilters splits editable rows from preserved pass-through filters, re-emitted on save; UI notes how many advanced filters are kept-but-not-editable.
  • [ux] boolean filter showed "true" yet saved "needs a value" → boolean rows seed to a concrete true.
  • [type-safety] NaN savable in a number in-list → rejected in buildDefinition.
  • stored operator invalid for a field's type → coerced to the first allowed on seed.

svelte-check + eslint clean; pre-push gate (test:all + build + e2e) passed.

mstomar125 and others added 2 commits August 7, 2026 11:12
The "Edit Query" panel was a raw JSON textarea. Replace it with a structured
builder driven by the target type's schema:

- Filter rows: Property (select over the schema's fields — no free-typed names),
  Operator (narrowed to the field's type), Value (typed control — enum select
  with labels, number input, boolean select, or text; `exists` takes no value,
  `in` accepts a comma-separated list).
- targetType is inherited from the view and shown as a read-only chip, never an
  input — a saved query can no longer target a type its columns don't match.
- Results stay visible while the builder is open (the editor already renders
  above the result view).
- Fix the preview count: `handleQueryPreview` now applies the definition's
  filters client-side via `executeQueryDefinition` instead of reporting the
  whole-type count regardless of filters.

The pure logic (operator narrowing, value coercion, row seeding, definition
building) lives in a new `query-editor-model.ts` and is unit-tested directly
(18 tests). Validated live against the running app: the builder renders on the
Task view, the status enum populates (Open/In Progress/Done/Cancelled), and
Preview reports a filtered count. svelte-check + eslint clean.

Co-Authored-By: Claude <[email protected]>
…1920)

Adversarial review of the filter builder found real defects:

- [data-loss] Content/relationship/metadata filters (and property filters on
  fields the schema no longer declares) were silently dropped on save, since
  only property filters became editable rows and save overwrote the filter list
  wholesale. `partitionFilters` now splits a definition into editable rows and
  `preserved` pass-through filters; `buildDefinition` re-emits the preserved
  ones ahead of the edited rows, and the UI notes how many advanced filters are
  kept-but-not-editable.
- [ux] A boolean filter rendered "true" (first select option) while its value
  stayed empty, so Save wrongly reported "needs a value". Boolean rows now seed
  to a concrete `true`.
- [type-safety] A number `in`-list accepted non-numeric text and saved `NaN`;
  buildDefinition now rejects any NaN on a number field.
- A stored operator invalid for its field's type is coerced to the first allowed
  operator when seeding, so the control can't show one value while holding
  another.

Tests extended to 24 (partition/preserve, boolean seed, NaN rejection, operator
coercion). svelte-check + eslint clean.

Co-Authored-By: Claude <[email protected]>
@mstomar125

Copy link
Copy Markdown
Contributor Author

Adversarial review → addressed → APPROVE. Independent review flagged a data-loss bug (non-property filters wiped on save), a save-blocking boolean UX defect, and a NaN type-safety gap — all fixed in the follow-up commit (partition/preserve pass-through filters, boolean seeds to true, NaN rejected, invalid stored operators coerced). 24 model unit tests, svelte-check + eslint clean, live-validated against the running app, gate green. APPROVE.

@mstomar125
mstomar125 merged commit f2e8bc1 into main Aug 7, 2026
@mstomar125
mstomar125 deleted the issue-1920-filter-builder branch August 7, 2026 09:24
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.

Replace the JSON query editor with a structured filter builder

1 participant