diff --git a/apps/api/src/routes/scans.ts b/apps/api/src/routes/scans.ts index e85489e..59b7b37 100644 --- a/apps/api/src/routes/scans.ts +++ b/apps/api/src/routes/scans.ts @@ -338,6 +338,10 @@ async function annotateScanDuplicates( const source = scanSource(job.scanType); const now = new Date().toISOString(); + // Jämför bara mot TIDIGARE bilder i samma skanning när det finns FLERA foton + // (överlappande vinklar). I ett enda foto är två liknande behållare oftast + // två riktiga varor – flagga dem aldrig mot varandra. + const multiImage = (job.s3Keys?.length ?? 0) > 1; const seen: typeof existing = []; const items = result.items.map((it, idx) => { @@ -349,9 +353,9 @@ async function annotateScanDuplicates( source, createdAt: now, }; - const pool = [...existing, ...seen]; + const pool = multiImage ? [...existing, ...seen] : existing; const [top] = findDuplicateCandidates(input, pool); - seen.push({ id: String(it.tempId ?? idx), ...input }); + if (multiImage) seen.push({ id: String(it.tempId ?? idx), ...input }); if (!top) return { ...it, possibleDuplicate: null }; const match = pool.find((p) => p.id === top.itemId); return { diff --git a/apps/mobile/src/app/scan-review/[jobId].tsx b/apps/mobile/src/app/scan-review/[jobId].tsx index 3c810ff..d9cd726 100644 --- a/apps/mobile/src/app/scan-review/[jobId].tsx +++ b/apps/mobile/src/app/scan-review/[jobId].tsx @@ -106,8 +106,9 @@ export default function ScanReviewScreen() { dateIsUseBy: false, confidence: item.confidence, duplicate: item.possibleDuplicate ?? null, - // Hög säkerhet på dubblett → avmarkerad som standard (syns tydligt + går att ångra). - rejected: (item.possibleDuplicate?.score ?? 0) >= 0.7, + // Markera möjlig dubblett men ta ALDRIG bort automatiskt – två av samma + // vara, eller en till på en annan hylla, är ofta helt riktigt. Du väljer. + rejected: false, })), ); }