Skip to content

Replace assistant-ui with first-party chat primitives; loop-on-evented-engine, LibSQL write serialization, and stored-agent authors#17721

Draft
mfrachet wants to merge 10 commits into
mainfrom
tree-wisteria
Draft

Replace assistant-ui with first-party chat primitives; loop-on-evented-engine, LibSQL write serialization, and stored-agent authors#17721
mfrachet wants to merge 10 commits into
mainfrom
tree-wisteria

Conversation

@mfrachet

@mfrachet mfrachet commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

This branch lands a set of related improvements across the Studio playground chat experience, the agentic loop engine, storage durability, and server-side author resolution.

Playground chat

  • Removes the @assistant-ui dependency and replaces it with first-party chat primitives (provider, tool card, message row, composer, attachments, voice) shared across both the agent chat and the agent-builder.
  • Renders streamed user attachments correctly and merges a user turn + attachments into a single optimistic bubble (no duplicate bubble).
  • Agent-builder pending indicator renders immediately (removed the 300ms anti-flash delay) while the initial skeleton keeps its delay.

Core / loop engine

  • Runs the agentic loop on the evented workflow engine with run-scoped internal workflow registration, so concurrent/nested runs don't clobber each other and resume still works.
  • Adds a workspace cleanup API with an idempotent destroy() and a shutdown cascade.
  • Supports gateway-owned auth resolution in the model router.

Storage durability

  • Serializes LibSQL writes per client to prevent concurrent autocommit writes from being swept into open transactions (lost-write fix), covering inserts/updates/batch/deletes/clears and interactive write transactions.
  • Shares mergeWorkflowStepResult across LibSQL/PG workflow snapshot updates, with a resilient fallback for non-serializable step results.

Server

  • Adds public-safe author enrichment for stored agents, applied consistently across list/get routes, soft-gated so missing auth/provider degrades gracefully.

Voice (client-sdks/react)

  • Adds agent voice helpers (speech recognition, mic recording, Web Audio playback) and makes agent text-to-speech audible.

Test plan

  • pnpm --filter ./packages/playground test → 1070/1070 pass, typecheck clean
  • LibSQL write-lock + workflows tests → pass
  • Server author-enrichment + stored-agents tests → pass
  • Core loop + workflow suites → pass

Notes

  • A follow-up worth tracking: deleteWorkflowRunById in the LibSQL workflows store is not yet wrapped in the new withClientWriteLock, unlike the other mutation paths.

mfrachet and others added 8 commits June 9, 2026 12:58
…tool card, message row)

The main agent chat is being migrated off @assistant-ui onto useChat +
MessageFactory from @mastra/react, mirroring the agent-builder chat. This lands
the foundational primitives behind the existing entry point so the runtime
contract (streaming, approvals, OM lifecycle, live workflow graphs) is preserved
when the mount is swapped.

- ChatProvider: faithful port of MastraRuntimeProvider onto useChat, with a
  split context (messages, running/cancel, send) and the existing
  ToolCallProvider wired from useChat's stream/generate/network approval
  handlers so every badge keeps working unchanged.
- ToolCard: dedicated component (replaces the renderToolCard idea and
  tool-fallback) taking plain props from MessageFactory; keeps
  useWorkflowStream + WorkflowRunProvider so dynamic workflow runs animate live.
  FileTreeBadge/SandboxExecutionBadge now take dataParts props instead of
  reading assistant-ui message state.
- MessageRow: MessageFactory-driven rendering with role-specific chrome,
  props-driven markdown, reasoning, signal badges, tool routing into ToolCard,
  message-level error/warning/tripwire slots, and user dataset-save /
  attachment / system-reminder UI. DatasetSaveAction and Reasoning are now
  plain-prop and assistant-ui-free.

All new MSW tests green (69 ai-ui tests); package typecheck clean. The mount
swap and deletion of the assistant-ui runtime/adapters follow in a later step.

Co-Authored-By: Mastra Code (anthropic/claude-opus-4-8) <noreply@mastra.ai>
…voice, thread shell, mount swap

Complete the migration of the main agent chat off @assistant-ui onto useChat +
MessageFactory. Rebuilds the thread shell and composer with local state, replaces
the assistant-ui attachment/voice adapters with a self-contained composer-attachments
module and a useReadAloud helper, swaps agent-chat.tsx onto the new ChatProvider, and
deletes the legacy MastraRuntimeProvider / to-assistant-ui-message / tool-fallback /
assistant-message / user-messages files and their tests.

Removes the four @assistant-ui/* dependencies from packages/playground and
@assistant-ui/react-ui (+ its CSS import) from packages/playground-ui, leaving zero
@assistant-ui references in both packages. Tool calls/results, dynamic/streaming
workflow execution (live WorkflowGraph), network routing, and agent-as-tool rendering
are preserved and verified by MSW unit tests and a live browser smoke pass.

Co-Authored-By: Mastra Code (anthropic/claude-opus-4-8) <noreply@mastra.ai>
… builder

Extract the reusable chat-message building blocks so both the agent-chat and
agent-builder surfaces compose the same leaves instead of maintaining parallel
implementations:

- Move Shimmer, the generic ToolCard shell, and a single-dot PendingIndicator
  into @mastra/playground-ui with colocated tests and barrel exports.
- Add a shared ReasoningStreamingLine leaf and route agent-builder reasoning,
  text, tripwire, and warning rendering through the shared primitives.
- Wire the missing Tripwire/Warning status slots into agent-builder.
- Apply the 300ms pending-indicator grace delay on both surfaces.

Also fix agent-chat rendering an empty "Hide reasoning" toggle/box for empty
or redacted reasoning parts: Reasoning now renders nothing when there is no
body and shows a clear label for redacted reasoning.

Co-Authored-By: Mastra Code (anthropic/claude-opus-4-8) <noreply@mastra.ai>
When a user sends a message with an attachment, the playground composer
emits each attachment as its own CoreUserMessage. The optimistic send path
mapped each to its own MastraDBMessage, so streaming rendered the text and
the attachment as two separate user bubbles while memory/reload showed one
combined multi-part message.

Merge all core user messages into a single optimistic MastraDBMessage so
the streaming UI matches the persisted reload shape. The single bubble
carries the clientMessageId so server echo reconciliation still matches.

Co-Authored-By: Mastra Code (anthropic/claude-opus-4-8) <noreply@mastra.ai>
… chat

User-attached images and files rendered blank in Studio chat while a
response was streaming. Fix the file-part shape used by the streaming
renderer so attachments display during streaming, matching how they
appear after a page reload.

Co-Authored-By: Mastra Code (anthropic/claude-opus-4-8) <noreply@mastra.ai>
@changeset-bot

changeset-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0fae4de

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@mastra/playground-ui Patch
@mastra/react Patch
@internal/playground Patch
mastra Patch
create-mastra Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5e005d7b-fa70-4ecc-ac94-bc3e3cec4ca1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tree-wisteria

Comment @coderabbitai help to get the list of available commands and usage tips.

@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
mastra-docs-1.x Ready Ready Preview, Comment Jun 9, 2026 7:00pm
mastra-playground-ui Ready Ready Preview, Comment Jun 9, 2026 7:00pm

Request Review

mfrachet and others added 2 commits June 9, 2026 19:59
Keep optimistic user message keys stable during reconciliation and restore model-list response attribution in Playground so refactored chat rows preserve the prior user experience.

Co-Authored-By: Mastra Code (openai/gpt-5.5) <noreply@mastra.ai>
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