Repository navigation
Clipboard and haptics: thicket-clipboard (-gtk, -android), thicket-haptics (-android), the gallery's section - #124
Conversation
…ptics (-android), the gallery's section docs/16 §16.10 item 5, first half. Also records the owner's decisions for the pickers: picked files copied into the app's cache and returned as a Path; results by UI-thread callback. - thicket-clipboard: set(text), get(onResult), text only; GdkClipboard (async read) and Android's ClipboardManager; MemoryClipboard for tests. - thicket-haptics: impact(Light | Medium | Heavy), selection(), availability; Android's performHapticFeedback; GTK uses Haptics.none; RecordingHaptics for tests. Measured: - bin/with-keyring.sh sbt -J-Xmx8G --error checkLinux: exit 0; clipboard 1, haptics 2 tests. - bin/gtk-selftests.sh: gallery 131 (128 + 3), todo 69. wl-paste in another process read the gallery's copy. - SELFTEST=1 examples/gallery/android/build.sh on s2test: 76/76 (71 + 5); build.sh now finds the gallery's taps in dumpsys vibrator_manager (2 played, Prebaked=CLICK). Falsified: with set doing nothing, both copy-and-paste rounds fail on GTK and Android (each pasting a previous run's text). With performHapticFeedback not called, the in-app check and build.sh's vibrator count both fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The change hinges on runtime-dependent behavior—a GC-state async GTK clipboard callback and a dumpsys-timestamp vibrator check—that cannot be verified in this review environment, so a vote quorum is needed instead.
No open issues 🎉
What changed in this PR
This PR adds two new device-service module families to the Thicket framework — thicket-clipboard (with -gtk and -android backends) and thicket-haptics (with an -android backend) — fulfilling the first half of docs/16 §16.10 item 5. It defines small platform-agnostic APIs, their platform implementations, in-memory/recording test fakes, a new gallery "Clipboard and haptics" section with GTK and Android self-tests, and the corresponding build wiring and documentation updates. The Apple half is deferred to issue #123.
Changes:
- Clipboard:
Clipboardtrait (set(text), callback-basedget) withGtkClipboard(GdkClipboard, asyncgdk_clipboard_read_text_async),AndroidClipboard(ClipboardManager, result posted to the main loop), andMemoryClipboardfor tests. - Haptics:
Hapticstrait (impact(Light|Medium|Heavy),selection(),availability) withAndroidHaptics(View.performHapticFeedback, noVIBRATEpermission),Haptics.nonefor GTK, andRecordingHapticsfor tests. - Gallery + build + docs: new
ClipboardDemo, gallery section and GTK/Android self-test checks, wiring intoServices/build.sbt/build.sh, and consistent count/status updates acrossREADME,docs/12,docs/14,docs/16, and the decision log.
| File | Description |
|---|---|
modules/clipboard/shared/.../Clipboard.scala |
New clipboard API trait (text, callback get). |
modules/clipboard/shared/.../testing/MemoryClipboard.scala |
In-memory clipboard fake answering get synchronously. |
modules/clipboard/shared/.../ClipboardSpec.scala |
Unit test for MemoryClipboard. |
modules/clipboard-gtk/.../GtkClipboard.scala |
GdkClipboard backend; async read via id-keyed continuation + GcState.guarded. |
modules/clipboard-android/.../AndroidClipboard.scala |
ClipboardManager backend; result posted to the main looper. |
modules/clipboard/README.md |
Module docs and how it's checked. |
modules/haptics/shared/.../Haptics.scala |
New haptics API (Impact, trait, Haptics.none). |
modules/haptics/shared/.../testing/RecordingHaptics.scala |
Recording fake capturing tap order. |
modules/haptics/shared/.../HapticsSpec.scala |
Unit tests for recording fake and Haptics.none. |
modules/haptics-android/.../AndroidHaptics.scala |
performHapticFeedback backend on the current activity's window. |
modules/haptics/README.md |
Module docs and how it's checked. |
examples/gallery/shared/.../ClipboardDemo.scala |
Gallery demo state (numbered copies, paste label, haptics label/tap). |
examples/gallery/shared/.../StorageDemo.scala |
Adds clipboard/haptics to Services. |
examples/gallery/shared/.../Gallery.scala |
New section, currentClipboard, demo wiring. |
examples/gallery/gtk/.../GalleryGtk.scala |
GTK clipboard/haptics self-test checks and service wiring. |
examples/gallery/android/.../GallerySelfTest.scala |
Android clipboard/haptics self-test steps. |
examples/gallery/android/.../GalleryActivity.scala |
Wires AndroidClipboard/AndroidHaptics into Services. |
examples/gallery/android/build.sh |
Packages new modules; checks vibrator history for the gallery's taps. |
examples/gallery/README.md |
Documents the new section's self-tests. |
build.sbt |
New projects, aggregates, -release 17, and gallery dependencies. |
README.md, docs/12, docs/14, docs/16, docs/decisions.md |
Status, count, release-artifact and decision-log updates. |
No objective defects were found in the diff. The native FFI callback follows the existing Handles/GcState.guarded pattern correctly, Availability reuse and -release 17 match established conventions, and the documented test counts are internally consistent across all docs. I did not raise any PR comments.
Review effort: Balanced
…124 had already merged (#131) * Pickers: thicket-pickers (-gtk, -android), answered through the real pickers in both galleries (#126) * Pickers: thicket-pickers (-gtk, -android), answered through the real pickers in both galleries docs/16 §16.10 item 5, built to the owner's decisions: every picked file is copied into the app's cache and handed back as a Path, by UI-thread callback. - thicket-pickers: Photos.pick(limit), Documents.open(mimeTypes, multiple), Documents.save(name, mimeType, bytes); PickedFiles (a directory per copy); fakes. Documents, not docs/16's Files, which would collide with java.nio.file.Files. - Android: the photo picker (ACTION_PICK_IMAGES; ACTION_GET_CONTENT before 13) and the Storage Access Framework. ThicketActivity passes onActivityResult to its listeners. - GTK: GtkFileDialog over GtkApp's window. Measured: - checkLinux (with-keyring, 8 GB): exit 0; PickersSpec 4/4, JVM and Native. - GTK gallery 135 (131 + 4), todo 69, under a private headless gnome-shell (the desktop was locked, which suspends windows and fails the Device foreground check). The self-test turns the portal off and answers the in-process chooser. - Android gallery 81/81 (76 + 5) on s2test: build.sh taps the photo picker and documents UI, and reads the saved file back from Downloads. Falsified: without the copy, PickersSpec's byte test and both GTK "copied into the app's cache" checks fail; with onActivityResult not passed on, every Android picker check and the read-back fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * GtkPickers: one picker at a time, as documented and as Android does (review) A request while a chooser is up now answers empty (None for save) on the next turn of the main loop, without showing a second chooser; the flag is shared by the photos and the documents. Before, each call showed its own dialog and both answered. The GTK self-test checks it: while the photo chooser is up, Documents.open answers empty and only one chooser is among the windows. Measured (headless gnome-shell, bin/gtk-selftests.sh): gallery 136 (135 + 1), todo 69. With the busy check removed, the new check fails: the second request opened its own chooser and answered with the photo meant for the first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * Gallery GTK: the busy check runs before the chooser is answered; answer it after a second Two races in the pickers' self-test, both seen on CI (GTK 4.14, Xvfb) and not on this desktop's GTK 4.22 until they were looked for: - "a picker asked for while one is up answers empty, without a second chooser" read 0 choosers: the answer loop, waiting on the same chooser, had already accepted and closed it. The first answer now waits for that check. - Answered while it is still loading its folder, the chooser closes with GTK's own criticals (gtk_box_remove on CI; thaw_updates here, 3 of them in one local run), which the self-test script counts as faults. The answer now comes a second after the chooser appears. Measured (bin/with-keyring.sh bin/gtk-selftests.sh, desktop): gallery 137 with 0 fault lines, twice; the second run's one failure was the Device foreground check while the screen was locked (ScreenSaver active), which the pickers do not touch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * AndroidPickers: uris is private, like the helpers beside it (review) It has no callers outside the companion object. Compiles: pickersAndroid/compile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…top of #124 as merged #124 merged as a squash, so this tree is main plus #127's own commit (634e2c4), not a merge of the old feat/clipboard-haptics snapshot. The commit applied onto main with no conflicts. Measured on the result, "iPhone 18 Pro": bin/verify-apple.sh 16 of 17 on the first pass, with the macOS gallery failing a preferences check. That was a collision with another worktree's gallery writing the same Application Support file at the same time. Run alone, after clearing the gallery's Keychain item as verify-apple does: macOS gallery 188/188, twice. iOS gallery 182/182; pbpaste and simctl pbpaste show the last copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
63613bf rebuilt this branch's tree as #124 plus 634e2c4, but its parents already held the pickers (#131), so as a merge it deleted them: modules/pickers*, PickersDemo, PickerDriver, GtkPickers, AndroidPickers, ThicketActivity's onActivityResult, and their docs (-1319 lines against main). Merging #127 would have removed the pickers from main. This tree is main plus the Apple-only diff (ca56ab2..63613bf: 18 files, the two C helpers, AppleClipboard, AppleHaptics, the Apple galleries, verify-apple.sh and the docs), with the doc and build conflicts keeping both sides. Measured: platforms/Test/compile clean (type-checks the Apple Scala); git diff --stat origin/main: 18 files, nothing outside the Apple change. Not measured here: the Apple self-tests, which need the Mac. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-apple (#123) (#127) * Clipboard and haptics: thicket-clipboard (-gtk, -android), thicket-haptics (-android), the gallery's section docs/16 §16.10 item 5, first half. Also records the owner's decisions for the pickers: picked files copied into the app's cache and returned as a Path; results by UI-thread callback. - thicket-clipboard: set(text), get(onResult), text only; GdkClipboard (async read) and Android's ClipboardManager; MemoryClipboard for tests. - thicket-haptics: impact(Light | Medium | Heavy), selection(), availability; Android's performHapticFeedback; GTK uses Haptics.none; RecordingHaptics for tests. Measured: - bin/with-keyring.sh sbt -J-Xmx8G --error checkLinux: exit 0; clipboard 1, haptics 2 tests. - bin/gtk-selftests.sh: gallery 131 (128 + 3), todo 69. wl-paste in another process read the gallery's copy. - SELFTEST=1 examples/gallery/android/build.sh on s2test: 76/76 (71 + 5); build.sh now finds the gallery's taps in dumpsys vibrator_manager (2 played, Prebaked=CLICK). Falsified: with set doing nothing, both copy-and-paste rounds fail on GTK and Android (each pasting a previous run's text). With performHapticFeedback not called, the in-app check and build.sh's vibrator count both fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Apple clipboard and haptics: thicket-clipboard-apple, thicket-haptics-apple (#123) The Apple half of docs/16 §16.10 item 5, built on #124. - thicket-clipboard-apple: NSPasteboard (clearContents, setString(_, forType: .string)) and UIPasteboard.general.string. Reads synchronously, answers on the next run-loop turn. - thicket-haptics-apple: UIImpactFeedbackGenerator (light/medium/heavy) and UISelectionFeedbackGenerator; on macOS NSHapticFeedbackManager (mapped, not Haptics.none: Force Touch trackpads). - Both are one C file each through the Objective-C runtime, compiled by Scala Native's clang, frameworks named in the object (as #108). No Swift, no shim-gen ABI. - Both galleries pass them in Services; the Apple self-test copies and pastes twice, pasting only after the copy raised changeCount, then checks the haptics label and "Tap". - bin/verify-apple.sh reads the last copy from outside: pbpaste (restoring the user's clipboard) and xcrun simctl pbpaste. Measured (bin/verify-apple.sh "iPhone Air", iOS 27.0 sim, Xcode 27.0): all 16 steps PASS. Gallery macOS 188 (185 + 3) on both runs, iOS 182 (179 + 3). Outside reads matched the last copy on all three runs. Own copies read back with no prompt in 25-77 ms on iOS (~220 ms on macOS). Text from simctl pbcopy, and the same app's copy from an earlier launch, show "Allow Paste" and block the read until answered. Falsified: with set doing nothing, both rounds fail on macOS and on the simulator. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Roberto Leibman <rleibman@magrathea.local> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: rleibman <3268890+rleibman@users.noreply.github.com>
docs/16§16.10 item 5, first half: clipboard and haptics. The decision log also records your answers on the pickers' shape: picked files are copied into the app's cache and returned as aPath, and results arrive by UI-thread callback. The Apple half is #123.What it adds
thicket-clipboard:set(text)andget(onResult), for text only.GdkClipboard, read withgdk_clipboard_read_text_async; Android usesClipboardManager.getis a callback on both, because GTK's read is asynchronous.MemoryClipboardfor tests.thicket-haptics:impact(Light | Medium | Heavy),selection()andavailability.View.performHapticFeedback, which follows the user's setting and needs noVIBRATEpermission.Haptics.none.RecordingHapticsfor tests.Measured
bin/with-keyring.sh sbt -J-Xmx8G --error checkLinux,THICKET_REQUIRE_SECRET_SERVICE=1bin/gtk-selftests.shSELFTEST=1 examples/gallery/android/build.sh(s2test, API 36)Evidence from outside the apps:
wl-pastein another process read the gallery's copy (Thicket gallery 52851, copy 2).dumpsys vibrator_manager) shows the gallery's taps:performHapticFeedback(constant=1) … played: Prebaked=CLICK.build.shnow checks it, counting only taps since the launch.Falsified:
setdoing nothing, both copy-and-paste rounds fail on GTK and on Android. Each paste showed a previous run's text, which also shows the read goes to the system clipboard.performHapticFeedbacknot called, the in-app check andbuild.sh's vibrator count both fail.Not done
🤖 Generated with Claude Code