Bulk scan ux parallelizable ocr against evidence matrix - #317
Merged
kilodesodiq-arch merged 3 commits intoJul 23, 2026
Conversation
Contributor
|
👋 Thanks for the contribution! This PR contains code/test changes and CI workflows were never auto-triggered (a GitHub Actions safety requirement for cross-repo forks). To unblock this for merging, a maintainer needs to either:\n\n1. Manually click 'Approve and run workflows' on this PR's Actions tab via the GitHub UI, or\n2. Approve the pending CI on the PR checks page.\n\nOnce the CI checks pass, this can be merged. 🚀 |
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.
Closes #301
PR: BulkScannerScreen — Concurrent Scan Pipeline
Backlog item: #93 (
docs/maintainer-issue-backlog.md)Files changed:
app/mobile/src/screens/BulkScannerScreen.tsx,app/mobile/src/__tests__/BulkScannerScreen.test.tsxDifficulty: Medium | Effort: M
Problem
BulkScannerScreenprocessed QR codes sequentially. Field operators scanningdozens of items per minute experienced throughput limited to one
verification round-trip at a time.
Solution
Introduced a bounded concurrent scan pipeline with three mechanisms:
Concurrency control (up to 4 in-flight)
inFlightRef(mutable ref) guards the callback against stale-state races —multiple rapid
onBarCodeScannedevents within the same render cycle nowshare a single synchronous counter.
inFlightCount(state) remains for UI display and for disabling theBarCodeScannercallback (onBarCodeScanned={undefined}) once at capacity.MAX_CONCURRENT = 4allows the camera to keep framing while earlier scansresolve in the background.
Deduplication
seenReftracksaidId → timestamppairs.aidIdwithinDEDUP_TTL_MS(5 s) are skipped with avisible "Duplicate scan — skipped" badge.
Rate limiting
aidIdwithinRATE_LIMIT_MS(300 ms) are rejectedwith a "Rate limited — slow down" badge, even outside the dedup window.
Acceptance criteria
inFlightRefguard +onBarCodeScanneddisabled at capacityseenRefTTL-based dedup with evictionTest details
Concurrency cap
Simulates rapid synchronous scans and asserts
maxObserved ≤ MAX_CONCURRENT.Throughput ≥ 2× (50 items)
Mocks
queueClaimConfirmationwith a configurable async delay.Fires 50 scan events through the component's handler in rapid succession,
measures wall-clock completion time, and compares against a sequential baseline
(50 × delay). Asserts
speedup ≥ 2.Dedup correctness
Feed
['aid-1', 'aid-2', 'aid-1', 'aid-3', 'aid-2']through the dedup logicand assert
['processed', 'processed', 'skipped', 'processed', 'skipped'].Rate limit correctness
Record a scan timestamp and immediately re-scan the same
aidId. Assertthe second scan is rate-limited.
Key implementation notes
inFlightCountis removed from theuseCallbackdependency array, sincethe guard no longer depends on state. This eliminates re-render cascades and
stale-closure bugs.
Rollback
Revert the two changed files. No migration or feature-flag required.