Skip to content

feat(copilotkit_flutter): send A2UI user actions back to the agent - #256

Open
pietroid wants to merge 2 commits into
feat/a2ui-surface-lifecyclefrom
feat/a2ui-actions
Open

pietroid wants to merge 2 commits into
feat/a2ui-surface-lifecyclefrom
feat/a2ui-actions

Conversation

@pietroid

@pietroid pietroid commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

Status

READY

Description

Closes #96. Part of the A2UI stack (#71). It builds on #255 (surface lifecycle, #246) and uses #250's run-scoped forwardedProps (#243).

Actions on a surface, like a button tap, now go back to the agent the way the runtime's A2UI middleware reads them.

  • Wire. A2uiActionDispatcher calls client.runAgent(agentId, forwardedProps: {a2uiAction: {userAction}}) with no user message. A2uiUserAction maps a2ui_core's A2uiRendererAction to the userAction body: name, surfaceId, sourceComponentId, timestamp, context, plus userMessage, catalogId and metadata when the action has them. The action is the same in v0.9 and v1.0. Only the binding syntax differs (path vs @path), and the context is already resolved. I checked this against @ag-ui/a2ui-middleware 0.0.10 (log_a2ui_event) and 0.0.16 (hidden user message named a2ui_action_context_<43 chars>, so hiddenChatRows already matches), and against React 1.79's runA2UIAction.
  • Statuses. A2uiSurfaceRegistry.actionStatuses / actionStatusChanges hold one status per surface, alongside the lifecycle statuses: A2uiActionPending, A2uiActionFailed (the turn ended with an error) and A2uiActionDropped (runAgent returned false, so nothing was sent and nothing is queued). A surface ignores its own actions while one is pending. A2uiSurfaceView shows an action row under the painted surface. The builder is also on A2uiActivityRenderer and CopilotA2ui, the same way as building, failed and rejected.
  • reportErrorsToAgent (off by default, on CopilotA2ui and A2uiActivityRenderer) sends the errors as one a2ui_error action per turn once the turn ends. Errors from history are not reported. After a report, nothing more is sent until the user acts again, which prevents a loop.
  • Fixtures. Synthetic a2ui_action_round_trip_0_0_10 / _0_0_16 hold the outgoing forwardedProps and then the in-place /items/2 update. The action context carries {itemIndex, pinnedIds, filterMax}. A widget contract test taps the fixture surface and compares the props it sends with both fixtures, and it also covers a v1.0 surface. test(a2ui): recorded runtime wire fixtures for runtime 1.79 and 1.91 #247 will replace these fixtures with recorded ones.
  • Docs. ADR 0022, a README "Actions" section (including how the action context carries local state) and an ARCHITECTURE update.

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

🤖 Generated with Claude Code

pietroid and others added 2 commits December 2, 2026 21:10
…10 and 0.0.16

Synthetic fixtures of a user action: a list surface whose refresh button's
context reads local state, then a run with no user message that carries the
action in forwardedProps.a2uiAction.userAction and an update to /items/2.
0.0.10 echoes the synthetic log_a2ui_event pair; 0.0.16 hides its action
message from the client.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A surface's actions now reach the agent the way the runtime's A2UI
middleware reads them.

- A2uiUserAction maps a2ui_core's A2uiRendererAction (the same in v0.9 and
  v1.0) to the middleware's userAction, and puts itself in the run's
  forwardedProps as a2uiAction.userAction.
- A2uiActionDispatcher calls runAgent with no message and those run-scoped
  props, and reads the end of the turn: no status when it ended well,
  A2uiActionFailed on an error, A2uiActionDropped when runAgent returned
  false because the agent was busy (nothing sent, nothing queued).
- A2uiSurfaceRegistry listens to its processor's actions and keeps
  actionStatuses / actionStatusChanges per surface; a surface ignores its
  actions while one is pending. A2uiSurfaceView shows an `action` row under
  the painted surface, with a builder on the view, A2uiActivityRenderer and
  CopilotA2ui. The renderer builds the dispatcher from the nearest
  CopilotKit client.
- reportErrorsToAgent (off by default) sends the surfaces' errors as one
  a2ui_error action per turn, once it ends; history errors are not
  reported, and nothing more is reported until the user acts again.
- A wire contract test taps the fixture surface and checks the forwarded
  props against both middleware generations' round-trip fixtures.
- ADR 0022, README "Actions" section, ARCHITECTURE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant