fix(clipboard): coordinate copy verifiably reaches the system clipboard (#92)#93
Merged
Conversation
…efore claiming success (#92) Field report (#92): radial "Copy Coords" shows the confirmation toast but third-party apps paste nothing. Repro first (house rule) — could NOT fault the original write path: - Instrumented tests exercising the exact MapScreen path (composition- resolved LocalClipboardManager + setText(AnnotatedString), Compose BOM 2024.12.01 / ui 1.7.6) pass on stock API 36 (engie_emulator) and Samsung One UI 16 (SM-X210), including the reported press-and-HOLD- then-release gesture: the clip lands as text/plain, content intact per platform ClipboardManager read-back. - Full UI drive of the real app (long-press map → radial → hold "Copy Coords" 900 ms → release) landed "39.24430, -123.15008" cross-app: KEYCODE_PASTE into Google Messages reproduced the exact text. So this ships as hardening, pending device confirmation from the reporter. The only seam left in the old path was an unconditional success toast over a void write API. The copy branch now writes through the platform ClipboardManager (ClipData.newPlainText) and reads the clip back BEFORE toasting — "Copied" only when the read-back matches, the new map.toast.copyFailed (en + zh-Hant) otherwise. An OEM-side silent drop now surfaces as an honest failure (and gives us a signal to chase) instead of lying to the operator. - CoordClipboard: verified platform write; never throws — OEM rejections and focus-blocked read-backs fail closed - MapScreen: radial copy branch gates the toast on the verified result - ClipboardWriteInstrumentedTest: pins write+verify and the held-click gesture on device against the system clipboard third-party pastes coerce from Verified: assembleDebug + testDebugUnitTest green (CI parity); connectedDebugAndroidTest green on engie_emulator (API 36) and SM-X210 (One UI 16); fixed build re-driven end-to-end — verified toast, OS clipboard overlay, share sheet, and a cross-app paste all agree on the same coordinate. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #92.
Repro evidence (first — house rule: end-to-end reproducer before any fix)
Verdict: could NOT reproduce the failure. The original write path (
LocalClipboardManager.setText(AnnotatedString), Compose BOM 2024.12.01 / ui 1.7.6 —LocalClipboardManageris not deprecated until 1.8, and the 1.7.6 bytecode confirmssetText→setPrimaryClip(ClipData.newPlainText(...))) lands a pasteable clip everywhere I could test, including the reporter's exact press-and-HOLD gesture.Oracle 1 — instrumented tests (system-clipboard read-back via platform
ClipboardManager)Exercise the exact MapScreen path: composition-resolved manager, write from a clickable's onClick, including a 900 ms hold (past the long-press timeout) before release. Assert against the platform clipboard (text/plain MIME + exact item text +
coerceToText), with a pre-seeded sentinel so a stale clipboard can't fake a pass.Oracle 2 — real app, real gesture, real third-party paste (adb drive on engie_emulator)
adb shell cmd clipboard get-primary-clipanddumpsys clipboardare both unavailable on API 36, so the platform read-back from a focused activity + the cross-app paste are the oracles.Root cause
Not reproducible on stock API 36 or Samsung One UI 16 — the write path is correct on these targets. The one real defect that IS provable from the code: the success toast was unconditional over a void write API.
ClipboardManager.setTextreturns nothing, so whatever happened on Gavin's device (OEM clipboard manager interference, a focus race, a ROM-side silent drop), the app claimed "Copied" without knowing.The fix (hardening — pending device confirmation from the reporter)
CoordClipboard(new): writes via the platformClipboardManagerwithClipData.newPlainText, then reads the clip back and compares before reporting success. Never throws; OEM rejections and focus-blocked read-backs fail closed (wrongly admitting failure beats wrongly claiming success).MapScreenradial copy branch: toast is now honest —map.toast.copiedonly when the read-back matches, newmap.toast.copyFailed(en + zh-Hant) otherwise. If Gavin's device drops the write, he now gets a failure toast = a signal we can chase, instead of a lie.ClipboardWriteInstrumentedTest: pins the write+verify contract and the held-click gesture on device. Re-ran post-fix: green on both emulator and SM-X210; full UI drive re-verified on the fixed build (verified toast + OS clipboard overlay + share sheet + cross-app paste into Messages all agree:9.26736, -0.05022).Verification
./gradlew assembleDebug✅./gradlew testDebugUnitTest✅ (CI parity)connectedDebugAndroidTest(clipboard class): ✅ engie_emulator API 36, ✅ SM-X210 One UI 16Follow-up for the reporter
If the failure persists on Gavin's device with this build, the new failure toast tells us the write is genuinely being rejected there — next ask: device model/ROM + whether a clipboard-manager/keyboard app is installed. If he still sees a success toast with nothing pasteable, the clip verifiably reached his system clipboard and something on-device is clearing it afterwards.
🤖 Generated with Claude Code