Skip to content

Promote one-cardinality relationships to form fields; exclude them from the Relationships modal (closes #2806) - #3050

Merged
malibio merged 7 commits into
mainfrom
issue-2806-one-relationship-fields
Sep 26, 2026
Merged

malibio merged 7 commits into
mainfrom
issue-2806-one-relationship-fields

Conversation

@malibio

@malibio malibio commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

A relationship whose local end is one (a task's Assignee, Creator, Project) now renders on the property form as a single-select autocomplete field. The Relationships modal shows only what is not on the form, so each edge has exactly one control.

  • relationship-grouping.ts: isFormPromoted (local one and no declared edge fields) plus a promoted bucket in partitionGroups. populated/addable exclude promoted groups. hasModalContent gates the modal trigger on what is left for it.
  • NodeRelationshipsState (new): one per-node load shared by TypedFormShell and PersonSchemaForm. It replaces the gate PersonSchemaForm had copied verbatim.
  • RelationshipField (new):
  • Promoted fields follow the form's own grid and count toward the X/Y fields badge.

Deviations from the issue

Also in this branch

  • src-tauri/build.rs: in debug builds, an unstaged skill bundle and installer are left out of the Tauri bundle config (via TAURI_CONFIG) with a cargo:warning, instead of failing. Clippy, cargo check/test and the pre-push gate no longer need bun run build:skill in a fresh worktree. Release builds stay strict; dev:tauri/tauri:build already run build:skill first; the nodespaced/nodespace sidecars stay strict.
  • methodology_linear_execution_test: the rollover test built its "ending today" date from Local::now(), while CEL today() reads UTC. It failed whenever the local and UTC dates differ (hit here at 00:09 CEST).

Testing

  • Unit and component tests:
    • Promotion/partition/gate unit tests.
    • RelationshipField component tests: transposed create, replace, clear, required, error.
    • Task/person/generic form tests for the fields, badge and trigger gate.
  • Frontend suite: passed, apart from the known load-flaky architecture benchmark and core-plugins timeout, which pass when re-run in isolation.
  • Real app check (isolated daemon DB, Playwright):
    • Assign Sam: the task shows assignee=Sam Lee and Sam's panel shows the task under tasks.
    • Reassign to Ana replaces the edge; Sam's side is empty and Sam isn't offered while assigned.
    • Set Project, then clear Assignee.
    • Modal Add menu offers only Blocks / Relates To / Duplicates.
    • Checked in light and dark mode; no console errors.
  • build.rs: clippy on nodespace-app passes with the skill unstaged (warning shown, settles to a no-op), and restaging it restores the normal path. The release path was not exercised.
  • Pushed with --no-verify at the author's request. The gate's only failure on the first run was the timezone test fixed above, and that file passes after the fix.

🤖 Generated with Claude Code

malibio and others added 4 commits September 25, 2026 23:34
…om the Relationships modal (closes #2806)

A relationship whose local end is `one` (a task's assignee, project, creator)
now renders on the property form as a single-select autocomplete field, and
the Relationships modal shows only what is not already on the form.

- relationship-grouping: `isFormPromoted` (local `one`, no declared edge
  fields) and a `promoted` bucket in `partitionGroups`; `populated`/`addable`
  exclude it, so each edge has exactly one control. `hasModalContent` gates
  the modal trigger on what is left for it.
- NodeRelationshipsState: one per-node load shared by TypedFormShell and
  PersonSchemaForm, replacing the gate PersonSchemaForm had copied verbatim.
- RelationshipField: title search over the target type (matches the
  title_template rendering), writes through addEdge/removeEdge so inbound
  groups are transposed; re-assign is a plain create (daemon replaces into a
  `one` end); clearable unless required.
- Promoted fields follow the form's own grid and count toward the badge.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
tauri_build copies every declared bundle resource and sidecar and fails on a
missing one, so clippy, cargo check/test and the pre-push gate all required
`bun run build:skill` in a fresh worktree although none of them reads the
skill. build.rs now drops the skill resources/installer from a DEBUG build's
bundle config (via TAURI_CONFIG) when they aren't staged, with a
cargo:warning. Release builds stay strict, as do the nodespaced/nodespace
sidecars; dev:tauri and tauri:build already run build:skill first.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ching CEL today()

The test used Local::now() while today() reads Utc::now(), so it failed
whenever the host-local date differed from the UTC date (e.g. 00:00-02:00 CEST).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@malibio

malibio commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator Author

Automated pragmatic-code-review

Review Type: Initial Review

Requirements Check (#2806)

  • ✅ Local-one relationships render as labeled autocomplete fields. isFormPromoted uses cardinality === 'one'. For inbound groups the backend already reports reverse_cardinality, so this is the local end. Keeping one groups that declare edge fields in the modal is sound.
  • ✅ Search covers target_type by resolved title. searchTargets sends queryNodes({ nodeType, titleContains }), which matches the stored title_template output.
  • ✅ Inbound picks create the edge with transposed arguments. Writes go through resolveEdgeEndpoints, which a test covers. The far node reflects the change on its next load.
  • ✅ Selecting a value replaces the existing edge. Verified in node_service/relationship.rs:1160-1220, including required+One.
  • ✅ The field can be cleared. The clear button is hidden only for a required outbound one group.
  • ✅ The modal excludes promoted groups from both the rail and + Add.
  • ⚠️ "Assigned to" and "Project" on the task form. The label reads "Assignee", the humanized reverse_name, not "Assigned to". Either confirm this and edit the criterion, or add a display label. blocks/relates_to/duplicates stay in the modal.
  • ✅ The trigger hides when nothing is left for the modal. hasModalContent, fail-open on load error, tested.
  • ✅ Forms for types with no one relationships are unchanged.

Code Review Findings

🟡 Listbox stays open after blur on an empty field

📁 packages/desktop-app/src/lib/components/relationships/relationship-field.svelte (onblur, listOpen)

  • Problem: onblur calls stopEditing() only when current is set. On an unset field, typing and then tabbing or clicking away leaves the absolute z-50 list floating over neighbouring fields.
  • Also: a mousedown on the list's scrollbar or on the non-option rows blurs the input and closes the list mid-scroll.
  • Fix:
    • Always close the list on blur.
    • Call preventDefault on the <ul>'s mousedown rather than on each option.
  • Principle: correct state transitions.

🟡 Same-node reloads can resolve out of order

📁 packages/desktop-app/src/lib/services/node-relationships-state.svelte.ts (#fetch)

  • Problem: Staleness is checked only by #nodeId. Suppose Assignee and then Project are assigned quickly. If the first reload lands last, the view reverts and Project shows empty although the edge exists. load() vs reload(), and A→B→A navigation, race the same way.
  • Fix: Use a request-generation counter, the same pattern RelationshipField.searchGeneration already uses.
  • Principle: latest request wins, not latest response.

🟡 select() isn't guarded while a write is in flight

📁 relationship-field.svelte (write, option onmousedown)

  • Problem: Options stay clickable while busy. A double click, or a second option, fires concurrent creates, and the end state is whichever commits last.
  • Fix: Start write() with if (busy) return;.
  • Principle: serialize user actions.

🟡 test-app-units.ts / test-gate.ts contradict the build.rs change

📁 scripts/test-app-units.ts, scripts/test-gate.ts

  • Problem: rust:test:app-units, which is part of test:all, still hard-exits when the skill isn't staged. Its comments, and the gate's, describe tauri_build as always needing the skill, which is now true only for release builds.
  • Fix: Relax the precheck for the two skill entries, or keep it strict and document why. Update the gate comment.
  • Principle: one source of truth for build prerequisites.

🟡 build.rs hand-syncs the bundle lists

📁 packages/desktop-app/src-tauri/build.rs (BUNDLE_RESOURCES, BUNDLE_EXTERNAL_BINS)

  • What's right: the mechanism. json_patch::merge replaces whole arrays, PROFILE == "debug" is correct, and an explicit TAURI_CONFIG is respected.
  • Problem: A new entry added to tauri.conf.json but not here would be silently dropped in unstaged debug builds.
  • Fix: serde_json is already compiled for the build host via tauri-build, so parse the conf and filter out the two skill entries instead.
  • Principle: DRY.

🟡 Accessibility: current value not announced; combobox has no active descendant

📁 relationship-field.svelte

  • Problem: When a value is set, <label for> names the button "Assignee", so "Sam Lee" is never spoken.
  • Problem: The combobox has no aria-activedescendant or option ids, so arrow-key highlight changes are invisible to assistive tech.
  • Problem: aria-controls points at a listbox that isn't in the DOM while the list is closed.
  • Principle: WAI-ARIA combobox pattern.

🟡 Missing tests for the new stateful logic

  • Problem: Several paths have no tests:
    • NodeRelationshipsState staleness and fail-open.
    • RelationshipField blur, Escape, arrow keys, stale search, a required field with no value, and an outbound one write.
    • PersonSchemaForm rendering a promoted field.
  • Principle: test coverage proportional to concurrency risk.

🟢 The form doesn't reload after the modal closes

  • Problem: showModalTrigger can go stale. Changes made on other nodes also don't reach an open form.
  • Fix: Reload when the modal closes. Cross-node freshness can be a follow-up.

🟢 autoOpen focus can miss promoted-only forms

  • Problem: With hasFields=false, the collapsible mounts only after load, so the single 150ms focus attempt can miss it.

🟢 Minor gaps in RelationshipField

  • Problem: searchTimer isn't cleared on unmount.
  • Problem: A search error shows as "No matches."

🟢 The PR bundles three unrelated changes

  • Assessment: Fine for a lean team.
  • Also: the branch is 3 commits behind origin/main. Rebase before merge.

🟢 Nit: the build.rs "." rerun fallback would watch the whole crate

  • Assessment: Unreachable in practice.

Recommendation: REQUEST CHANGES

The design is sound: one load and partition shared by both surfaces, verified replace semantics, clean pure-function partition with good tests. Before merge:

  • Fix the listbox left open on blur.
  • Fix the same-node reload race.
  • Guard select() while busy.
  • Resolve the test-app-units.ts/test-gate.ts contradiction.
  • Settle the label criterion.

🤖 Generated with Claude Code

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator 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 a comment — GitHub blocks requesting changes on your own PR). Full findings in the review comment above.

malibio and others added 2 commits September 26, 2026 00:39
- RelationshipField: blur always closes the list (an empty field used to
  leave it floating); the listbox cancels mousedown so a scrollbar drag or
  status row can't blur the input; a second pick while a write is in flight
  is ignored; search failure shows "Search failed." instead of "No matches.";
  pending search timer cleared on unmount.
- Accessibility: the set-value button is named "<Field>: <value>";
  options carry ids and the input exposes aria-activedescendant;
  aria-controls only while the list exists.
- NodeRelationshipsState: staleness keyed on request order (generation
  counter), so two quick edits' reloads can't land out of order.
- Forms reload relationships when the Relationships modal closes, so the
  trigger gate reflects edits made there.
- Tests: out-of-order reloads, node switch, no refetch; field blur, list
  mousedown, arrow keys + active descendant, Escape, outbound write, busy
  guard, search failure, accessible name; person form promoted field.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ign test scripts

- build.rs reads bundle.resources/externalBin from tauri.conf.json (serde_json
  build-dep, already compiled for the host by tauri-build) instead of
  hand-synced constants; stays strict if either isn't a plain list. The
  rerun-if-changed fallback no longer watches the whole crate.
- test-app-units.ts no longer treats the skill bundle entries as compile
  prerequisites (build.rs drops them in debug), and instead requires
  packages/skill/dist/install.js, which a nodespace-app unit test reads.
- test-gate.ts: build:skill is documented as a TEST prerequisite, not a
  build one.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@malibio

malibio commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator Author

Address-review summary

Commits: 17be2305 (frontend), f7fb17e1 (build/scripts). The pre-push gate passed in full: frontend, skill, Rust, e2e and Tauri-seam.

✅ Addressed

  • The list stays open after blur on an empty field.
    • Blur now always closes the list.
    • The <ul> cancels mousedown, so a scrollbar drag or a status row no longer blurs the input.
    • Tests cover both.
  • Same-node reloads resolving out of order. NodeRelationshipsState now keeps only the most recently started fetch (a generation counter). A deferred-promise test resolves reloads out of order.
  • select() while busy. write() returns early while busy. A test checks that the second pick is ignored.
  • test-app-units.ts / test-gate.ts contradicting build.rs.
    • The skill bundle entries are no longer treated as compile prerequisites.
    • The script now requires packages/skill/dist/install.js, because resolve_installer_path_falls_back_to_source_checkout_dist reads it. So build:skill is still needed for rust:test, as a test prerequisite.
    • The gate comment now says so.
    • Verified: with the bundle unstaged, clippy passes and all 195 nodespace-app unit tests pass.
  • Hand-synced build.rs lists.
    • The lists are now read from tauri.conf.json via a serde_json build dependency, which is already compiled for the host by tauri-build.
    • The build stays strict if either list isn't a plain array.
  • Accessibility.
    • The set-value button is named "<Field>: <value>".
    • Options have ids, and the input exposes aria-activedescendant.
    • aria-controls is set only while the list exists.
    • Tests cover these.
  • Tests. Added tests for NodeRelationshipsState and the field's blur, list mousedown, arrow keys, Escape, outbound write, busy guard, search failure and accessible name. Also added a person form test that renders a promoted field.
  • Reload when the modal closes. Both forms reload on close, through a function binding.
  • Timer cleanup and search error. The search timer is cleared on unmount, and a failed search shows "Search failed."
  • The "." rerun fallback. Removed: the build now watches only an existing ancestor, or nothing.

⏭️ Skipped

  • autoOpen focus on promoted-only forms. Rare and cosmetic. The focus attempt already targets inputs in the form. Revisit if a promoted-only type becomes common.
  • Rebase. The PR squash-merges and GitHub reports it mergeable. I'll merge main in only if a conflict appears.
  • Fail-open unit test on NodeRelationshipsState. A rejected load in that standalone unit context was flagged as a test error by the harness, for reasons I couldn't isolate. The behaviour is covered by the task, person and generic form "fails open" tests, which exercise this class.

❓ Open for the author

  • Label: "Assignee" (the humanized reverse_name) or "Assigned to" as the issue wrote it.

🤖 Generated with Claude Code

@malibio

malibio commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator Author

Automated pragmatic-code-review (re-review)

Review Type: Re-Review (aed60902..f7fb17e1)

Previous Review Summary:

  • 13 recommendations in the previous review.
  • 10 addressed.
  • 3 knowingly deferred: autoOpen focus, rebase, and the label criterion.
  • 2 new issues, both 🟢.

Verification of previous findings

  • ✅ Listbox open on blur.
    • Blur now always closes the list.
    • <ul> cancels mousedown, and the option's select() still runs in the same dispatch.
    • The regression test would fail on the old code.
  • ✅ Same-node reload race.
    • A #generation counter now drops stale responses.
    • I traced load/reload overlap and A→B→A.
    • The out-of-order test would fail on the old nodeId check.
  • ✅ select() while busy. write() returns early while busy. The test would fail on the old code.
  • ✅ test-app-units.ts / test-gate.ts.
    • The skill entries are filtered by their exact conf spelling.
    • ../../skill/dist/install.js resolves to packages/skill/dist/install.js, which the test really reads (skill_setup.rs:1140).
    • The producer prefix matches bun run build:skill.
  • ✅ build.rs hand-synced lists.
    • The lists are now parsed from tauri.conf.json.
    • The filter logic is correct and keeps non-string entries.
    • let-else stays strict when a list isn't a plain array.
    • The tauri.pro.conf.json --config path is unaffected.
  • ✅ Accessibility.
    • The value button's accessible name is "<Field>: <value>".
    • Options have ids, and the input sets aria-activedescendant to the highlighted one.
    • aria-controls is set only while the list exists.
    • All of these are tested.
  • ✅ Tests. The new tests are real regression tests. The skipped fail-open unit test is covered by the form tests.
  • ✅ Reload when the modal closes.
    • The Svelte 5.56 function binding is valid.
    • The modal's open is $bindable, forwarded through Dialog.Root bind:open, and openTarget sets it too.
    • Every close reloads, and opening doesn't reload spuriously.
  • ✅ Timer cleanup and search error.
  • ✅ "." rerun fallback removed.
  • ⏭️ Deferred, acceptable: autoOpen focus; rebase (check mergeability right before merge).
  • ❓ Open: the "Assignee" vs "Assigned to" label criterion is a product call.

New findings

🟢 A failed write on an empty field can lose the query and focus

📁 packages/desktop-app/src/lib/components/relationships/relationship-field.svelte

  • Problem: While busy, the focused input becomes disabled, which can fire blur, and blur now calls stopEditing() unconditionally. After a failed write, the empty field shows the error, but the query is gone and focus is lost.
  • Fix: Use readonly + aria-busy instead of disabled, since the busy guard already blocks a second write. Or refocus in the catch path.

🟢 Misplaced JSDoc and stale error text in scripts/test-app-units.ts

  • Problem: The new constants sit between requiredPaths's JSDoc and the function.
  • Problem: The failure message still says "cannot compile… staged paths", which is wrong for the test prerequisite.

Recommendation: APPROVE

  • Every 🟡 finding is fixed, verified against the source.
  • Before closing the issue, settle the label criterion and confirm the PR still merges cleanly.

🤖 Generated with Claude Code

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator 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 a comment — GitHub blocks self-approval). Full findings in the review comment above.

…c and message

- RelationshipField: readonly + aria-busy instead of disabled while a write
  is in flight, so the focused input isn't blurred (which closed the list and
  dropped the query a failed write should leave for a retry).
- test-app-units.ts: requiredPaths' JSDoc back on requiredPaths; the
  missing-path message no longer claims the crate cannot compile, since a
  test prerequisite can be what's missing.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@malibio

malibio commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator Author

Address-review (re-review) summary

b79386fb, full pre-push gate passed.

  • ✅ Failed write on an empty field lost its query and focus. While busy, the input is now readonly + aria-busy instead of disabled. The busy guard already blocks a second write, and a focused input no longer blurs mid-write.
  • ✅ test-app-units.ts.
    • requiredPaths' JSDoc is back on requiredPaths.
    • The missing-path message now reads "unit tests need N paths that are missing" rather than "cannot compile".

Re-review decision: not needed. Both are low-risk 🟢 fixes with no new logic paths. The review loop is complete. Still open for the author: the "Assignee" vs "Assigned to" label.

🤖 Generated with Claude Code

@malibio
malibio merged commit 9198f1f into main Sep 26, 2026
@malibio
malibio deleted the issue-2806-one-relationship-fields branch September 26, 2026 06:14
malibio added a commit that referenced this pull request Sep 26, 2026
…#3064)

* Author bare inbound many-to-many edges from either end (closes #2805)

A task's Blocked By / Related From / Duplicated By are the same stored edges
as another task's Blocks / Relates To / Duplicates, but the Relationships modal
dropped empty inbound groups from + Add and rendered populated ones read-only,
so recording "A is blocked by B" meant opening B.

- groupAcceptsEdgesHere: outbound groups, and inbound groups without edge
  fields, accept add/remove here. Writes transpose via resolveEdgeEndpoints.
- partitionGroups offers empty bare inbound groups in `addable`.
- The modal rail splits by authorability rather than direction, and the
  remove control follows the same predicate.
- Inbound groups with declared edge fields stay read-only: their values are
  authored at the declaring end.

The local-one half of the issue (assign/reassign as a form field) shipped in
#3050.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Address review: key the row footer on authorability, not direction

- The expanded-row footer used direction === 'in' to say "edit from the
  owning node"; a bare inbound group with undeclared edge keys is now
  authorable here, so the undeclared-keys message is the right one. The
  detail pane reads groupAcceptsEdgesHere once for both footer and remove.
- openTarget and groupSupportsEdgeEditing docs scoped to edge-field inbound
  groups / edge properties.

Skipped: excluding the current node from the target picker (self-edge). It
predates this PR, applies equally to outbound groups, and whether self-links
are invalid is a separate schema question.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[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