Playground UI's build spent most of its time generating `.d.ts` files
through `vite-plugin-dts`, which needs TypeScript 6's classic compiler
API. This runs TypeScript 7's `tsc --emitDeclarationOnly` alongside the
Vite bundle instead, so the package builds about 4.5x faster locally
(~16.5 s to ~3.5 s) with the same published types.
## What changed
- `vite.config.ts`: a small plugin replaces `vite-plugin-dts`. It starts
`tsc -p tsconfig.build.json` (TS 7) once at the first `buildStart`
(Rolldown calls `buildStart` per output format), and once the bundle is
written it moves the declarations into `dist/src`, rewrites `@/` aliases
to relative paths, drops CSS side-effect imports, and writes the
per-entry `dist/<entry>.d.ts` re-export files, same as the plugin did.
Type errors still fail the build.
- Removed `vite-plugin-dts`, its patch, and its `typescript-classic` (TS
6) extension. Other TS 6 users (zod-to-ts, Storybook docgen, the `ts6`
catalog) are untouched.
- Vite 8 follow-ups (folded in from #28130): `@vitejs/plugin-react` 5 →
6.1.2, the version made for Vite 8 that Studio already uses, and
`rollupOptions` → `rolldownOptions`. Build output is unchanged.
- Type-only entry points (`lib/form/types`, `ee/topics/types`,
`domains/chat/om/om-types`, `domains/chat/messages/message-metadata`)
now export their types; `vite-plugin-dts` published them as empty
`export {}`.
## Testing
`pnpm -F @mastra/playground-ui build` on Vite 8 (current main), 5 runs
each, back to back on the same machine (32 cores):
| | runs (s) | median |
| --- | --- | --- |
| main (`vite-plugin-dts`, dts step ~13.5 s) | 16.51, 16.28, 16.54,
16.58, 16.53 | 16.53 s |
| this PR (TS 7 `tsc` in parallel with the ~1.4 s bundle) | 3.58, 3.51,
3.45, 3.54, 3.59 | 3.54 s |
Published types are equivalent to main's:
1. Same files: identical `npm pack` file list and `dist` (2229 `.d.ts`),
and every JS/CSS/map file is byte-identical.
2. Same API: loading both builds' declarations in one TypeScript
program, all 794 entry points export the same 4002 symbols with mutually
assignable types. The only differences are the 19 types now exported
from the four type-only entries above.
3. Typechecking the emitted `.d.ts` with `skipLibCheck: false` gives the
same 36 pre-existing errors on both (missing optional deps like
`@xyflow/system`).
4. Consumers: `@internal/playground` and `@internal/factory-ui`
typecheck; Platform `frontend` typechecks with the same result against
main's build and this one.
5. Playground UI's own typecheck, lint, and full test suite (5920 tests)
pass. A deliberate type error makes `build` exit 1, and only one `tsc`
process runs per build. Storybook starts and serves stories with
plugin-react 6. `pnpm dev` keeps the declarations across watch rebuilds,
and on a clean checkout does the full build with declarations first.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## ELI5
The Playground UI build now creates its type declaration files with
TypeScript instead of a separate declaration plugin. This removes build
tooling and is intended to make builds faster while still failing when
the code has type errors.
## Changes
- Replaced `vite-plugin-dts` with a Vite plugin that runs TypeScript 7
using `tsconfig.build.json` and emits declarations alongside the bundle.
- The plugin moves declarations into `dist/src`, rewrites `@/` imports,
removes CSS side-effect imports, and generates entry-point declaration
files.
- Changed Vite configuration from `rollupOptions` to `rolldownOptions`.
- Removed the `vite-plugin-dts` patch and its `typescript-classic`
package extension.
- Updated `@vitejs/plugin-react` to `6.1.2`.
- Added declarations for types at four entry points and documented the
build process.
## Reported results
The author reports median build times of 16.53 seconds on `main` and
3.54 seconds with this change, based on five runs per version. The
author also reports matching published JavaScript, CSS, and map files;
matching exports across 794 entry points except for 19 newly exported
types; and the same 36 pre-existing declaration typecheck errors.
Reported checks include successful typechecks for
`@internal/playground`, `@internal/factory-ui`, and Platform `frontend`;
passing Playground UI typecheck, lint, and 5,920 tests; and checks for
build failure on a deliberate type error, one `tsc` process per build,
Storybook startup, and declaration retention during watch rebuilds.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
## Impact
The optimization stack reduced observed Mastra Code memory from **2–20
GiB to 300–750 MiB per process** during long-running dogfood sessions.
For this PR specifically, a controlled real-TUI benchmark reduced
`pi-tui` allocation from **101.6 MiB/s to 32.5 MiB/s (−68%)** with
identical terminal output.
## What changed
- Keep assistant render objects stable instead of rebuilding them per
stream update.
- Apply streamed updates at render cadence and preserve completed render
caches.
- Scan ANSI output once on the common path.
- Prune complete chat entries and release every tracked reference.
No scrollback reduction, virtualization, forced GC, or output changes.
## Stack
[#21821](https://github.com/mastra-ai/mastra/pull/21821) process
diagnostics → **2 of 3** →
[#21813](https://github.com/mastra-ai/mastra/pull/21813) live streamed
messages.
> The 2–20 GiB → 300–750 MiB range is observational across varied
workloads. The controlled result attributable to this PR is the 68%
allocation reduction above.
## Validation
Focused tests, typecheck, lint, streaming/pruning real-TUI E2E, and
counterbalanced base/branch profiling pass.
---------
Co-authored-by: Mastra Code (openai/gpt-5.6-sol) <noreply@mastra.ai>
Large streamed tool arguments and shell output could repeatedly rebuild
and rerender expensive TUI previews, making the interface sluggish or
appear frozen during file writes, edits, and long shell commands.
This switches streamed tool-argument parsing to incremental `jsonriver`
state, coalesces bursty renders and shell output, and keeps quiet-mode
previews bounded while still showing a rolling highlighted view of
current progress. It also makes parser and shell-output cleanup
lifecycle-safe, flushes final streamed args before input teardown, and
adds a local Render Smoke provider for reproducing realistic and
stress-rate streams.
Before, each incoming fragment could reparse and rerender the growing
payload. After, parsing remains incremental and visual updates are
applied at a bounded cadence without dropping the final state.
Verified with:
```sh
pnpm --filter ./mastracode/tui exec vitest run src/tui/handlers/__tests__/tool.test.ts src/tui/handlers/tool.test.ts --reporter=dot --bail 1
pnpm --filter ./mastracode/tui check
```
Also manually verified write, edit, and command-argument streaming with
the included Render Smoke server at realistic chat speed.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## ELI5
When Mastra Code streams tool inputs and shell output, the screen would
“jitter” because it tried to re-render too often while data was still
arriving. This PR makes the TUI read streamed JSON incrementally and
only repaint at the right moments, while also cleaning up partial work
safely so interrupted runs don’t leave stale UI.
## What changed
- Tool-argument streaming: replaced `partial-json` with incremental
streaming JSON parsing using `jsonriver`, buffering per `toolCallId`,
updating the tool UI via coalesced renders, and cleaning up parser state
on end/error.
- Render performance: added a `RenderScheduler` plus
`requestRender(state)` (coalesced) and `flushRender(state)` (immediate)
helpers, and rewired many TUI code paths to use them instead of direct
`ui.requestRender()` calls.
- Shell output streaming: buffered streamed shell output per
`toolCallId`, coalesced high-frequency updates, and added lifecycle-safe
cleanup helpers (`clearPendingShellOutputs`, `clearToolInputParsers`)
used across agent/message/tool transitions.
- Render lifecycle hardening: ensured flushes happen at key lifecycle
boundaries (start/end/thread changes/subagents/messages), prevented
duplicate or post-disposal renders via scheduler disposal, and flushed
remaining streamed work before teardown.
- Quiet-mode preview improvements: tightened character/width caps and
quote-aware highlighting for large/streaming `write_file`,
`string_replace_lsp` (edit), and shell command previews; updated tests
to reflect bounded highlighting and rolling preview behavior during
streaming.
- Render Smoke local stress tooling: added `render-smoke:*` scripts, a
local SSE-based mock server, and installer/uninstaller logic with
idempotency and force-uninstall support, enabling realistic
streaming-rate reproduction across platforms and invalid configurations.
- Tests & deps: added/updated Vitest suites for render scheduling,
parser/shell-output cleanup, and streaming/quiet-preview behavior;
bumped `@earendil-works/pi-tui` to `0.80.6`, swapped `partial-json` →
`jsonriver`, and added a patch to optimize `visibleWidth` for printable
ASCII.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Mastra Code (openai/gpt-5.5) <noreply@mastra.ai>
Migrates the workspace to pnpm 11.3.0 and moves pnpm config out of
package.json into pnpm-workspace.yaml, which is where pnpm v11 reads
these settings.
It also enables the global virtual store for faster git worktree
installs:
```yaml
# Share pnpm's virtual store across git worktrees: https://pnpm.io/git-worktrees
enableGlobalVirtualStore: true
```
I also moved the standalone e2e fixture pnpm settings into local
pnpm-workspace.yaml files so their overrides and build approvals still
apply under pnpm v11.
Verified with pnpm 11.3.0 install --frozen-lockfile and git diff
--check.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## ELI5
This PR upgrades the repository to pnpm v11 (11.3.0), moves workspace
pnpm settings out of package.json into pnpm-workspace.yaml so pnpm v11
reads them, and enables a shared global virtual store to speed up
installs (useful for git worktrees). It also updates tests, fixtures,
and CI to use pnpm-specific env vars and workspace-aware installs.
## Changes Overview
### Core changes
- Bumped required pnpm in root package.json: engines.pnpm → >=11.0.0 and
updated packageManager to pnpm@11.3.0 (with new integrity).
- Added/expanded top-level pnpm-workspace.yaml:
- enableGlobalVirtualStore: true to share pnpm’s virtual store across
git worktrees.
- Reworked patchedDependencies to versioned patch entries (e.g.,
`@changesets/get-dependents-graph`@2.1.3/2.1.4, tsup@8.5.1).
- Added packageExtensions (e.g., `@uiw/codemirror-theme-dracula`@*).
- Extended trustPolicyExclude and expanded overrides to constrain many
deps (ssri, qs, zod variants, etc.).
- Broadened allowBuilds to explicitly disable builds for many packages.
### E2E & fixture workspace changes
- Removed pnpm/resolutions and top-level pnpm blocks from many
package.json files and introduced local pnpm-workspace.yaml files in
fixture/e2e directories (commonjs, create-mastra, deployers, monorepo,
no-bundling, type-check, memory, agent-builder, mcp, playground
kitchen-sink, pkg-outputs, etc.).
- Those local pnpm-workspace.yaml files reintroduce necessary overrides
(e.g., ssri >=6.0.2, qs ^6.15.1) and allowBuilds settings so
fixture-specific build allowances and overrides continue to apply under
pnpm v11.
### Tests & tooling updates
- Updated many e2e tests and setup scripts to export pnpm-specific env
vars (pnpm_config_registry, pnpm_config_minimum_release_age, etc.)
instead of npm_config_* so pnpm receives registry/minimum-release-age
configs.
- Extended pnpm-specific env var allowlist (packages/_types-builder)
with additional pnpm_config_* keys.
- Small TypeScript typings and build tweaks (tsup externals, various
Droppable typing updates).
- Patch update: changesets-get-dependents-graph patch updated to
construct Range with includePrerelease: true.
### CI & GitHub Actions
- Composite action explicitly sets up Node 22 via actions/setup-node@v6
and continues to install pnpm via pnpm/action-setup@v4.
- Turbo action now runs turborepo via pnpm dlx (pnpm dlx turbo ...) and
disables telemetry.
- Multiple CI steps and workflows changed pnpm install
--ignore-workspace → pnpm install to be workspace-aware where
appropriate.
### Commit / migration notes
- Added commit(s) to preserve nested pnpm workspace configs for
fixtures, add missing packageExtensions, and make other adjustments
required by pnpm v11 (including explicit allowBuilds in nested
workspaces so frozen installs pass).
- Author verified migration with pnpm 11.3.0 using install
--frozen-lockfile and git diff --check, but noted further
testing/investigation will follow (primary motivation: enable
worktree/global virtual store behavior).
## Impact & reviewer notes
- Requires pnpm >=11.0.0 locally and in CI (declared 11.3.0). Update
local tooling if needed.
- Workspace overrides, patched deps, and build allowances were relocated
to pnpm-workspace.yaml — reviewers should confirm fixture behavior,
package linking, and build approvals still match expectations.
- enableGlobalVirtualStore changes dependency layout/hoisting for
worktree installs; test git worktree installs and CI runs.
- Verify e2e fixtures, CI jobs, and any environment-specific
registry/settings propagate correctly via pnpm_config_* env vars.
<!-- review_stack_entry_start -->
[](https://app.coderabbit.ai/change-stack/mastra-ai/mastra/pull/17038?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)
<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Mastra Code (openai/gpt-5.5) <noreply@mastra.ai>
## Description
Upgrade TypeScript from `5.9.3` to `6.0.3` across the monorepo. TS 6 is
the last JS-based release before the Go-based TS 7 — this upgrade
prepares the codebase for the eventual v7 migration.
### What changed
**Version bump:**
- pnpm catalog: `^5.9.3` → `^6.0.3`
**Deprecated option removals (TS 6 deprecations → errors in TS 7):**
- Removed `baseUrl` from 5 tsconfig files (playground-ui, playground,
react SDK) — `paths` now resolves relative to the tsconfig without
`baseUrl`
- Removed `baseUrl` from 3 e2e test template tsconfigs (no-bundling,
monorepo app, inner-tools)
- Updated root `tsconfig.json` `moduleResolution` from `"Node"` (alias
for deprecated `Node10`) to `"bundler"`
**@types auto-discovery (TS 6 breaking change):**
- Added `"types": ["node"]` to `tsconfig.node.json` (base config for
most packages)
- Added `"types": ["node"]` to standalone tsconfigs that don't extend
`tsconfig.node.json` (`mcp-registry-registry`, `create-mastra`,
`memory/integration-tests`, `playground/e2e/kitchen-sink`)
- Added `"types": ["node"]` to e2e test templates (`commonjs`,
`no-bundling`, `type-check`)
**Build fixes:**
- Patched `tsup@8.5.1` to fix `baseUrl` deprecation error in DTS builder
(upstream
[egoist/tsup#1388](https://github.com/egoist/tsup/issues/1388), unmerged
[fix PR #1390](https://github.com/egoist/tsup/pull/1390))
- Fixed `convex` and `elasticsearch` `tsconfig.build.json` to properly
extend local `tsconfig.json` (matching all other stores)
**Code fixes:**
- Removed 2 now-unused `@ts-expect-error` directives in `packages/core`
for `ReadableStream` async iteration (natively supported in TS 6's
ES2025 lib)
- Added type assertion for `Response.json()` return in `mcp-docs-server`
(now returns `Promise<unknown>` instead of `Promise<any>`)
- Fixed type narrowing in `editor/processor-graph-hydrator.ts` for
`.parallel()` and `.map()` calls
### Verified locally
- **Full monorepo build**: 122/122 tasks pass — all `.d.ts` generation
works correctly
- **Typecheck**: all packages pass
- **Lint**: 112/112 tasks pass
- **E2E tests**: monorepo + no-bundling suites pass locally
## Type of Change
- [x] Code refactoring
## Checklist
- [x] I have made corresponding changes to the documentation (if
applicable)
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] I have addressed all Coderabbit comments on this PR
Link to Devin session:
https://app.devin.ai/sessions/286c1e429f144e4eb8f4a69033a347fd
Requested by: @TylerBarnes
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: tyler <tylerdbarnes@gmail.com>