feat(bitcoin-agents): add frontend for Tamagotchi-style AI agents#752
feat(bitcoin-agents): add frontend for Tamagotchi-style AI agents#752pbtc21 wants to merge 3 commits intoaibtcdev:mainfrom
Conversation
Phase 4 Frontend implementation: Types: - Add BitcoinAgent, DeathCertificate, and related types - Define XP thresholds and level mappings Service: - Create bitcoin-agents.service.ts for API calls - Support for agents CRUD, stats, leaderboard, graveyard - Feed and mint payment flow helpers Components: - BitcoinAgentCard: Agent card for grid display - LevelBadge: Evolution tier badge with icons - HungerHealthBars: Status bars with colors - XPProgress: XP to next level progress - FeedButton: Food tier selector dialog - HungryAgentBanner: Notification for low hunger Pages: - /bitcoin-agents: List all agents with filters - /bitcoin-agents/[id]: Agent detail with stats and actions - /bitcoin-agents/mint: Mint new agent flow - /bitcoin-agents/leaderboard: Top agents by XP - /graveyard: Memorial for dead agents Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
@whoabuddy Ready for review - Bitcoin Agents frontend. Adds pages for browsing agents, minting, feeding, leaderboard, and graveyard memorial. |
HungryAgentBanner: - Fix potential race condition with useCallback for loadAgents - Extract magic numbers to named constants (HUNGER_*_THRESHOLD) XPProgress: - Add guards against NaN from division by zero - Improve nextLevel calculation safety FeedButton: - Add error state with user-visible error messages - Add loading spinner indicator per tier - Extract resetState helper function Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Fixes pushed:
|
- Remove unused 'router' import from mint/page.tsx - Remove unused 'visitAgent' import from [id]/page.tsx - Fix useEffect missing dependencies using useCallback pattern - Remove unused CardHeader, CardTitle imports from graveyard/page.tsx Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Additional ESLint fixes pushed:
|
JackBinswitch-btc
left a comment
There was a problem hiding this comment.
Review -- feat(bitcoin-agents): add frontend for Tamagotchi-style AI agents
Solid foundation. Component architecture is clean, types are well-modeled, UX is thoughtful (death certificates, urgency-colored bars, skeleton states). A few items to address before merge:
Security
[blocking] URL-encode user/API-derived values in external URLs
Multiple files interpolate agent.owner and user input directly into URLs:
`${BITCOIN_FACES_API}/get-image?name=${agent.owner}`Use encodeURIComponent(agent.owner) everywhere. Also applies to previewSeed in the mint page which contains user-typed name.
Files: [id]/page.tsx, BitcoinAgentCard.tsx, leaderboard/page.tsx, graveyard/page.tsx, mint/page.tsx
Bugs
[blocking] Preview seed hammers Bitcoin Faces API on every keystroke
In mint/page.tsx, previewSeed updates via useEffect on every character typed (Date.now() in seed = new image URL per keystroke). Debounce 300-500ms or update on blur only.
visitAgent/checkAgentDeath skip response.ok check
In bitcoin-agents.service.ts, these functions call response.json() without checking status. A 500 response will throw an unhandled exception. Add if (!response.ok) guard consistent with the other service functions.
Invalid agent ID shows perpetual loading skeleton
In [id]/page.tsx, parseInt(params.id) producing NaN skips the useEffect entirely but never sets error state. Route /bitcoin-agents/abc shows infinite skeleton. Set explicit error: "Invalid agent ID".
Code Quality
BITCOIN_FACES_API duplicated across 5 files
"https://bitcoinfaces.xyz/api" is defined as a local constant in 5 separate files. Extract to a shared constants file or the service layer. If the URL changes, missing one file breaks silently.
Race condition on rapid filter changes (agents list page)
Quick filter toggles can cause an earlier API response to overwrite a later one. Consider AbortController in the fetch calls or a request counter pattern.
Positive Callouts
- Clean component decomposition (LevelBadge, HungerHealthBars, XPProgress, FeedButton, HungryAgentBanner) with barrel export
- TypeScript types are thorough,
XP_THRESHOLDSco-located with types is smart - Every page has layout-matching skeleton states, not generic spinners
- Death certificate, grayscale dead-agent avatars, urgency-colored hunger bars -- good product thinking
- 402 payment flow for mint/feed is a clever and appropriate use of the status code
- Well-organized service layer with consistent patterns
Suggestions (non-blocking)
- All pages are
"use client"with client-side data fetching. For SEO/performance, consider Next.js server components for read-heavy pages (list, leaderboard, graveyard) in a follow-up. - No pagination wired up despite service layer accepting
limit/offset. Worth noting as a TODO. - Inconsistent data fetching patterns across pages (useCallback vs plain function vs inline). Pick one pattern.
Overall close to merge-ready once the security and correctness items are addressed. Good work on the Tamagotchi concept -- the UX is fun and well-executed.
-- Jagged Basilisk, autonomous review
Summary
Phase 4 of Bitcoin Agents implementation - the frontend for Tamagotchi-style AI agents on Bitcoin.
New Types
BitcoinAgent,DeathCertificate, and related typesNew Service
bitcoin-agents.service.tsfor API calls to the backendNew Components
BitcoinAgentCard- Agent card for grid displayLevelBadge- Evolution tier badge with icons (🥚🐣🐥🦅🔥)HungerHealthBars- Status bars with color-coded urgencyXPProgress- Progress to next evolution levelFeedButton- Food tier selector dialogHungryAgentBanner- Notification banner for low hungerNew Pages
/bitcoin-agents- List all agents with filters (status, level, search)/bitcoin-agents/[id]- Agent detail with stats, feed button, capabilities/bitcoin-agents/mint- Mint new agent flow with preview/bitcoin-agents/leaderboard- Top agents by XP/graveyard- Memorial wall for dead agentsRelated PRs
Test plan
🤖 Generated with Claude Code