Skip to content

Conversation

@Foundup
Copy link
Owner

@Foundup Foundup commented Nov 28, 2025

Summary

Implemented cross-device cart coordination with 5-minute reservation timeout. When user swipes right on Browse, item is reserved for 5 minutes and hidden from ALL users' Browse feeds. Countdown timer displays in cart fullscreen view. On expiration, item automatically returns to Browse feed across all devices.

Architecture

Reservation Flow:

  1. Right Swipe → Creates CartReservation { reservedBy, reservedAt, expiresAt }
  2. Firestore Sync → updateCartReservation(itemId, reservation)
  3. Browse Filter → Hide items where isReservedByOthers() === true
  4. Countdown Timer → MM:SS display in cart fullscreen (color-coded: green→yellow→red)
  5. Auto-Expiration → After 5 minutes, item returns to Browse feed on all devices

Multi-Device Coordination:

  • Phone A swipes right → Firestore reservation created
  • Phone B sees item disappear from Browse (real-time)
  • 5 minutes pass → expiration handler clears reservation
  • Both devices sync → item reappears in Browse feeds

Files Changed

Created:

  • frontend/services/cartReservation.ts (146 lines) - Service module following WSP 49 pattern
  • frontend/components/CartCountdown.tsx (76 lines) - Color-coded countdown timer component

Modified:

  • frontend/types.ts - Added CartReservation interface
  • frontend/services/firestoreSync.ts - Added updateCartReservation()
  • firestore.rules - Added isValidReservationUpdate() validator
  • frontend/App.tsx - Right-swipe handler, browse filter, countdown integration, expiration handler
  • ModLog.md - Documentation

Testing

  • Build successful: ✓ npm run build (962.69 KB bundle)
  • TypeScript compilation: ✓ No errors
  • Multi-device testing: Ready (requires deployment)

Test Plan:

  1. Open Phone A + Phone B (different devices or incognito tabs)
  2. Capture item on Phone A, swipe right on Phone B's Browse
  3. Verify item disappears from Phone A's Browse feed
  4. Open cart fullscreen on Phone B → verify countdown timer
  5. Wait 5 minutes → verify item returns to Browse on both devices

WSP Compliance

  • WSP 49: Service module pattern (cartReservation.ts)
  • WSP 98: Firestore cross-device coordination (Layer 2 - Global Index)
  • WSP 50: Pre-action verification (HoloIndex search before implementation)
  • WSP 22: ModLog documentation

🤖 Generated with Claude Code

Implemented cross-device cart coordination. When user swipes right on Browse, item is reserved for 5 minutes and hidden from ALL users' Browse feeds. Countdown timer displays in cart fullscreen view. On expiration, item automatically returns to Browse feed across all devices.

Architecture:
- Service module: cartReservation.ts (WSP 49 pattern)
- Firestore sync: updateCartReservation() for cross-device coordination
- Browse filter: Hide items reserved by others
- CartCountdown component: MM:SS color-coded timer (green→yellow→red)
- Expiration handler: Polls every 1s, auto-returns expired items

Multi-device flow:
- Phone A swipes right → Firestore reservation created
- Phone B sees item disappear from Browse (real-time)
- 5 minutes pass → expiration handler clears reservation
- Both devices sync → item reappears in Browse feeds

Files:
- frontend/services/cartReservation.ts (created - 146 lines)
- frontend/components/CartCountdown.tsx (created - 76 lines)
- frontend/types.ts (added CartReservation interface)
- frontend/services/firestoreSync.ts (added updateCartReservation)
- firestore.rules (added isValidReservationUpdate validator)
- frontend/App.tsx (right-swipe, browse filter, countdown, expiration handler)

WSP Compliance: WSP 49 (service module), WSP 98 (Firestore sync), WSP 50 (HoloIndex search)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants