feat: add FlowTool, the tool-call card, and its message part - #44
feat: add FlowTool, the tool-call card, and its message part#44divyanshub024 wants to merge 2 commits into
Conversation
…t-plan-5bad8e # Conflicts: # CHANGELOG.md # README.md # docs/public/_redirects # docs/src/content/docs/theming.mdx # lib/flow_ui.dart # lib/src/theme/flow_theme.dart # playground/lib/src/demo_registry.dart # playground/lib/src/playground_item.dart
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 94c026c. Configure here.
| .merge(style?.errorMessageStyle), | ||
| ), | ||
| ), | ||
| ); |
There was a problem hiding this comment.
Error text skips selection block
Medium Severity
errorMessage renders as a bare Text with no FlowSelectionBlock. Sibling cards wrap that same host-written paragraph so a thread copy keeps a newline; without the block, Flutter concatenates the failure with the prose or code on either side.
Triggered by learned rule: FlowThread selection and copy contracts
Reviewed by Cursor Bugbot for commit 94c026c. Configure here.
| color: colors.onSurfaceMuted, | ||
| ), | ||
| ); | ||
| } |
There was a problem hiding this comment.
Header chrome joins thread selection
Medium Severity
The header is documented as chrome, and the title and chip opt out of selection, but the settled status Icons and the chevron do not. Icon paints with RichText, so a drag through the card copies those glyphs into the clipboard.
Additional Locations (1)
Triggered by learned rule: FlowThread selection and copy contracts
Reviewed by Cursor Bugbot for commit 94c026c. Configure here.


Summary
Adds
FlowTool, roadmap item 17: the tool-call card.successonce complete,error_outlineinerroron failure. Nothing new to localize for status.FlowCodeBlocks (jsonand plain by default, wrapping) under host-localized section labels, behind a widget-owned disclosure (initiallyExpanded+onExpandedChanged, theExpansionTilecontract).errorMessagerenders under the header, outside the disclosure, as a live region.FlowToolPartjoins the sealed part model withFlowToolStatus { pending, running, complete, error }.FlowMessagerenders it and keys the card by the provider's callid;FlowThreadforwardstoolInputLabelandtoolOutputLabel. Copy reuses the existingonCodeCopy/copiedCodePartcontract through synthesizedFlowCodeParts, the markdown-fence precedent.FlowToolStylejoins the component styles with aFlowTheme.toolStyledefault. The four accents recolor the mark, never the words.surfaceContainerLowest,outlinefirming tooutlineVarianton hover), not the confirmation's raised one: a tool call is a record of the runtime's work, the confirmation is the host's gate._redirectsline, roadmap rows and changelog entry included.Reviewer notes:
PageStorage, keyed through aPageStorageKeyon the part's wrapper, becauseFlowThreadremounts its subtree when a conversation first outgrows the viewport, which opening a card in a short thread triggers. It is stored under a private identifier built from the key chain rather than the framework's computed one: the blocks'SelectableTextrestores its scroll offset from the same chain and casts it todouble?, which aboolthere crashes. Found in the playground and fixed before this PR.ClipRect+Align(heightFactor:)on one controller shared with the chevron, sinceAnimatedSizedrops the content on the first frame of a collapse.FlowConfirmationPartbeside the tool part.Flexible, so under pressure each gets at most half the row; a priority layout is a possible follow-up. A host-rendered output slot and grouping consecutive calls are out of scope.Screenshots
New component, so no before column.
How this was verified
toolstage in Chrome (web-server build): all five variants, light and dark. Expanding a card inside the 420px thread stays open across the viewport flip, collapses without a bounce, and the two cards keep independent state. Copy shows the check on the right block, the running mark turns, and the phone stage ellipsizes the title and chip.?embed=tool&variant=...&theme=...).flutter analyzeclean at the root and inplayground/;example/reports only its pre-existing missingenv.g.dart.dart format .applied.Checklist
flutter analyze libandflutter analyzeinexample/andplayground/are cleandart format .applieddependencies:inpubspec.yaml(Flutter SDK and flutter.dev packages only)lib/flow_ui.dartand documented indocs/and the README tableCHANGELOG.mdupdated for user-facing changes, with breaking changes called outfeat:,fix:,refactor:,docs:,chore:)Note
Medium Risk
Adds a new sealed
FlowMessagePartsubtype, so host exhaustive switches must handleFlowToolPart; thread/message rendering and PageStorage disclosure logic are non-trivial but presentation-only.Overview
Ships
FlowTool, the tool-call card for assistant turns: a morphing status mark (pending → running → complete/error), host title and detail chip, collapsible input/output as nestedFlowCodeBlocks, and errors visible outside the disclosure.Adds
FlowToolPart/FlowToolStatusto the sealed message-part model.FlowMessageandFlowThreadrender tool parts (thread-leveltoolInputLabel/toolOutputLabel, sharedonCodeCopy), and cards keyed by callidkeep disclosure state in PageStorage across thread remounts.FlowToolStyleandFlowTheme.toolStyleround out theming; public exports, docs, playground variants, roadmap/changelog/README updates included.Reviewed by Cursor Bugbot for commit 94c026c. Bugbot is set up for automated code reviews on this repo. Configure here.