Skip to content

Commit d1cd236

Browse files
devonjonesclaude
andauthored
feat: add sprite sheet support for 3D model thumbnails (#213)
* feat: add sprite sheet support for 3D model thumbnails Implements sprite sheet generation and interactive viewing for OpenForge 3D models, reducing storage costs and improving user experience with 360° model previews. ## Backend Changes - Add `sprite_metadata` JSONB column to images table (schema v15-16) - Update image SQL queries to handle sprite_metadata - Add `/api/sprites` endpoint for sprite sheet generation - Fix image comparison to detect sprite_metadata changes - Update `insert_image()` to use ON CONFLICT DO UPDATE for sprite metadata ## Scanner Improvements - Add `--sprites` flag to generate sprite sheets during scan - Add `bin/generate_sprite` tool for sprite sheet creation - Add `bin/resort_fixtures` tool for stable fixture sorting - Fix fixture sorting to use full_name for top-level array - Use /tmp for temp sprite files to avoid path length issues - Preserve sprite_metadata.angles sort order by index ## Frontend Components - Add SpriteViewer component with interactive 3D rotation - Implement unwrapped cube layout for angle selection (10 angles) - Add keyboard navigation (arrow keys for rotation) - Add mouse drag support for horizontal rotation - Auto-focus viewer for immediate keyboard interaction - Reset angle when switching between blueprints ## Type Definitions - Add SpriteThumbnailData, SpriteAngle types - Update ThumbnailData union type - Add comprehensive test coverage (27 tests for SpriteViewer) ## Testing - Add sprite_metadata change detection test - Update image-gallery tests for sprite support - Add full SpriteViewer test suite (rendering, controls, keyboard, mouse, a11y) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * adding design * fix: address review feedback - improve code quality and maintainability 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: use tempfile.gettempdir() for subprocess cwd 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: decompose generate_sprite into focused helper functions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: add sprite_metadata support to update_image() 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * chore: remove accidentally shipped progress tracking file 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * chore: remove accidentally shipped fixture data files 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * chore: restore sewers.json to original state 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * chore: remove version_15.py - should come from PR #153 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: extract sprite viewer event handling into custom hooks - Extract keyboard rotation logic into useKeyboardRotation hook - Extract mouse drag rotation logic into useMouseDragRotation hook - Reduce SpriteViewer component from handling state + rendering + keyboard + mouse events to just state + rendering - Follows single responsibility principle and reduces cognitive load - Raise NotImplementedError for --db-update flag instead of silent warning 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: remove --db-update flag from generate_sprite Database updates will be handled through the fixture workflow, not directly by this CLI tool. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: use key prop pattern for sprite viewer state reset Replace useEffect-based state reset with React key prop pattern. When sprite_url changes, React will unmount and remount the component with fresh state - more idiomatic than manual reset. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: address code quality improvements from Gemini review 1. Add try/finally cleanup for sprite files in bin/generate_sprite 2. Validate default_angle against actual sprite_metadata instead of hardcoded max 3. Add try/finally cleanup for temp files in create_and_upload_thumbnail 4. Simplify CTE in insert_image (remove unnecessary WITH clause) 5. Derive angle constants from sprite metadata instead of hardcoding 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: use blueprint.id for key and dynamic angleMap 1. Use blueprint.id instead of sprite_url for SpriteViewer key - More explicit and robust for component remounting 2. Build angleMap dynamically from angle names - Decouple frontend from backend array order - Component adapts if angle structure changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: add specific error handling for stl-thumb failures 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: improve exception handling in helper functions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * security: only pass required environment keys to config 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 7b85135 commit d1cd236

124 files changed

Lines changed: 2634 additions & 537 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.beads/.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# SQLite databases
2+
*.db
3+
*.db?*
4+
*.db-journal
5+
*.db-wal
6+
*.db-shm
7+
8+
# Daemon runtime files
9+
daemon.lock
10+
daemon.log
11+
daemon.pid
12+
bd.sock
13+
14+
# Local version tracking (prevents upgrade notification spam after git ops)
15+
.local_version
16+
17+
# Legacy database files
18+
db.sqlite
19+
bd.db
20+
21+
# Merge artifacts (temporary files from 3-way merge)
22+
beads.base.jsonl
23+
beads.base.meta.json
24+
beads.left.jsonl
25+
beads.left.meta.json
26+
beads.right.jsonl
27+
beads.right.meta.json
28+
29+
# Keep JSONL exports and config (source of truth for git)
30+
!issues.jsonl
31+
!metadata.json
32+
!config.json

.beads/README.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Beads - AI-Native Issue Tracking
2+
3+
Welcome to Beads! This repository uses **Beads** for issue tracking - a modern, AI-native tool designed to live directly in your codebase alongside your code.
4+
5+
## What is Beads?
6+
7+
Beads is issue tracking that lives in your repo, making it perfect for AI coding agents and developers who want their issues close to their code. No web UI required - everything works through the CLI and integrates seamlessly with git.
8+
9+
**Learn more:** [github.com/steveyegge/beads](https://github.com/steveyegge/beads)
10+
11+
## Quick Start
12+
13+
### Essential Commands
14+
15+
```bash
16+
# Create new issues
17+
bd create "Add user authentication"
18+
19+
# View all issues
20+
bd list
21+
22+
# View issue details
23+
bd show <issue-id>
24+
25+
# Update issue status
26+
bd update <issue-id> --status in_progress
27+
bd update <issue-id> --status done
28+
29+
# Sync with git remote
30+
bd sync
31+
```
32+
33+
### Working with Issues
34+
35+
Issues in Beads are:
36+
- **Git-native**: Stored in `.beads/issues.jsonl` and synced like code
37+
- **AI-friendly**: CLI-first design works perfectly with AI coding agents
38+
- **Branch-aware**: Issues can follow your branch workflow
39+
- **Always in sync**: Auto-syncs with your commits
40+
41+
## Why Beads?
42+
43+
**AI-Native Design**
44+
- Built specifically for AI-assisted development workflows
45+
- CLI-first interface works seamlessly with AI coding agents
46+
- No context switching to web UIs
47+
48+
🚀 **Developer Focused**
49+
- Issues live in your repo, right next to your code
50+
- Works offline, syncs when you push
51+
- Fast, lightweight, and stays out of your way
52+
53+
🔧 **Git Integration**
54+
- Automatic sync with git commits
55+
- Branch-aware issue tracking
56+
- Intelligent JSONL merge resolution
57+
58+
## Get Started with Beads
59+
60+
Try Beads in your own projects:
61+
62+
```bash
63+
# Install Beads
64+
curl -sSL https://raw.githubusercontent.com/steveyegge/beads/main/scripts/install.sh | bash
65+
66+
# Initialize in your repo
67+
bd init
68+
69+
# Create your first issue
70+
bd create "Try out Beads"
71+
```
72+
73+
## Learn More
74+
75+
- **Documentation**: [github.com/steveyegge/beads/docs](https://github.com/steveyegge/beads/tree/main/docs)
76+
- **Quick Start Guide**: Run `bd quickstart`
77+
- **Examples**: [github.com/steveyegge/beads/examples](https://github.com/steveyegge/beads/tree/main/examples)
78+
79+
---
80+
81+
*Beads: Issue tracking that moves at the speed of thought*

.beads/config.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Beads Configuration File
2+
# This file configures default behavior for all bd commands in this repository
3+
# All settings can also be set via environment variables (BD_* prefix)
4+
# or overridden with command-line flags
5+
6+
# Issue prefix for this repository (used by bd init)
7+
# If not set, bd init will auto-detect from directory name
8+
# Example: issue-prefix: "myproject" creates issues like "myproject-1", "myproject-2", etc.
9+
# issue-prefix: ""
10+
11+
# Use no-db mode: load from JSONL, no SQLite, write back after each command
12+
# When true, bd will use .beads/issues.jsonl as the source of truth
13+
# instead of SQLite database
14+
# no-db: false
15+
16+
# Disable daemon for RPC communication (forces direct database access)
17+
# no-daemon: false
18+
19+
# Disable auto-flush of database to JSONL after mutations
20+
# no-auto-flush: false
21+
22+
# Disable auto-import from JSONL when it's newer than database
23+
# no-auto-import: false
24+
25+
# Enable JSON output by default
26+
# json: false
27+
28+
# Default actor for audit trails (overridden by BD_ACTOR or --actor)
29+
# actor: ""
30+
31+
# Path to database (overridden by BEADS_DB or --db)
32+
# db: ""
33+
34+
# Auto-start daemon if not running (can also use BEADS_AUTO_START_DAEMON)
35+
# auto-start-daemon: true
36+
37+
# Debounce interval for auto-flush (can also use BEADS_FLUSH_DEBOUNCE)
38+
# flush-debounce: "5s"
39+
40+
# Git branch for beads commits (bd sync will commit to this branch)
41+
# IMPORTANT: Set this for team projects so all clones use the same sync branch.
42+
# This setting persists across clones (unlike database config which is gitignored).
43+
# Can also use BEADS_SYNC_BRANCH env var for local override.
44+
# If not set, bd sync will require you to run 'bd config set sync.branch <branch>'.
45+
# sync-branch: "beads-sync"
46+
47+
# Multi-repo configuration (experimental - bd-307)
48+
# Allows hydrating from multiple repositories and routing writes to the correct JSONL
49+
# repos:
50+
# primary: "." # Primary repo (where this database lives)
51+
# additional: # Additional repos to hydrate from (read-only)
52+
# - ~/beads-planning # Personal planning repo
53+
# - ~/work-planning # Work planning repo
54+
55+
# Integration settings (access with 'bd config get/set')
56+
# These are stored in the database, not in this file:
57+
# - jira.url
58+
# - jira.project
59+
# - linear.url
60+
# - linear.api-key
61+
# - github.org
62+
# - github.repo

.beads/interactions.jsonl

Lines changed: 13 additions & 0 deletions
Large diffs are not rendered by default.

.beads/issues.jsonl

Lines changed: 13 additions & 0 deletions
Large diffs are not rendered by default.

.beads/metadata.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"database": "beads.db",
3+
"jsonl_export": "issues.jsonl"
4+
}

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
# Use bd merge for beads JSONL files
3+
.beads/issues.jsonl merge=beads

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
"quickfix.biome": "explicit",
88
"source.organizeImports.biome": "explicit"
99
}
10-
}
10+
}

AGENTS.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Agent Instructions
2+
3+
This project uses **bd** (beads) for issue tracking. Run `bd onboard` to get started.
4+
5+
## Quick Reference
6+
7+
```bash
8+
bd ready # Find available work
9+
bd show <id> # View issue details
10+
bd update <id> --status in_progress # Claim work
11+
bd close <id> # Complete work
12+
bd sync # Sync with git
13+
```
14+
15+
## Landing the Plane (Session Completion)
16+
17+
**When ending a work session**, you MUST complete ALL steps below. Work is NOT complete until `git push` succeeds.
18+
19+
**MANDATORY WORKFLOW:**
20+
21+
1. **File issues for remaining work** - Create issues for anything that needs follow-up
22+
2. **Run quality gates** (if code changed) - Tests, linters, builds
23+
3. **Update issue status** - Close finished work, update in-progress items
24+
4. **PUSH TO REMOTE** - This is MANDATORY:
25+
```bash
26+
git pull --rebase
27+
bd sync
28+
git push
29+
git status # MUST show "up to date with origin"
30+
```
31+
5. **Clean up** - Clear stashes, prune remote branches
32+
6. **Verify** - All changes committed AND pushed
33+
7. **Hand off** - Provide context for next session
34+
35+
**CRITICAL RULES:**
36+
- Work is NOT complete until `git push` succeeds
37+
- NEVER stop before pushing - that leaves work stranded locally
38+
- NEVER say "ready to push when you are" - YOU must push
39+
- If push fails, resolve and retry until it succeeds

CLAUDE.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,25 @@ For language-specific coding preferences and patterns, see:
126126
- Python/Backend: `openforge/CLAUDE.md`
127127
- JavaScript/Frontend: `src/CLAUDE.md`
128128

129+
## Code Organization Philosophy
130+
131+
### Function Complexity and Cognitive Load
132+
133+
**Core Principle**: Functions should be describable with as few uses of "and" or "or" as possible.
134+
135+
- **Single Screen Rule**: Generally, a function should be viewable on a single screen to keep cognitive load down
136+
- **Helper Functions**: Use private/helper functions extensively to extract specific tasks
137+
- Python: Use `_function_name()` for private helpers
138+
- JavaScript/React: Use custom hooks or helper functions
139+
- **Pragmatic Exceptions**: Larger functions are acceptable when breaking them up would genuinely complicate rather than simplify
140+
- **Test for Complexity**: If you're describing what a function does and you use multiple "and"s or "or"s, it's probably doing too much
141+
142+
**Examples**:
143+
- ❌ "This component handles state AND rendering AND keyboard events AND mouse drag events" - too many responsibilities
144+
- ✅ "This component manages sprite viewer state and delegates event handling to custom hooks"
145+
- ❌ "This function validates input AND transforms data AND saves to database" - should be 3 functions
146+
- ✅ "This function validates and saves user data (validation is a prerequisite for saving, so it's cohesive)"
147+
129148
## Background Context
130149

131150
### Technical Experience

0 commit comments

Comments
 (0)