Skip to content

feat(mothership): Add conversationId to mship block#4577

Merged
Sg312 merged 1 commit into
stagingfrom
feat/mothership-block-conversationId
May 13, 2026
Merged

feat(mothership): Add conversationId to mship block#4577
Sg312 merged 1 commit into
stagingfrom
feat/mothership-block-conversationId

Conversation

@Sg312
Copy link
Copy Markdown
Collaborator

@Sg312 Sg312 commented May 13, 2026

Summary

Add convo id to mship block

Type of Change

  • New feature

Testing

Manual

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
Copy Markdown

vercel Bot commented May 13, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped May 13, 2026 2:58am

Request Review

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 13, 2026

Greptile Summary

This PR adds an optional conversationId input to the Mothership block, enabling workflows to continue an existing Mothership conversation rather than always starting a fresh one. The conversationId is also surfaced as a block output so downstream blocks can reference it.

  • mothership-handler.ts: Reads inputs.conversationId, trims whitespace, and uses it as chatId for the API request (falling back to generateId() when absent). Returns conversationId in the output, falling back to the locally-computed chatId.
  • route.ts & mothership-tasks.ts: The execute endpoint now includes conversationId: effectiveChatId in the success response, and the Zod schema marks it as required.
  • mothership.ts: Adds conversationId as an optional short-text input and a string output in the block definition.

Confidence Score: 5/5

Safe to merge — the change is additive and all existing paths are unaffected.

All changed paths are well-covered: the handler correctly trims and falls back, the route always returns conversationId so the non-optional schema is consistent, and the new test explicitly validates both the trimmed chatId in the outgoing request body and the correct generateId call count when a conversation ID is supplied versus when one is generated.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/executor/handlers/mothership/mothership-handler.ts Adds optional conversationId input handling with whitespace trimming and fallback to generateId(); propagates conversationId in the return value.
apps/sim/app/api/mothership/execute/route.ts Adds conversationId: effectiveChatId to the success JSON response; no logic changes to auth, lifecycle, or error paths.
apps/sim/blocks/blocks/mothership.ts Adds conversationId as an optional short-input field and a string output in the block definition; clean change.
apps/sim/lib/api/contracts/mothership-tasks.ts Adds required conversationId: z.string() to mothershipExecuteResponseSchema; aligns with the route always returning the field.
apps/sim/executor/handlers/mothership/mothership-handler.test.ts Updates happy-path assertions for conversationId and adds a new test verifying whitespace trimming and correct chatId propagation to the request body.

Sequence Diagram

sequenceDiagram
    participant W as Workflow Executor
    participant H as MothershipBlockHandler
    participant R as /api/mothership/execute
    participant M as Mothership Service

    W->>H: execute(ctx, block, inputs)
    note over H: inputs.conversationId provided?
    alt conversationId provided
        H->>H: "chatId = inputs.conversationId.trim()"
    else not provided
        H->>H: "chatId = generateId()"
    end
    H->>H: "messageId = generateId()"
    H->>H: "requestId = generateId()"
    H->>R: "POST { messages, chatId, messageId, requestId, ... }"
    R->>R: "effectiveChatId = chatId || generateId()"
    R->>M: "runHeadlessCopilotLifecycle({ chatId: effectiveChatId })"
    M-->>R: "result { content, toolCalls, usage }"
    R-->>H: "{ content, model, conversationId: effectiveChatId, tokens, toolCalls }"
    H-->>W: "{ content, model, conversationId, tokens, toolCalls, cost }"
Loading

Reviews (1): Last reviewed commit: "Add convo id to mship block" | Re-trigger Greptile

@Sg312 Sg312 merged commit 689e1f7 into staging May 13, 2026
13 checks passed
@waleedlatif1 waleedlatif1 deleted the feat/mothership-block-conversationId branch May 13, 2026 06:20
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