Skip to content

android: Back the platform clipboard with ClipboardManager - #22

Closed
Bombatomica64 wants to merge 1 commit into
longbridge:mainfrom
Bombatomica64:fix/android-clipboard
Closed

Bombatomica64 wants to merge 1 commit into
longbridge:mainfrom
Bombatomica64:fix/android-clipboard

Conversation

@Bombatomica64

Copy link
Copy Markdown

Problem

AndroidClipboard stored copied text in process memory only. Text copied in a GPUI app (for example Kit's input or TextView "Copy") could not be pasted into other apps, and paste inside the app never saw what other apps had copied. The clipboard package (packages::clipboard, backed by GpuiClipboard.java and ClipboardManager) already existed but the platform clipboard did not use it.

Change

With the clipboard feature (on by default), AndroidClipboard::read / write go through packages::clipboard::{get_text, set_text}. The in-process copy is kept and used as a fallback, with a log::warn!, when the JNI call fails (for example if a host does not package GpuiClipboard.java). Without the feature, behaviour is unchanged.

Testing

  • cargo fmt --all, cargo check, cargo ndk -t arm64-v8a check with and without --features clipboard, and cargo test --lib (46 passed).
  • cargo test doc tests: platform_view and platform_view_element fail identically on main, so that failure is not from this change.
  • aarch64-apple-ios was not checked (Linux machine); the change is Android-only code.
  • On device: used by an Android test app for GPUI Kit 0.7.0 (host entry point, Android 13 emulator via Redroid). Kit's Copy shows Android 13's clipboard overlay, and the copied text reads back on paste.

Related Kit report: longbridge/gpui-kit#3310

🤖 Generated with Claude Code

AndroidClipboard kept copied text in process memory only, so copy/paste
did not reach other apps and paste never saw the system clipboard. With
the clipboard feature enabled, read/write now go through
packages::clipboard (ClipboardManager via JNI), keeping the in-memory
copy as a fallback when the JNI call fails.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings September 29, 2026 07:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Bombatomica64

Copy link
Copy Markdown
Author

Sorry for the noise. I've combined this into a single PR, #24, so there's only one to review. Closing this one.

@Bombatomica64
Bombatomica64 deleted the fix/android-clipboard branch September 29, 2026 07: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.

2 participants