feat(optimizer): implement legendary gems optimizer UI (PROJ-002)#12
Merged
Conversation
CRITICAL fixes: - C1: Add Client Component Boundary section to plan.md - C2: Add Progressive Enhancement Strategy section to plan.md HIGH fixes: - U1: Clarify FR-021b exponential backoff (fixed 1s delay, single retry) - C3: Add phase checkpoints to all phases in tasks.md - G1/G3: Add validation tasks T090-T092 (usability, Lighthouse, performance) MEDIUM fixes: - U2: Define large number formatting thresholds (>=1M uses M, >=10K uses K) - U3: Add mobile alternative for hover tooltips (tap/long-press) - G2: Add T093 for SC-006 validation (2-second build load) - I1: Move deferred tasks to Phase 11 section LOW fixes: - G4: Clarify T075 to include mode display in UI - I2: Add FR-008a for optimistic UI updates - I3: Add FR-037a for resource budget constraint Constitution compliance verified.
- Updated Optimizer UI summary to reflect 93 tasks and 47 FRs - Added analysis status line showing all 14 findings resolved - Updated phase count to 11 (including deferred features)
- Add Vitest + React Testing Library for unit/integration tests - Add Playwright for E2E testing - Configure vitest.config.ts with jsdom environment - Add test setup file with jest-dom matchers - Add playwright.config.ts for E2E tests - Create e2e directory for future E2E tests - Add test scripts to package.json (test, test:run, test:coverage, test:e2e) - Add example smoke test for Home page
- Add types.ts with TypeScript interfaces for optimization - Add constants.ts with tier weights, resonance/CR tables - Add resonance.ts for resonance calculations and threshold detection - Add scoring.ts for priority score calculations - Add resources.ts for resource constraint handling - Add engine.ts with main optimize() function - Add engine.test.ts with 15 passing unit tests Algorithm: O(n log n) weighted greedy with tier multipliers Power formula: (Resonance × 1.0 + CR × 2.0) × tierMultiplier × thresholdBonus × diminishingFactor
…opies - Update ResourceInventory to use gemPower and copyInventory - Update optimize-api.schema.json to v1.1.0 with correct fields - Add data model correction warning callout - Align spec with optimization engine implementation
- Update task count to 96 tasks total (62 MVP, 34 post-MVP) - Mark 6 optimization engine tasks as already implemented - Correct resource model: gemPower/copyInventory instead of platinum/pearls - Add resonance.ts to already implemented files - Update parallel execution groups for Phase 5 - Add screen reader announcement task (T091) - Update version to 2.0.0 with new date
- Update FR-010 from 'Platinum, Telluric Pearls' to 'Gem Power and Gem Copy Inventory' - Aligns spec.md with data-model.md and API contract v1.1.0 - Resolves D-01/A-01 findings from cross-artifact analysis
…ssions - Researched three options: device fingerprinting, registration form, hybrid - Chose localstorage uuid v4 with optional email opt-in - Rejected fingerprinting due to gdpr concerns and 40-60% stability - Rejected registration due to high friction and 20-30% abandonment - Updated fr-029 to reflect simplified approach - Updated data-model.md with anonymoussession entity - Updated memory bank with architecture decision
- mark all phase 0 research items as resolved - add t-04 research summary for session strategy decision - update storage description to reflect server-side sessions - add anonymous sessions to constitution check - update data model section to include anonymoussession entity - update api contracts section to include session endpoint - add session management to source code structure
- Expand ResourceInventory model with full resource tracking (crests, crafting materials, awakening) - Add AwakenedSlot, AcquisitionPath, and InventoryGem entities - Add FR-047 to FR-054 for awakening management and resource deficit features - Add rate-limited (HTTP 429) error handling to FR-021 - Add session invalidation handling (FR-029d) - Add Advanced Strategies toggle for dormant 5-star infusion (FR-037b) - Add 8 game data CSV files in docs/ for reference values - Synchronize all spec artifacts to v2.0.0 - Update task count to 135 total tasks - Add clarification session history for design decisions
….0.0 - Mark 34 items as RESOLVED based on spec.md v2.0.0 updates - Update CHK062, CHK065, CHK066, CHK067 with resolution details - Update Summary table with accurate counts (34 resolved, 36 open, 2 critical) - List open critical items (CHK030, CHK031) and high-priority items - Update version to 2.0.0 and date to 2026-02-17
- CHK030: Add task-based assessment criteria for SC-008 comprehension - CHK031: Specify UI elements for US1-Acceptance-5 max capacity indication - CHK001: Add FR-002a visual hierarchy requirements for gem catalog - CHK002: Add FR-016b interaction state requirements (hover, focus, active, disabled, loading) - CHK007: Add structured JSON error format to FR-011 with field-level codes All critical items resolved. Open items reduced from 36 to 31.
- CHK038: Add FR-021e with per-error-type UI specs - CHK041: Add resonance boundary values to edge case section - CHK054: Update FR-045 with WCAG AA contrast ratios All critical and high-priority items resolved. Open items reduced from 31 to 28.
…ifications - Add Constitution Check tables with pass/fail status - Include Implementation Phases with completion status - Add Key Decisions section with rationale - Expand T112 testing criteria with assessment parameters - Add UI specifications for FR-002a, FR-016b, FR-045 - Fix duplications in specify-rules.md
- Create type definitions (gem, optimization, build types) - Add static gem database (gems.json) with 85 legendary gems - Create utility functions (formatting, validation, sanitization) - Add session management with localStorage UUID identification - Create Drizzle SQLite schema for server-side persistence - Add localStorage helpers for anonymous ID Implements: T003-T012 of PROJ-002-optimizer-ui
- add Button, Card, Input, Select, Modal components (T013-T017) - add GemCatalog, GemCard, GemSelector, GemDetail components (T018-T021) - fix ESLint errors: useId() for unique IDs, simplified Input state - all components support accessibility (ARIA, focus management)
- add slots.ts with slot config, validation, duplicate prevention (T022-T024, T026) - add resonance.ts wrapper for UI components (T025) - implement base/wing slot type derivation and validation - implement wing slot unlocking via resonance thresholds - add type conversion helpers between UI and optimization types
- create optimize page with gem catalog integration (T027-T032) - add equipped gems display with quality/rank selectors (T028) - add summary stats with resonance and wing slots display (T029) - implement gem add/remove flow with optimistic updates (T030) - add empty states for equipped gems panel (T031) - includes mock gem data for development
- add ResourceInput component with debounced validation (T033-T037) - create session API endpoints GET/POST for session persistence (T038-T039) - integrate resource state with auto-persistence in optimize page (T040) - add session invalidation handling with toast notification (T040a) - export ResourceInventory and InventoryGem types from build.ts - add database connection module with Drizzle ORM setup
- create optimize api route with typed error responses - add request validation for gems and resources - implement 30-second timeout per fr-022 - add typed error responses (400, 408, 422, 500) per fr-021
- create skeleton component with pulse animation (t052) - add optimizebutton with loading states and timer (t053, t067) - create toast notification system with auto-dismiss (t060) - add cn utility for class name composition
- create optimizationmodal with progress indicator (t054) - add resultspanel for ranked recommendations (t055) - create recommendationcard with expandable details (t056-t059) - enhance skeleton grid with variant support
- create optimization error display components (t061-t063) - add validation, insufficient-resources, timeout errors - create useOptimize hook with retry and cancellation (t064-t066) - implement offline error handling
- create screen reader announcer component (t068-t069) - add awakened slots panel with toggle ui (t069a-t069b) - create acquisition paths overview component (t069f) - add resource deficit display (t069e) - implement acquisition utilities with crafting rates (t069g-t069h)
- implement calculateAwakenedResonance with 10% bonus - add awakened bonus breakdown helpers - complete t069c and t069d (schema already had awakenedSlots)
- mark phases 1-5 as complete - update current structure with implemented files - add session history for 2026-02-18
- T100a: add advanced strategies toggle (default: off) to optimization controls (FR-037b) - T100b: implement dormant 5-star gem infusion recommendations in optimization engine - T100c: create InfusionRecommendationCard component for displaying infusion paths - T105: create useOptimisticUpdate hook with automatic rollback on failure (FR-008a) - T106: create useMultiTabSync hook using BroadcastChannel API for cross-tab conflict detection
Contributor
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)CRITICAL
Details: The
This means the function does NOT actually escape HTML special characters, leaving the application vulnerable to XSS attacks. The function will pass through dangerous characters unchanged. Files Reviewed (18 files)
|
The htmlEscapeMap was incorrectly mapping special characters to themselves instead of proper html entities, leaving the application vulnerable to xss attacks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements a complete legendary gems optimization tool for Diablo Immortal players. This feature addresses the core user need: making informed decisions about which gems to upgrade given limited resources. The weighted greedy algorithm provides prioritized upgrade recommendations based on tier rankings, resonance thresholds, and resource efficiency.
Value Delivered:
Technical Changes
Core Optimization Engine
src/lib/optimization/engine.ts- Weighted greedy algorithm with priority scoringsrc/lib/optimization/scoring.ts- Power gain calculations, tier multipliers, threshold bonusessrc/lib/optimization/resources.ts- Resource constraint filtering, budget-aware selectionsrc/lib/optimization/constants.ts- Resonance tables, tier rankings, upgrade costsAPI Routes
src/app/api/optimize/route.ts- POST/api/optimizewith 30s timeout, validation, and error handlingsrc/app/api/session/route.ts- Session persistence for anonymous userssrc/app/api/builds/route.ts- CRUD operations for saved builds (max 5 per session)src/app/api/builds/[id]/route.ts- Individual build managementUI Components
Data & Types
src/data/gems.json- Static database of 1-star, 2-star, and 5-star legendary gemssrc/types/gem.ts- Gem-related types (StarRating, Quality, Rank, EquippedGem)src/types/build.ts- Session state, saved builds, awakened slotssrc/types/optimization.ts- Optimization input/result typesDatabase
src/lib/db/schema.ts- Drizzle schema for sessions and builds (SQLite)src/lib/db/queries.ts- Database query functionsTesting & Quality
vitest.config.ts,playwright.config.ts- Testing configurationsrc/__tests__/- Integration tests, performance tests, WCAG contrast testsnext.config.ts- CSP headers, security configurationDependencies Added
Files Changed Summary
Testing Instructions
Prerequisites
1. Manual UI Testing
/optimize/builds2. Automated Tests
3. Key Test Scenarios
User Stories Implemented
Breaking Changes
None. This is a new feature with no existing API contracts to break.
Future Work
The following integrations are planned but not implemented: