[PR #1953] [MERGED] Fix legacy chat gallery recovery #5355

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/issue-1929-gallery-recovery


📝 Commits (1)

  • 5882fcf Fix legacy chat gallery recovery

📊 Changes

1 file changed (+221 additions, -0 deletions)

View changed files

📝 src-tauri/src/state.rs (+221 -0)

📄 Description

Linked issue

Closes #1929

Why this change

  • Legacy restored orphaned chat gallery files from data/gallery/<chatId>/ during startup when the chat still existed but the gallery storage row was missing. Refactor now stores managed gallery uploads as files again, but startup still had no equivalent recovery path.

What changed

  • Added startup recovery for legacy chat-owned gallery folders under data/gallery/<chatId>/.
  • Recovered valid image files are copied into the current flat managed gallery folder, enrolled into the gallery collection, and removed from the legacy source path after the row is created.
  • Added a regression test covering recovery, missing-chat negative control, unsupported-file negative control, and restart idempotency.

Refactor impact

Primary owner:

Rust storage

Impact areas reviewed:

  • Startup storage repair in src-tauri/src/state.rs
  • Managed gallery file shape (filePath, filename, url)
  • Legacy chat gallery ownership (data/gallery/<chatId>/<image>)

Boundary notes:

  • This stays in the src-tauri storage lane. It does not change React feature code, engine contracts, shared API wrappers, remote runtime routing, dependencies, schemas, or version files.
  • The recovery intentionally does not guess ownership for flat data/gallery/<filename> files because a missing row leaves no reliable chat/resource owner.

Pressure points touched:

  • AppState::from_data_dir_with_resource_dir startup initialization
  • data/gallery managed media recovery

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

  • Codex reproduced the bug before the production fix with cargo test --manifest-path src-tauri\Cargo.toml app_state_startup_recovers_legacy_chat_gallery_files; before the fix the test failed because startup listed 0 gallery rows instead of the expected recovered row.
  • Codex verified the fix with cargo test --manifest-path src-tauri\Cargo.toml app_state_startup_recovers_legacy_chat_gallery_files.
  • Codex ran cargo check --manifest-path src-tauri\Cargo.toml.
  • Codex ran pnpm check after installing locked dependencies in the fresh worktree with pnpm install --frozen-lockfile.
  • Codex ran node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json.
  • Bunny review pass completed locally before opening this draft.

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 for startup storage recovery; no new discoverable UI behavior.

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 changes were needed for this internal storage recovery bugfix.

UI evidence

N/A. This is a backend/storage startup recovery bug with no direct visible UI state; proof is the targeted Rust regression and full repo check above.

Summary by CodeRabbit

  • New Features

    • Automatic startup recovery of legacy gallery files, which are scanned, relocated to the managed directory, and indexed with duplicate prevention.
  • Tests

    • Added unit tests validating supported media recovery, proper asset management, cleanup of legacy files, and restart idempotency.

🔄 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/1953 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 6/2/2026 **Status:** ✅ Merged **Merged:** 6/2/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/issue-1929-gallery-recovery` --- ### 📝 Commits (1) - [`5882fcf`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5882fcf1745b8a4fd8cf3a1598e9fb927c9ab001) Fix legacy chat gallery recovery ### 📊 Changes **1 file changed** (+221 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/state.rs` (+221 -0) </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 #1929 ## Why this change - Legacy restored orphaned chat gallery files from `data/gallery/<chatId>/` during startup when the chat still existed but the gallery storage row was missing. Refactor now stores managed gallery uploads as files again, but startup still had no equivalent recovery path. ## What changed - Added startup recovery for legacy chat-owned gallery folders under `data/gallery/<chatId>/`. - Recovered valid image files are copied into the current flat managed gallery folder, enrolled into the `gallery` collection, and removed from the legacy source path after the row is created. - Added a regression test covering recovery, missing-chat negative control, unsupported-file negative control, and restart idempotency. ## Refactor impact Primary owner: Rust storage Impact areas reviewed: - Startup storage repair in `src-tauri/src/state.rs` - Managed gallery file shape (`filePath`, `filename`, `url`) - Legacy chat gallery ownership (`data/gallery/<chatId>/<image>`) Boundary notes: - This stays in the `src-tauri` storage lane. It does not change React feature code, engine contracts, shared API wrappers, remote runtime routing, dependencies, schemas, or version files. - The recovery intentionally does not guess ownership for flat `data/gallery/<filename>` files because a missing row leaves no reliable chat/resource owner. Pressure points touched: - `AppState::from_data_dir_with_resource_dir` startup initialization - `data/gallery` managed media recovery ## 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 - Codex reproduced the bug before the production fix with `cargo test --manifest-path src-tauri\Cargo.toml app_state_startup_recovers_legacy_chat_gallery_files`; before the fix the test failed because startup listed 0 gallery rows instead of the expected recovered row. - Codex verified the fix with `cargo test --manifest-path src-tauri\Cargo.toml app_state_startup_recovers_legacy_chat_gallery_files`. - Codex ran `cargo check --manifest-path src-tauri\Cargo.toml`. - Codex ran `pnpm check` after installing locked dependencies in the fresh worktree with `pnpm install --frozen-lockfile`. - Codex ran `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json`. - Bunny review pass completed locally before opening this draft. ## 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 for startup storage recovery; no new discoverable UI behavior. ## 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 changes were needed for this internal storage recovery bugfix. ## UI evidence N/A. This is a backend/storage startup recovery bug with no direct visible UI state; proof is the targeted Rust regression and full repo check above. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Automatic startup recovery of legacy gallery files, which are scanned, relocated to the managed directory, and indexed with duplicate prevention. * **Tests** * Added unit tests validating supported media recovery, proper asset management, cleanup of legacy files, and restart idempotency. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:15: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#5355
No description provided.