Skip to content

fix: keep hotspot conditional branches coherent across UI and persistence#42

Merged
trmquang93 merged 1 commit intomainfrom
fix/conditional-connection-coherence
Apr 27, 2026
Merged

fix: keep hotspot conditional branches coherent across UI and persistence#42
trmquang93 merged 1 commit intomainfrom
fix/conditional-connection-coherence

Conversation

@trmquang93
Copy link
Copy Markdown
Collaborator

Summary

Conditional connections carry two indicators — connectionPath (renderer) and conditionGroupId (modal/grouping). These could drift apart, producing branches that rendered as conditional but reopened in plain navigate mode. This PR makes hotspot-backed conditional groups coherent across creation, mutation, deletion, and load.

  • New canonical isConditionalConnection predicate in utils/connectionHelpers.js; consumed by ConnectionEditModal and useInteractionCallbacks.
  • saveHotspot now stamps a single shared conditionGroupId across each branch and its api-success/api-error sub-branches.
  • deleteConnection on a hotspot branch rebuilds hotspot.conditions from surviving connections and collapses back to plain navigate when only one remains.
  • convertToConditionalGroup / addToConditionalGroup mirror new branches onto the hotspot, so HotspotModal opens with the full set.
  • importFlow heals legacy v1–v9 files in two idempotent passes (path → groupId, groupId → path).

Test plan

  • npm run lint clean
  • npm test — 699/699 pass (new tests in useScreenManager.test.js and importFlow.test.js)
  • Manual: create a hotspot conditional group, delete one branch, verify HotspotModal reopens with the right remaining conditions
  • Manual: convert a single hotspot connection to conditional via drag-to-existing; double-click — modal opens in conditional mode
  • Manual: load a v9 file with mismatched connectionPath/conditionGroupId and confirm both renderer and modal agree

…ence

Conditional connections carry two indicators — `connectionPath` (renderer)
and `conditionGroupId` (modal/grouping). They could drift apart in three
flows, producing branches that rendered as conditional but reopened as
plain navigate (or vice versa):

- saveHotspot wrote per-branch connections without a shared conditionGroupId
- deleteConnection on a hotspot branch left the owning hotspot.conditions stale
- convertToConditionalGroup / addToConditionalGroup updated connections only,
  not the hotspot, so HotspotModal opened with a stale single target
- legacy v1–v9 .drawd files could load with mismatched indicators

Fixes:
- New canonical `isConditionalConnection` predicate in utils/connectionHelpers.js
- saveHotspot now stamps a single shared conditionGroupId across each branch
  and its api-success/api-error sub-branches
- deleteConnection rebuilds hotspot.conditions from surviving branches,
  collapsing back to plain navigate when only one remains
- convert/addToConditionalGroup mirror the new branch onto the hotspot
- importFlow heals legacy mismatches in two idempotent passes
@trmquang93 trmquang93 merged commit cd25a02 into main Apr 27, 2026
1 check passed
@trmquang93 trmquang93 deleted the fix/conditional-connection-coherence branch April 27, 2026 00:25
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