[PR #1270] [MERGED] Fix refactor gallery upload failure handling #5016

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1270
Author: @cha1latte
Created: 5/26/2026
Status: ✅ Merged
Merged: 5/26/2026
Merged by: @cha1latte

Base: refactor ← Head: fix/issue-1232-gallery-upload-remote


📝 Commits (1)

  • 81ed7d8 Fix gallery upload failure visibility

📊 Changes

7 files changed (+114 additions, -16 deletions)

View changed files

➕ src/features/catalog/gallery/hooks/use-gallery.test.ts (+17 -0)
📝 src/features/catalog/gallery/hooks/use-gallery.ts (+16 -9)
➕ src/shared/api/file-payload.test.ts (+52 -0)
📝 src/shared/api/file-payload.ts (+13 -1)
📝 src/shared/api/image-generation-api.ts (+9 -3)
📝 src/shared/api/settings-assets-api.ts (+5 -2)
📝 src/shared/components/ui/ImageUploadDropzone.tsx (+2 -1)

📄 Description

Linked issue

Closes #1232

Why this change

  • Refactor chat gallery uploads need to fail clearly in remote-runtime/browser flows instead of leaving the gallery unchanged with an unhelpful message.
  • Xel's audit note also called out oversized upload preflight before renderer/base64 work; the shared payload path still lacked that API-boundary guard even though the dropzone and Rust decoder had size checks.

What changed

  • Preserve the underlying single-file chat gallery upload error, so an older/unsupported remote runtime can surface the actual chat_gallery_upload is not exposed by the remote runtime message.
  • Add an opt-in max-byte preflight to fileToUploadPayload() and apply the 20 MB image limit to chat gallery, character gallery, and background upload API wrappers before arrayBuffer()/base64 conversion.
  • Reuse the shared image-upload size constant in the dropzone so UI validation and API-boundary validation stay aligned.
  • Add focused Vitest coverage for oversized preflight, valid image encoding, single-file remote error preservation, and multi-file batch summary behavior.

Refactor impact

Primary owner:

  • Shared API and catalog/gallery upload hooks.

Impact areas reviewed:

  • Chat gallery upload error handling
  • Character gallery upload payload creation
  • Background upload payload creation
  • Shared image upload dropzone size limit
  • Remote-runtime command support in current refactor

Boundary notes:

  • The fix stays in shared API and feature hook boundaries; engine and Rust storage code are unchanged.
  • Current refactor already allowlists and dispatches chat_gallery_upload; this PR covers the remaining compatibility/error visibility path plus the payload preflight requested in the issue comment.
  • No schema, version, dependency, auth, storage migration, or prompt-pipeline changes.

Pressure points touched:

  • Shared mode UI chat gallery
  • Shared API file payload conversion
  • Shared image upload dropzone

Validation

  • pnpm check passes locally
  • pnpm typecheck passes locally
  • pnpm build passes locally
  • pnpm check:architecture passes locally
  • pnpm check:docs passes locally
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passes locally
  • Rust clippy/tests were run for Rust behavior changes
  • Browser or Tauri app manual verification completed
  • Playwright, screenshot, or recording evidence added for UI changes
  • Remote runtime smoke checked when relevant

Manual verification notes

  • Codex ran pnpm exec vitest run src\shared\api\file-payload.test.ts src\features\catalog\gallery\hooks\use-gallery.test.ts: 2 files / 4 tests passed.
  • Codex re-ran the scratch before/after repro with pnpm exec vitest run --config scratch\vitest.issue-1232.config.ts: 1 file / 1 test passed after the fix.
  • Codex ran pnpm check:frontend: passed.
  • Codex ran pnpm check:architecture: dependency-cruiser passed and Rust structure check passed.
  • Codex ran pnpm check:docs: checked 40 docs and repo guidance files.
  • Codex attempted full pnpm check, but local verification timed out in the Rust phase after Cargo dependency compilation hit sandbox machine resource failures.
  • GitHub CI supplied the full baseline for PR #1270: Frontend, Architecture, and Organization passed; Rust Capability Layer passed; Browser Smoke and Performance passed; Auto-label passed; Pull Request template check skipped as expected.
  • CodeRabbit current-head status is successful and reviewThreads is empty.
  • Verification proof gist: https://gist.github.com/cha1latte/9548e2a75aab5005c07a7763b8e62035

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

No docs or release metadata changes needed; this is a narrow upload error/preflight fix.

UI evidence

No layout change. The user-facing path is covered by unit proof that single-file remote upload errors preserve the underlying unsupported-command message; the proof gist above includes the command results.


🔄 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/1270 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/26/2026 **Status:** ✅ Merged **Merged:** 5/26/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/issue-1232-gallery-upload-remote` --- ### 📝 Commits (1) - [`81ed7d8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/81ed7d8975e6e7b6d91fe524c3ca6ce49650cf4d) Fix gallery upload failure visibility ### 📊 Changes **7 files changed** (+114 additions, -16 deletions) <details> <summary>View changed files</summary> ➕ `src/features/catalog/gallery/hooks/use-gallery.test.ts` (+17 -0) 📝 `src/features/catalog/gallery/hooks/use-gallery.ts` (+16 -9) ➕ `src/shared/api/file-payload.test.ts` (+52 -0) 📝 `src/shared/api/file-payload.ts` (+13 -1) 📝 `src/shared/api/image-generation-api.ts` (+9 -3) 📝 `src/shared/api/settings-assets-api.ts` (+5 -2) 📝 `src/shared/components/ui/ImageUploadDropzone.tsx` (+2 -1) </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 #1232 ## Why this change - Refactor chat gallery uploads need to fail clearly in remote-runtime/browser flows instead of leaving the gallery unchanged with an unhelpful message. - Xel's audit note also called out oversized upload preflight before renderer/base64 work; the shared payload path still lacked that API-boundary guard even though the dropzone and Rust decoder had size checks. ## What changed - Preserve the underlying single-file chat gallery upload error, so an older/unsupported remote runtime can surface the actual `chat_gallery_upload is not exposed by the remote runtime` message. - Add an opt-in max-byte preflight to `fileToUploadPayload()` and apply the 20 MB image limit to chat gallery, character gallery, and background upload API wrappers before `arrayBuffer()`/base64 conversion. - Reuse the shared image-upload size constant in the dropzone so UI validation and API-boundary validation stay aligned. - Add focused Vitest coverage for oversized preflight, valid image encoding, single-file remote error preservation, and multi-file batch summary behavior. ## Refactor impact Primary owner: - Shared API and catalog/gallery upload hooks. Impact areas reviewed: - Chat gallery upload error handling - Character gallery upload payload creation - Background upload payload creation - Shared image upload dropzone size limit - Remote-runtime command support in current `refactor` Boundary notes: - The fix stays in shared API and feature hook boundaries; engine and Rust storage code are unchanged. - Current `refactor` already allowlists and dispatches `chat_gallery_upload`; this PR covers the remaining compatibility/error visibility path plus the payload preflight requested in the issue comment. - No schema, version, dependency, auth, storage migration, or prompt-pipeline changes. Pressure points touched: - Shared mode UI chat gallery - Shared API file payload conversion - Shared image upload dropzone ## Validation <!-- Check only what you personally ran or manually verified. Treat unchecked items as explicit TODOs. --> - [ ] `pnpm check` passes locally - [ ] `pnpm typecheck` passes locally - [ ] `pnpm build` passes locally - [ ] `pnpm check:architecture` passes locally - [ ] `pnpm check:docs` passes locally - [ ] `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passes locally - [ ] Rust clippy/tests were run for Rust behavior changes - [ ] Browser or Tauri app manual verification completed - [ ] Playwright, screenshot, or recording evidence added for UI changes - [ ] Remote runtime smoke checked when relevant ### Manual verification notes - Codex ran `pnpm exec vitest run src\shared\api\file-payload.test.ts src\features\catalog\gallery\hooks\use-gallery.test.ts`: 2 files / 4 tests passed. - Codex re-ran the scratch before/after repro with `pnpm exec vitest run --config scratch\vitest.issue-1232.config.ts`: 1 file / 1 test passed after the fix. - Codex ran `pnpm check:frontend`: passed. - Codex ran `pnpm check:architecture`: dependency-cruiser passed and Rust structure check passed. - Codex ran `pnpm check:docs`: checked 40 docs and repo guidance files. - Codex attempted full `pnpm check`, but local verification timed out in the Rust phase after Cargo dependency compilation hit sandbox machine resource failures. - GitHub CI supplied the full baseline for PR #1270: Frontend, Architecture, and Organization passed; Rust Capability Layer passed; Browser Smoke and Performance passed; Auto-label passed; Pull Request template check skipped as expected. - CodeRabbit current-head status is successful and `reviewThreads` is empty. - Verification proof gist: https://gist.github.com/cha1latte/9548e2a75aab5005c07a7763b8e62035 ## 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 No docs or release metadata changes needed; this is a narrow upload error/preflight fix. ## UI evidence No layout change. The user-facing path is covered by unit proof that single-file remote upload errors preserve the underlying unsupported-command message; the proof gist above includes the command results. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:12:31 +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#5016
No description provided.