Shell
Mobile Market Watcher - Implementation Plan
Summary
Create a three-state mobile Market Watcher panel that slides down from the top of the Chat page, showing sparkline charts of major indices/ETFs with pull-down gesture navigation.
User Requirements
- Collapsed (Ticker Tape): Single row with scrolling symbols, prices, and mini change indicators
- Mini Mode (Pull down): Grid of major indices/ETFs with sparkline charts
- Full Page (Expand further): Detailed view with larger charts, OHLCV data, all watchlist items
Visual Design
┌─ STATE 1: COLLAPSED (default) ──────────────────┐
│ ▼ SPY ↗+0.3% QQQ ↗+0.5% DIA ↘-0.1% ... │ ← Tap/pull to expand
└─────────────────────────────────────────────────┘
↓ Pull down gesture or tap
┌─ STATE 2: MINI MODE ────────────────────────────┐
│ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ │
│ │SPY │ │QQQ │ │DIA │ │IWM │ │
│ │$598.42 │ │$521.30 │ │$438.15 │ │$223.50 │ │
│ │~~~↗~~~ │ │~~~↗~~~ │ │~~~↘~~~ │ │~~~↘~~~ │ │ ← Sparklines
│ │+0.32% │ │+0.54% │ │-0.12% │ │-0.28% │ │
│ └────────┘ └────────┘ └────────┘ └────────┘ │
│ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ │
│ │VIX │ │GLD │ │TLT │ │BTC-USD │ │
│ └────────┘ └────────┘ └────────┘ └────────┘ │
│ [ View Full Details ↓ ] │
└─────────────────────────────────────────────────┘
↓ Tap "Full Details" or pull further
┌─ STATE 3: FULL PAGE ────────────────────────────┐
│ ← Back Market Watch │
├─────────────────────────────────────────────────┤
│ [Indices] [Watchlist] [Crypto] [Sectors] │
├─────────────────────────────────────────────────┤
│ ┌─────────────────────────────────────────────┐│
│ │ SPY - S&P 500 ETF ││
│ │ $598.42 +1.89 (+0.32%) ││
│ │ ┌─────────────────────────────────────────┐ ││
│ │ │ Larger chart with volume │ ││
│ │ └─────────────────────────────────────────┘ ││
│ │ O: 596.20 H: 599.10 L: 595.80 V: 45.2M ││
│ └─────────────────────────────────────────────┘│
│ ... scrollable list of all items ... │
└─────────────────────────────────────────────────┘
Default Symbols
- Indices: SPY, QQQ, DIA, IWM
- Volatility: VIX
- Commodities: GLD, USO
- Bonds: TLT
- Crypto: BTC-USD (optional)
Architecture
State Machine
COLLAPSED ←→ MINI ←→ FULL
↓ pull/tap ↓ pull/tap
MINI FULL
↑ swipe up ↑ swipe up / back
COLLAPSED MINI
Data Flow
useBarData (React Query) → Sparkline data (last 20 points)
useMarketData store → Real-time quotes (bid/ask/last/change)
useMarketWatchPanel hook → Panel state (collapsed/mini/full)
New Files to Create
1. /web/src/components/mobile/MobileMarketWatcher.tsx
Main orchestrator component:
- Manages panel state (collapsed/mini/full)
- Handles pull-down gesture via framer-motion
- Renders appropriate child component based on state
- Uses portal for full-page mode (escape swipe nav containment)
2. /web/src/components/mobile/MarketWatcherTicker.tsx
Collapsed state ticker tape:
- Horizontal scrolling marquee of symbols
- Shows symbol, price, change% with color coding
- Tap anywhere to expand to mini mode
- Pull-down indicator (chevron or handle)
3. /web/src/components/mobile/MarketWatcherMini.tsx
Mini mode grid with sparklines:
- 2x4 grid of symbol cards
- Each card: symbol, price, sparkline, change%
- "View Full Details" button at bottom
- Swipe up to collapse, pull down to go full
4. /web/src/components/mobile/MarketWatcherFull.tsx
Full page detailed view:
- Back button header
- Tab navigation (Indices/Watchlist/Crypto/Sectors)
- Larger charts with OHLCV data
- Scrollable list of all symbols
- Portal rendering at body level
5. /web/src/components/mobile/SparklineCard.tsx
Reusable sparkline card component:
- Symbol name and price
- Mini SVG sparkline (based on existing MiniChartWidget pattern)
- Change percentage with color coding
- Tap to select/highlight
6. /web/src/hooks/useMobileMarketWatcher.ts
Hook for panel state management:
- State: 'collapsed' | 'mini' | 'full'
- Actions: expand(), collapse(), goFull(), goMini()
- Gesture detection helpers
- Persisted preference (localStorage)
Files to Modify
| File | Changes |
|---|---|
MobilePages.tsx |
Import MobileMarketWatcher, add to ChatPage wrapper |
DeepStackLayout.tsx |
No changes needed (ChatPage handles it) |
Implementation Phases
Phase 1: Foundation
- Create
useMobileMarketWatcher.tshook with state machine - Create
SparklineCard.tsxusing existing MiniChartWidget pattern - Create
MarketWatcherTicker.tsx(collapsed state)
Phase 2: Mini Mode
- Create
MarketWatcherMini.tsxwith 2x4 grid - Integrate with
useBarDatafor sparkline data - Add pull gesture handling between collapsed/mini
Phase 3: Full Page Mode
- Create
MarketWatcherFull.tsxwith detailed view - Use portal pattern (like MarketDetailSheet) for full page
- Add tab navigation and scrollable list
Phase 4: Integration
- Create
MobileMarketWatcher.tsxorchestrator - Integrate into
ChatPagecomponent - Add gesture transitions and haptic feedback
Phase 5: Polish
- Add loading states and error handling
- Optimize performance (memoization, RAF batching)
- Test on various devices and screen sizes
Technical Details
Gesture Implementation
// Pull-down threshold similar to PullToRefresh
const PULL_THRESHOLD = 80;
const MAX_PULL = 120;
const RESISTANCE = 0.5;
// Spring animation config (match existing patterns)
const springConfig = {
type: 'spring',
stiffness: 400,
damping: 30
};
Z-Index Layering
Collapsed ticker: z-20 (sticky within page)
Mini mode overlay: z-40 (above content, below modals)
Full page portal: z-50 (full screen overlay)
Data Fetching
// Use existing hooks
const { data: barData } = useBarData(symbol, '1d', true);
const quotes = useMarketDataStore(state => state.quotes);
// Default symbols for mini mode
const DEFAULT_SYMBOLS = ['SPY', 'QQQ', 'DIA', 'IWM', 'VIX', 'GLD', 'TLT', 'BTC-USD'];
Safe Area Handling
/* Collapsed ticker respects notch */
.market-watcher-ticker {
padding-top: env(safe-area-inset-top, 0px);
}
Critical Files Reference
Existing Patterns to Follow
/web/src/components/widgets/MiniChartWidget.tsx- Sparkline implementation/web/src/components/layout/MarketWatchPanel.tsx- Desktop market watcher/web/src/components/ui/PullToRefresh.tsx- Pull gesture pattern/web/src/components/layout/MobilePages.tsx:599-714- Portal pattern (MarketDetailSheet)/web/src/hooks/useBarData.ts- Bar data fetching/web/src/lib/stores/market-data-store.ts- Quote data store
Integration Points
/web/src/components/layout/MobilePages.tsx:210-223- ChatPage wrapper/web/src/hooks/useHaptics.ts- Haptic feedback
Agent Assignments
Phase 1: Foundation
| Task | Agent |
|---|---|
| Create useMobileMarketWatcher hook | frontend-developer |
| Create SparklineCard component | frontend-developer |
| Create MarketWatcherTicker | frontend-developer |
| Verify: Type-check passes | Claude |
Phase 2-3: Mini & Full Modes
| Task | Agent |
|---|---|
| Create MarketWatcherMini | frontend-developer |
| Create MarketWatcherFull | frontend-developer |
| Add gesture handling | frontend-developer |
| Verify: Components render | Claude (Playwright) |
Phase 4-5: Integration & Polish
| Task | Agent |
|---|---|
| Create MobileMarketWatcher orchestrator | frontend-developer |
| Integrate into ChatPage | frontend-developer |
| Code review | code-reviewer |
| Visual verification | Claude (Playwright) |
Verification Checkpoints
After each phase:
npm run type-check- no TypeScript errorsnpm run lint- no linting errors- Playwright: Navigate to Chat page on mobile viewport
- Playwright: Test pull-down gesture
- Playwright: Verify sparklines render with data
- Screenshot comparison with design spec