Skip to content

fix(mothership): thinking and subagent text#3613

Merged
emir-karabeg merged 11 commits intostagingfrom
fix/mothership-thinking
Mar 17, 2026
Merged

fix(mothership): thinking and subagent text#3613
emir-karabeg merged 11 commits intostagingfrom
fix/mothership-thinking

Conversation

@Sg312
Copy link
Collaborator

@Sg312 Sg312 commented Mar 16, 2026

Summary

Improves the Mothership chat experience and redesigns key landing/home UI surfaces.

Mothership Chat:

  • Adds first-class <thinking> tag support — model reasoning traces are parsed via parseSpecialTags and suppressed from the UI
  • Tracks subagent text blocks explicitly with a subagent field on ContentBlock, so text emitted inside a subagent context stays grouped within its AgentGroup
  • Introduces a subagent_end block type to properly close subagent groups and trigger a delayed PendingTagIndicator when a subagent/tool run finishes without trailing text
  • Enhances tool call display: successful calls for certain tools (search_online, scrape_page, function_execute, etc.) now render as expandable card outputs with formatted result bodies
  • Replaces the Loader spinner with a new animated PillsRing icon for executing tool calls
  • Adds ToolCallResult type (success, output, error) and passes result data through to ToolCallItem

Landing Page:

  • Completely overhauls the features preview section (~1,000+ new lines) with interactive workspace, mothership, and default preview animations
  • Redesigns the navbar with dropdown menus for Blog and Docs links
  • Makes the collaboration section fully mobile-responsive (layout, typography, image sizing)
  • Updates the footer layout

Home Templates:

  • Redesigns template cards with rich visual previews (mini workflow diagrams, table previews, knowledge base previews, file previews) instead of static icons
  • Removes the expand/collapse toggle — all templates are now shown in categorized groups
  • Makes the template grid responsive (grid-cols-1grid-cols-3) and adds contentVisibility: 'auto' for rendering performance
  • Memoizes TemplateCard and WorkflowMiniBlock components
  • Adds a slide-in animation for the chat input bar on first submission

Blog:

  • Renames the blog route from /studio to /blog across all pages, content, and static assets
  • Adds WebP thumbnail images for blog posts
  • Updates author/content image paths

Other:

  • Redesigns the 404 page
  • Updates auth page layouts for consistency
  • Hardcodes isProd and isHosted feature flags to true
  • Removes unused ChatSkeleton loading state
  • Sidebar and workspace header UI adjustments
  • Docs layout and favicon updates

Fixes #(issue)

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: UI/UX improvements, route rename (/studio/blog)

Testing

  • Verify Mothership chat: send messages that trigger subagent usage and tool calls — confirm thinking tags are hidden, subagent text stays grouped within its agent group, and tool results render as cards for supported tools
  • Verify the PendingTagIndicator appears briefly after a subagent/tool finishes when no trailing text is present
  • Test the landing page on mobile and desktop — navbar dropdowns, collaboration section responsiveness, features preview transitions
  • Confirm /blog routes work and /studio redirects are configured in next.config.ts
  • Check home template grid renders correctly at all breakpoints with visual previews
  • Confirm the 404 page renders the new design
  • Note: isProd and isHosted are hardcoded to true — verify this doesn't break self-hosted/dev environments (see Cursor Bugbot flag)

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Mar 16, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Mar 17, 2026 2:53pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 16, 2026

Greptile Summary

This PR improves how the mothership chat renders AI thinking blocks and subagent text by parsing <thinking> tags from streamed content, properly scoping text blocks to their originating subagent, introducing result cards for completed tool calls, and showing a "Thinking…" indicator between subagent turns.

Key changes:

  • <thinking> tag support: parseSpecialTags now recognises <thinking>…</thinking> as a first-class ContentSegment type; the content is passed through the markdown prose renderer in chat-content.tsx, and SpecialTags returns null as a safe fallback.
  • Subagent text scoping: use-chat.ts tags outgoing text blocks with the active subagent name; parseBlocks routes those blocks into the owning AgentGroup rather than the main conversation stream.
  • subagent_end block type: signals the close of a subagent turn both to the parser (flushes the current group) and to the "trailing thinking" heuristic.
  • Tool result cards: ToolCallItem now renders a collapsible result card for tools in CARD_TOOLS once they succeed, replacing the plain flat line.
  • showTrailingThinking indicator: shows "Thinking…" while the model is between subagent turns or after all tools in the last group have completed — but the current guard has a logic gap where it also fires when a subsequent agent group still has executing tools (see inline comment).
  • Panel layout fix: MothershipView gains relative z-10 bg-[var(--bg)] to prevent visual bleed-through.

Confidence Score: 3/5

  • Mostly safe but contains a logic bug that causes the "Thinking…" indicator to display while tools are actively executing.
  • The streaming/rendering refactor is well-structured, and the use-chat.ts and tool card changes are solid. However, showTrailingThinking fires when a prior subagent has ended even if the current agent group still has in-flight tools, producing a misleading UI state. There is also a secondary edge case where subagent-tagged text blocks can be appended to the wrong agent group if the active group belongs to a different subagent.
  • apps/sim/app/workspace/[workspaceId]/home/components/message-content/message-content.tsx — the showTrailingThinking condition and the subagent-text group guard both need tightening before merge.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/home/components/message-content/message-content.tsx Core rendering logic updated to handle subagent_end blocks, tag subagent-emitted text blocks into agent groups, and show a trailing "Thinking…" indicator — but the indicator condition incorrectly fires while a later agent group still has executing tools, and the subagent-text guard doesn't validate that the active group belongs to the same subagent.
apps/sim/app/workspace/[workspaceId]/home/types.ts Adds ToolCallResult interface, result field on ToolCallData, subagent_end content block type, and subagent field on ContentBlock. Minor inconsistency: ToolCallInfo.result still uses an inline type instead of the new ToolCallResult.
apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/agent-group/tool-call-item.tsx Significantly refactored: introduces FlatToolLine for simple tool status display, ToolCallCard for card-style rendering of result output for tools in CARD_TOOLS, and a StatusIcon helper. Replaces Loader with PillsRing spinner. Logic looks correct.
apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/special-tags/special-tags.tsx Adds thinking to SPECIAL_TAG_NAMES and the ContentSegment union; <thinking> blocks are parsed but the SpecialTags renderer returns null for them, while chat-content.tsx handles them via the markdown path. SpecialTagsProps technically allows a thinking segment even though it never reaches SpecialTags in practice.
apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts The ensureTextBlock helper now guards by activeSubagent to prevent reusing blocks across subagent boundaries; subagent_end events push a typed block; content text blocks are tagged with the activeSubagent name. Changes look correct.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[SSE stream: content event] -->|activeSubagent set| B[Tag text block with subagent name]
    A -->|no activeSubagent| C[Plain text block]

    D[SSE stream: subagent_end] --> E[Push subagent_end block]
    E --> F[activeSubagent = undefined]

    B --> G[parseBlocks]
    C --> G
    E --> G

    G -->|block.subagent && group| H[Append to AgentGroup items]
    G -->|block.type === subagent_end| I[Flush current group to segments]
    G -->|plain text block| J[Flush group → push TextSegment]
    G -->|tool_call isDispatch| K[Open new AgentGroup]
    G -->|tool_call calledBy| L[Nest under matching AgentGroup]

    M[MessageContent renders segments] --> N{showTrailingThinking?}
    N -->|isStreaming && !hasTrailingContent && hasSubagentEnded or allToolsDone| O[Show PendingTagIndicator]
    N -->|else| P[No indicator]

    style O fill:#f9a,stroke:#c55
    style H fill:#afa,stroke:#585
Loading

Comments Outside Diff (1)

  1. apps/sim/app/workspace/[workspaceId]/home/types.ts, line 146-154 (link)

    P2 ToolCallInfo.result duplicates the new ToolCallResult interface

    This PR introduces ToolCallResult (lines 132–136) with the exact same shape as the inline result type on ToolCallInfo. Keeping the two in sync manually is error-prone. Reference the new interface directly:

Last reviewed commit: 17c12ea

@cursor
Copy link

cursor bot commented Mar 17, 2026

PR Summary

High Risk
High risk because it introduces a new CSV import API that creates and bulk-inserts table data, changes tool-approval behavior in the copilot/mothership orchestrator, and hard-codes isProd/isHosted feature flags to true, which can impact environment-specific security/feature gating.

Overview
Improves streamed chat rendering for Mothership/Subagents by adding support for a <thinking> tag (suppressed in UI), tracking subagent text blocks explicitly (including a new subagent_end block), and showing a delayed PendingTagIndicator when a subagent/tool run finishes without trailing text.

Enhances tool call display by passing tool results through message blocks and rendering successful tool calls for certain tools as expandable “card” outputs; swaps the executing spinner to a new animated PillsRing icon.

Adjusts orchestration behavior by gating “requiresConfirmation” waits behind a new promptForToolApproval option (enabled for /api/copilot/chat, disabled for /api/mothership/chat), and adding an MCP build tool path that uses the main orchestrator in fast mode with workflow authorization.

Adds CSV/TSV → Tables import via a new /api/table/import-csv endpoint with schema inference, name sanitization, batching, and rollback on failure, plus UI/hooks to upload CSVs from the Tables page (header action + context menu) and invalidate relevant React Query caches.

Also includes various UI/layout tweaks (navbar/pricing spacing, sidebar headers, text wrapping/overflow) and updates deployment tool outputs/handling to include workflowId and respect isDeployed/deployedAt semantics.

Written by Cursor Bugbot for commit ceba8cf. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: Hardcoded isProd and isHosted break self-hosted deployments
    • Restored isProd to check NODE_ENV and isHosted to check NEXT_PUBLIC_APP_URL instead of being hardcoded to true.
  • ✅ Fixed: Logging full tool output may leak sensitive data
    • Removed the output field from the tool success log entry to prevent sensitive data from appearing in logs.

Create PR

Or push these changes by commenting:

@cursor push 3eed0e0545
Preview (3eed0e0545)
diff --git a/apps/sim/lib/copilot/orchestrator/sse/handlers/tool-execution.ts b/apps/sim/lib/copilot/orchestrator/sse/handlers/tool-execution.ts
--- a/apps/sim/lib/copilot/orchestrator/sse/handlers/tool-execution.ts
+++ b/apps/sim/lib/copilot/orchestrator/sse/handlers/tool-execution.ts
@@ -455,7 +455,6 @@
       logger.info('Tool execution succeeded', {
         toolCallId: toolCall.id,
         toolName: toolCall.name,
-        output: result.output,
       })
     } else {
       logger.warn('Tool execution failed', {

diff --git a/apps/sim/lib/core/config/feature-flags.ts b/apps/sim/lib/core/config/feature-flags.ts
--- a/apps/sim/lib/core/config/feature-flags.ts
+++ b/apps/sim/lib/core/config/feature-flags.ts
@@ -1,12 +1,12 @@
 /**
  * Environment utility functions for consistent environment detection across the application
  */
-import { env, isFalsy, isTruthy } from './env'
+import { env, getEnv, isFalsy, isTruthy } from './env'
 
 /**
  * Is the application running in production mode
  */
-export const isProd = true
+export const isProd = env.NODE_ENV === 'production'
 
 /**
  * Is the application running in development mode
@@ -21,7 +21,9 @@
 /**
  * Is this the hosted version of the application
  */
-export const isHosted = true
+export const isHosted =
+  getEnv('NEXT_PUBLIC_APP_URL') === 'https://www.sim.ai' ||
+  getEnv('NEXT_PUBLIC_APP_URL') === 'https://www.staging.sim.ai'
 
 /**
  * Is billing enforcement enabled

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

* Is the application running in production mode
*/
export const isProd = env.NODE_ENV === 'production'
export const isProd = true
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded isProd and isHosted break self-hosted deployments

High Severity

isProd and isHosted are hardcoded to true, replacing the previous environment-based checks. This makes isAuthDisabled always false (line 40: isTruthy(env.DISABLE_AUTH) && !isHosted), completely breaking self-hosted deployments that rely on DISABLE_AUTH. It also disables billing bypass in development (!isProd guards in subscription.ts will never trigger), and isProd and isDev can now both be true simultaneously.

Additional Locations (1)
Fix in Cursor Fix in Web

logger.info('Tool execution succeeded', {
toolCallId: toolCall.id,
toolName: toolCall.name,
output: result.output,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging full tool output may leak sensitive data

Medium Severity

The newly added output: result.output field in the success log dumps the entire tool execution result at info level. Tool outputs can contain file contents, database rows, API keys, user data, or other sensitive information. This could lead to sensitive data appearing in logs and potentially very large log entries for tools that return substantial payloads.

Fix in Cursor Fix in Web

@emir-karabeg emir-karabeg force-pushed the fix/mothership-thinking branch from bdd1cf8 to 17c12ea Compare March 17, 2026 14:43
@emir-karabeg
Copy link
Collaborator

@greptile

@emir-karabeg emir-karabeg merged commit 8fa4f3f into staging Mar 17, 2026
6 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/mothership-thinking branch March 17, 2026 17:13
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.

2 participants