Repository navigation
feat(scan): let a phone scan from the camera or the photo library - #578
Merged
Merged
Conversation
On a phone the scan row first asks where the photo comes from, in a bottom sheet shaped like the attachment source sheet (Take Photo / Photo Library). Take Photo opens the camera through a capture input and scans the photo from its bytes (scan_image_bytes, a raw IPC body with no path to grant); Photo Library keeps the granted pick_file image dialog. Desktop is unchanged. Adds NSCameraUsageDescription to the iOS plist.
Contributor
|
… as best effort A camera photo whose bytes cannot be loaded now lands as a failed scan in the status overlay rather than vanishing after the sheets have closed. The threat model and the command's docs now say what is scrubbed: the Rust working copy and the recognized lines, not the IPC body, Vision's NSData or the webview's buffers.
# Conflicts: # src/components/Main/icons.tsx
The read of the capture's bytes is an await with nothing of the session in hand. A lock while it runs (and an unlock of another workspace after) used to let the finished read scan the photo into the new session's editor. The app store now counts dropped sessions; the capture stamps one before the read and discards the photo if it has moved.
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.
Summary
On a phone, "Scan a card or document…" in the Add picker used to open the photo library only, so a card had to be photographed first and then picked. It now first asks where the photo comes from, in a bottom sheet shaped like the attachment source sheet of #577:
<input type="file" accept="image/*" capture="environment">. The photo is aFilewith no path on disk, so it is sent to Rust as the raw IPC body and scanned by a newscan_image_bytescommand.pick_fileimage dialog (iOS shows the Photos picker for it), keeping the existing path grant.Choosing either closes the sheet and the picker and hands over to the editor the scan fills. Backing out of the camera or the picker leaves the sheet open. Desktop is unchanged.
Changes
src/components/Main/Scan/SourceSheet.tsx: the sheet, mounted fromScan(afterAddSecretinMain) behind aui.scanSourceflag so it stacks over the picker. It is not rendered inside the picker because the bottom-sheet card'stranslatewould box in a fixed sheet.src/components/Main/Scan/capture.ts: reads the captured file's bytes and runs the shared scan;run.tsnow takes a path or bytes.ActionRowmoved tosrc/components/elements/ActionRow.tsxwith the same content as feat(attachments): attach from the photo library on a phone #577, so the two merge as one move.scan::scan_bytesand anOcr::recognize_datawith a Vision implementation (VNImageRequestHandler(data:)); bytes and recognized lines are zeroized after parsing. Other platforms report the bytes path as unsupported.src-tauri/gen/apple/rowel_iOS/Info.plist:NSCameraUsageDescription, required for the camera option.docs/threat-model.md: whyscan_image_bytesneeds no grant (the bytes are data the webview already holds; nothing on disk is read).Testing
bun run test(1080 tests, incl. newsrc/test/scanMobile.test.tsxcovering the sheet, both sources, cancel and hand-over),bun run lint,bun run typecheck.cargo test scan,cargo check,cargo fmt --check.icons.tsx.Decisions