Skip to content

fix(publishing): make the divergence indicator react to structural edits - #892

Merged
chrisdburr merged 1 commit into
stagingfrom
feat/publish-state-reactivity
Aug 17, 2026
Merged

chrisdburr merged 1 commit into
stagingfrom
feat/publish-state-reactivity

Conversation

@chrisdburr

Copy link
Copy Markdown
Collaborator

Summary

Fixes the last defect from the 2026-08-12 staging walkthrough (finding 5): after editing a published case, the canvas badge's "changes pending" indicator only updated on a full page reload.

  • Root cause: the badge's change-detection fetch ran once per mount and was never invalidated — its enable-gate stays true continuously once a case is published, so no dependency ever changed again.
  • Fix: useChangeDetection gains an optional refreshKey; the badge (and, for consistency, the status dialog wrapper) pass the canvas store's case object. The store guarantees exactly one write path to that object — every structural edit replaces it, and comment mutations live in separate slices and cannot touch it — so the indicator reacts live to edits while comment activity stays inert by construction. No polling; the status dialog's instant open is unchanged (guarded by an existing e2e tripwire).
  • New tests: refetch-on-invalidation and stable-reference no-op at the hook level; badge-appears-without-remount and comment-immunity at the component level against the real store.

Review chain

  • QA: PASS — both new tests confirmed to fail on the pre-fix hook; comment-immunity asserted through the real store shape; the one-write-path invariant verified structurally in the store rather than by caller enumeration.
  • Code review: APPROVE — comment-immunity verified at every store call site; one pre-existing, non-blocking finding (the hook lacks a stale-response guard for overlapping fetches, now more reachable) filed as a follow-up issue.
  • Suite on final commit: lint/typecheck clean, unit 1280/1280, integration green vs real Postgres, e2e journey+publishing 7/7.

The canvas publish badge's "changes pending" dot (components/cases/header.tsx)
and the status dialog's divergence copy both fetched change-detection state
once per enable/mount and never invalidated it, so an edit made without
navigating away left both stale until a full reload.

Add an optional refreshKey to useChangeDetection: pass the store's
assuranceCase object, which structural edits always replace (never mutate)
via setAssuranceCase, while comment mutations live in separate store slices
and never touch it — giving reactive invalidation with built-in
comment-immunity, no polling required.
@github-actions

Copy link
Copy Markdown

Fallow combined report

GitHub PR summary, scope: project

Important

Quality gates need attention. Found 2 findings.

Checks

Area Status Result Threshold Details
Dead code warn 1 issue configured rules
Duplication pass 0 clone groups n/a 0.0% duplicated lines
Health fail 1 finding configured complexity gates
Top fixes
Severity Fix Location Why
minor Split branches or add focused tests around the risky path. components/cases/header.tsx:22 'Header' has CRAP score 37.1 (threshold: 30.0, cyclomatic 11)
minor fallow/dev-dependency-in-production package.json:134 devDependency 'tailwindcss' is imported by production code at runtime (consider moving to dependencies)

Generated by fallow.

@chrisdburr
chrisdburr merged commit 1167c9f into staging Aug 17, 2026
5 checks passed
@chrisdburr
chrisdburr deleted the feat/publish-state-reactivity branch August 17, 2026 11:30
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