Commit b4c8bcc
committed
fix(mcp): repair DataTable onRowClick per-row binding + Slot/RESULT envelope
#494 asked whether the DataTable ``onRowClick`` per-row ``{{ field }}``
substitution actually works end-to-end through the iframe. It does NOT,
and the new browser tests prove it:
- ``{{ sku }}`` and ``{{ id }}`` are NOT resolved — the renderer's
action-scope spreads the clicked row dict at ``$event``, not into the
scope's top level. Only ``$event``, ``$result``, ``$error``, and
state keys are direct lookups. The renderer leaves unresolved
templates as literal strings, so the host calls ``get_variant_details``
with ``sku="{{ sku }}"`` verbatim and the tool either rejects the
call or treats it as a missing-SKU lookup.
- Even with the substitution fixed, the drill-down still doesn't render
because ``SetState("detail", RESULT)`` puts the full PrefabApp
envelope (``{$prefab, view, defs, state}``) into ``state.detail``,
but ``Slot`` checks ``"type" in D`` on the stored value to decide
whether to render — and the envelope's keys don't include ``type``.
Slot falls back to its placeholder children every time.
Both failure modes are wired together: even if you fix the
substitution, the response card silently doesn't render. Both fixes
are needed, applied in the same commit so the drill-down ships working
end-to-end.
Fix shape
=========
1. ``{{ sku }}`` → ``str(EVENT.sku)`` (compiles to ``{{ $event.sku }}``).
Same for ``{{ id }}`` → ``str(EVENT.id)``. The ``EVENT`` Rx exposes
``$event`` directly, and ``.sku`` / ``.id`` chains via dot-path to
the row dict's fields. Applied to both row-click DataTables:
``build_search_results_ui`` and ``build_item_detail_ui``'s nested
variants table.
2. ``on_success=SetState("detail", RESULT)`` →
``on_success=SetState("detail", RESULT.view)``. The ``RESULT`` Rx
compiles to ``{{ $result }}`` which evaluates to the full envelope;
``RESULT.view`` evaluates to the root view component, which DOES
have ``type`` and renders cleanly inside the Slot.
Verification
============
Three new browser tests in ``test_other_cards_render.py``:
- ``test_search_results_row_click_passes_clicked_sku`` — clicks row
``SKU-0003``, asserts the stub received ``received_sku="SKU-0003"``
(not the literal template, not None, not some other row's SKU).
Cross-process verification via a temp-file the stub writes to.
- ``test_item_detail_variant_row_click_passes_clicked_variant_id`` —
same shape for the item-detail variants table, asserts
``received_variant_id=700002`` (the middle row's id).
- ``test_search_results_row_click_populates_detail_slot`` — full
end-to-end DOM assertion: after click, the echoed response card
("Echoed Variant Details" + the SKU) actually renders inside the
detail Slot.
The substitution-side test ALONE is the diagnostic that catches a
host-side regression in #491-class binding handling. Pre-fix it
caught the literal-template bug; post-fix it pins the working
behavior. The Slot-render test pins the envelope-extraction fix.
Empirical note: the renderer attaches the row-click handler at the
``<td>`` cell level, not the ``<tr>`` row level — ``tr.click()`` and
``tr.dispatchEvent("click")`` both fail to fire the handler, while
``td.click()`` does. The tests use the cell selector as the
canonical click target.
Closes #494.1 parent 7688267 commit b4c8bcc
5 files changed
Lines changed: 277 additions & 24 deletions
File tree
- katana_mcp_server
- src/katana_mcp/tools
- tests
- browser
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
526 | 526 | | |
527 | 527 | | |
528 | 528 | | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
537 | 544 | | |
538 | 545 | | |
539 | | - | |
540 | | - | |
| 546 | + | |
| 547 | + | |
541 | 548 | | |
542 | 549 | | |
543 | 550 | | |
| |||
963 | 970 | | |
964 | 971 | | |
965 | 972 | | |
966 | | - | |
967 | | - | |
968 | | - | |
969 | | - | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
970 | 976 | | |
971 | | - | |
972 | | - | |
973 | | - | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
974 | 981 | | |
975 | 982 | | |
976 | | - | |
977 | | - | |
| 983 | + | |
| 984 | + | |
978 | 985 | | |
979 | 986 | | |
980 | 987 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
| 18 | + | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
| |||
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
| 31 | + | |
28 | 32 | | |
29 | 33 | | |
30 | 34 | | |
| |||
284 | 288 | | |
285 | 289 | | |
286 | 290 | | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
287 | 327 | | |
288 | 328 | | |
289 | 329 | | |
| |||
405 | 445 | | |
406 | 446 | | |
407 | 447 | | |
| 448 | + | |
408 | 449 | | |
409 | 450 | | |
410 | 451 | | |
| |||
537 | 578 | | |
538 | 579 | | |
539 | 580 | | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
540 | 636 | | |
541 | 637 | | |
Lines changed: 147 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
18 | 23 | | |
19 | 24 | | |
20 | 25 | | |
21 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
22 | 35 | | |
23 | 36 | | |
24 | 37 | | |
| |||
84 | 97 | | |
85 | 98 | | |
86 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
773 | 773 | | |
774 | 774 | | |
775 | 775 | | |
776 | | - | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
777 | 780 | | |
778 | | - | |
| 781 | + | |
779 | 782 | | |
780 | 783 | | |
781 | 784 | | |
| |||
805 | 808 | | |
806 | 809 | | |
807 | 810 | | |
808 | | - | |
| 811 | + | |
809 | 812 | | |
810 | 813 | | |
811 | 814 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments