[PR #2223] [MERGED] Fix generated game background cover resize #5486

Closed
opened 2026-10-22 04:16:44 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2223
Author: @cha1latte
Created: 6/4/2026
Status: ✅ Merged
Merged: 6/4/2026
Merged by: @cha1latte

Base: refactor ← Head: fix/issue-2142-game-background-cover


📝 Commits (2)

  • a284bc7 Fix generated background cover resize
  • 041b974 Guard generated background resize formats

📊 Changes

1 file changed (+245 additions, -3 deletions)

View changed files

📝 src-tauri/crates/assets/src/lib.rs (+245 -3)

📄 Description

Linked issue

Closes #2142

Why this change

  • Generated game scene backgrounds in refactor were uploaded exactly as returned by the image provider. Providers that ignore the requested 16:9 dimensions could therefore store square or otherwise mismatched backgrounds, unlike legacy main's gameBackgroundImage() path that cover-resized to the VN scene canvas.

What changed

  • Added a generated-background-only resize step in marinara-assets before writing backgrounds/generated/* uploads.
  • The resize uses center-cover semantics at 1280x720 and re-encodes to the uploaded image format.
  • Added asset-service regression coverage for the generated background path plus negative controls proving generated illustrations, manual/custom background uploads, and whitespace-wrapped subcategory names keep their original dimensions.
  • Added generated-background dimension guards before full image decode.
  • Narrowed the generated-background resize path to PNG, JPEG, and WebP, matching the current game generation filenames and the asset crate's enabled codecs.

Refactor impact

Primary owner:

Rust storage, game mode generated assets

Impact areas reviewed:

  • src/features/modes/game/api/game-api.ts generated backgrounds call uploadGeneratedAsset("backgrounds", "generated", ...).
  • src-tauri/crates/assets/src/lib.rs owns the managed game asset write boundary.
  • Adjacent backgrounds/illustrations and manual/custom background uploads were covered as negative controls.
  • Oversized generated background dimensions were covered as a rejection path before full decode.
  • Direct generated .gif and .avif background uploads were covered as rejection paths before decode/write; normal non-generated background extension acceptance is unchanged.

Boundary notes:

  • The change stays in the Rust managed asset service and does not add React, feature internals, raw Tauri calls, dependencies, schema changes, or prompt/provider changes.
  • Generated game image filenames are PNG/WebP/JPG through the existing imageExt() path, so the resize path uses only the asset crate's already-declared PNG/JPEG/WebP codec support.

Pressure points touched:

  • Managed game asset upload/write path only.

Validation

  • Matching validation command passes locally (for example pnpm typecheck, pnpm build, pnpm check:architecture, pnpm check:docs, or full pnpm check when warranted)
  • Full pnpm check passes before PR push/handoff
  • Human/manual validation completed by contributor or reviewer

Manual verification notes

  • Before fix: cargo run --manifest-path scratch/issue-2142-repro/Cargo.toml reproduced the bug with stored_dimensions=512x512 and failed because generated backgrounds were not 1280x720.
  • After fix: cargo run --manifest-path scratch/issue-2142-repro/Cargo.toml passed with stored_dimensions=1280x720.
  • cargo test --manifest-path src-tauri/Cargo.toml -p marinara-assets -- --nocapture passed: 15 tests, including direct generated .gif/.avif rejection before decode/write.
  • cargo clippy --manifest-path src-tauri/Cargo.toml --workspace --all-targets -- -D warnings passed.
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passed.
  • pnpm install --frozen-lockfile was needed in the fresh issue worktree; it did not change dependency declarations.
  • pnpm check passed.
  • git diff --check passed.
  • GitHub checks on head 041b974b passed: Browser Smoke and Performance, Frontend/Architecture/Organization, Rust Capability Layer, Bunny Review, and CodeRabbit.
  • Tooling note: node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch/issue-2142-bugfix-verification.json could not run because the proof-gate script is not present in this Codex install.

Feature Discoverability

Check exactly one:

  • Updated src/features/shell/discovery/ because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool.
  • N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find.

Reason:

  • Bugfix only; no new user-discoverable feature or workflow.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

UI evidence

N/A - this is a storage-side image processing fix. The focused repro copied the actual post-fix stored image to local scratch proof and asserted its decoded dimensions.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/2223 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 6/4/2026 **Status:** ✅ Merged **Merged:** 6/4/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/issue-2142-game-background-cover` --- ### 📝 Commits (2) - [`a284bc7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a284bc7003475745f798c393353fea0feabd9d35) Fix generated background cover resize - [`041b974`](https://github.com/Pasta-Devs/Marinara-Engine/commit/041b974b28c979b2b729790da71f967b96e281e7) Guard generated background resize formats ### 📊 Changes **1 file changed** (+245 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/crates/assets/src/lib.rs` (+245 -3) </details> ### 📄 Description <!-- Target branch: `refactor`. Change the base to `refactor` before submitting unless a maintainer explicitly asked for another base. --> <!-- Keep all checkboxes unchecked until a human has actually verified them. --> ## Linked issue Closes #2142 ## Why this change - Generated game scene backgrounds in refactor were uploaded exactly as returned by the image provider. Providers that ignore the requested 16:9 dimensions could therefore store square or otherwise mismatched backgrounds, unlike legacy main's `gameBackgroundImage()` path that cover-resized to the VN scene canvas. ## What changed - Added a generated-background-only resize step in `marinara-assets` before writing `backgrounds/generated/*` uploads. - The resize uses center-cover semantics at `1280x720` and re-encodes to the uploaded image format. - Added asset-service regression coverage for the generated background path plus negative controls proving generated illustrations, manual/custom background uploads, and whitespace-wrapped subcategory names keep their original dimensions. - Added generated-background dimension guards before full image decode. - Narrowed the generated-background resize path to PNG, JPEG, and WebP, matching the current game generation filenames and the asset crate's enabled codecs. ## Refactor impact Primary owner: Rust storage, game mode generated assets Impact areas reviewed: - `src/features/modes/game/api/game-api.ts` generated backgrounds call `uploadGeneratedAsset("backgrounds", "generated", ...)`. - `src-tauri/crates/assets/src/lib.rs` owns the managed game asset write boundary. - Adjacent `backgrounds/illustrations` and manual/custom background uploads were covered as negative controls. - Oversized generated background dimensions were covered as a rejection path before full decode. - Direct generated `.gif` and `.avif` background uploads were covered as rejection paths before decode/write; normal non-generated background extension acceptance is unchanged. Boundary notes: - The change stays in the Rust managed asset service and does not add React, feature internals, raw Tauri calls, dependencies, schema changes, or prompt/provider changes. - Generated game image filenames are PNG/WebP/JPG through the existing `imageExt()` path, so the resize path uses only the asset crate's already-declared PNG/JPEG/WebP codec support. Pressure points touched: - Managed game asset upload/write path only. ## Validation <!-- Check only what you personally ran or manually verified. Treat unchecked items as explicit TODOs. --> <!-- Do not submit *.test.ts or *.test.tsx files as PR proof; cite existing checks, command output, app/browser/Tauri verification, or manual notes instead. --> - [ ] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [ ] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes - Before fix: `cargo run --manifest-path scratch/issue-2142-repro/Cargo.toml` reproduced the bug with `stored_dimensions=512x512` and failed because generated backgrounds were not `1280x720`. - After fix: `cargo run --manifest-path scratch/issue-2142-repro/Cargo.toml` passed with `stored_dimensions=1280x720`. - `cargo test --manifest-path src-tauri/Cargo.toml -p marinara-assets -- --nocapture` passed: 15 tests, including direct generated `.gif`/`.avif` rejection before decode/write. - `cargo clippy --manifest-path src-tauri/Cargo.toml --workspace --all-targets -- -D warnings` passed. - `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passed. - `pnpm install --frozen-lockfile` was needed in the fresh issue worktree; it did not change dependency declarations. - `pnpm check` passed. - `git diff --check` passed. - GitHub checks on head `041b974b` passed: Browser Smoke and Performance, Frontend/Architecture/Organization, Rust Capability Layer, Bunny Review, and CodeRabbit. - Tooling note: `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch/issue-2142-bugfix-verification.json` could not run because the proof-gate script is not present in this Codex install. ## Feature Discoverability Check exactly one: - [ ] Updated `src/features/shell/discovery/` because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool. - [ ] N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find. Reason: - Bugfix only; no new user-discoverable feature or workflow. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [ ] Confirmed this PR does not restore old staging/package-workspace/release claims ## UI evidence N/A - this is a storage-side image processing fix. The focused repro copied the actual post-fix stored image to local scratch proof and asserted its decoded dimensions. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:16:44 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#5486
No description provided.