Skip to content

feat(home): add double-enter to send top queued message#4005

Merged
waleedlatif1 merged 1 commit intostagingfrom
waleedlatif1/enter-twice-send-queue
Apr 7, 2026
Merged

feat(home): add double-enter to send top queued message#4005
waleedlatif1 merged 1 commit intostagingfrom
waleedlatif1/enter-twice-send-queue

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • When streaming and there are queued messages, pressing Enter twice on an empty input sends the top queued message immediately (Cursor-style)
  • First Enter primes the top message, second Enter within 3s sends it
  • Typing dismisses the primed state, returning to normal behavior

Type of Change

  • New feature

Testing

Tested manually

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 Apr 7, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 7, 2026 2:19am

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 7, 2026

PR Summary

Medium Risk
Medium risk because it changes core chat keyboard-submit behavior during streaming and introduces timed “primed” state that could cause accidental queued-message sends if edge cases aren’t handled.

Overview
Adds a double-Enter shortcut in the home chat: when a response is streaming and the input is empty, pressing Enter first primes the top queued message and pressing Enter again within 3s sends it immediately.

Implements priming state/timer management in mothership-chat.tsx and wires new UserInput callbacks so typing dismisses the primed state and Enter can be intercepted before normal submit.

Reviewed by Cursor Bugbot for commit ff5a601. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 7, 2026

Greptile Summary

This PR adds a Cursor-style "double-enter" shortcut: while the AI is streaming and there are queued messages, pressing Enter twice on an empty input sends the top queued message immediately. The first Enter primes the message (stored via a ref with a 3-second auto-clear timer), and the second Enter within that window triggers the send. Typing any content dismisses the primed state.

  • State is managed entirely via refs in mothership-chat.tsx, keeping the feature out of the render cycle and avoiding unnecessary re-renders — a clean approach.
  • onEnterWhileEmpty and onPrimedDismiss callbacks are forwarded to UserInput via stable ref wrappers, consistent with existing patterns in the file.
  • The @-mention early-return path in handleInputChange skips the onPrimedDismiss call, leaving the primed state active for up to 3 seconds even after the user begins composing a mention.
  • No visual feedback is surfaced when the first Enter primes a message, making the feature effectively invisible — users have no cue to press Enter a second time.

Confidence Score: 5/5

Safe to merge — only P2 UX/consistency findings remain

Both findings are P2: a small window where the primed state may linger after an @-mention interaction, and the absence of visual feedback for the primed state. Neither causes data loss, an incorrect send, or a broken user flow. The core logic — ref-based state, timer cleanup, Enter interception, and stable ref wrappers — is sound and follows established codebase patterns.

user-input.tsx has the minor onPrimedDismiss omission in the @-mention branch worth addressing in a follow-up; no correctness concerns in mothership-chat.tsx

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx Adds primed-queue state machine (refs + 3-second timer) and wires Enter/dismiss callbacks into UserInput
apps/sim/app/workspace/[workspaceId]/home/components/user-input/user-input.tsx Adds onEnterWhileEmpty / onPrimedDismiss props; intercepts Enter keydown when streaming with empty input; @-mention branch skips onPrimedDismiss

Sequence Diagram

sequenceDiagram
    participant U as User
    participant UI as UserInput
    participant MC as MothershipChat
    participant Q as MessageQueue

    Note over U,Q: isSending=true, queue non-empty

    U->>UI: Press Enter (input empty)
    UI->>MC: onEnterWhileEmpty()
    MC->>Q: messageQueueRef.current[0]
    MC-->>MC: primedQueueIdRef = topMessage.id
    MC-->>MC: Start 3 s timer → clearPrimed
    MC-->>UI: return true
    UI-->>U: (no visual feedback)

    alt Second Enter within 3 s
        U->>UI: Press Enter (input still empty)
        UI->>MC: onEnterWhileEmpty()
        MC->>Q: messageQueueRef.current[0]
        Note over MC: primedQueueIdRef === topMessage.id
        MC-->>MC: clearPrimed()
        MC->>Q: onSendQueuedMessage(topMessage.id)
        MC-->>UI: return true
    else User types content
        U->>UI: Keystroke → handleInputChange
        UI->>MC: onPrimedDismiss()
        MC-->>MC: clearPrimed() — timer cancelled
    else 3 s elapses
        MC-->>MC: clearPrimed() fires automatically
    end
Loading

Comments Outside Diff (1)

  1. apps/sim/app/workspace/[workspaceId]/home/components/user-input/user-input.tsx, line 535-549 (link)

    P2 Missing onPrimedDismiss in the @-mention branch

    When the user types @ while the input is primed, the early return at the end of the @-mention branch exits before reaching the if (newValue.trim()) onPrimedDismiss?.() guard at line 553. This means the primed state silently persists even though the user has clearly begun composing a new message.

    The window is small (≤ 3 s before the timer fires clearPrimed), but for consistency the primed state should be dismissed as soon as the user interacts with the input in a content-adding way:

Reviews (1): Last reviewed commit: "feat(home): add double-enter to send top..." | Re-trigger Greptile

@waleedlatif1 waleedlatif1 merged commit cc8c9e8 into staging Apr 7, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/enter-twice-send-queue branch April 7, 2026 02:26
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