Skip to content

design(mcp): build_po_modify_ui — diff-decorated PO modify card (#721 child) #722

@dougborg

Description

@dougborg

Child of #721 (modify-card redesign umbrella). Applies the #551 framework (entity-view + state machine + status badges + shared tier-1/4 helpers) to purchase-order modify / delete / correct.

Scope

Single new entrypoint build_po_modify_ui(response, *, confirm_request, confirm_tool) in prefab_ui.py.

Covers callers:

  • modify_purchase_order (foundation/purchase_orders.py)
  • delete_purchase_order (foundation/purchase_orders.py)
  • correct_purchase_order (foundation/corrections.py)

All three currently route through _modification.to_tool_resultbuild_modification_preview_ui / build_modification_result_ui. The dispatch in _modification.to_tool_result adds an entity_type == \"purchase_order\" branch that calls build_po_modify_ui.

Content

Same entity view shape as build_po_create_ui from #551 — reuses _PO_FIELD_SPEC — decorated with:

  • Diff display per changed field: before → after rendering driven by the changes parameter to _render_entity_view. The FieldChangeView payload comes from a converter that flattens ModificationResponse.changes per action.
  • Per-field status pills in applied state: each changed field shows APPLIED / APPLIED (verified) / FAILED per the corresponding ActionResult.succeeded + verified flags.
  • Operation grouping is implicit: header-field changes appear under the Header group; row additions/deletions appear under the Line Items group with added/removed kind; additional-cost rows under their own group.

Title verb varies by operation discriminator:

  • modify → "Purchase Order Modify"
  • delete → "Purchase Order Delete"
  • correct → "Purchase Order Correct"

Confirm label + operation_label follow.

Tasks

  • Implement build_po_modify_ui using shared helpers from design(mcp): redesign build_order_preview_ui per #537 four-tier framework (PO / SO / MO) #551.
  • Implement _action_results_to_field_changes (or scope local to PO if cleaner).
  • Implement _action_results_to_field_statuses (parallel — drives the applied-state per-field pills).
  • Add entity_type == \"purchase_order\" branch in _modification.to_tool_result.
  • Tests: TestBuildPOModifyUI with preview / applied / per-action-status / diff-decoration coverage. Field-spec parity test — every field in _PO_FIELD_SPEC that's non-None in the fixture appears in the rendered card.

Acceptance

  • build_po_modify_ui renders the full PO entity view with diff decoration for changing fields and per-field status in applied state.
  • No "Update Header" / "Add Additional Cost" / "N field(s) changed" terminology in the rendered card.
  • Each of modify_purchase_order / delete_purchase_order / correct_purchase_order dispatches to build_po_modify_ui via _modification.to_tool_result.
  • Existing tests for these three tools pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions