Repository navigation
feat(cards,modals): Chart, Table options, tooltips, Card width, DateInput/NumberInput, dispatch_action (#202) - #253
Conversation
…DateInput/NumberInput, dispatch_action (#202) Core slice of upstream 4717a384 (chat@4.34.0), 0153a39f (chat@4.36.0), 4a0b5c0c (chat@4.40.0), 84219537 and ad904325 (chat@4.41.0): - cards: Chart() + Chart* TypedDicts, chart_element_to_fallback_text (JS String() number formatting), chart case in card fallback text and shared card_utils; Table caption/page_size/widths/vertical_align/ grid_lines/grid_style; Button/LinkButton tooltip; Card width. - modals: DateInput/NumberInput children (+ VALID_MODAL_CHILD_TYPES, ModalChild); dispatch_action on Select/RadioSelect. - Root exports, upstream-named tests, UPSTREAM_SYNC/CHANGELOG, and regenerated fidelity_target.json (282 -> 265 missing). Additive only: unset options are omitted, so existing output is unchanged. Part of #184
|
Warning Review limit reachedNext included review available in 58 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (10)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…art/tooltip gap docs (#202)
|
Merge gate: CI green (Analyze (actions), Analyze (python), CodeQL, Lint & Type Check, test (3.12), test (3.13)); local Codex review (gpt-6-astra, xhigh, --base origin/main) on 4f294d2: "No actionable regressions found within the documented core-only scope. Targeted card, modal, and export tests passed, along with type checking, linting, and strict upstream test-fidelity verification."; 1 recorded astra round on the final HEAD (earlier review feedback addressed in 4f294d2); origin/main already an ancestor, so no re-merge was needed; CodeRabbit rate-limited (no review posted), no human reviews. Merging with --admin (Protect Main requires a code-owner approval). |
Summary
This PR ports the platform-neutral card and modal builder additions from chat@4.34–4.41. It covers only the builders, TypedDicts, fallback text and exports. Adapters render the new fields in #212 (Slack) and #220 (Teams).
cards.pyChart(title=, chart=)builder andchartalias.ChartSegment,ChartDataPoint,ChartSeries,PieChartDefinition,SeriesChartDefinition(x_label/y_label),ChartDefinitionandChartElement.ChartElementis added toCardChild.chart_element_to_fallback_text()renders the title followed by an ASCII table.Label/Valuerows.card_child_to_fallback_textandshared/card_utils.py::_child_to_fallback_text.Table()gainscaption,page_size,widths,vertical_alignandgrid_lines, plusgrid_style, with the newTableVerticalAlignmentandTableGridStyletypes.Button()/LinkButton()gaintooltip.Card()gainswidth(CardWidth).modals.pyDateInput()/NumberInput()builders, their TypedDicts and thedate_input/number_inputaliases. Both types are added toVALID_MODAL_CHILD_TYPESandModalChild.dispatch_actiononSelect()/RadioSelect().chat_sdk/__init__.py: every new builder, alias and type is exported and listed in__all__.Upstream commits mapped
4717a384(#696)Chart*types,Chart(),chartElementToFallbackText,Tablecaption/pageSize0153a39f(#757)DateInput/NumberInputelements and builders, valid modal children4a0b5c0c(#895)CardWidth,Card.width,tooltiponButton/LinkButton(the callback-URL half belongs to #194)84219537(#906)TableVerticalAlignment,TableGridStyle,widths/verticalAlign/gridLines/gridStylead904325(#952)dispatchActiononSelect/RadioSelect929878b5(#838)LinkButton(id=...)already exists. Recorded in the jsx-runtime row ofdocs/UPSTREAM_SYNC.mdTests ported
Every upstream test name listed in the issue now exists:
tests/test_cards.py(11 tests)tests/test_modals.py[Select, RadioSelect] × [True, False, None]min=0,max=0anddecimal=FalseDateInput/NumberInput, matching upstream's updated test.45.0→45,1.5,-0.0→0,0.00001,1e-7,1e21→1e+21,10**21, NaN, Infinity, and others.x_labelrender as empty cells.card_to_fallback_textand the adapter-sharedcard_to_fallback_textboth include the chart.tests/test_root_reexports.py).fromReactModalElementcopy of "preserves dispatchAction=%s", and the jsx-runtime tooltip/width cases.Fidelity (
--report-targetat chat@4.41.1,scripts/fidelity_target.jsonregenerated):Two notes on the modals numbers:
test_valid_children_pass_throughused to be fuzzy-matched to the unrelated JSX test "should pass through plain modal children", which now correctly reports as missing.[DateInput]/[NumberInput]"should create with required fields" / "should include optional fields" as missing. Those names are shared withTextInput/ExternalSelect, and the matcher counts names without regard to whichdescribeblock they belong to. The DateInput and NumberInput tests are ported; the remaining misses are theTextInput/ExternalSelectgaps tracked in Extend verify_test_fidelity.py MAPPING to cover all packages/chat/src/*.test.ts #78.Strict at the pin: 733/733 (unchanged).
Validation
audit_test_quality: 0 hard failures--check-docs: pass--strictat chat@4.31.0: passDivergences
None are added to the non-parity table. Notes:
_js_number_to_string, which implements ECMAScriptNumber::toString. The goal is to match upstreamString(v)output ("Kit Kat | 45"for45.0). I checked it against NodeString()on 80,000 random doubles and found no mismatches. The only differences are thatintvalues below1e21render exactly (JS rounds them above 2**53) and aNonevalue renders as"". Other numeric types (Decimalfrom PostgresNUMERIC,Fraction, NumPy scalars) are converted toint/floatfirst, soDecimal("45.00")renders"45". This is recorded indocs/UPSTREAM_SYNC.mdunder "Card and modal builders".None, where upstream sets them toundefined. This is the repo's standard convention (hazard fix: launch must-fix items — security, perf, docs #7), not a new divergence.Consumer impact
The change is additive. With the new options unset, the output of
Card(),Table(),Button(),LinkButton(),Select()andRadioSelect()is byte-identical to before; tests assert this forTable,Card, the tooltips anddispatch_action.modal_to_slack_viewraisesValueErrorfordate_input/number_input.slack.blocksprimitives (card_to_slack_blocksandcard_to_slack_fallback_text) raiseSlackBlockErrorfor achartchild.data_visualizationblock.dispatch_action,captionandpage_sizeare ignored.Button(callback_url=..., tooltip=...)losestooltipwhen the URL is swapped for a token, becausecallback_url.pystill copies a fixed key list. fix(callback-url): single-use, conversation-bound callback tokens with 7-day TTL (#194) #256 ports upstream's keep-every-field copy. No adapter renderstooltipbefore [4.41/T5] Teams cards & dialogs: Adaptive Card 1.5 Table, tooltips, width, Input.Date/Number #220.Closes #202
Part of #184
Merge gate
Reviewer findings (2 independent reviewers, 4 findings), all fixed in
4f294d2:tooltipdropped fromcallback_urlbuttons. Real. The fix, the keep-every-field copy, is owned by [4.41/CB] Callback tokens: consume once, bind to conversation, shorter TTL, preserve button fields #194 (PR fix(callback-url): single-use, conversation-bound callback tokens with 7-day TTL (#194) #256, which rewrites the same hunk), so it is not duplicated here. The gap is now documented in the CHANGELOG bullet and in thedocs/UPSTREAM_SYNC.md"Card and modal builders" section._js_number_to_stringrenderedDecimal("45.00")as"45.00"andFraction(1, 2)as"1/2". Non-intIntegral values are now converted toint, andDecimalor other Real values tofloat, before formatting. Three new parametrized cases fail without the fix.DateInput/NumberInputoptional/placeholderand onTablepage_sizesurvived. Addedtest_falsy_optional_and_placeholder_are_keptandtest_keeps_empty_caption_and_zero_page_size. All five modal mutations and thecaption/page_size/widthsmutations are now caught.cards.tsdefault: return []). They also note thatslack.blockscard_to_slack_fallback_textraises for charts until [4.41/SL7] Slack cards & modals: data_table / data_visualization blocks, datepicker, number_input, selection change events #212.gpt-6-astra: 1 round, on
4f294d2. The verdict was clean: "No actionable regressions found within the documented core-only scope."Bots: CodeRabbit was rate-limited and posted no review comments. There were no Gemini comments.
CI on
4f294d2: all green (Lint & Type Check, test 3.12 and 3.13, CodeQL).Local validation: all green: ruff, audit (0 hard failures),
--check-docs,--strict733/733 at chat@4.31.0, pytest 5604 passed, pyrefly 0 errors. Fidelity:Delta vs committed report (HEAD): missing 265 -> 265 (+0). These are Python-only tests, and the total stays at 265 against chat@4.41.1.