8000 Camera (#130) onto main: it merged into feat/pickers after #131 had already merged by rleibman · Pull Request #133 · rleibman/thicket · GitHub
[go: up one dir, main page]

Skip to content

Camera (#130) onto main: it merged into feat/pickers after #131 had already merged - #133

Merged
rleibman merged 2 commits into
mainfrom
feat/camera-main
Nov 1, 2026
Merged

rleibman merged 2 commits into
mainfrom
feat/camera-main

Conversation

@rleibman
@rleibman rleibman commented Nov 1, 2026
Copy link
Copy Markdown
Owner

The same slip as #126/#131: #130 merged into its base, feat/pickers, 52 seconds after #131 merged into main. So the camera is on feat/pickers and not on main. I couldn't retarget #130 to main beforehand, because it needed the pickers, which weren't on main until #131 merged.

This PR is #130's squash (1f572b1) cherry-picked onto main. It applied cleanly:

The details are in #130: Android 86/86, GTK 137, checkLinux exit 0, and both Copilot reviews addressed.

To avoid a third time: there's nothing stacked left. From now on I'll branch from main, or retarget a child PR the moment its parent merges.

🤖 Generated with Claude Code

…e cache like a picked file (#130)

* Camera capture: thicket-camera and -android, the photo copied into the cache like a picked file

docs/16 §16.10 item 5.

- thicket-camera: Camera.capturePhoto(onResult: Option[Path] => Unit), availability;
  Camera.unavailable for GTK; FakeCamera. Reuses thicket-pickers' PickedFiles.
- thicket-camera-android: ACTION_IMAGE_CAPTURE writing to a MediaStore entry Thicket creates
  (FileProvider is AndroidX); the photo is copied into the cache and the entry deleted.
  Android 10+; NeedsPermission(Camera) for an app that declares CAMERA without it granted.

Measured:
- checkLinux (with-keyring, 8 GB): exit 0; CameraSpec 2/2, JVM and Native.
- bin/gtk-selftests.sh on the desktop: gallery 137 (136 + 1), todo 69.
- SELFTEST=1 examples/gallery/android/build.sh on s2test: 85/85 (81 + 4). build.sh presses the
  emulator camera's shutter and Done; the JPEG comes back (FF D8 FF) and the entry is gone;
  backing out answers no photo.

Falsified: a first version made the entry IS_PENDING; the camera app could not write to it and
no photo came back (the JPEG check failed). With the delete removed, both "no entry left"
checks fail, naming the entries left behind.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* AndroidCamera: sweep entries a killed run left behind (review)

The MediaStore entry a capture writes to is remembered only in memory, so if Android kills the
app while the camera app is in front, it would stay in the user's photo library. Each new
AndroidCamera now deletes, on a worker thread, the thicket-*.jpg entries this app owns
(OWNER_PACKAGE_NAME, never another app's) and is not waiting on.

The Android self-test plants such an entry and checks that a new AndroidCamera removes it.

Measured: SELFTEST=1 examples/gallery/android/build.sh on s2test, 86/86 (85 + 1). With the
sweep deleting nothing, the new check fails: "planted List(thicket-….jpg); swept Some(0)".

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>

* AndroidCamera: one sweep per camera, reported through onSwept (review)

The self-test built an AndroidCamera, whose constructor sweeps, and then called sweep again:
two sweeps raced to delete the one planted entry, and the one the check listened to could
count 0. The constructor now takes onSwept and sweep is private, so there is one sweep and
its count is the one checked.

Measured: SELFTEST=1 examples/gallery/android/build.sh on s2test, 86/86.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Decision log: the camera entry's Android count is 86, with the sweep check (review)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI 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.

🟡 Changes recommended

A moderate unresolved concurrency defect remains where the sweep worker reads the shared pending var off the UI thread, risking deletion of an in-flight capture's MediaStore entry.

1 open issue
What changed in this PR

This PR cherry-picks PR #130 (camera capture: thicket-camera and thicket-camera-android) onto main. As described, #130 had merged into its base branch feat/pickers moments after #131 merged the pickers into main, leaving the camera stranded off main; this applies #130's squash cleanly (the only delta from the reviewed tree being AndroidPickers.uris becoming private, which arrived via #131). Functionally it adds a new device-service module for taking a photo with the platform's own camera screen, wired into the gallery and documented.

Changes:

  • Adds thicket-camera (Camera trait with capturePhoto/availability, Camera.unavailable, FakeCamera) and thicket-camera-android (ACTION_IMAGE_CAPTURE into a Thicket-created MediaStore entry, copied into the cache via PickedFiles and deleted; plus a constructor sweep for entries a killed run left behind).
  • Integrates the camera into the gallery's Pickers section (GTK uses Camera.unavailable; Android uses AndroidCamera) with GTK and Android self-test checks.
  • Wires the modules into build.sbt and updates docs/counts (README, decisions log, 12/14/16).
File Description
modules/​camera/​shared/​.../​Camera.scala New Camera trait and Camera.unavailable factory.
modules/​camera/​shared/​.../​testing/​FakeCamera.scala Test fake returning a fixed photo/None and counting requests.
modules/​camera/​shared/​.../​CameraSpec.scala Unit tests for the fake and Camera.unavailable.
modules/​camera/​README.md Module README.
modules/​camera-android/​.../​AndroidCamera.scala Android implementation: MediaStore capture, cache copy, entry delete, leftover sweep.
examples/​gallery/​shared/​.../​StorageDemo.scala Adds camera to the Services case class.
examples/​gallery/​shared/​.../​PickersDemo.scala Adds takePhoto, camera labels, and lastTaken self-test hook.
examples/​gallery/​shared/​.../​Gallery.scala Renames section, adds "Take a photo" button, threads camera into PickersDemo.
examples/​gallery/​gtk/​.../​GalleryGtk.scala GTK self-test check + noCamera; registers Camera.unavailable.
examples/​gallery/​android/​.../​GallerySelfTest.scala Android camera/sweep self-tests + AndroidCameraChecks.
examples/​gallery/​android/​.../​GalleryActivity.scala Registers AndroidCamera.
examples/​gallery/​android/​build.sh Packages camera modules; adds photo drive action.
build.sbt New camera/cameraAndroid projects and aggregation wiring.
README.md, docs/​decisions.md, docs/​12, docs/​14, docs/​16, examples/​gallery/​README.md Status, decision log, release and count updates.

I reviewed the implementation, gallery wiring, build aggregation, and docs. Referenced APIs (ThicketActivity.Listener.activityResult, PickedFiles.copy, Permission.Camera, Availability imports) and the GTK/Android self-test counts all check out. One concurrency note was filed on the sweep worker reading the shared pending var off the UI thread; everything else is consistent with the established pickers/device-service patterns.

Review effort: Balanced

Copilot AI 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.

🟢 Approval recommended

The review surfaced no high-confidence, objective defects and recorded no inline issues, with constructor call sites, imports, -release 17 settings, and self-test counts all verified internally consistent.

1 open issue

Review effort: Balanced

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com&g
8000
t;
@rleibman
rleibman merged commit 2155b5e into main Nov 1, 2026
2 checks passed
rleibman added a commit that referenced this pull request Nov 1, 2026
Conflicts were both sides adding beside each other (build, gallery wiring, docs);
each keeps both, camera first as on main.

Measured: platforms/Test/compile clean; GTK gallery 138 (137 + share's 1), todo 69
(bin/gtk-selftests.sh); Android gallery 90/90 (86 + share's 4) on s2test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rleibman added a commit that referenced this pull request Nov 1, 2026
One conflict in docs/16 §16.10: main's camera bullet kept, and this branch's
pointer to docs/17 for tier 3. Docs only; nothing to measure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rleibman added a commit that referenced this pull request Nov 1, 2026
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>
rleibman added a commit that referenced this pull request Nov 1, 2026
One conflict, the decision log: both entries kept, #114's first.

Measured: platforms/Test/compile clean; checkLinux exit 0 on the second run.
The first run failed one effectZioJVM test (not identified: --error hid the
name); effectZioJVM/testFull alone then passed 25/25, and the whole check
passed on the rerun, so a timing flake under load, as #117's was. Apple
self-tests not run here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rleibman added a commit that referenced this pull request Nov 1, 2026
Two conflicts, the decision log (both entries kept, Apple's first) and docs/14's
list of platform modules (both sets).

Measured: checkLinux exit 0; platforms/Test/compile clean. MotionDemo's
sensorsLabel changes the shared gallery, so: GTK gallery 137, todo 69
(bin/gtk-selftests.sh under a headless gnome-shell: the desktop was locked, and
the first, locked run failed only the Device foreground check); Android gallery
86/86 on s2test. Apple self-tests not run here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rleibman added a commit that referenced this pull request Nov 1, 2026
Two conflicts, the decision log (both entries kept, Apple's first) and docs/14's
list of platform modules (both sets).

Measured: checkLinux exit 0; platforms/Test/compile clean. The shared gallery
changes are comments only. Apple self-tests not run here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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

0