Skip to content

Separate the default type view from persisted query nodes (closes #1919) - #1986

Merged
mstomar125 merged 2 commits into
mainfrom
issue-1919-default-query-view
Aug 7, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
issue-1919-default-query-view

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Summary

QueryNodeViewer now serves two shapes from one component, branching on the loaded node (not the tab's decorative nodeType flag):

  • schema node → DEFAULT type view — all nodes of the type, unfiltered, nothing persisted. The first divergence (filter edit, view / group-by change, or title rename) materializes a real nodeType:'query' node (targetType inherited from the schema, generatedBy:'user') and re-routes the tab to it via the existing onNodeIdChange → updateTabContent → {#key} remount, so subsequent edits persist.
  • query node → SAVED query — reads the stored QueryDefinition + view config off the node and executes the filters. queryNodes only filters by nodeType, so filter → sort → limit run client-side in the new query-node-model helpers.

Plus: stop writing query defs onto schema nodes; in-place editable titles ("Default" / "Untitled Query") with the tab title reflecting the query name; view config (last view + Kanban group-by) moved off localStorage onto properties.viewConfig (QueryPreferencesService deleted — this was its only consumer); /query slash command disabled (plugin keeps node/viewer/reference).

No backend changes — QueryNodeBehavior stores arbitrary properties.

Review findings — all addressed

An adversarial pragmatic-code-review (posted on #1919) returned REQUEST CHANGES with 4 real 🟡s, all fixed in the follow-up commit:

  • F1 — saved/default fetch now passes an explicit FETCH_LIMIT=1000 (was relying on the daemon's 100 default), and shows a visible caveat when the set is capped, so filtering no longer silently under-returns.
  • F2 — parent/children relationship filters can't be evaluated from a single node → a visible caveat ("results may be broader than the saved query") instead of silently widening. New unevaluableFilters helper (+3 tests).
  • F3 — materialize re-routes even if the post-create getNode momentarily returns null (avoids an orphan + a duplicate on the next divergence).
  • F4 — Escape during a title edit no longer commits the discarded draft (cancel guard vs the input's blur).
  • F7 (🟢) — empty state reads "No results match this query." on a saved query vs "No nodes of this type yet." on the default.

⚠️ Not runtime-verified

Implemented + reviewed headless; not run in a live app. The reviewer recommends a manual smoke test before merge: materialize-from-view-change, Escape-during-rename, and a saved query over a >100-instance type. Side-nav nesting of saved queries is a deliberate follow-up (TODO in navigation-sidebar).

Testing

query-node-model 28 unit tests; full frontend suite 184 files / 4349 tests green; quality:fix clean (0/0); full pre-push gate (test:all + cargo build + Tauri-seam e2e) green.

🤖 Generated with Claude Code

mstomar125 and others added 2 commits August 6, 2026 16:07
QueryNodeViewer now serves two shapes from one component, branching on the
node it is handed rather than the tab's decorative nodeType flag:

- schema node → DEFAULT type view: all nodes of the type, unfiltered, nothing
  persisted. The first divergence — a filter edit, a view/group-by change, or a
  title rename — MATERIALIZES a real nodeType:'query' node (targetType inherited
  from the schema, generatedBy:'user') and re-routes the tab to it (via the
  existing onNodeIdChange → updateTabContent → {#key} remount), so subsequent
  edits persist.
- query node → SAVED query: reads the stored QueryDefinition + view config off
  the node and executes the filters. queryNodes only filters by nodeType, so the
  definition (filters → sort → limit) is executed client-side in the new
  query-node-model helpers.

Also:
- Stop writing query definitions onto schema nodes; drop the schema-node read.
- Titles follow the BaseNodeViewer pattern: "Default" for the type view,
  "Untitled Query" for a fresh materialized query, both editable in place; the
  tab title reflects the query node's content.
- View config (last view + Kanban group-by) now lives on the query node's
  properties.viewConfig instead of localStorage. KanbanView takes groupBy +
  onGroupByChange (viewer-owned) instead of QueryPreferencesService, which is
  deleted along with its type and test (its only consumer was this path).
- Disable the /query slash command (queryNodePlugin keeps its node, viewer, and
  reference registrations) — it produced definition-less, non-rendering nodes.

Side-nav nesting of saved queries under their type is left as a follow-up
(TODO in navigation-sidebar). query-node-model has 25 unit tests. No backend
changes (QueryNodeBehavior stores arbitrary properties).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Addresses the pragmatic-code-review findings on #1919:

- 🟡 F1: saved/default fetch now passes an explicit limit (FETCH_LIMIT=1000)
  instead of relying on the daemon's 100-node default, so client-side filtering
  runs over a realistic candidate set; when the set is capped, a visible caveat
  says so rather than silently under-returning.
- 🟡 F2: parent/children relationship filters can't be evaluated from a single
  node, so a saved query with them now shows a visible caveat that results may be
  broader than the definition, instead of silently widening. New
  `unevaluableFilters` helper (+3 unit tests).
- 🟡 F3: materialize re-routes the tab even if the post-create getNode momentarily
  returns null — the node exists, so we avoid an orphan + a duplicate on the next
  divergence.
- 🟡 F4: Escape during a title edit sets a cancel guard so the input's
  blur-triggered commit no longer renames/materializes with the discarded draft.
- 🟢 F7: empty state now reads "No results match this query." on a saved query
  vs "No nodes of this type yet." on the default view.

Left as noted minors (store surfaces them / low-impact): rapid saved-view toggles
racing on one version (F5, store OCC handles), a dropped second divergence keeping
its in-memory view (F6), and no-op Edit→Save still materializing (F8).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

Copy link
Copy Markdown
Contributor Author

Pragmatic code review — RE-REVIEW — issue #1919 "Separate the default type view from persisted query nodes"

Review Type: Re-Review · Previously reviewed: 44ccd3d9 · Fix commit: 25fb95c7 (git diff 44ccd3d9..HEAD = 3 files, +121/−7) · Build reported green (query-node-model 28 tests incl. 3 new; suite 184/4349; quality:fix 0/0). Delta only re-reviewed; helpers + viewer re-read in full for context.

Previous Review Summary

  • Findings: 8 (F1–F4 🟡, F5–F8 🟢) → verdict was REQUEST CHANGES, gated on F1–F4.
  • Addressed in this commit: 5 (F1, F2, F3, F4, F7).
  • Consciously deferred (documented in commit): 3 (F5, F6, F8 — all 🟢 polish).

Per-finding verdict

✅ F1 — Saved/default fetch capped at 100 → silent under-return — Resolved (scoped, made honest)

📁 packages/desktop-app/src/lib/components/viewers/query-node-viewer.svelte:58, 210, 235, 238
Both branches now pass limit: FETCH_LIMIT (1000). Verified end-to-end: NodeQuery.limit is typed (adapter-core.ts:75), the Tauri adapter forwards query to query_nodes_simple, the daemon maps a non-zero limit to Some(1000) (node_service.rs:511), and core only substitutes DEFAULT_QUERY_LIMIT=100 when limit.is_none() (query.rs:299) with no upper clamp — so 1000 is honored, not re-capped. fetchCapped is set on both branches and reset at the top of loadAndQuery (:186). The caveat "showing the first 1000 nodes of this type" (:149) renders on queryState === 'success' (:614). 1000 is a reasonable bound for realistic type sizes, and server-side filtering is explicitly out of scope for this issue. The honest caveat is exactly the "make the cap visible rather than silent" resolution the initial review allowed.
Minor (non-blocking): fetchCapped = nodes.length >= FETCH_LIMIT is a false-positive at exactly 1000 matching nodes (warns "capped" when nothing was truncated). Conservative/harmless.

✅ F2 — parent/children filters silently widen — Resolved (visible caveat, pass-through preserved)

📁 packages/desktop-app/src/lib/components/query/query-node-model.ts:240 · viewer:147-156
New unevaluableFilters flags exactly the un-evaluable set — type==='relationship' with relationshipType parent/children — matching matchesFilter's pass-through branch (model:196). The caveat is gated on mode === 'saved' && unevaluableFilters(...).length > 0, so the default view (empty filters) never triggers it, and it only appears when such filters exist. Pass-through is unchanged, so results are still returned (not emptied). operator and relationshipType are typed unions, so the "unknown operator" leg is unreachable via the type system. 3 focused unit tests cover flag/no-flag/empty. This is the "surface it, don't silently drop" resolution requested.
Minor (non-blocking, pre-existing-shaped): relationshipType is optional in QueryFilter; a malformed relationship filter with relationshipType absent still passes through matchesFilter's default leg but is not flagged by unevaluableFilters (which checks only parent/children). Only reachable via an unvalidated cast in parseQueryDefinition; realistic AI-emitted filters use the four named types. Not worth blocking.

✅ F3 — createNode ok but getNode null → orphan + duplicate — Resolved

📁 packages/desktop-app/src/lib/components/viewers/query-node-viewer.svelte:333-344
The null-created early-return is gone; only the epoch guard remains (ADR-053 correct). Store seeding is now conditional (if (created)), but rerouteTab(newId) always fires after a successful create. The remount's loadAndQuery(newId) re-fetches the node (which does exist), resolveViewerMode returns 'saved', and the tab lands in saved mode — so the next divergence updates rather than materializing a second node. Orphan + duplicate both prevented. (Residual only in the pathological double-null case, where a second getNode also returns null → schema-not-found empty state; acceptable, and strictly better than the previous silent no-op.)

✅ F4 — Escape during title edit still commits/materializes — Resolved (robust)

📁 packages/desktop-app/src/lib/components/viewers/query-node-viewer.svelte:114, 446, 450-457, 490
Escape sets titleEditCancelled = true before flipping isEditingTitle; commitTitle early-returns (resetting the flag) when the blur-teardown fires it. Verified no leak paths: Enter goes through .blur() with the flag false (still commits); startEditTitle resets the flag on every re-open; and the flag is also cleared inside the cancel branch. If the teardown blur never fires in some browser, commitTitle simply isn't called (still a clean cancel) and the next startEditTitle resets state. Solid.

✅ F7 — Empty-state copy — Resolved

📁 packages/desktop-app/src/lib/components/viewers/query-node-viewer.svelte:644
Now branches on mode: "No results match this query." (saved) vs "No nodes of this type yet." (default) — also the honest message for targetType:'*'. The nav-reachability half of F7 remains a deliberate TODO (unchanged), consistent with the initial review's "fine to defer".

⏸ F5 / F6 / F8 — Consciously deferred (acceptable)

The commit message explicitly records these as left minors: F5 (rapid saved-view toggles racing one version — store OCC surfaces it), F6 (dropped 2nd divergence keeps its in-memory view), F8 (no-op Edit→Save still materializes). All three were 🟢 polish and don't gate the feature. Deferral is documented and reasonable.


New issues introduced by the delta

None blocking. Observations:

  • executionCaveat reactivity — clean. The $derived.by reads fetchCapped, mode, and currentDefinition.filters (itself a $derived over queryNode) — all reactive, so the caveat updates correctly on load/re-execute.
  • Default fetch → 1000 interacts with Kanban's unbounded rendering. List/Table paginate at PAGE_SIZE=25, but Kanban renders every result node, so a 1000-node type could mount ~1000 cards. This is the exact concern already tracked in Kanban view: bound large boards (pagination/virtualization) + browser DnD tests #1985 (bound large boards). Cross-referenced, not a regression to fix here.
  • No type errors in the delta: limit is typed on NodeQuery, unevaluableFilters is typed, tests import it cleanly.

Recommendation: APPROVE

All four blocking findings (F1–F4) from the initial REQUEST CHANGES are resolved correctly and adversarially verified; F7 is fixed; F5/F6/F8 are documented deferrals of 🟢 polish. The two residual minors (exact-boundary fetchCapped false-positive; unflagged relationship filter with an absent relationshipType) are non-blocking and can be follow-ups if desired. A live run exercising materialize-from-view-change, Escape-during-rename, and a saved query over a >1000-instance type is still worth doing before/after merge, since these paths aren't covered by svelte-check or the unit suite.

@mstomar125 mstomar125 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Automated pragmatic-code-review (re-review): APPROVE (posted as comment — GitHub blocks self-approval). Findings above.

@mstomar125

Copy link
Copy Markdown
Contributor Author

Status: ready, holding for a live smoke test before merge.

Gate-green, reviewed twice (adversarial REQUEST CHANGES → all 4 🟡 fixed → re-review APPROVE), 28 model unit tests, quality:fix clean. The one gap both reviews flagged is that this behavioral change was not run in a live app. Deliberately holding the merge for a manual pass over:

  • default view → change the view (List/Kanban) → confirm a query node materializes and the tab re-points + title updates;
  • Escape while renaming the title → confirms it does NOT rename/materialize with the discarded draft;
  • open a saved query over a type with >1000 instances → confirms the "showing the first 1000…" caveat appears.

Not merging until that pass is done. Branch/worktree preserved.

@mstomar125
mstomar125 merged commit 19e0435 into main Aug 7, 2026
2 checks passed
@mstomar125
mstomar125 deleted the issue-1919-default-query-view branch August 7, 2026 06:53
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