feat(camera): add name hint for failed item recognition #323
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
Fixes #310 - Adds the ability to provide a name hint when camera item recognition fails, helping the AI identify difficult items like gas cans and radial saws.
Problem
Camera item recognition was failing on certain items (specifically mentioned: gas can, radial saw) with no way for users to provide additional context to help the AI. Users would just see "Could not identify the item. Please try again." and have to retake the photo or give up.
Solution
1. Enhanced Error UI with Hint Option
When recognition fails, the error screen now shows:
2. Name Hint Input Flow
Clicking "Try Again with Hint" reveals:
3. Backend: analyze-item API Enhancement
Updated
/api/analyze-itemto accept optionalnameHintform parameter:When hint is provided, it's passed to OpenAI:
Key points:
4. Smart Retry Logic
New
retryWithHint()function:Distinguishing Recognition Failures vs. Prohibited Items
The API already distinguishes between:
prohibited: truewith specificprohibitionReasonrecognized: falsewithoutprohibitedflagThe hint feature only appears for genuine recognition failures, not for prohibited items. This ensures the hint can't be used to bypass safety restrictions.
User Flow Example
Technical Details
Files Changed
src/app/api/analyze-item/route.ts- Accept and use nameHint parametersrc/components/AddItemClient.tsx- Add hint UI and retry logicState Management
showHintInput: boolean- Toggle hint input visibilitynameHint: string- Store user's hint textDependencies
TextFieldto MUI importsTesting Checklist
Manual Testing Needed
Edge Cases
Screenshots
Before (Current)
Error screen with only "Try Again" button
After (This PR)
Error screen showing:
Hint input screen showing:
Related
🤖 Generated with Claude Code