feat: condition chip sync (two-way merge, opt-in)#43
Merged
Conversation
Two-way merge with per-item LWW + tombstones. Opt-in setting. Approved across all design sections (data model, merge algorithm, API layer, frontend integration, error handling, testing).
Add render-level Vitest tests for ConditionChips.svelte covering: - defaults render while the backend list loads - custom chips load from listConditionChips on mount - add flow calls addConditionChip with trimmed text (incl. dedup/empty guards) - remove flow calls removeConditionChip and reflects the returned list - graceful degradation: defaults survive list/add/remove failures This is the first true component-render test in the repo. Enabling it required two vitest.config.ts changes (documented inline): - resolve.conditions: ['browser'] so bare imports resolve to the client build (has mount()), not the server build - environmentOptions.jsdom.consumer = 'client' so vite-plugin-svelte emits client components for jsdom tests The test file opts into jsdom via a file pragma so the default 'node' environment used by all other tests is unaffected. Full suite (48 files, 416 tests) still passes. Adds @testing-library/svelte as a dev dependency.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in setting that synchronizes "known condition" chip presets between the office server and remote clients via two-way merge with per-item last-write-wins and tombstones. Default off — each machine keeps its own list unless the user opts in.
Design
Spec:
docs/superpowers/specs/2026-07-03-condition-chip-sync-design.mdPlan:
docs/superpowers/plans/2026-07-03-condition-chip-sync.mdWhat changed
Backend (Rust)
ConditionChiptype (crates/core) — struct with deterministic UUID v5 ID from normalized text (case/whitespace-insensitive)condition_chipstable (migration m010) — id, text, updated_at, deleted_at (tombstones)ConditionChipsRepo(crates/db) — CRUD + the coremerge_incomingLWW function (9 tests covering all merge scenarios: remote-newer, local-newer, tombstone-wins, re-add-after-tombstone, tie-break, idempotency, pruning)sharing_vocab_api.rs) —GET /v1/condition-chips+POST /v1/condition-chips/syncon the existing vocab_portConditionsRemoteHTTP client — mirrors templates_remote, gates on pairing + vocab portsync_condition_chipssetting — defaults false, opt-inFrontend (Svelte 5)
ConditionChips.svelte— loads from Tauri commands instead of settings blob, graceful fallback to defaultsSide improvement
How it works
Test results
cargo test -p medical-core --lib condition_chip— 5 passcargo test -p medical-db --lib condition_chips— 9 passcargo test -p medical-db --lib migrations— 21 passcargo clippy --workspace— cleannpm run check— 0 errors, 0 warningsnpx vitest run— 416 tests pass (full suite)Commits (11 tasks, TDD)
Each commit is a self-contained task with its own tests, following the subagent-driven development workflow with spec + quality review per task.