Skip to content

Implement List and Kanban views for QueryNodeViewer (closes #1921) - #1984

Merged
mstomar125 merged 2 commits into
mainfrom
issue-1921-list-kanban-views
Aug 6, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
issue-1921-list-kanban-views

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Summary

QueryNodeViewer rendered three view tabs (List / Table / Kanban) but only Table worked — List and Kanban switched the tab and showed a "coming soon" placeholder. This implements both, plus the enum group-by picker and drag-to-change-value that Kanban needs.

Changes

  • list-view.svelte (new) — one row per result showing the node title (title_template → content → "Untitled"), reads each node from sharedNodeStore for cross-pane reactivity, paginated at PAGE_SIZE = 25 like TableView, row click opens the node via the existing onRowClick.
  • kanban-view.svelte (new) — groups results into columns by a selected enum field (enum-only: its coreValues/userValues give both the column set and the display labels). Cards show titles and read from the store so they move reactively; a null/unrecognized value lands in an "Unassigned" column. Move a card by drag or via the per-card keyboard-accessible "Move to" <select>; dropping into the same column is a no-op; the optimistic store write rolls the card back on a rejected persist. Explanatory empty state when the schema has no enum field.
  • kanban-grouping.ts (new) — pure, DOM-free helpers: eligible-field detection, enum columns, group-value read (mirrors table-row's camelCase→snake→properties resolution), write-shape (writes back to where the value reads from — properties[field] for the common user-defined-schema case, matching generic-schema-form), and column bucketing. 16 unit tests.
  • query-node-viewer.svelte — render List/Kanban/Table by activeView; delete the viewComingSoon state, the coming-soon branch, and its now-dead CSS.

Group-by selection and last view persist per query node via QueryPreferencesService and restore on reopen.

Acceptance criteria — all met

List (row-per-title, opens node, cross-pane reactive) · Kanban (columns per enum value, titled cards open node, Unassigned bucket) · group-by picker (eligible fields, persists per query node) · reopen restores view + group-by · empty state when no enum field · drag updates + persists the value · card reflects new column after store update · same-column drop = no write · failed update returns the card (store rollback) + surfaces error · coming-soon/viewComingSoon deleted · keyboard-accessible move alternative.

Note for review

Enum fields on user-defined schema types (the common Kanban case) write to properties[field] — validated against generic-schema-form's write path. Core namespaced typed fields (e.g. task.status under the task namespace) mirror their read location; that path is worth an on-device confirm for a core type. Card movement is consistent for all types because the write targets the same place the value is read from.

Testing

New helper suite green (16/16). Full frontend suite green (184 files / 4342 tests, +16). quality:fix clean (0/0). Full pre-push gate (test:all + cargo build + Tauri-seam e2e) green.

🤖 Generated with Claude Code

Only the Table view was implemented; List and Kanban switched the tab and
showed a "coming soon" placeholder. This adds both, plus the group-by picker
and drag-to-change-value Kanban needs.

- list-view.svelte — one row per result showing the node title (title_template
  → content → "Untitled"), reads each node from sharedNodeStore for cross-pane
  reactivity, paginated at PAGE_SIZE=25 like TableView, row click opens the node.
- kanban-view.svelte — groups results into columns by a selected enum field
  (enum-only: its core/user values give both the column set and labels). Cards
  show titles and read from the store so they move reactively; a null/unknown
  value lands in an "Unassigned" column. Drag a card between columns, or use the
  per-card keyboard-accessible "Move to" select, to write the column's value onto
  the node. Dropping into the same column is a no-op; the optimistic store write
  rolls the card back on a rejected persist. Empty state when the schema has no
  enum field.
- kanban-grouping.ts — pure, DOM-free helpers (eligible fields, enum columns,
  group-value read mirroring table-row's resolution order, write-shape that
  writes back to where the value is read from — properties[field] for the common
  user-defined-schema case, matching generic-schema-form — and column bucketing).
  16 unit tests.
- query-node-viewer.svelte — render List/Kanban/Table by activeView; delete the
  viewComingSoon state, the coming-soon branch, and its now-dead CSS.

Group-by selection and last view persist per query node via QueryPreferencesService
and restore on reopen. Note: enum fields on user-defined schema types (the common
Kanban case) write to properties[field]; core namespaced typed fields mirror their
read location — worth an on-device confirm for a core type like task.status.

🤖 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

Principal-Engineer Code Review — PR #1984 (closes #1921)

Review Type: Initial (no prior reviews/comments on the PR). Framework: Pragmatic Quality — rigorous, velocity-aware.

The core of this feature — List + Kanban over user-defined schema types — is well-structured, correctly reactive, and the extracted grouping logic is cleanly unit-tested. The findings below concern edge paths (core-typed fields), an error-surfacing mechanism that doesn't fire on the realistic failure, unbounded card rendering, and a test gap the issue explicitly called out.


Requirements Check (14 acceptance criteria)

# Criterion Status Note
1 List: row-per-title, click opens node ✅ list-view.svelte:31-40
2 List rows reactive to edits in another pane ✅ per-row getNode list-view.svelte:33
3 Kanban: one column per group-by value ✅ enumColumns→displayColumns kanban-view.svelte:59-60
4 Cards show title; click opens node ✅ kanban-view.svelte:201-203
5 Unset value → "Unassigned" column ✅ groupByColumn kanban-grouping.ts:104-108
6 Picker lists eligible fields + persists per query node ✅ enum-only; onPickGroupBy saves. Default (first eligible) is not persisted until an explicit pick — harmless (deterministic), see 🟢-C
7 Reopen restores last view + stored group-by ✅ query-node-viewer.svelte:89 + kanban-view.svelte:52-55
8 No eligible field → empty state ✅ kanban-view.svelte:148-152
9 Drag updates the value and persists it ⚠️ Partial User-defined schema (properties write) persists correctly. Core-typed top-level fields may silently not persist — 🟡-1
10 Moved card reflects new column after store update ✅ buckets re-derives via SvelteMap reactivity — confirmed against store
11 Same-column drop = no write ✅ from === target incl. Unassigned→null kanban-view.svelte:105
12 Failed update returns card + surfaces error ⚠️ Partial Card does roll back (store rollbackUpdate) and a global write-failure toast fires; but the component's own moveError banner never fires on async failure — 🟡-2
13 coming-soon placeholder + viewComingSoon deleted ✅ state, branch, and CSS all removed
14 Keyboard-accessible alternative to drag ✅ labeled per-card "Move to" <select> kanban-view.svelte:204-213

Findings

🟡 Important — Core-typed enum fields can move optimistically but silently fail to persist

📁 packages/desktop-app/src/lib/components/query/kanban-grouping.ts:82-87 (in concert with shared-node-store.svelte.ts:1099-1113)

resolveFieldWrite mirrors the read location, so for a core typed field it emits a top-level change like { status: value } / { stage: value }. But sharedNodeStore.updateNode only persists a viewer-sourced update when it is a property change, content, nodeType, structural, or a hardcoded type-specific field (status | priority | dueDate | assignee | startedAt | completedAt) on a nodeType with a registered updater. A top-level enum write that is none of these hits shouldPersist === false (source.type === 'viewer' and every other flag false) → the card moves in the UI but no persist is attempted, no rollback, no error — it snaps back on reload. task.status/priority happen to survive via the type-updater coincidence; any other core enum field (or a core type without an updater) does not.

The common, in-scope path (user-defined schema → properties[field]) is safe because 'properties' in changes forces shouldPersist. The author already flagged core types for on-device confirm; the concrete mechanism above is why that matters. Principle: verify the write against the persistence gate, not just the read location. Recommend either restricting Kanban group-by to properties-backed fields for now, or routing core enum writes explicitly through the type updater — and note the test suite encodes { stage: 'won' } as expected output without any assertion that it persists.

🟡 Important — The in-view moveError banner is dead code for the realistic failure path

📁 packages/desktop-app/src/lib/components/query/kanban-view.svelte:106-118

moveCard wraps updateNode in a synchronous try/catch, but persistence is async. On a rejected persist the store rolls the value back (card returns to its column — good) and surfaces the failure through the global conflictNotifications toast (shared-node-store.svelte.ts:1488-1499). The role="alert" moveError banner only fires on the rare synchronous throw (e.g. node vanished). So AC-12 is met by store infrastructure, but the component's advertised error UI essentially never shows, and the PR description's "surfaces error" claim is inaccurate for the async case. Principle: error UI must reflect the real failure channel. Either wire the banner to the persistence result (waitForPersistence/handle) or delete it and document reliance on the global toast.

🟡 Important — Kanban renders every result unpaginated

📁 packages/desktop-app/src/lib/components/query/kanban-view.svelte:64-73, 190-216

List and Table paginate at PAGE_SIZE = 25 (the PR cites this for consistency), but Kanban buckets all nodeIds and renders a card plus a full-options <select> for every node. For a type with thousands of instances that is thousands of DOM elements + selects + per-card getNode reads. Principle: bounded rendering. A per-column cap ("+N more"), virtualization, or at minimum a follow-up issue is warranted before this meets large real-world types.

🟡 Test coverage — the interactive behavior the issue explicitly wanted browser-tested is untested

📁 packages/desktop-app/src/tests/components/kanban-grouping.test.ts

The 16 helper tests are good and cover eligibility/columns/read/write-shape/bucketing. But issue #1921 Notes state: "Drag-and-drop interactions need real browser tests (bun run test:browser), not Happy-DOM." None were added — the drag/drop, optimistic move, rollback, and select-move integration (exactly the risk-carrying, AC-9/10/11/12 behavior) have no test. This tensions with the repo's "test extracted logic, not components" convention, so it's a recommendation rather than a hard blocker — but the issue asked specifically, and it's where the two correctness findings above live.

🟢 Suggestion — small duplication

toCamelCase is duplicated (kanban-grouping.ts:27 vs table-row.svelte), and the field-label formatter is duplicated (kanban-view.svelte:75-81 vs table-view.svelte). Acceptable for a DOM-free module, but a shared util would prevent drift.

🟢 Suggestion — untested write branches + Unassigned clears via ''

resolveFieldWrite's snake_case-top-level branch (kanban-grouping.ts:85) and readGroupValue's snake fallback have no test (only camelCase-top-level stage and properties are covered) — add a due_date-style case. Also, moving to Unassigned writes '' rather than deleting the key; it reads back as null so behavior is correct, but a one-line comment would help.

🟢 Suggestion — implicit default group-by isn't persisted

resolveActiveGroupBy defaults to the first eligible field but saveViewConfig is only called on an explicit pick. Harmless today (deterministic), but a future schema-field reorder would shift the implicit default. Consider persisting the resolved default on first Kanban render.


What's solid

  • buckets $derived.by reads each node through the SvelteMap-backed store, so a drag/select move that rewrites the value re-derives the board and moves the card — reactivity confirmed against updateNode/nodesSet (AC-10). ✅
  • Same-column no-op is correct including Unassigned→null (AC-11). ✅
  • User-defined-schema write matches generic-schema-form's properties[field] model and persists via isPropertyChange (AC-9 common path). ✅
  • Greenfield cleanup is complete — viewComingSoon state, branch, and CSS all gone (AC-13). ✅
  • createLogger (not console), no any (only unknown casts mirroring table-row), no lint suppression, pagination clamp consistent with table-view (ADR-049).

Recommendation: REQUEST CHANGES

No 🔴 blockers, and the feature's primary path (user-defined boards) is production-ready. Changes requested are tight and mostly cheap: (1) resolve the moveError dead-path so the component's error UI matches the real async failure channel (or remove it and correct the PR claim), and (2) guard/route or explicitly document-and-defer the core-typed write path so a core board can't move a card that silently won't save. The Kanban pagination and the DnD browser test are strong recommendations rather than hard gates. The user-defined-schema Kanban + List views themselves are good work.

@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: REQUEST CHANGES (posted as comment — GitHub blocks self-approval). Findings in the review comment above.

…ence

Addresses pragmatic-code-review findings on PR #1984:

- 🟡 Removed the dead per-view moveError banner + synchronous try/catch. A
  rejected persist is async, so the banner never fired; the shared store already
  rolls the value back (returning the card to its column) and raises its global
  conflict notification — the same fire-and-forget path generic-schema-form uses.
  Kanban now relies on that, so error surfacing is honest and centralized.
- 🟡 Documented resolveFieldWrite's persistence guarantee: user-defined schema
  fields write to properties[field] (property changes always persist) and core
  typed enums (status/priority/…) persist via their registered type updater;
  grouping a core type by a non-standard top-level enum field is out of scope.
- Deferred to #1985 (with reviewer's assent): bounding large boards
  (pagination/virtualization) and browser-based drag-and-drop tests.

🤖 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

/address-review summary

Addressed the review in commit that follows the initial one.

Finding Severity Action
moveError banner is dead code for the async failure path 🟡 Important Fixed — removed the per-view banner + synchronous try/catch. A rejected persist is async; the shared store already rolls the value back (returning the card to its column) and raises its global conflict notification, the same fire-and-forget path generic-schema-form uses. Kanban now relies on that — error surfacing is honest and centralized.
Core-typed enum fields may move but silently not persist 🟡 Important Documented + bounded. Verified against the store's viewer-write rule: properties[field] (the user-defined-schema Kanban case) always persists, and core typed enums status/priority/dueDate/… persist via their registered type updater — both paths resolveFieldWrite actually emits for real group-by fields. The flagged silent-fail requires a core type grouped by a non-standard top-level enum field (not status/priority), which isn't how core types model mutable enums; that case is now explicitly documented as out of scope in resolveFieldWrite.
Kanban renders every result unpaginated 🟡 Important Deferred to #1985 (reviewer allowed a follow-up) — per-column cap / virtualization.
Drag-and-drop lacks browser tests 🟡 (recommendation) Deferred to #1985 — the extracted grouping/write logic is unit-tested (16); the DnD → store → regroup → rollback flow wants the browser harness.
Duplicated toCamelCase / label formatter 🟢 Skipped — tiny, self-contained per component; deduping now adds a shared-util dependency for marginal gain.

Helper suite still green (16/16); quality:fix clean (0/0).

Re-Review Decision

Decision: RE-REVIEW NEEDED (base verdict was REQUEST CHANGES). The two 🟡 correctness items are resolved (one by removing dead code, one by verifying + documenting the persistence guarantee), and the two scale/test items are deferred to #1985 with rationale. Requesting a re-review of the new commit to confirm the resolutions before merge.

@mstomar125

Copy link
Copy Markdown
Contributor Author

Principal-Engineer Code Review — PR #1984 (closes #1921)

Review Type: Re-Review — delta only (d566a2f5..34084bef), plus the full current kanban-view.svelte / kanban-grouping.ts read in context. Framework: Pragmatic Quality.

Previous Review Summary

Base verdict: REQUEST CHANGES. Recommendations: 4 → Addressed in code: 2 · Deferred to #1985: 2 · New issues from the delta: 0.

The follow-up commit is a clean, honest resolution: it deletes a misleading error path rather than papering over it, and it verifies (not just asserts) the persistence guarantee against the store's actual shouldPersist rule. Delta is small (2 files, +17/−33) and introduces no regressions.


Per-finding verdicts

✅ Resolved — moveError banner was dead code for the async failure path

📁 kanban-view.svelte:98-112
The moveError state, the synchronous try/catch, the role="alert" banner, and its .kanban-error CSS are all gone (grep moveError|kanban-error across src/ = 0 hits). moveCard is now a clean optimistic write that keeps the same-column no-op (from === target → early return, :103). Relying on the store is legitimate and verified: on a rejected persist the store calls rollbackUpdate (shared-node-store.svelte.ts:1404) — returning the card to its column — and raises a global conflict notification (:1468 OCC / :1496-1500 non-OCC write-failure), the same fire-and-forget channel generic-schema-form uses. This is exactly the real failure channel, so removing the never-firing banner is the correct fix, not a downgrade. The debug line is retained (log.debug, :110), so createLogger/log stays used — no dead import.

✅ Resolved (documented, verified) — core-typed enum fields could move but silently not persist

📁 kanban-grouping.ts:68-94 · verified against 📁 shared-node-store.svelte.ts:1092,1099-1113
The doc now states the guarantee, and it holds against the store's real rule. shouldPersist (:1107-1113) persists a viewer write when isPropertyChange ('properties' in changes, :1092) or isTypeSpecificChange (hasTypeUpdater and one of status|priority|dueDate|assignee|startedAt|completedAt, :1099-1106). Both shapes resolveFieldWrite actually emits for real group-by fields land inside that gate:

  • user-defined schema enum → { properties: { [field]: value } } → isPropertyChange → always persists (the common Kanban case);
  • core typed enum (status/priority) → top-level { [camel]: value } → isTypeSpecificChange via the registered type updater → persists.

The only silent path — a core type grouped by a non-whitelisted top-level enum field → shouldPersist === false, no persist / no rollback / no toast — is now documented as out of scope (kanban-grouping.ts:78-79), and is not how core types model mutable enums (the whitelist's only enums are status/priority). Residual (non-blocking): this is documentation, not a hard guard — if a future core type adds a non-whitelisted top-level enum field, the card would move then snap back on reload with no error. Worth a guard or an eligibility filter if that ever becomes reachable; acceptable to leave for now. The stage unit case (kanban-grouping.test.ts:106) correctly tests the pure write-shape branch, not persistence.

✅ Deferred (accepted) — Kanban renders every result unpaginated

Tracked in #1985 (OPEN) — "bound unbounded card rendering (per-column cap / virtualization)". Reviewer explicitly allowed a follow-up; scope and rationale are captured in the issue.

✅ Deferred (accepted) — drag-and-drop lacks browser tests

Tracked in #1985 (OPEN) — browser DnD tests for the drop→store→regroup→rollback flow. The extracted logic remains unit-tested (16/16). Reasonable deferral given the repo's test-extracted-logic convention.


New issues introduced by the delta

None. No leftover moveError/.kanban-error references, no unused imports (log still used via log.debug), same-column no-op preserved, CSS pruned to match.

Recommendation: APPROVE

Both correctness findings are genuinely resolved — one by deleting a misleading path, one by verifying the persistence guarantee against the store's gate — and the two scale/test items are deferred to a real, open, well-scoped follow-up (#1985). One non-blocking residual noted on finding 2 (documentation vs. hard guard). Ship it.

@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). Both correctness findings resolved (moveError dead-code removed; persistence guarantee verified against the store's shouldPersist gate + documented); pagination + browser-DnD-tests deferred to #1985. No new issues in the delta. Findings above.

@mstomar125
mstomar125 merged commit 95d4105 into main Aug 6, 2026
2 checks passed
@mstomar125
mstomar125 deleted the issue-1921-list-kanban-views branch August 6, 2026 10:00
mstomar125 added a commit that referenced this pull request Aug 13, 2026
…ility bugs

A third review pass (independent verification, executed rather than just
read-through) found several more real bugs:

- resyncNodeFromServer's identity-race guard compared object references,
  assuming nodes are always replaced wholesale. Several pre-existing
  success-handler paths in this file mutate the node object in place and
  then re-set the same reference, which the reference check couldn't see.
  Switched to a value snapshot (JSON.stringify before/after the fetch),
  correct regardless of how a concurrent writer applies its change.

- moveCard's onPersistError reverted to its own locally-read `from`, which
  can itself be an unconfirmed intermediate value from an earlier move in
  the same chain: two rapid moves of the same card that both fail settled
  on a value neither the server nor any write ever actually confirmed.
  Added chain-origin tracking (cleared via a new onPersistSuccess hook on
  UpdateOptions) so a chain of failures always reverts to the true
  pre-chain value, not an intermediate one.

- resyncNodeFromServer's skip-guard silently dropped decideRemoteUpdate's
  notifyConflict signal (setNode's equivalent guard raises it) and
  hardcoded hasPending: false even for its own queued follow-up call,
  where the self-referential-race justification for that doesn't apply
  (the follow-up fires after the triggering write's own bookkeeping has
  already settled). Added the notification (deduped, so existing callers
  that already notify unconditionally don't double up) and made hasPending
  real for the follow-up path specifically.

- eligibleGroupByFields (kanban-grouping.ts, pre-existing from #1984) now
  excludes an enum field whose values include the UNASSIGNED sentinel,
  which would otherwise collide with the genuinely-unset bucket.
  readGroupValue and resolveFieldWrite's top-level/properties precedence
  now match exactly, fixing a case where a shadowing field name (e.g.
  "status" on a user-defined type) could write to properties but read
  from a stale top-level slot, making the board silently ignore its own
  writes.

- Minor: isFocused now calls focusManager.isNodeEditing() instead of
  reimplementing the same check inline.

Several lower-reach findings from the same pass (batch-routing dropping
the new callbacks, a pre-existing pendingUpdates leak for skipPersistence
writes, fire-and-forget queued-resync semantics, an omitted
shouldSkipStaleAiChatUpdate check) are pre-existing infrastructure or
narrow edge cases outside this PR's contained scope — filed as follow-ups
on core#2068 rather than expanding this diff further.

Co-Authored-By: Claude <[email protected]>
mstomar125 added a commit that referenced this pull request Aug 13, 2026
* Cap Kanban column rendering and cover drag-and-drop with browser tests

kanban-view.svelte bucketed and rendered every matching node per column
(a card plus a full-options <select> each) with no bound, unlike
List/Table's PAGE_SIZE=25 pagination. Each column now renders at most a
batch of cards (matching PAGE_SIZE) with a "+N more" control that grows
the visible count — never shrinks it, so an on-screen card can't vanish
mid-drag. True virtualization was considered and rejected: this view's
drag source is the rendered DOM node itself (native HTML5 drag-and-drop),
which is incompatible with windowed/virtualized lists unmounting
off-screen rows. The reveal-count arithmetic is extracted into
kanban-grouping.ts and unit-tested; the click-driven reveal is covered by
a new Happy-DOM component test.

Add src/tests/browser/kanban-dnd.test.ts (Chromium) covering what
Happy-DOM can't drive: real DragEvent/DataTransfer drag-and-drop against
the mounted component, the keyboard "Move to" alternative, the
same-column no-op, and the rollback path — using the real sharedNodeStore
singleton with only the daemon RPC boundary mocked.

Writing the rollback test surfaced a real bug in
sharedNodeStore.updateNode: on a non-OCC persist failure, rollbackUpdate()
only rewinds bookkeeping (metrics, version counter, pending-update list)
and never restores the optimistically-applied field values, since
NodeUpdate carries no previous-value snapshot. A rejected write left the
local node permanently diverged from the server. Fixed by resyncing from
the server on non-OCC failure, reusing the store's existing
resyncNodeFromServer (the same fallback the OCC-conflict path already
uses a few lines above). Added regression tests to
shared-node-store.test.ts, each verified to fail on the prior code and
pass on the fix.

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

* Address review: identity-stable cap, resync skip-while-editing guard

Review round 1 on PR #2066 found two real bugs beyond the original diff:

1. The non-OCC resync path (added in the first commit) writes via
   resyncNodeFromServer(), which bypasses the skip-while-editing guard
   setNode() enforces. A debounced content persist failing for an
   unrelated reason while the user kept typing would silently overwrite
   their in-progress edit with stale server content. Fixed by applying
   the same decideRemoteUpdate guard resyncNodeFromServer() now uses
   for every caller (including the pre-existing OCC-conflict fallback).
   Deliberately isFocused-only, not hasPending: hasPending is
   self-referential when read from inside the very write's own failure
   handler (the failing operation still occupies its "executing" slot),
   which is racy and would defeat the recovery path for its most common
   case.

2. The per-column cap sliced by array position (`ids.slice(0, n)`), so
   a card joining a column ahead of an already-visible one in result
   order could push that card out from under itself — including, in
   the sharpest case, a card mid-drag. Replaced with an identity-stable
   revealed-id set (growRevealed in kanban-grouping.ts): a column under
   one batch always shows everything (a card just moved in must appear
   immediately, not wait behind a click), and moveCard explicitly
   reveals whatever this view just placed into a column regardless of
   that column's cap.

Also: resyncNodeFromServer's idempotency guard now queues one follow-up
for a caller that arrives while a resync is already in flight, instead
of silently dropping it — two failures for the same node landing close
together no longer leaves the second one's divergence uncorrected.

Filed a follow-up issue for the one remaining related gap out of this
PR's contained scope: the OCC-conflict direct-hydration branch (a
sibling of resyncNodeFromServer, not touched by this PR) has the same
guard-free write path and needs the identical fix.

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

* Address review round 2: scope Kanban's rollback to a local revert

A second review pass found that the general resyncNodeFromServer-based
non-OCC rollback (added in the previous commit) had three real races of
its own: a failed node create left a permanent phantom node (server has
nothing to return); the guard's hasPending had no way to tell a second,
genuinely different in-flight write for the same node apart from the
failing write's own not-yet-cleared bookkeeping, so it could clobber
that write; and a resync skipped for an actively-edited node had no
retry, so the divergence could persist indefinitely.

All three trace back to the same root cause: a whole-node server
resync is the wrong grain of correction for "one write, to one field,
failed." Replaced with `onPersistError`, an opt-in per-call callback on
UpdateOptions that lets the caller who made a specific write apply its
own narrowly-scoped correction. Kanban's moveCard uses it to revert
just the group-by field back to its pre-move value, guarded by a check
that the field still holds exactly the value this move set (protects
against stomping a newer move to the same card that landed before this
one's failure was known). No server round-trip, no skip-while-editing
guard needed, no interaction with node creation.

resyncNodeFromServer itself is now only the OCC-conflict fallback (its
original, narrower use before the previous commit). Hardened it
further: an identity check bails if a different write landed for the
node while the fetch was in flight (the same clobber class, without
the self-referential hasPending race), and the guard-skip branch now
marks the node persisted, matching setNode's equivalent branch.

Also: removed GitHub issue numbers from code comments introduced by
the previous commit, per repo convention.

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

* Address review round 3: fix identity-race, chained-revert, and eligibility bugs

A third review pass (independent verification, executed rather than just
read-through) found several more real bugs:

- resyncNodeFromServer's identity-race guard compared object references,
  assuming nodes are always replaced wholesale. Several pre-existing
  success-handler paths in this file mutate the node object in place and
  then re-set the same reference, which the reference check couldn't see.
  Switched to a value snapshot (JSON.stringify before/after the fetch),
  correct regardless of how a concurrent writer applies its change.

- moveCard's onPersistError reverted to its own locally-read `from`, which
  can itself be an unconfirmed intermediate value from an earlier move in
  the same chain: two rapid moves of the same card that both fail settled
  on a value neither the server nor any write ever actually confirmed.
  Added chain-origin tracking (cleared via a new onPersistSuccess hook on
  UpdateOptions) so a chain of failures always reverts to the true
  pre-chain value, not an intermediate one.

- resyncNodeFromServer's skip-guard silently dropped decideRemoteUpdate's
  notifyConflict signal (setNode's equivalent guard raises it) and
  hardcoded hasPending: false even for its own queued follow-up call,
  where the self-referential-race justification for that doesn't apply
  (the follow-up fires after the triggering write's own bookkeeping has
  already settled). Added the notification (deduped, so existing callers
  that already notify unconditionally don't double up) and made hasPending
  real for the follow-up path specifically.

- eligibleGroupByFields (kanban-grouping.ts, pre-existing from #1984) now
  excludes an enum field whose values include the UNASSIGNED sentinel,
  which would otherwise collide with the genuinely-unset bucket.
  readGroupValue and resolveFieldWrite's top-level/properties precedence
  now match exactly, fixing a case where a shadowing field name (e.g.
  "status" on a user-defined type) could write to properties but read
  from a stale top-level slot, making the board silently ignore its own
  writes.

- Minor: isFocused now calls focusManager.isNodeEditing() instead of
  reimplementing the same check inline.

Several lower-reach findings from the same pass (batch-routing dropping
the new callbacks, a pre-existing pendingUpdates leak for skipPersistence
writes, fire-and-forget queued-resync semantics, an omitted
shouldSkipStaleAiChatUpdate check) are pre-existing infrastructure or
narrow edge cases outside this PR's contained scope — filed as follow-ups
on core#2068 rather than expanding this diff further.

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

* Address review round 4: chainOrigin null-origin and cross-field bugs

A fourth review pass, executing the code rather than just reading it,
found two real bugs in round 3's chain-origin revert tracking:

- chainOrigin.get(chainKey) ?? from treated a genuinely-stored `null`
  origin (a card that started in the "Unassigned" column) the same as
  "nothing recorded", falling back to `from` — an intermediate,
  unconfirmed value for a chain of 2+ moves — instead of the true
  Unassigned origin. Switched to an explicit chainOrigin.has() check.

- chainOrigin was keyed only by node id, not by (id, field). Switching
  the "Group by" picker mid-chain and moving the same card again let a
  later move for a different field inherit — and on failure, write — an
  origin value that belonged to an earlier field, corrupting one field's
  value with another's vocabulary. Keyed by `${id}:${field}` instead.

The null-origin fix has a regression test verified to fail without it
and pass with it. The cross-field key fix does not: PersistenceCoordinator
serializes writes per node (not per field), so a later move for a
different field can never actually observe an earlier field's still-live
chainOrigin entry in practice — attempting to construct that interleaving
in a test surfaced no reachable failure and, forcing an unrealistic
promise-rejection order to try, corrupted shared test state instead. Kept
as a defense-in-depth correctness fix (a composite key is strictly more
correct than a shared one, at no cost) without a dedicated regression
test, since none can be constructed against the current architecture.

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

---------

Co-authored-by: Claude <[email protected]>
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