feat(desktop,host-service): delete legacy mastra chat in favor of chat-v3

Merged
SA
3mo ago
+303-32592

579 files, −32,592 lines. Removes both legacy mastra chat stacks. chat-v3 (ChatV3Pane, behind the chat-v3 flag) is the replacement and is untouched — verified present along with packages/chat, packages/chat-runtime, and host-service/src/chat-v3.

This is a deliberate user-facing removal

Legacy chat had ~46 sustained users (active 3+ weeks with 20+ messages), 25 of them heavy, generating 67% of messages. But of 575 users who touched it in 30 days, 87% sent fewer than 20 messages and averaged barely one active week, and 85–90% of first-timers never returned. Approved on that basis.

Deleted

AreaFiles
desktop shared chat components162
desktop v2 ChatPane123
desktop v1 ChatPane78
packages/chat-legacy23
provider-auth passengers (slash commands, file search, MCP overview)20
host-service model-providers14
host-service chat runtime + chat router (14 procedures)4
desktop chat-runtime-service IPC + chat-preferences store3
other dead paths10

Two removals beyond the obvious, both verified:

  • model-providers — ModelProviderRuntimeResolver was passed only to ChatRuntimeManager; after deletion there are zero references to prepareRuntimeEnv/hasUsableRuntimeEnv repo-wide. Terminal agents never used it.
  • The chat-kind agent concept in packages/shared — with agents.run's chat branch gone, the superset agent could never launch (no hostAgentConfigs row carries that preset id), so leaving it would have meant an agent in the picker that always threw. Rippled into cli/sdk/mcp/automation dispatch. The preset model override went with it, since it existed solely for the chat agent.

What survives, deliberately

  • Provider auth: settings/models and onboarding still drive OAuth and API keys through provider-auth's auth namespace. Only its workspace namespace — the chat features that rode along in #6441 as hostages of a single router — is deleted.
  • Rescued rather than dropped (30 renames): the provider OAuth dialogs and hooks now live in renderer/components/ProviderAuth/, and the Tiptap prompt editor the v2 terminal rich input depends on moved to renderer/components/TiptapPromptEditor/. Both were importing from inside the deleted chat tree.
  • v1 layouts: tabs persist version 9 → 10 with a migration that downgrades persisted chat panes to terminal panes, so old layouts keep rendering instead of hitting an unhandled pane type. chat-preferences moved to DEAD_KEYS per apps/desktop/AGENTS.md.

Deps removed: @mastra/memory, @ai-sdk/anthropic, @ai-sdk/openai, @ai-sdk/react, @mastra/core (desktop). mastracode stays — it backs provider-auth's credential storage and the mastracode terminal agent, which is unrelated to chat.

Out of scope

The cloud chat router and chat_sessions/chat_attachments tables (FKs from automation_runs; separate cleanup).

Verification

lint 0 · typecheck 0 (36/36) · sherif 0 · host-service 1071/1071 · desktop 2617/2617 · provider-auth 53/53 · full monorepo test 15/15 tasks green. Neither known host-service flake fired.


Summary by cubic

Remove legacy Mastra chat (v1/v2) from desktop and host-service and consolidate on chat‑v3. Old behavior: chat panes and a mastra-backed runtime. New behavior: only chat‑v3 (behind the chat-v3 flag); no "chat" pane type or sessionId-based resolution.

  • Desktop: drop the chatRuntimeService router; remove the "chat" pane type from UI state; update notifications resolver/tests to remove sessionId lookups; delete the legacy Chat UI tree.
  • Host-service: remove the chat runtime and router; delete the model-provider subsystem and the LocalModelProvider wiring.
  • Settings: normalizeAgentPresetPatch no longer takes an AgentDefinition; call sites updated.
  • Dependencies: remove @ai-sdk/anthropic, @ai-sdk/openai, @ai-sdk/react, @mastra/core, and @superset/chat-legacy.
  • Behavior: persisted layouts referencing chat panes are downgraded to terminal panes; slash commands/file search/MCP overview tied to legacy chat are removed; provider auth continues via auth: routes.

Migration/rollout

  • Replace any code that creates or expects pane.type: "chat"; use terminal panes or the chat‑v3 pane flow.
  • Update calls to resolvePaneId(...) to the new signature without sessionId.
  • Remove any client usage of the chatRuntimeService TRPC router.
  • If you imported provider OAuth dialogs/hooks or the Tiptap prompt editor from the old Chat tree, update imports to renderer/components/ProviderAuth/ and renderer/components/TiptapPromptEditor/.
  • Ensure builds do not depend on removed packages (@ai-sdk/*, @mastra/core, @superset/chat-legacy).
  • Host-service consumers: stop passing modelResolver when starting the service.
  • If you call normalizeAgentPresetPatch, drop the definition argument.