Commit ebf33b8
feat(mcp): per-entity PO modify card with field-level diff overlay — #722
Foundation + first migration for the #721 modify-card umbrella. Replaces
the today's ``ActionResult``-shaped modify card (which showed "Update
Header / 2 field(s) changed / Operation #1, Target #2641831" — internal
model abstractions the user can't action on) with a per-entity entry
that mirrors the create-card layout and decorates the changing fields
with ``before → after``.
What lands:
- ``FieldChangeView`` + ``_index_changes_by_field`` + ``_render_field_diff_line``
— renderer-facing field-diff projection, shared by every future modify
card. Flattens ``ActionResult.changes`` across all actions into a single
field-name keyed map so the entity view's render code can do simple
``changes.get("expected_arrival_date")`` lookups.
- ``_render_po_entity_view(entity, *, changes=None)`` — the PO entity-view
body, extracted from the old inlined ``build_po_create_ui`` Tier 2/3
content. Called by BOTH the create card (``changes=None``) and the new
modify card. Single source of truth for "what fields show in a PO card";
the create-modify pair can't drift over time.
- ``build_po_modify_ui`` — the new entrypoint. Handles
``modify_purchase_order`` / ``delete_purchase_order`` /
``correct_purchase_order`` (verb from ``confirm_tool``). Renders the
entity view with the diff overlay; the leading ``✗`` glyph + inline
Muted error line appears only on failed actions (the agreed hybrid
status approach — card-level header Badge carries the all/most-case
status, per-field decoration only when it carries information).
- Dispatch in ``_modification.to_tool_result`` — switches on
``response.entity_type``. PO routes to the new entrypoint; other
entities fall through to the legacy ``build_modification_preview_ui`` /
``build_modification_result_ui`` pair until their child PRs (#723 SO,
#724 MO, #725 stock-transfer, #726 item) ship. The legacy builders
delete once every entity migrates.
Tests:
- ``TestFieldDiffIndex`` — pins ``_index_changes_by_field`` projection
(multi-action flattening, added/unchanged kinds, failed-action error
propagation).
- ``TestBuildPOModifyUI`` — smoke + diff-decoration + supplier composite
diff + failed-action ``✗`` glyph + delete verb + partial-failure
header badge + ``state.result`` seeding on applied path.
- ``TestPOEntityViewSharedBetweenCreateAndModify`` — pins the dual-call
contract so a future refactor of ``_render_po_entity_view`` can't
silently drift the create card away from modify.
What this PR does NOT touch (deferred to follow-ups):
- Line-item / additional-cost adds/removes (the ``add_row`` / ``delete_row``
/ ``add_additional_cost`` operations) — the entity view doesn't yet
render those rows. The current PO create card doesn't render them
either, so this is consistent with #728's create-card scope, not a
regression. Adding the nested-rows section is its own follow-up
(probably the next PO modify PR or rolled into the SO migration where
the entity-view component for line-items first matters).
- Other entities (SO, MO, stock_transfer, item) — child PRs #723-#726.
Closes #722
Refs #721
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 96d467e commit ebf33b8
7 files changed
Lines changed: 1894 additions & 131 deletions
File tree
- katana_mcp_server
- src/katana_mcp/tools
- foundation
- tests
- browser
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
554 | 554 | | |
555 | 555 | | |
556 | 556 | | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
564 | | - | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | | - | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
569 | 569 | | |
570 | 570 | | |
571 | 571 | | |
572 | 572 | | |
| 573 | + | |
573 | 574 | | |
574 | 575 | | |
575 | 576 | | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
576 | 591 | | |
577 | 592 | | |
578 | 593 | | |
| |||
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
762 | 762 | | |
763 | 763 | | |
764 | 764 | | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
765 | 775 | | |
766 | 776 | | |
767 | 777 | | |
768 | 778 | | |
769 | 779 | | |
770 | 780 | | |
| 781 | + | |
771 | 782 | | |
772 | 783 | | |
773 | 784 | | |
| |||
777 | 788 | | |
778 | 789 | | |
779 | 790 | | |
780 | | - | |
781 | 791 | | |
782 | 792 | | |
783 | 793 | | |
| |||
Lines changed: 23 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
578 | 578 | | |
579 | 579 | | |
580 | 580 | | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
581 | 589 | | |
582 | 590 | | |
583 | 591 | | |
584 | 592 | | |
585 | 593 | | |
586 | 594 | | |
587 | 595 | | |
| 596 | + | |
588 | 597 | | |
589 | 598 | | |
590 | 599 | | |
| |||
600 | 609 | | |
601 | 610 | | |
602 | 611 | | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | 612 | | |
608 | 613 | | |
609 | 614 | | |
| |||
1097 | 1102 | | |
1098 | 1103 | | |
1099 | 1104 | | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
1100 | 1112 | | |
1101 | 1113 | | |
1102 | 1114 | | |
1103 | 1115 | | |
1104 | 1116 | | |
1105 | 1117 | | |
1106 | 1118 | | |
| 1119 | + | |
1107 | 1120 | | |
1108 | 1121 | | |
1109 | 1122 | | |
| |||
1118 | 1131 | | |
1119 | 1132 | | |
1120 | 1133 | | |
1121 | | - | |
1122 | | - | |
1123 | | - | |
1124 | | - | |
1125 | 1134 | | |
1126 | 1135 | | |
1127 | 1136 | | |
| |||
1537 | 1546 | | |
1538 | 1547 | | |
1539 | 1548 | | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
1540 | 1554 | | |
1541 | 1555 | | |
1542 | 1556 | | |
1543 | 1557 | | |
1544 | 1558 | | |
1545 | 1559 | | |
1546 | 1560 | | |
| 1561 | + | |
1547 | 1562 | | |
1548 | 1563 | | |
1549 | 1564 | | |
| |||
1557 | 1572 | | |
1558 | 1573 | | |
1559 | 1574 | | |
1560 | | - | |
1561 | | - | |
1562 | | - | |
1563 | | - | |
1564 | 1575 | | |
1565 | 1576 | | |
1566 | 1577 | | |
| |||
0 commit comments