feat: add image confirmation step to AI extraction flow

Users now see the extracted photo during item editing and can choose to:
- 'Use Photo': Auto-save the image with the item
- 'Skip Photo': Create item without saving the photo

Changes:
1. frontend/components/AIOnboarding.tsx: Added image preview panel in edit form
   - Shows extracted image to user
   - Buttons to accept/reject photo
   - Visual feedback when photo is skipped

2. frontend/hooks/useAIExtraction.ts: Updated confirmSingleItem and confirmAllItems
   - Respect user's photo decision (_skipPhoto flag)
   - Only pass extractedImageBlob if user approved it
   - Prevents unwanted auto-photo-save

This gives users full control over which extracted photos are auto-saved.
This commit is contained in:
2026-04-21 20:00:55 +03:00
parent c95e4c40b8
commit c3f63ade6a
5 changed files with 49 additions and 8 deletions

View File

@@ -133,6 +133,8 @@ export function useAIExtraction(inventory: Item[], onComplete: (itemData: any) =
const confirmSingleItem = (index: number) => {
const data = extractedItems[index];
const skipPhoto = data._skipPhoto === true; // User explicitly rejected the photo
const newItem = {
name: String(data.Item || data.name || "New AI Item"),
category: String(data.Category || data.category || "Uncategorized"),
@@ -149,9 +151,11 @@ export function useAIExtraction(inventory: Item[], onComplete: (itemData: any) =
min_quantity: 1.0,
box_label: data.box_label ? String(data.box_label) : null,
labels_data: JSON.stringify(data),
// Pass extracted image blob and image_processing metadata for auto-photo-save
extractedImageBlob,
imageProcessing: data.image_processing
// Only pass image blob if user approved it
...(skipPhoto ? {} : {
extractedImageBlob,
imageProcessing: data.image_processing
})
};
onComplete(newItem);
@@ -174,6 +178,8 @@ export function useAIExtraction(inventory: Item[], onComplete: (itemData: any) =
try {
for (let i = 0; i < itemsToProcess.length; i++) {
const data = itemsToProcess[i];
const skipPhoto = data._skipPhoto === true;
const newItem = {
name: String(data.Item || data.name || "New AI Item"),
category: String(data.Category || data.category || "Uncategorized"),
@@ -190,9 +196,11 @@ export function useAIExtraction(inventory: Item[], onComplete: (itemData: any) =
min_quantity: 1.0,
box_label: data.box_label ? String(data.box_label) : null,
labels_data: JSON.stringify(data),
// Pass extracted image blob and image_processing metadata for auto-photo-save
extractedImageBlob,
imageProcessing: data.image_processing
// Only pass image blob if user approved it
...(skipPhoto ? {} : {
extractedImageBlob,
imageProcessing: data.image_processing
})
};
await onComplete(newItem);
}