Skip to content

fix(mobile): show empty message when pasting an empty clipboard - #5316

Merged
iscekic merged 3 commits into
mainfrom
clipboard-paste-error-02fd
Aug 18, 2026
Merged

fix(mobile): show empty message when pasting an empty clipboard#5316
iscekic merged 3 commits into
mainfrom
clipboard-paste-error-02fd

Conversation

@iscekic

@iscekic iscekic commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Tapping paste with nothing copied shows a file-read error ("Couldn't read this file"). The paste hook reported empty, denied, and unsupported-type through one onUnreadable callback, so callers could not distinguish an empty clipboard from a denied or unreadable one.

The change classifies the paste failure. useClipboardPaste now reports onFailure(reason) where reason is 'empty' or 'unreadable'. The three paste call sites toast Nothing to paste only for the empty case; denied permission and unreadable image keep the current unreadable copy.

User: Tapping paste with nothing copied now shows "Nothing to paste" instead of a file-read error. The user can copy and tap again.

Product manager: The empty-clipboard paste case now has a clear, retryable message, distinct from denied permission and unreadable image.

Maintainer: useClipboardPaste classifies paste failure as 'empty' vs 'unreadable'. A new hasClipboardUrl helper inspects content type only (no iOS paste prompt) and returns false on error. Classification runs after the existing reads; readClipboardText is not gated on a content-type probe, so URL-only clipboards still paste.

Verification

  • Unit tests cover the new classification paths: empty, denied text, denied URL, unreadable image with and without text.
  • pnpm typecheck, pnpm lint, pnpm check:unused pass in apps/mobile.
  • git diff --check is clean.
  • E2E (bot-e2e, iOS): new-session empty-clipboard paste toasts Nothing to paste.

Visual Changes

The empty-clipboard paste toast copy changes from "Couldn't read this file" to "Nothing to paste". Denied and unreadable toasts are unchanged. This is a text-only change to a transient toast; no layout or styling changed. The rendered copy was verified by E2E (Appium hierarchy).

Reviewer Notes

  • The paste no-file branch order is the core logic; review it against the plan's step 2.
  • hasClipboardUrl catches the Android UnavailabilityError and returns false.

Human steps

No step is needed. No secret, migration, flag, or deploy-order change.

Tapping paste with nothing copied toasts a file-read error. Classify the
paste failure in useClipboardPaste as empty vs unreadable, and have the
three paste call sites toast "Nothing to paste" only for the empty case.
Denied permission and unreadable image keep the current unreadable copy.
@iscekic iscekic self-assigned this Aug 18, 2026
@kilo-code-bot

kilo-code-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Incremental review of commit eab07f40 (the change since the previous review at ce0c52f8): it removes the hasClipboardText helper and simplifies the empty-vs-unreadable classification to a single hasClipboardUrl() probe. The new semantics (a denied non-URL text read now reports 'empty') is explicitly documented in the updated onFailure contract comment, no stale references to the removed export remain, tests were updated to match every classification path, and no new listeners, timers, or subscriptions were introduced (no memory-leak surface).

Files Reviewed (4 files)
  • apps/mobile/src/lib/agent-attachments/clipboard-image.ts
  • apps/mobile/src/lib/agent-attachments/clipboard-image.test.ts
  • apps/mobile/src/lib/agent-attachments/use-clipboard-paste.ts
  • apps/mobile/src/lib/agent-attachments/use-clipboard-paste.test.ts
Previous Review Summaries (2 snapshots, latest commit ce0c52f)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit ce0c52f)

Status: No Issues Found | Recommendation: Merge

Executive Summary

Incremental review of commit ce0c52f83 (the only change since the previous review at b8d5b0ae): it adds the generated sentry.options.json to apps/mobile/.gitignore — a trivial maintenance change with no functional impact, no new code paths, and no memory-leak surface. Previous review of the paste-classification logic remains valid and unchanged.

Files Reviewed (1 file)
  • apps/mobile/.gitignore

Previous review (commit b8d5b0a)

Status: No Issues Found | Recommendation: Merge

Executive Summary

Reviewed the empty-vs-unreadable paste classification across the shared hook, both new clipboard probe helpers, and all three call sites; the branch order in paste is correct (image unreadable falls back to text, then clipboardHasImage short-circuits to 'unreadable', then the hasClipboardText/hasClipboardUrl probes run only for text-capable callers), all probe helpers are non-throwing, and no listeners, timers, or subscriptions were added that could leak.

Files Reviewed (7 files)
  • apps/mobile/src/lib/agent-attachments/use-clipboard-paste.ts
  • apps/mobile/src/lib/agent-attachments/clipboard-image.ts
  • apps/mobile/src/lib/agent-attachments/use-clipboard-paste.test.ts
  • apps/mobile/src/lib/agent-attachments/clipboard-image.test.ts
  • apps/mobile/src/components/agents/chat-composer.tsx
  • apps/mobile/src/components/agents/new-session-prompt.tsx
  • apps/mobile/src/components/kilo-chat/use-message-input-clipboard-image-hint.ts

Reviewed by kimi-k3 · Input: 71.3K · Output: 4.6K · Cached: 205.8K

Review guidance: REVIEW.md from base branch main

The @sentry/react-native/expo config plugin writes sentry.options.json
during expo prebuild. The file duplicates the DSN already tracked in
sentry-dsn.js and must not be committed.
hasStringAsync reports true for an empty-string item, so hasClipboardText
wrongly classified an empty clipboard as unreadable. Remove hasClipboardText
and probe only hasClipboardUrl, which is false for an empty string. An empty
clipboard now toasts "Nothing to paste".

@pandemicsyn pandemicsyn left a comment

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.

lgtm. just flagging that the robot pointed there might be a missing helper.

Comment thread apps/mobile/src/lib/agent-attachments/use-clipboard-paste.ts
@iscekic iscekic added the human-ready The PR is ready for human review. label Aug 18, 2026
@iscekic
iscekic merged commit 829bd76 into main Aug 18, 2026
18 checks passed
@iscekic
iscekic deleted the clipboard-paste-error-02fd branch August 18, 2026 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

human-ready The PR is ready for human review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants