Skip to content

Decode QR codes and barcodes in text capture - #2096

Open
x1xhlol wants to merge 9 commits into
CapSoftware:mainfrom
x1xhlol:feat/qr-capture
Open

Decode QR codes and barcodes in text capture#2096
x1xhlol wants to merge 9 commits into
CapSoftware:mainfrom
x1xhlol:feat/qr-capture

Conversation

@x1xhlol

@x1xhlol x1xhlol commented Aug 6, 2026

Copy link
Copy Markdown

Summary

Extends the text-capture flow (Ctrl/Cmd+Shift+T) with QR code and barcode recognition: if the selected area contains a QR code or barcode, its decoded payload is copied to the clipboard instead of running OCR. No code found → falls back to OCR exactly as before.

  • New barcode module using rxing (Rust port of ZXing — free, on-device, supports QR plus the common 1D/2D barcode formats), decoding with TryHarder on the captured region's luma data.
  • capture_ocr_text tries the barcode decode first (on a blocking task), and only falls back to OCR when nothing is found:
    capture region in-memory → decode QR/barcode
       ├─ payload found → clipboard
       └─ none → native OCR → clipboard
    
  • No new UI or settings: same shortcut, same selector, same default-off screenshot/notification toggles.

Builds on #2095 (OCR text capture); the barcode change itself is the top commit.

Showcase

Select a QR code and its payload is on the clipboard, ready to paste:

QR payload copied to clipboard

Testing (Windows, end-to-end on a live dev build)

Test Result
QR-only selection → clipboard = exact payload
QR + surrounding caption text → payload wins over OCR
Text-only selection → OCR fallback (exact text match)
No click-blocking overlay left after capture
Regression: normal screenshot flow unaffected

macOS compiles the same path (the decoder is pure Rust, platform-independent); runtime-tested on Windows only.

Greptile Summary

The PR adds barcode and QR decoding ahead of native OCR in the desktop text-capture flow.

  • Adds an on-device rxing decoder and copies decoded payloads directly to the clipboard.
  • Adds OCR-area target selection, a default global shortcut, persisted capture preferences, and the corresponding Rust/TypeScript IPC wiring.
  • Retains native OCR as the fallback when no barcode payload is found.

Confidence Score: 4/5

The PR appears safe to merge, with only a non-blocking redundant comment to remove.

The barcode-first capture path retains OCR fallback behavior, keeps persisted fields backward-compatible, and coordinates overlay cleanup across success and failure paths; the only accepted concern is comment-policy compliance.

Files Needing Attention: apps/desktop/src-tauri/src/barcode.rs

Important Files Changed

Filename Overview
apps/desktop/src-tauri/src/barcode.rs Adds luma-based barcode decoding through rxing; contains one redundant doc comment.
apps/desktop/src-tauri/src/recording.rs Adds barcode-first text capture with blocking decode work, native OCR fallback, clipboard output, and capture-window handling.
apps/desktop/src-tauri/src/hotkeys.rs Adds the OCR-area action and conflict-aware one-time default shortcut seeding.
apps/desktop/src/routes/target-select-overlay.tsx Extends area selection with OCR capture and explicit overlay cleanup and error restoration.
apps/desktop/src/utils/tauri.ts Updates generated bindings to match the new Rust commands, target mode, settings, and hotkey action.
apps/desktop/src-tauri/src/general_settings.rs Adds backward-compatible default-off settings for retaining OCR screenshots and showing notifications.
Prompt To Fix All With AI
### Issue 1
apps/desktop/src-tauri/src/barcode.rs:3
**Redundant barcode helper comment**

This comment only restates that `decode_barcode` decodes a barcode and returns text, adding maintenance noise without documenting a non-obvious invariant or rationale.

```suggestion

```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "Decode QR codes and barcodes in text cap..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

Context used (3)

@socket-security

socket-security Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcargo/​rxing@​0.9.288100100100100
Addedcargo/​regex@​1.13.110010093100100
Addedcargo/​regex-automata@​0.4.1810010093100100
Addedcargo/​regex-syntax@​0.8.1110010093100100

View full report

Comment thread apps/desktop/src-tauri/src/barcode.rs Outdated
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.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.

1 participant