Skip to content

feat: implement clipboard performance optimization for large text (#335)#518

Open
gidadoabdullateef5 wants to merge 1 commit into
rinafcode:mainfrom
gidadoabdullateef5:feat/clipboard-optimization-335
Open

feat: implement clipboard performance optimization for large text (#335)#518
gidadoabdullateef5 wants to merge 1 commit into
rinafcode:mainfrom
gidadoabdullateef5:feat/clipboard-optimization-335

Conversation

@gidadoabdullateef5
Copy link
Copy Markdown

@gidadoabdullateef5 gidadoabdullateef5 commented May 30, 2026

Closes #335


Background

Copying and pasting extremely large text payloads (e.g., 100KB+) previously blocked the main React JS thread while data was serialized and transmitted across the native bridge. This caused noticeable UI freezes and degraded the user experience.

Changes Made

This PR introduces a performance-optimized, non-blocking clipboard strategy designed to handle large strings safely by deferring execution and providing instant UI feedback.

  1. Async Service Wrap (clipboardService.ts): Integrated expo-clipboard to communicate with the OS clipboard asynchronously. Added expo-haptics to provide immediate physical feedback upon successful operation, and hooked into AppLogger for telemetry.
  2. Deferred Execution Hook (useOptimizedClipboard.ts): Built a React hook that intelligently defers heavy native bridge serialization. It leverages InteractionManager.runAfterInteractions combined with a setTimeout macro-task to ensure React can fully render visual loading states before the main thread locks up handling the payload.
  3. Interactive Demo Screen (clipboard-demo.tsx): Created a developer sandbox accessible via the Mobile Settings to simulate copying/pasting 100KB, 500KB, and 1MB string payloads to visually test the non-blocking behavior.
  4. Documentation: Authored docs/clipboard-strategy.md outlining the architectural approach to handling heavy bridge operations.
  5. Testing: Implemented comprehensive unit tests validating the async state machine, timeout deferrals, and error handling for native bridge failures.

Impact

  • ✨ Responsive UI during clipboard operations, even with 1MB+ payloads.
  • ⚡ Smooth user experience with integrated haptic and visual loading feedback.
  • 🛠 Comprehensive test coverage and documentation for future maintainers.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 30, 2026

@gidadoabdullateef5 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER
Copy link
Copy Markdown
Contributor

Kindly resolve conflict and fix workflow.

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.

Implement clipboard performance optimization for large text

3 participants