Skip to content

improvement(mothership): show continue options on abort#3746

Merged
Sg312 merged 3 commits intostagingfrom
improvement/mothership-show-continue
Mar 24, 2026
Merged

improvement(mothership): show continue options on abort#3746
Sg312 merged 3 commits intostagingfrom
improvement/mothership-show-continue

Conversation

@Sg312
Copy link
Collaborator

@Sg312 Sg312 commented Mar 24, 2026

Summary

Show continue options on abort

Type of Change

  • Bug fix

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

vercel bot commented Mar 24, 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 24, 2026 11:01pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 24, 2026

Greptile Summary

This PR aims to show "Continue" options after a user-aborted stream, consolidating the abort-handling logic into a new resolveInterruptedToolCalls helper and persisting the continue-options block to the backend via persistPartialResponse.

Key changes:

  • Introduces resolveInterruptedToolCalls, which marks in-flight tool calls as cancelled and appends a stopped block plus a <options>…continue…</options> text block to the last assistant message.
  • persistPartialResponse now also appends the continue-options content/blocks to what gets saved on the backend when a stream is aborted.
  • The "Stopped by user" label is shortened to "Stopped".

Critical issue: resolveInterruptedToolCalls is called unconditionally inside finalize, which runs at the end of every stream — including normal, successful completions. Because the function always pushes the stopped and continue-options blocks to the last assistant message (guarded only by isLastAssistant, not by whether an abort actually occurred), every successfully completed response will incorrectly display a "Stopped" icon and a "Continue" option.

Secondary issue: CONTINUE_OPTIONS_CONTENT is declared at line 1234 but first used at lines 1193/1198 inside persistPartialResponse. This works today only because the callback is invoked asynchronously, but it is fragile and should be moved before its first use (ideally to module scope).

Confidence Score: 2/5

  • Not safe to merge — the unconditional call to resolveInterruptedToolCalls inside finalize will corrupt every normally completed assistant message with a spurious "Stopped" icon and "Continue" options.
  • The P0 logic bug in finalize affects the main happy path (every non-aborted message), not just the abort edge case. The fix is small and targeted, but it needs to land before this can be merged.
  • use-chat.ts — specifically the resolveInterruptedToolCalls call site inside finalize and the declaration order of CONTINUE_OPTIONS_CONTENT.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts Refactors abort handling into resolveInterruptedToolCalls, but calling it unconditionally from finalize will append a "Stopped" block and "Continue" options to every successfully completed response. Also introduces CONTINUE_OPTIONS_CONTENT after its first point of use.
apps/sim/app/workspace/[workspaceId]/home/components/message-content/message-content.tsx Minor copy change: renames the stopped-state label from "Stopped by user" to "Stopped". Safe, no logic changes.

Sequence Diagram

sequenceDiagram
    participant User
    participant stopGeneration
    participant resolveInterruptedToolCalls
    participant finalize
    participant persistPartialResponse
    participant Messages

    User->>stopGeneration: clicks Stop button
    stopGeneration->>resolveInterruptedToolCalls: call (marks executing→cancelled,<br/>adds stopped+continue blocks)
    resolveInterruptedToolCalls->>Messages: setMessages(...)
    stopGeneration->>persistPartialResponse: await (saves partial content + blocks to backend)
    persistPartialResponse-->>Messages: (backend persisted with continue options)

    Note over finalize: Also called on normal stream end
    finalize->>resolveInterruptedToolCalls: call (UNCONDITIONAL ⚠️)
    resolveInterruptedToolCalls->>Messages: appends stopped+continue to last assistant msg<br/>even on successful completion
Loading

Reviews (1): Last reviewed commit: "Fix lint" | Re-trigger Greptile

@Sg312 Sg312 merged commit b9926df into staging Mar 24, 2026
11 checks passed
icecrasher321 added a commit that referenced this pull request Mar 25, 2026
icecrasher321 added a commit that referenced this pull request Mar 25, 2026
@waleedlatif1 waleedlatif1 deleted the improvement/mothership-show-continue branch March 25, 2026 04:18
Sg312 pushed a commit that referenced this pull request Mar 25, 2026
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