Skip to content

refactor(mcp): typed Rx refs for prefab Confirm args + pin no-SendMessage on Cancel#85

Merged
dougborg merged 1 commit into
mainfrom
refactor/mcp-typed-rx-refs
May 20, 2026
Merged

refactor(mcp): typed Rx refs for prefab Confirm args + pin no-SendMessage on Cancel#85
dougborg merged 1 commit into
mainfrom
refactor/mcp-typed-rx-refs

Conversation

@dougborg
Copy link
Copy Markdown
Owner

Summary

Closes #54, closes #53.

#54 — Typed Rx refs for CallTool template args. The four Confirm-button CallTool actions used bare-string templates like "{{ preview.order_id }}" to bind iframe state into tool arguments. A typo ("{{ preivew.order_id }}") would silently expand to empty and the host would call the tool with a missing arg — opaque failure. Added a _preview_ref(field) -> Rx helper; the four builders now route through it:

arguments={
    "order_id": _preview_ref("order_id"),
    "status_code": _preview_ref("new_status_code"),
    ...
},

Wire shape is identical (Rx serializes to the same template string), so all 16 existing tests continue to pass. The win is a single namespaced choke-point: the preview. prefix can no longer be typo'd, and field names are greppable.

#53 — Pin no-SendMessage on Cancel. PR #83 already replaced the old SendMessage("Cancel the X") chain with [SetState("cancelled", True), ShowToast(...)], but no test enforced that contract. Added test_cancel_buttons_do_not_send_chat_messages which walks every preview card's envelope, finds each Cancel button, and asserts no sendMessage action in the on_click chain.

Test plan

  • uv run poe check — 300/300 Python tests pass (was 299, +1 new test)
  • All existing prefab UI assertions on "{{ preview.X }}" still pass — Rx serializes to the same template string
  • New test_cancel_buttons_do_not_send_chat_messages would fail if any builder regresses to SendMessage on Cancel
  • Manual: clicking Cancel in Claude Desktop still surfaces the toast + "Cancelled" pill without a chat message

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 20, 2026 21:49
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the MCP prefab preview-card builders to use a centralized, typed Rx helper for preview.* tool-argument bindings, and adds a regression test ensuring Cancel buttons don’t reintroduce chat-noise by firing SendMessage.

Changes:

  • Introduced _preview_ref(field) -> Rx and routed all 4 preview-card Confirm CallTool(arguments=...) bindings through it.
  • Added test_cancel_buttons_do_not_send_chat_messages to assert Cancel buttons never include a sendMessage action in their onClick chain.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
statuspro_mcp_server/src/statuspro_mcp/tools/prefab_ui.py Centralizes preview.* reactive argument references via _preview_ref and updates Confirm CallTool argument wiring in all preview cards.
statuspro_mcp_server/tests/tools/test_prefab_ui.py Adds a regression test that scans preview-card envelopes to ensure Cancel buttons don’t send chat messages.

Comment thread statuspro_mcp_server/src/statuspro_mcp/tools/prefab_ui.py Outdated
@dougborg dougborg force-pushed the refactor/mcp-typed-rx-refs branch from f8860b3 to 36ee222 Compare May 20, 2026 21:56
…sage on Cancel

Closes #54, closes #53.

**#54 — Typed Rx refs for CallTool template args.** The four Confirm-button
``CallTool`` actions used bare-string templates like
``"{{ preview.order_id }}"`` to bind iframe state into tool arguments.
A typo (``"{{ preivew.order_id }}"``) would silently expand to empty and
the host would call the tool with a missing arg, with no signal on our
side. Added a ``_preview_ref(field) -> Rx`` helper next to the existing
action builders; the four builders now go through it:

    "order_id": _preview_ref("order_id"),
    "status_code": _preview_ref("new_status_code"),
    ...

Wire shape is identical (``Rx`` serializes to the same template string),
so all existing tests continue to pass. The win is a single namespaced
choke-point and refactor-safe references — the ``preview.`` prefix can
no longer be typo'd, and field names are greppable.

**#53 — Pin no-SendMessage on Cancel.** PR #83 already replaced the
``SendMessage("Cancel the X")`` chain with
``[SetState("cancelled", True), ShowToast(...)]``, but no test enforced
that contract. Added ``test_cancel_buttons_do_not_send_chat_messages``
which walks every preview card's envelope, finds each Cancel button,
and asserts no ``sendMessage`` action in the on_click chain. Pinning so
a future regression that re-introduces SendMessage on Cancel surfaces
here instead of as chat-noise in production.

Co-Authored-By: Claude <noreply@anthropic.com>
@dougborg dougborg force-pushed the refactor/mcp-typed-rx-refs branch from 36ee222 to eec6641 Compare May 20, 2026 21:57
@dougborg dougborg requested a review from Copilot May 20, 2026 22:05
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@dougborg dougborg merged commit 8587b47 into main May 20, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants