Repository navigation
Classify node types by frontend integration, not core-list membership (closes #1998) - #2013
Conversation
Review Addressed — commit
|
…closes #1998) isCustomSchemaType(nodeType) was defined as !CORE_NODE_TYPES.has(nodeType) but every call site used it to ask a different question: "does this type have a dedicated frontend integration, or does it need the generic schema-driven fallback?" Those coincided until `project` was added as a core type with no frontend plugin registration, and they were already wrong in the other direction for `person`, `document`, `user` and `ai-chat` — registered plugins that the core list never contained. Replace the list-membership proxy with predicates that ask the plugin registry, so they stay correct as types are registered at runtime: - `hasInlineNodeComponent` / `rendersAsEntityRow` — does a plugin register an inline node component? Types without one render read-only via the BaseNode fallback, so they get the open-in-other-pane button, are skipped by arrow navigation, and open directly rather than resolving to a parent viewer. - `needsGenericSchemaForm` — no hardcoded schema form registered. Call sites audited individually rather than given one shared replacement: - schema-form-loader: the generic-schema fetch is now unconditional inside the no-hardcoded-form branch — reaching it already establishes the only condition the fallback depends on. This was the blocking gate; fixing the render gate alone would not have populated a schema for `project`. - base-node-viewer render gate: drops the redundant type check — genericSchema is only populated by the loader's no-hardcoded-form path, so a type with no schema still renders no panel. - base-node-viewer arrow-nav + slash-command paths: `rendersAsEntityRow`. - node-row open button, navigation-service routing: `rendersAsEntityRow`. - navigation-service display name: ungated — getPlugin is already self-limiting and a registered core type's display name is as good a title here. Also fixes two bugs this exposed: - The loader cached "no type-specific form" per type and returned early, so revisiting such a node after resetGenericSchema() left the panel empty. - GenericSchemaForm read only flat properties, but core types with backend behavior nest schema fields under properties[nodeType] (properties.project.*). Reads now mirror the backend's nested-first, flat-fallback order; writes stay flat since NodeService hoists schema-defined fields on write. CORE_NODE_TYPES and isCustomSchemaType are deleted — with every call site migrated, their only remaining consumer was their own test, which is exactly the stale abstraction that caused this bug. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The reviewer was right and my justifying comment was wrong. I verified both
halves against the Rust source:
- `normalize_flat_properties_to_namespace` (crud.rs:1715-1720) returns early
when `properties[nodeType]` is already an object — and the form's spread
`{...node.properties, [field]: value}` always includes that namespace, so the
new flat key was never hoisted.
- `flatten_properties_for_api` (convert.rs:76-86) returns only the namespace
contents when that key holds an object, so the stranded top-level key is
dropped on read.
Reproduced live against the daemon. The old payload produced exactly the
predicted state — `{"project":{"status":"active"},"status":"completed"}` — with
the edit stranded top-level and the namespace unchanged. The namespaced payload
round-trips correctly.
Writes now go through `buildFieldWrite`, which mirrors `resolveFieldValue`'s
precedence (same approach as task-schema-form.svelte:210-225). Corrected the
comments that asserted backend hoisting. Added 6 write-path tests, including a
round-trip assertion in both shapes — the coverage gap that let this through.
Confirmed real and intended. PersonNode wraps BaseNode with an editable content
area, so `/person` is typed into in place; the old pane-navigation was a side
effect of the same conflated predicate, and handleCustomEntitySlashCommand's own
doc says it is for entities that are "read-only inline". Documented at the call
site and pinned the full classification of all 18 registered types in a test, so
any future registration that flips one has to update it knowingly.
Added a per-type schema cache including negative entries, so schema-less
structural types cost one round trip per session rather than one per navigation,
and demoted the expected-failure log from warn to debug.
- #6 null/undefined sentinel nit — pre-existing, `fieldStats` handles both, and
normalizing means touching every field binding for no behavior change.
- #5 was confirmatory (the changed 'task Node' → 'Task Node' expectations are a
genuine improvement, not a masked regression); no action needed.
Tests: 4464 passing (+8). quality:fix clean.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
getEnumValues moved from GenericSchemaForm into SchemaFieldLeaf on main, so the EnumValue type import this branch carried no longer has a use here. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
5b4840e to
f17967e
Compare
|
Rebased onto current main ( Four conflicts, all in import blocks, from #2011 (the #2005 fix) landing Two things needed a real decision rather than a mechanical resolution:
Verification: full frontend suite green (212 files / 4683 tests), Note |
Pragmatic Code Review — PR #2013Review Type: Initial Review SummaryThis is a genuinely good change and a net positive. It replaces a hand-maintained The PR's headline claims were verified against the code rather than taken on trust, including reading the Rust write path end to end. Two hold up; the third is right in its conclusion but wrong in its stated reason — see Finding 2.
The rebase was also clean: Requirements Check
Findings🟡 Important 1 — Removing the type gate on the tab-title fallback regresses titles for core types📁 The old code consulted So an untitled text node's tab now reads "Text Node" instead of "text Node". The PR's own test churn is the tell: The justification in the comment — "a registered core type's display name is as good a title here as a user-defined one's" — is the part to push back on. It is not equivalent: user-defined plugin names are entity nouns chosen by the user; core plugin names are registry labels with "Node" baked in, which is why you get the stutter. This is also unrelated to #1998: Recommendation: revert this hunk, or re-gate it so it applies to entity-style types only: if (rendersAsEntityRow(node.nodeType)) {
const plugin = pluginRegistry.getPlugin(node.nodeType);
if (plugin?.name) return plugin.name;
}Engineering principle: Minimize blast radius — a refactor should not silently change user-visible behavior outside its stated scope. When a test assertion must be edited to accommodate a refactor, that is a signal to re-examine whether the change was intended. 🟡 Important 2 — The doc comment's causal explanation is wrong; the spread it describes is the actual constraint📁 The comment asserts:
The early return is real ( The predicted breakage only occurs because So the code is correct as written, but self-consistently: the namespaced branch is required because of the spread, not because namespaced nodes reject flat writes. Someone "simplifying" the spread away would find the branch inexplicable — and someone trusting the comment would protect the wrong invariant. Two related premises in the same block are also inaccurate:
Recommendation: keep the behavior; fix the explanation. Either (a) drop the spread and send only the changed field, deleting both branches — cleanest, and removes the shadowing hazard at its source; or (b) keep the spread and correct the comment to say the payload spread is what necessitates re-nesting. Also correct the "user-defined types are flat" premise. Engineering principle: Comments must explain the real "why". A comment that misattributes a constraint to a remote component is worse than none — it obstructs the next person's reasoning. 🟡 Important 3 —
|
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: COMMENT — approve-in-principle. Full findings in the review comment above. Findings 1 (tab-title regression) and 3 (fire-and-forget schema load) to address before merge; Finding 2 is a doc-comment correction.
Finding 1 (Important) — the plugin-name tab-title fallback was ungated, so every registered core type fell back to its plugin `name`. Those are registry labels rather than user-facing nouns, making an untitled text node's tab read "Text Node". Re-gated to entity rows, where plugin names are entity nouns worth showing. The two navigation-service assertions changed to 'Task Node' were reverted to 'task Node' — they had been updated to accommodate the regression, not because the prior behavior was wrong. This branch never affected `project` anyway, which registers no plugin. Finding 3 (Important) — loadGenericSchema is invoked unawaited and wrote genericSchema with no check that the viewer was still on that type. This PR runs it for every type lacking a hardcoded form rather than only UUID types, so a navigate-during-fetch could publish the previous node's schema; because hasTitleTemplate derives from it, that could leave the wrong page's header read-only. Added a pendingType recency check around the assignment. The cache write stays outside the guard — a fetched schema is valid for its own type regardless of later navigation. Finding 2 (Important, docs only) — the code was correct but the comment misattributed why. The backend's normalize step early-returns on the *payload*, not the stored node, so a bare flat write into a namespaced node merges fine; it is buildFieldWrite's spread of existing properties that reintroduces the namespace key and shadows the edit. Also corrected the claim that user-defined types store fields flat — create_node namespaces every type except `schema` — and noted `person` reads nested-only, unlike project/task. Suggestion 5 — documented that schemaCache is per-loader-instance, which is what makes negative caching safe; hoisting it to a module singleton would be a behavior change rather than an optimization. Skipped: - Suggestion 4 (drop hasInlineNodeComponent): the review itself notes it earns its place as the positive framing that makes rendersAsEntityRow readable. Removing a tested, coherent export is churn. - Suggestion 6 (stale top-level sibling cleanup): flagged in the review as follow-up issue material, not this PR. Touching the write path here would widen scope well past #1998. - Finding 2 option (a) (drop the spread, delete both branches): cleaner, but a live behavior change to the write path justified only by reasoning about Rust merge semantics. Not the right risk for a review-response commit on an otherwise-ready PR; worth revisiting with a test that exercises the partial payload directly. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review addressed —
|
Finding 4 (Important, new) — the pendingType guard added in the previous commit only covered navigations that themselves trigger a generic-schema fetch. `loadForm` skips `loadGenericSchema` entirely for types that ship a hardcoded form (task, person), so navigating project -> task left the token naming `project`; a late-resolving project fetch then passed the recency check and published. The properties panel is shielded by the typed-form branch winning in the viewer, but hasTitleTemplate is not — it drives the header's readonly state, which is precisely what the original finding was raised to prevent. Inert today only because no core type ships a title_template, an assumption this file already documents as temporary. Cleared pendingType in resetGenericSchema instead, which is the actual navigation boundary: the token now tracks where the viewer is rather than what was last fetched. Also moved its declaration up with the other fields, where it was orphaned between methods. Added two regression tests using deferred per-type promises. Verified they pin the behavior rather than merely passing: with the fix reverted, the hardcoded-form case fails and the generic-to-generic case still passes, confirming the second was already covered and the first is what was missing. Not taken, from the same re-review (both nits, neither blocking): - The re-gate comment says plugin names are "entity nouns worth showing"; for `collection`/`user`/`document` the labels are "Collection Node"/"User Reference"/"Document Reference", so the claim is broader than the set it admits. The gate is still a strict improvement and a no-op for `project`; rewording invites re-litigating naming that predates this PR. - create_node's namespacing exception list is wider than `schema` alone — `task` branches earlier and stores verbatim if its schema fetch fails, and database-settings returns before normalization. Worth documenting, but it belongs with the stale-sibling cleanup issue rather than expanding a comment this PR only touched to correct a causal claim. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Pragmatic Code Review — PR #2013Review Type: Re-Review Previous Review Summary
All three 🟡 Important findings were addressed, and the two skips are well-reasoned — I agree with both and am not re-raising them. Finding 2 option (a) deferral is also the right call: verification below found the write path has more edge cases than either review knew, which vindicates not touching it in a review-response commit. Each claim was verified independently rather than accepted from the response summary, including reading the Rust source end to end. Findings 1 and 2 are fully and correctly resolved. Finding 3's guard is real but has a hole the response did not consider. Requirements Check (delta impact only)
No criterion regressed. Criteria 6 and 7 moved from Findings✅ Finding 1 — tab-title regression: correctly fixed📁 Checked the gate against every registered plugin rather than trusting the reasoning:
The gate now excludes all 12 inline types, including One honest caveat, not a blocker: the gate's stated rationale — "plugin names are entity nouns worth showing as a title" — is only half-true for the set it admits. 🟡 Important 4 (NEW) — the
|
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review (re-review of aa53c485): COMMENT — approve-in-principle. Findings 1 and 2 verified as correctly resolved; one new Important finding (stale recency token on the hardcoded-form navigation path) has since been fixed in c9322894.
Re-review addressed —
|
Post-review step 4 tagged HEAD "for future delta reviews". Nothing consumed those tags: the command's own Review Mode Selection derives the re-review baseline from `gh pr view --json reviews,comments`, which is how the PR #2013 re-review established its base range without one. They were not inert. A tag is a strong ref, so each pinned a pre-squash branch commit that would otherwise be collectable once its branch was deleted, under a bare-timestamp name carrying no PR, issue, or branch. Removed at the source rather than instructing agents to skip it, so the three sibling dev clones inherit the fix on pull. Also pruned the accumulated tags (43 local / 32 remote review-*, plus pr-634-reviewed-*) after confirming each was safe: 36 mapped to merged PRs via the GitHub commits/pulls API, and the rest had lost their PR association only because their branches were deleted. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Summary
isCustomSchemaType(nodeType)was defined as!CORE_NODE_TYPES.has(nodeType), but every call site used it to ask a different question: does this type have a dedicated frontend integration, or does it need the generic schema-driven fallback? Those two questions coincided untilprojectwas added as a core type with no frontend plugin registration.While auditing, I found the predicate was already wrong in the other direction:
person,document,userandai-chatare registered plugins that the core list never contained, so they were being classified as custom schema types. And there were 7 call sites, not the 4 the issue lists —base-node-viewer.svelte:796, 1197, 1221(arrow navigation and two slash-command paths) were also affected.Approach
Replaced the list-membership proxy with predicates that ask the plugin registry, so they stay correct as types register at runtime:
hasInlineNodeComponent/rendersAsEntityRow— does a plugin register an inline node component? Types without one render read-only via the BaseNode fallback, so they get the open-in-other-pane button, are skipped by arrow navigation, and open directly rather than resolving to a parent viewer.needsGenericSchemaForm— no hardcoded schema form registered.Each call site was audited individually rather than given one shared replacement:
schema-form-loader.svelte.ts:62project.base-node-viewer.svelte:1348genericSchemais only populated by the loader's no-hardcoded-form path, so a type with no schema still renders no panel.base-node-viewer.svelte:796, 1197, 1221rendersAsEntityRownode-row.svelte:164rendersAsEntityRownavigation-service.ts:172rendersAsEntityRownavigation-service.ts:140getPluginis already self-limiting, and a registered core type's display name is as good a title here.Two additional bugs this exposed
loadFormcached "no type-specific form" per type and returned early, so afterresetGenericSchema()on navigation, revisiting such a node left the properties panel empty.GenericSchemaFormread only flat properties. Core types with backend behavior nest schema fields underproperties[nodeType]— verified live: aprojectnode storesproperties.project.{status, priority, start_date}. The form would have rendered with empty controls. Reads now mirror the backend's nested-first, flat-fallback order (extracted toschema-field-resolution.tsso it is unit-testable); writes stay flat since NodeService hoists schema-defined fields on write.Deletion
CORE_NODE_TYPESandisCustomSchemaTypeare removed. The issue listed keepingCORE_NODE_TYPESas a non-goal, but with every call site migrated its only remaining consumer was its own test — exactly the stale abstraction that caused this bug. Flagging it explicitly since it departs from the stated scope.Verification
Ran the app and opened a
projectnode withstatus: active, priority: high, start_date: 2026-03-01:end_datecorrectly showing "Pick a date"The generic-form edit path (PATCH) was verified directly against the API and persists correctly to
properties.project.status. One caveat: I could not complete the click-to-edit round trip in the UI, because the test node was created via a raw API call and so was absent from the store'spersistedNodeIds, making the store route the edit as an insert (500 duplicate key); the daemon then became unresponsive under LLM model loading before I could redo it via a store-hydrated path. The code path itself is unchanged by this PR and is covered by the PATCH verification above.Tests: 4456 frontend + 24 browser + full Rust suite pass (baseline 4439; +17 new).
bun run quality:fixclean.🤖 Generated with Claude Code