Skip to content

feat(mobile): Long press to copy message text#2060

Open
Crypto-Virus wants to merge 1 commit intopingdotgg:t3code/mobile-remote-connectfrom
Crypto-Virus:t3code/mobile-long-press-copy
Open

feat(mobile): Long press to copy message text#2060
Crypto-Virus wants to merge 1 commit intopingdotgg:t3code/mobile-remote-connectfrom
Crypto-Virus:t3code/mobile-long-press-copy

Conversation

@Crypto-Virus
Copy link
Copy Markdown

@Crypto-Virus Crypto-Virus commented Apr 16, 2026

copy-feature-clean.mp4

Summary

  • Long press message bubbles to open a copy sheet with selectable text and a "Copy all" button
  • Animated confirmation with haptic feedback, auto-dismisses after 600ms
  • Extracted createExternalStore utility — refactored both messageCopySelection and reviewCommentSelection to use it, eliminating ~60 lines of duplicate boilerplate

🤖 Generated with Claude Code

Long press on user or assistant message bubbles opens a form sheet with
selectable text and a "Copy all" button. Extracts a reusable
createExternalStore utility and refactors both message copy and review
comment stores to use it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Apr 16, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 16, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 66b14234-c720-4b53-a064-68d4361572d2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment on lines +45 to +55
const onCopyAll = useCallback(() => {
if (messageText) {
void Clipboard.setStringAsync(messageText);
void Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
setCopied(true);
dismissTimerRef.current = setTimeout(() => {
dismissTimerRef.current = null;
router.back();
}, 600);
}
}, [messageText, router]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Medium threads/MessageCopySheet.tsx:45

In onCopyAll, if the button is pressed multiple times before React re-renders with disabled={copied}, the code overwrites dismissTimerRef.current without clearing the previous timer. This leaks the previous timer ID, and if the component unmounts before all timers fire, only the last timer gets cleaned up. The orphaned timer(s) will still call router.back() potentially after the user has navigated elsewhere.

  const onCopyAll = useCallback(() => {
    if (messageText) {
      void Clipboard.setStringAsync(messageText);
      void Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
      setCopied(true);
+      if (dismissTimerRef.current) {
+        clearTimeout(dismissTimerRef.current);
+      }
      dismissTimerRef.current = setTimeout(() => {
        dismissTimerRef.current = null;
        router.back();
      }, 600);
    }
  }, [messageText, router]);
🤖 Copy this AI Prompt to have your agent fix this:
In file apps/mobile/src/features/threads/MessageCopySheet.tsx around lines 45-55:

In `onCopyAll`, if the button is pressed multiple times before React re-renders with `disabled={copied}`, the code overwrites `dismissTimerRef.current` without clearing the previous timer. This leaks the previous timer ID, and if the component unmounts before all timers fire, only the last timer gets cleaned up. The orphaned timer(s) will still call `router.back()` potentially after the user has navigated elsewhere.

Evidence trail:
apps/mobile/src/features/threads/MessageCopySheet.tsx lines 44-54 (onCopyAll function creates timer without clearing existing one), lines 37-42 (cleanup effect only clears dismissTimerRef.current which is only the last timer), lines 49-52 (timer assignment overwrites ref without clearTimeout), line 99 (disabled={copied} relies on React re-render)

Copy link
Copy Markdown
Contributor

@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 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6bead6f. Configure here.

key={attachment.id}
activeOpacity={0.7}
onPress={() => props.onPressImage(uri, headers)}
<Pressable onLongPress={() => props.onLongPressMessage(message.text)}>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Long-pressing image-only messages opens empty copy sheet

Medium Severity

The onLongPress handler unconditionally passes message.text to the copy sheet, even when the text is empty (e.g., image-only messages). Since OrchestrationMessage.text is Schema.String (allows ""), setMessageCopyText("") stores an empty string. In MessageCopySheet, the guard if (!messageText) treats "" as falsy and returns null, so the user sees a confusing empty form sheet (just a grabber on a blank background) that they must manually dismiss. The onLongPressMessage handler needs to skip opening the sheet when the text is empty.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6bead6f. Configure here.

@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp bot commented Apr 16, 2026

Approvability

Verdict: Needs human review

1 blocking correctness issue found. This PR introduces a new user-facing feature (long press to copy message text) with new components, routes, and state management. Additionally, there are two unresolved medium-severity bugs identified: a timer leak on rapid button presses and an empty sheet appearing for image-only messages.

You can customize Macroscope's approvability policy. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant