Skip to content

Modify-card Tier-1 state badge frozen at build time — PARTIAL FAILURE shows APPLIED on PO/SO morph path #860

@dougborg

Description

@dougborg

Problem

The Tier-1 state badge on _render_preview_header is rendered from a Python-time string (applied_state_label / applied_state_variant) which is baked into the Prefab tree at build time. On the in-place preview→Confirm morph path, the header badge ALWAYS reads APPLIED (default/green variant) — even when the apply outcome is PARTIAL FAILURE or FAILED.

The on_success SetState chain in build_so_modify_ui (and similarly in build_po_modify_ui) already seeds state.applied_outcome_label / state.applied_outcome_variant slots, but nothing binds them to the header Badge. The per-field glyphs and the state-driven sub-entity failed-action Alert provide partial signals, but the prominent Tier-1 badge stays frozen at success chrome.

The standalone-applied path (when the apply response is rendered directly, is_preview=False) already handles this correctly — applied_state_label / applied_state_variant are overwritten with the actual outcome bucket before tree construction. The gap is specifically the in-place morph path.

Where this manifests

Fix shape

Convert _render_preview_header to emit two parallel Badge branches keyed off state.applied_outcome_label, mirroring the BOM card. Cleanest factoring is probably a helper that takes the state-slot names and renders the If/Elif/Else fork once.

Because the rendered tree shape changes for every consumer of _render_preview_header, this is a cross-card sweep, not a single-card fix. Splitting it into its own PR keeps #858 + #722 reviewable as the per-card landing for SO/PO and lets the badge-morph land as one focused diff.

Acceptance criteria

  • Existing PO + SO modify card tests still pass.
  • Browser test for the SO morph path (added in feat(mcp): build_so_modify_ui — diff-decorated SO modify card #858) extends to assert the post-Confirm header badge reads PARTIAL FAILURE / destructive.
  • BOM modify card pattern factored into a reusable header helper, or the SO/PO header builders adopt the same inline If/Elif/Else.

Refs

Priority + Workstream

P2-soon (visible UX bug but not a workflow break — the sub-entity Alert + per-action glyphs still surface the failure), Cards workstream.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions