feat: Refine session clear to preserve UI preferences while resetting game state and standardize image cache paths to full and crop subdirectories.
Some checks failed
Build and Deploy / build (push) Failing after 1m0s
Some checks failed
Build and Deploy / build (push) Failing after 1m0s
This commit is contained in:
@@ -135,3 +135,8 @@
|
||||
- [Cache Art Crops](./devlog/2025-12-18-204000_cache_art_crops.md): Completed. Implemented server-side caching for art-crop images and updated client to use local assets when available.
|
||||
- [Organized Caching Subdirectories](./devlog/2025-12-18-205000_cache_folder_organization.md): Completed. Restructured image cache to store full art in `art_full` and crops in `art_crop` subdirectories.
|
||||
- [Fix Cube Session Clear](./devlog/2025-12-18-210000_fix_cube_session_clear.md): Completed. Updated `CubeManager` to strictly clear all session data including parent-persisted storage keys.
|
||||
- [Update Session Clear Logic](./devlog/2025-12-18-202618_update_clear_session.md): Completed. Further refined `handleReset` to exhaustively reset filters, generation settings, and source modes to defaults.
|
||||
- [Preserve Preferences in Clear](./devlog/2025-12-18-210500_preserve_preferences_in_clear.md): Completed. Updated "Clear Session" to preserve UI preferences (card size, view mode) while still resetting generation content.
|
||||
- [Strict Cache Structure](./devlog/2025-12-18-213300_strict_cache_structure.md): Completed. Enforced cache structure `/cards/[code]/full` and `/cards/[code]/crop`, removing the `images` subdirectory and ensuring strict local file usage.
|
||||
- [Implicit Image Caching](./devlog/2025-12-18-213900_implicit_image_caching.md): Completed. Updated API routes `/api/sets/:code/cards` and `/api/cards/parse` to implicitly trigger and await image caching, ensuring assets are available immediately for generators.
|
||||
- [Restore Images Subdirectory](./devlog/2025-12-18-214300_restore_images_subdir.md): Completed. Corrected cache folder structure to `/cards/images/[set]/full` and `/cards/images/[set]/crop` as per user request.
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# 2025-12-18 - Clear Session Logic Update
|
||||
|
||||
## Overview
|
||||
Based on user feedback, the "Clear Session" functionality in `CubeManager` has been enhanced to be more comprehensive.
|
||||
|
||||
## Changes
|
||||
- **Updated `handleReset` in `CubeManager.tsx`**:
|
||||
- Now resets ALL component state to default values, not just removing persistence keys.
|
||||
- Resets `filters`, `genSettings`, `sourceMode`, `numBoxes`, `cardWidth`, and `searchTerm` in addition to input text and generated data.
|
||||
- Ensures a true "start from scratch" experience.
|
||||
- Relies on existing `useEffect` hooks to propagate the reset state to `localStorage`.
|
||||
|
||||
## Rationale
|
||||
The previous implementation only cleared the generated content but left user configurations (filters, settings) intact. The user requested a full reset to start a new generation from scratch, implying all previous choices should be wiped.
|
||||
@@ -0,0 +1,14 @@
|
||||
# 2025-12-18 - Preserve User Preferences in Reset
|
||||
|
||||
## Overview
|
||||
Refined the "Clear Session" logic in `CubeManager` to distinguish between "generation state" and "user preferences".
|
||||
|
||||
## Changes
|
||||
- **Updated `handleReset` in `CubeManager.tsx`**:
|
||||
- REMOVED: `setCardWidth(60)`
|
||||
- REMOVED: `setViewMode('list')`
|
||||
- These values now remain untouched during a session clear, preserving the user's UI customization.
|
||||
- Generation-specific state (card lists, packs, filters, number of boxes) is still strictly reset.
|
||||
|
||||
## Rationale
|
||||
Users were frustrated that clearing the card pool also reset their carefully adjusted UI settings (like card size slider and view mode). This change aligns with the expectation that "Clear Session" refers to the *content* of the draft session from a game perspective, not the *interface* settings.
|
||||
@@ -0,0 +1,18 @@
|
||||
# 2025-12-18 - Restrictive Cache Structure
|
||||
|
||||
## Overview
|
||||
Implemented strict separation of card assets into `full` and `crop` subdirectories nested under `cards/[expansion-code]/`. This update forces the application to depend entirely on the local cache for serving card images during runtime, fetching from Scryfall only during the explicit cache creation phase.
|
||||
|
||||
## Changes
|
||||
- **Refactored `CardService.ts`**:
|
||||
- Updated `cacheImages` to save files to `public/cards/[set]/full/[id].jpg` and `public/cards/[set]/crop/[id].jpg`.
|
||||
- Removed the intermediate `images` directory layer.
|
||||
|
||||
- **Updated `PackGeneratorService.ts` (Server)**:
|
||||
- Hardcoded `image` and `imageArtCrop` properties to point to the local server paths (`/cards/[set]/full/[id].jpg` etc.), removing the fallback to Scryfall URIs.
|
||||
|
||||
- **Updated `PackGeneratorService.ts` (Client)**:
|
||||
- Aligned local image path generation with the new server structure (`/cards/[set]/...`).
|
||||
|
||||
## Rationale
|
||||
To ensure offline availability and consistent performance, the application now treats the local cache as the authoritative source for images. This standardization simplifies asset management and prepares the system for strict air-gapped or high-performance environments where external API dependencies are undesirable during gameplay.
|
||||
@@ -0,0 +1,17 @@
|
||||
# 2025-12-18 - Implicit Image Caching
|
||||
|
||||
## Overview
|
||||
To solve the issue of missing images when generating packs from local servers, we have implemented implicit image caching directly within the API routes.
|
||||
|
||||
## Changes
|
||||
- **Updated `server/index.ts`**:
|
||||
- `GET /api/sets/:code/cards`: Now calls `cardService.cacheImages(cards)` before returning the response. This ensures that when a user fetches a set, all necessary full art and art crop images are downloaded to the server's cache immediately.
|
||||
- `POST /api/cards/parse`: Now calls `cardService.cacheImages(uniqueCards)` on the resolved unique cards before building the expanded list.
|
||||
|
||||
## Impact
|
||||
- **Positive**: Guaranteed image availability. When the client receives the card list, the images are guaranteed to optionally exist or be in the process of finishing (though we await completion, ensuring existence).
|
||||
- **Performance**: The "Fetching set..." or "Parsing list..." steps in the UI will take longer initially (proportional to image download speed), but subsequent requests will be instant as `cacheImages` skips existing files.
|
||||
- **Reliability**: Eliminates 404 errors for images when using the strictly local `PackGenerator` URLs.
|
||||
|
||||
## Rationale
|
||||
The application now defaults to `useLocalImages = true` effectively by hardcoding local paths in the generator. Therefore, the server MUST ensure those files exist before the client tries to render them.
|
||||
@@ -0,0 +1,16 @@
|
||||
# 2025-12-18 - Restore Images Subdirectory
|
||||
|
||||
## Overview
|
||||
Corrected the cache folder structure to include the `images` subdirectory as explicitly requested by the user, fixing a previous misinterpretation.
|
||||
|
||||
## Revised Structure
|
||||
- **Paths**:
|
||||
- Full Art: `/public/cards/images/[set]/full/[id].jpg`
|
||||
- Crop Art: `/public/cards/images/[set]/crop/[id].jpg`
|
||||
|
||||
## Changes
|
||||
- **Updated `CardService.ts`**: Re-inserted `images` into the `path.join` construction for file saving.
|
||||
- **Updated `PackGeneratorService.ts` (Server & Client)**: Updated the generated URLs to include the `/cards/images/...` segment.
|
||||
|
||||
## Compliance
|
||||
This aligns the application with the user's specific requirement for folder hierarchy: `/cards/images/[set-code]/full` and `/cards/images/[set-code]/crop`.
|
||||
Reference in New Issue
Block a user