Repository navigation
Apple clipboard and haptics: thicket-clipboard-apple, thicket-haptics-apple (#123) - #127
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>
…-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>
There was a problem hiding this comment.
🔵 Needs a closer look
The change hinges on hand-written Objective-C FFI correctness that only the author could verify by running on macOS/iOS, which is not reproducible in this Linux review environment.
No open issues 🎉
What changed in this PR
This PR adds the Apple half of Thicket's clipboard and haptics device services (docs/16 §16.10 item 5, issue #123), stacked on #124 which built the base modules plus GTK/Android. It introduces two new Scala Native modules — thicket-clipboard-apple (NSPasteboard/UIPasteboard) and thicket-haptics-apple (UIImpactFeedbackGenerator/UISelectionFeedbackGenerator/NSHapticFeedbackManager) — each backed by a small C helper that drives Objective‑C through objc_msgSend and links UIKit/AppKit via LC_LINKER_OPTION, mirroring #108's Keychain helper rather than adding a Swift shim. Both galleries pass the services through, a combined ClipboardDemo and self-tests exercise copy/paste/tap, and bin/verify-apple.sh reads the pasteboard back from outside the app.
Changes:
- New
thicket-clipboard-apple/thicket-haptics-applemodules (C helpers + Scala FFI), wired intobuild.sbt(platforms, galleries), with clipboard depending onrendererAppleforpostToUiand haptics needing no renderer. - Gallery integration:
Servicesgainsclipboard/haptics, a "Clipboard and haptics" section,ClipboardDemo, and self-test checks on all four hosts (Apple gates each paste on a raised pasteboardchangeCountto avoid the iOS "Allow Paste" hang). - Documentation and verification updates (decision log,
docs/12/14/16, module READMEs,verify-apple.shpasteboard read-back, Androidbuild.shvibrator check).
I reviewed the native Objective‑C FFI (msgSend casts, autorelease/retain of kept generators, CoreFoundation string bridging, framework linking), the Scala↔C ABI signatures, the strength→pattern mappings (light→Alignment, medium→Generic, heavy→LevelChange; selection→Alignment), the gallery/self-test wiring, build aggregation, -release 17 placement, and doc counts. Verified all Services(...) call sites and the single screen(...) caller are updated, and that self-test helpers (eventually, buttonIn, AppleInspect.*, Await) and the integration points exist and match. I found no objective defects to report; the implementation is internally consistent and matches the established C-helper pattern.
| File | Description |
|---|---|
modules/clipboard-apple/.../AppleClipboard.scala |
Scala FFI + synchronous read answered via postToUi; changeCount for self-test |
modules/clipboard-apple/.../thicket_pasteboard.c |
C helper: general pasteboard set/get/free/changeCount via objc_msgSend |
modules/haptics-apple/.../AppleHaptics.scala |
Scala FFI for impact/selection + availability |
modules/haptics-apple/.../thicket_feedback.c |
C helper: iOS feedback generators, macOS NSHapticFeedbackManager |
modules/clipboard/.../Clipboard.scala, MemoryClipboard.scala, ClipboardSpec.scala |
Core clipboard API + in-memory fake + unit test |
modules/haptics/.../Haptics.scala, RecordingHaptics.scala, HapticsSpec.scala |
Core haptics API + recording fake + unit tests |
| `modules/clipboard-gtk | android/..., haptics-android/...` |
examples/gallery/.../ClipboardDemo.scala, Gallery.scala, StorageDemo.scala |
Combined demo, gallery section, Services fields |
examples/gallery/{macos,ios,gtk,android}/... |
Host wiring + self-test checks for clipboard/haptics |
examples/gallery/android/build.sh, bin/verify-apple.sh |
External pasteboard/vibrator verification |
build.sbt |
New module defs, dependencies, platforms/root aggregation |
README.md, docs/{12,14,16}, docs/decisions.md, module READMEs |
Status, release, counts, decision log |
No blocking issues found. The native Apple FFI and iOS pasteboard-prompt behavior are only verifiable on macOS/iOS (done by the author: all 16 verify-apple.sh steps pass), which can't be reproduced in this Linux review environment.
Review effort: Balanced
|
@copilot resolve the merge conflicts in this pull request |
…oard-haptics # Conflicts: # README.md # build.sbt # docs/12-component-status.md # docs/14-releasing.md # docs/16-device-services.md # docs/decisions.md # examples/gallery/README.md # examples/gallery/shared/shared/src/main/scala/example/gallery/StorageDemo.scala # modules/clipboard/README.md # modules/haptics/README.md Co-authored-by: rleibman <3268890+rleibman@users.noreply.github.com>
Done — I merged |
…oard-haptics # Conflicts: # README.md # build.sbt # docs/12-component-status.md # docs/14-releasing.md # docs/16-device-services.md # docs/decisions.md # examples/gallery/README.md # examples/gallery/shared/shared/src/main/scala/example/gallery/StorageDemo.scala
|
Merged
Checked on Linux: The camera, #130, also merged into a stale base; #133 brings it to |
…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>
|
Merged |
There was a problem hiding this comment.
🔵 Needs a closer look
A critical finding shows the PR appears based on a stale main and would revert the entire unrelated pickers feature across many files, an active issue that must be resolved before merging.
No open issues 🎉
Review effort: Balanced
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>
|
Heads-up for the Mac session:
🤖 Generated with Claude Code |
Both sides grew the Apple galleries: - GalleryIos/GalleryMac: Services get device, clipboard and haptics. - GallerySelfTest: storage -> device -> clipboard -> sheet -> big list, both check groups kept. - build.sbt: the Apple galleries depend on deviceApple, clipboardApple and hapticsApple. - verify-apple.sh's header, docs/12's Apple counts (the two measured apart; the combined run is the Mac's) and the decision log keep both. Measured: platforms/Test/compile clean (type-checks the Apple Scala). Not measured: the Apple self-tests on the combined gallery, which need the Mac. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both sides grew the Apple galleries: Services get device, motion, clipboard and haptics; the self-test runs storage -> device -> motion -> clipboard -> sheet -> big list; the Apple galleries depend on motionIos, clipboardApple and hapticsApple. Docs keep both sides (README, docs/12, 14, 16); the decision log's 2026-11-01 entry moved back to the top. Measured: platforms/Test/compile clean. #127 is Apple-only, so cc3ee5a's GTK (137) and Android (86) counts stand. Not measured: the Apple self-tests on the combined gallery (the Mac's). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both sides grew the Apple galleries: Services get device, location, clipboard and haptics; the self-test runs storage -> device -> location -> clipboard -> sheet -> big list; the Apple galleries depend on locationApple, clipboardApple and hapticsApple. docs/12, 14 and the decision log keep both sides; its 2026-11-01 entry moved back to the top. Measured: platforms/Test/compile clean. Shared gallery code is unchanged from 427494e but for #127's Apple-only additions. Not measured: the Apple self-tests on the combined gallery (the Mac's). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closes #123. The Apple half of
docs/16§16.10 item 5.Built on #124 (
feat/clipboard-haptics), which must merge first. Until then this diff includes #124's commit; the change here is the last commit.What it adds
thicket-clipboard-appleNSPasteboard.general, usingclearContents()thensetString(_, forType: .string).UIPasteboard.general.string.getanswers on the next run-loop turn throughAppleApp.postToUi. Because of that it depends onrendererApple, the wayclipboardGtkdepends on its renderer.thicket-haptics-appleUIImpactFeedbackGenerator(light, medium, heavy; one per strength, kept) andUISelectionFeedbackGenerator.NSHapticFeedbackManager.defaultPerformer.resources/scala-native.objc_msgSend) and names UIKit or AppKit in the object file (LC_LINKER_OPTION), as Apple (Mac): secrets in the Keychain, thicket-secrets-apple, and the gallery's secrets checks #108's Keychain helper does..c,.cppand.Sbut not.m(checked intools_3-0.5.12).Haptics.none. A Force Touch trackpad (current MacBooks, Magic Trackpad 2) plays them; with a mouse nothing is felt and nothing fails..alignment, Medium →.generic, Heavy →.levelChange, selection →.alignment.availabilityisAvailable, because AppKit does not say whether such a trackpad is attached.clipboardandhapticsinServices.clipboardChecks: Copy then Paste, twice, then the haptics label and "Tap".changeCount(see below).bin/verify-apple.shreads the gallery's last copy from outside the app after each run:pbpasteon macOS, which also puts the user's clipboard back afterwards, andxcrun simctl pbpasteon iOS.Measured
bin/verify-apple.sh "iPhone Air"(macOS 27.0.1, Xcode 27.0, iOS 27.0 simulator): all 16 steps PASS.pbpasteafter each macOS runThicket gallery 44460, copy 2/Thicket gallery 9382, copy 2, matching the gallery's last copyxcrun simctl pbpaste "iPhone Air"Thicket gallery 1759, copy 2, matchingAvailable; the "Tap" call returns. The simulator plays nothing, so that is all it can showiOS "Allow Paste" on the simulator (screenshots taken during the runs):
xcrun simctl pbcopy: prompt, "GalleryIos would like to paste from CoreSimulatorBridge".UIPasteboard.stringblocks the main thread until the user answers. In the run it waited the full 120 s and was never answered. Nothing can tap the prompt from the command line, so neither answer was measured.sethung the run instead of failing it.Falsified
setdoing nothing, with the final self-test: bo 8000 th rounds fail on macOS and on the simulator. The change count stays put, and the outside reads show the older text.changeCountgate:Not done
pbpaste/pbcopy). An image on it would not survive a run. Here it was empty before and after.🤖 Generated with Claude Code