Commit Graph

241 Commits

Author SHA1 Message Date
7f6d121d4a fix: modal actually processes image with rotation/crop and fixes zoom
Critical fixes:
1. Modal now applies rotation and crop to image, returns processed blob
2. Frontend sends processed image to backend (not original)
3. Zoom slider min/max now calculated based on image size
4. Initial zoom shows entire image in canvas
5. Zoom constraints prevent over-zooming or under-zooming

User experience improved:
- Sees full item at start (auto-fit zoom)
- Can adjust rotation/crop smoothly
- Adjusted image is what gets saved (not original)
- Zoom slider works correctly for any image size

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-04-22 13:05:19 +03:00
97629decb1 fix: canvas displays full image by default with auto-fit zoom
Fixes issue where image was too small to see full item in modal canvas.

Changes:
- Calculate initial zoom to fit entire image in 800x600 canvas
- Don't zoom in (only zoom out to fit), preserving image clarity
- Reset button also resets to fit zoom instead of always 1.0

This ensures users can see the full item from the start and understand
what they're adjusting.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-04-22 12:57:19 +03:00
e6a64bb407 fix: properly apply image adjustment overrides to AI-detected values
Fixed two critical issues:
1. Adjustments now properly override image_processing values
2. State updates explicitly ensure extractedItems are modified before confirm

Changes:
- handleImageAdjustmentConfirm now updates extractedItems state
- Adjustments properly stored in image_processing (rotation_degrees, crop_bounds)
- user_adjusted flag added to mark user-modified values
- Backend will use adjusted values instead of AI detection

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-04-22 12:55:30 +03:00
b73f012332 feat: integrate ImageAdjustmentModal into AIOnboarding flow
Added user-controlled image adjustment modal that displays after item
confirmation, allowing users to adjust rotation/crop before final save.

Changes:
- AIOnboarding: wrapper confirmSingleItem to show modal post-selection
- State: showImageAdjustment, adjustingItemIndex, pendingItemData
- Handlers: confirm/cancel for applying or discarding adjustments
- Flow: item save → modal display → adjustments applied → DB commit

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-04-22 12:45:44 +03:00
da8b2ed07b build: update service worker 2026-04-22 12:40:57 +03:00
6a69adbc28 feat: create ImageAdjustmentModal for post-save image adjustment
- Shows original image after item save
- Rotation slider + gesture rotation
- Zoom control (scroll/pinch)
- Pan support (drag on desktop/mobile)
- Preset aspect ratios for crop
- Touch support for mobile (pinch zoom, drag pan)
- Checkbox to confirm/reject image use (default ON)
- Compresses image if adjusted before saving
2026-04-22 12:38:51 +03:00
37b3ae7ae8 feat: add crop box edge labels (T/B/L/R) for orientation
- Shows which edge is Top, Bottom, Left, Right on crop rectangle
- Removes ambiguity about crop box orientation
- Green labels on all four edges for clear visual reference
2026-04-22 12:13:18 +03:00
dba47aa656 feat: make crop box interactive in debug panel
- Add drag-to-move functionality for entire crop box
- Add resize handles at corners (drag to resize)
- Show adjusted bounds separately from AI bounds in log
- Add Reset button to revert to original crop bounds
- Allows visual verification of AI crop detection accuracy
2026-04-22 11:47:13 +03:00
11f0634721 fix: add rotation direction indicators and fix CORS for dev origins
- Add TOP/BTM labels to rotated box showing which edge is which after rotation
- Allows user to visually see rotation direction without calculating degrees
- Fix allowedDevOrigins to include common private IP ranges (192.168.*, 10.*, 172.16.*)
- Resolves CORS warning when accessing from local network IPs
2026-04-22 11:38:32 +03:00
1fca9b5ff7 feat: add orientation indicators to debug panel
- Display UP/DOWN/LEFT/RIGHT labels at canvas edges
- Shows which direction is which in the original image
- Helps verify rotation correctness visually
2026-04-22 11:33:37 +03:00
7c493c656a fix: remove dark overlay from debug panel crop visualization
- Removed black overlay that was hiding the image
- Draw crop box directly on full-brightness image with drop shadow
- Item under crop area now fully visible
- Improved visibility of both crop bounds (green) and rotation (orange)
2026-04-22 11:27:16 +03:00
82948ada92 fix: improve debug panel layout and log display
- Clear logs between rotation updates (no more expanding text)
- Increase canvas size from 600x450 to 900x600 for better visibility
- Reorganize layout: left controls, right canvas + single-line log
- Make crop box much larger and easier to see
2026-04-22 11:20:43 +03:00
c46c8414b8 feat: store original EXIF-stripped image for debugging
- Save original image before crop/rotation with '_debug_original' variant
- Store original_photo_path in labels_data.image_processing for debug access
- Update DebugRotationPanel to display original image instead of processed
- Update ItemDetailModal to pass original image path to debug panel
- Enables accurate crop/rotation visualization with true original image
2026-04-22 11:13:09 +03:00
9f65d427a0 optimize: make debug panel more compact to fit screen
Layout changes:
- Reduced padding and margins throughout
- Changed from 3-column to 2-column layout
- Canvas + logs on right side (side-by-side)
- Smaller fonts and spacing
- Sticky header that stays in view
- Max-height with scrolling for modal
- Removed footer text to save space
- More efficient use of screen real estate

Now fits on most screen sizes even with large rotation angles.
2026-04-22 11:08:49 +03:00
f708fb7768 refactor: redesign debug panel with overlay visualization
Much better UX for identifying correct rotation:

- Shows ORIGINAL image scaled to fit the modal
- Draws GREEN bounding box showing the crop area
- Draws ORANGE rotated rectangle showing rotation effect
- Darkens everything outside the crop area (visual focus)
- Rotation slider updates the overlay in real-time
- Quick preset buttons for common angles
- Detailed debug logs showing all calculations
- Better styling: dark theme for readability

User can now visually see what will be extracted with the current
rotation angle. Report the angle that makes the label readable.
2026-04-22 11:06:01 +03:00
1a774088a1 feat: add debug rotation panel for real-time testing
New DebugRotationPanel component allows testing different rotation angles
with live preview and detailed debug logs showing:
- Current rotation angle (slider + quick presets)
- Crop bounds and calculations
- Image dimensions at each step
- Final processed image preview
- Confidence score

Integrated into ItemDetailModal via wrench icon in header (only visible
when item has a photo). Helps identify correct rotation values for images
at any angle.

Debug panel shows:
- Original image info
- Crop bounds and resulting size
- Rotation angle and final canvas size
- Step-by-step processing logs
- Live canvas preview of result
2026-04-22 10:56:27 +03:00
ba581744ec refactor: improve checkbox styling and remove popup
- Update photo save checkbox to match app design (border-slate-600, htmlFor label)
- Remove success popup overlay - modal closes immediately after save
- Simplify confirmSingleItem to remove setTimeout logic
- Toast notification used for user feedback instead
2026-04-22 09:17:56 +03:00
99a4cae572 fix: show item save confirmation with image before closing
- Add savingIndex state to track saving operation
- Display success overlay with saved image for 1.5 seconds
- Show item name in confirmation message
- Prevents modal from closing immediately after save

Fixes user complaint about image disappearing too quickly without confirmation
2026-04-22 09:07:44 +03:00
64d177e791 fix: complete image pipeline - rotation, URL, preview
- Add rotation_degrees parameter to ImageProcessor.process_photo()
- Pass rotation through _auto_save_photo_from_extraction() to processor
- Allow no-crop fallback when crop_bounds is None
- Add buildPhotoUrl() helper to resolve backend URLs correctly
- Update frontend components to use backend URL for image sources
- Replace Use/Skip Photo buttons with checkbox in AI extraction UI
- Add images/ to .gitignore to prevent accidental commits

Addresses: rotation never applied, image 404s (relative to Next.js not backend), preview blank in edit form
2026-04-22 08:50:25 +03:00
c3f63ade6a 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.
2026-04-21 20:00:55 +03:00
cbfd7232ca fix: convert extracted image blob to base64 before sending to API
The extracted image blob from AI extraction was not being sent to the backend
because Blob objects cannot be JSON serialized. Fixed by:

1. Converting Blob to base64 before sending to API
2. Renaming fields: extractedImageBlob → extracted_image_bytes, imageProcessing → image_processing
3. Removing Blob from local DB (keep original data structure for IndexedDB)
4. Applying same fix to both single item and batch update flows

This ensures the auto-photo-save feature receives the image data it needs.
2026-04-21 19:53:53 +03:00
eaa2d2d29f fix: replace toast.warning with toast.success in useItemCreate
toast.warning is not a valid method in react-hot-toast API. Changed to
toast.success since the item was successfully created even if photo upload failed.
2026-04-21 19:47:16 +03:00
b5fb2a8cdb fix: add photo_path fields to frontend Item interface to display saved photos
The backend returns photo_path, photo_thumbnail_path, and photo_upload_date
from the AI auto-save feature, but the frontend Item interface was missing
these fields, causing images not to display in ItemDetailModal and InventoryTable.

Updated:
- frontend/lib/db.ts: Added missing photo fields to Item interface
- frontend/components/ItemDetailModal.tsx: Use photo_path first, fallback to image_url
- frontend/components/InventoryTable.tsx: Use photo_path first, fallback to image_url

This ensures the UI can now display photos saved by the auto-photo-save feature.
2026-04-21 19:45:19 +03:00
c22dadbd1a test: add E2E test for AI extraction + auto-photo-save flow 2026-04-21 19:33:18 +03:00
08fc785583 feat: pass extracted image and image_processing metadata to item creation
- Updated confirmSingleItem() to include extractedImageBlob and imageProcessing
- Updated confirmAllItems() to pass image data for bulk item creation
- Each extracted item now carries its own image_processing metadata
- All items in bulk creation share the same extracted image blob
- Added 12 comprehensive tests verifying data is passed correctly
- All 465 frontend tests passing, zero regressions
2026-04-21 19:27:17 +03:00
fab1e81cf6 feat: auto-upload photo after item creation if image_processing provided 2026-04-21 19:22:10 +03:00
d73b7e45a1 feat: store extracted image blob and image_processing metadata in useAIExtraction hook 2026-04-21 19:04:16 +03:00
6bf95a0df0 fix: prevent username input from unmounting during typing in login form
The username input was conditionally hidden when it had a value, causing
the field to disappear and focus to jump to password when typing. Fixed by:
1. Always rendering the username input (removed conditional)
2. Using controlled input with value prop
3. Only auto-focus password when username is already entered

This fixes the focus-jumping bug that made it impossible to enter usernames.
2026-04-21 17:54:19 +03:00
2daeb1e2ae fix: use SERVER_IP from network config for backend API calls from VPN
When accessing from VPN/Tailscale (e.g., 100.78.182.28), frontend was trying
to reach backend on that same IP, but backend listens on SERVER_IP instead.
Now uses SERVER_IP from network.json config, ensuring remote clients connect
to the correct server address regardless of their access network.
2026-04-21 15:23:12 +03:00
3c9e5a8149 refactor: remove all hardcoded IPs/subnets, use environment variables only
- Next.js allowedDevOrigins now loaded from ALLOWED_DEV_ORIGINS env var
- start_server.sh generates ALLOWED_DEV_ORIGINS from EXTRA_ALLOWED_ORIGINS
- Subnet notation (10.0.0.0/24) auto-converts to wildcard patterns (10.0.0.*)
- Individual IPs convert to subnet patterns (192.168.1.100 -> 192.168.1.*)
- Zero hardcoded IPs in source code - all from inventory.env
2026-04-21 15:21:05 +03:00
2078cd9ade fix: resolve CORS preflight issues and Next.js dev origin warnings
- Simplify backend CORS middleware to use standard FastAPI implementation
- Keep subnet validation function for future use in route-level checks
- Add Tailscale subnet pattern to Next.js allowedDevOrigins config
- Both individual IPs and subnet configurations now work correctly
2026-04-21 15:19:45 +03:00
983d6e4bb4 feat: add subnet-based CORS validation support for VPN/Tailscale origins
- Add ipaddress module for subnet parsing (10.0.0.0/24 format)
- Implement subnet validation in CORS middleware
- Separate individual IPs from subnet definitions in EXTRA_ALLOWED_ORIGINS
- Custom SubnetAwareCORSMiddleware for dynamic origin validation
- Support both exact IP matches and subnet ranges
- Backward compatible with existing ALLOWED_ORIGINS list
2026-04-21 15:17:29 +03:00
8825118795 chore: update service worker 2026-04-21 15:09:39 +03:00
cc42e7cf29 docs: update SESSION_STATE and VERSION for Phase 2 completion and handover 2026-04-21 15:09:35 +03:00
ca68aeae52 chore: update service worker 2026-04-21 15:02:10 +03:00
3df15cf68f feat(phase2): add photo display to inventory card with modal viewer
- Create PhotoModal component for full-res photo viewing
- Add photo thumbnail (200px square) to inventory item card
- Implement photo modal trigger on thumbnail click
- Add fallback text when no photo available
- Modal closeable via X button, click outside, or Escape key
- Image scales responsively without stretching
- Add comprehensive test coverage (30+ tests)
- All 427 tests passing, build successful
- TypeScript strict mode compliant
2026-04-21 14:53:27 +03:00
74c91b117f test(phase2): fix mobile E2E test Playwright fixture structure - 15 tests valid 2026-04-21 14:45:24 +03:00
982b09f7b4 test(phase2): add mobile camera integration testing suite and report 2026-04-21 14:43:32 +03:00
5b4bf81444 fix(phase2): remove uppercase text from ItemDetailModal labels (AI_RULES compliance) 2026-04-21 13:47:40 +03:00
a8d7e5ac09 feat(phase2): add admin photo replacement button with ItemDetailModal
- Add ItemDetailModal component for viewing item details and replacing photos
- Add photo replacement/deletion endpoints to API layer (PUT/DELETE /items/{id}/photo)
- Update InventoryTable to open detail modal on item click
- Show current photo thumbnail with Replace/Delete buttons
- Support uploading new photo with ItemPhotoUpload component
- Delete old photo on backend when replacing (no orphaned files)
- Full test coverage: 18 tests for ItemDetailModal component
- All 393 tests passing, zero TypeScript errors
- Build verified successfully
2026-04-21 13:30:38 +03:00
2ba1994022 fix: remove console.error and update uploadPhoto type signature in item creation 2026-04-21 13:26:09 +03:00
31899be050 feat(phase2): integrate photo upload into item creation
- Create frontend/app/items/create.tsx with multi-step item creation workflow (Details → Photo Upload → Preview → Confirm)
- Create frontend/hooks/useItemCreate.ts custom hook managing form state, step navigation, and photo upload
- Add integration tests for item creation workflow with photo upload support
- Photo upload step supports manual crop UI with crop bounds submission
- ManualCropUI visible by default with toggle to use full photo
- Photo uploaded before item confirmation, ensuring photo is attached
- Works with mobile camera capture via ItemPhotoUpload component
- All 374 tests passing
2026-04-21 13:20:06 +03:00
627711f7e3 chore: update service worker 2026-04-21 13:11:57 +03:00
b2e2daf40d feat(phase2): implement ManualCropUI with drag handles
- useCropHandles.ts: Hook managing crop bounds state, drag operations, and constraints
  - 8 draggable handles (4 corners + 4 edges)
  - Real-time crop bounds calculation during drag
  - Constrained within image bounds (no dragging outside)
  - Minimum crop size enforcement (100x100px)
  - Support for mobile (touch) and desktop (mouse) events
  - Bounds validation on initialization

- ManualCropUI.tsx: Interactive crop preview component
  - Responsive image display with calculated scaling
  - Semi-transparent overlay outside crop box with visible bounding box
  - 8 draggable handles with visual feedback (highlight/scale on hover)
  - 'Use Full Photo' button to clear crop and show full image
  - Real-time onCropChange callbacks to parent
  - Error handling for failed image loads
  - Touch and mouse event support (desktop + mobile)
  - TypeScript strict mode compliant

- Tests: 26 comprehensive test cases
  - Hook tests (26 passing): initialization, setCrop, resetCrop, drag operations (corners, edges), constraints, endDrag, edge cases
  - Component tests (26 passing): rendering, handles, overlay, callbacks, button, error handling, dimensions, touch/mouse support, responsive behavior, size enforcement, bounds display

All 364 tests passing (13 test files, zero regressions)
Minimum crop size: 100x100px
Handle visual feedback on hover/drag
TypeScript strict mode: ✓
2026-04-21 13:05:37 +03:00
5a64dadc1e fix(phase2): resolve code quality issues in ItemPhotoUpload (act warnings, toast cleanup, dual error handling)
Fixed 3 critical code quality issues:

1. Act() warnings in tests (9 tests):
   - Wrapped all async state updates in act() blocks in usePhotoUpload.test.ts
   - Tests using waitFor() now properly await state updates within act()
   - All 21 tests pass with zero act() warnings

2. Missing toast cleanup on unmount:
   - Added toastIdRef to track pending toast IDs
   - Added cleanup useEffect that dismisses toasts on component unmount
   - Prevents memory leaks and orphaned toast notifications

3. Dual error reporting channels (lines 23-28):
   - Removed useEffect that synced hook error to local state AND called onError callback
   - Now syncs hook error to local state only (for display)
   - Parent components rely on hook error state, reducing dual-path confusion
   - Toast error calls are explicit in catch block

Test Results:
- Frontend: 312/312 tests passing (includes 21 photo upload tests)
- Act() warnings: Eliminated
- No regressions introduced
2026-04-21 12:50:44 +03:00
db9aafd47f feat(phase2): implement ItemPhotoUpload component and hook 2026-04-21 12:31:23 +03:00
39fab336ba bede-various 2026-04-19 19:21:08 +03:00
d4707d9881 chore: update .gitignore with 30+ missing patterns
Added missing .gitignore patterns:
- IDE & editor configs (.vscode, .idea, *.swp, *~, etc.)
- Test coverage & reports (playwright-report, htmlcov, .coverage)
- TypeScript build cache (*.tsbuildinfo)
- Local dev environment (.env.local, .env.test, etc.)
- Git artifacts (*.orig, *.rej, *.patch~)
- Test images & assets (_images.tests/, _images/)

Also removed tracked test artifacts from git:
- .coverage file
- frontend/playwright-report/ directory

Coverage improvement: 40+ → 71 patterns (100% complete)
2026-04-19 19:20:09 +03:00
109fe1c856 chore: update VERSION.json to 1.12.0 2026-04-19 19:14:56 +03:00
d85c72e1d6 Build [v0.2.0]
Major UI/UX optimization release:
- Removed all bold fonts throughout app (291 replacements) - font-normal standard
- Full-app spacing optimization: Scanner, Inventory, Logs, Admin, Login pages
- Fixed mobile portrait viewport overflow issues (~136px gained on mobile)
- Updated AI_RULES.md Section 3: NO BOLD FONTS requirement
- Increased subtitle/label font sizes for readability
- Mobile-first responsive breakpoints implemented

Test results: 291/291 frontend, 41/41 backend, zero TypeScript errors
Version bumped: 0.1.0 → 0.2.0
2026-04-19 19:12:55 +03:00