[GH-ISSUE #1155] Bundle AI sprite background cleanup runtime/dependencies #574

Closed
opened 2026-10-20 17:30:21 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @ghost on GitHub (May 24, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1155

Migrated from Pasta-Devs/Marinara-Engine-Refactor#24: https://github.com/Pasta-Devs/Marinara-Engine-Refactor/issues/24

Original author: @Xelvanis
Original created: 05/20/2026 05:23:53
Original updated: 05/24/2026 18:59:16
Original assignees: None
Original state: OPEN


Context

A dev wants to look at bundling the optional AI sprite background cleanup dependencies into the app/install package by default, instead of requiring users to already have backgroundremover available on their machine.

Current main behavior does not install Python, pip packages, or backgroundremover. It only checks for an already-available background remover command/runtime and falls back to built-in matte cleanup when optional AI cleanup is unavailable.

Current behavior on main

Relevant current-code anchors from main:

Possible implementation directions

  • Bundle a prepared backgroundremover executable/runtime with the app and update discovery to prefer the bundled command before checking env vars/local app data/PATH.
  • Bundle or install a pinned app-managed portable Python runtime, stored and updated by Marinara without touching system Python or PATH. This would need OS-specific builds, checksum/signature verification, update/cleanup logic, and clear user messaging for large downloads.
  • Include the model files in the install package or manage model download explicitly, instead of relying on the external CLI/model path behavior at first use.
  • Update the frontend message/CTA so users know whether AI cleanup is already bundled, needs a first-run download, or is unavailable on their platform.

Acceptance criteria

  • Users do not need to manually install system Python just to use bundled AI cleanup, if the chosen approach supports their platform.
  • The packaged runtime/dependencies are pinned and reproducible.
  • The app does not silently modify system Python or PATH.
  • Cleanup status clearly reports whether AI cleanup is bundled, downloaded, missing, disabled, or using built-in fallback.
  • Existing built-in cleanup remains available as the safe fallback.

Original comments

@cha1latte on 05/24/2026 18:59:16

Taking this one.

Source: https://github.com/Pasta-Devs/Marinara-Engine-Refactor/issues/24#issuecomment-4529679325

Originally created by @ghost on GitHub (May 24, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1155 Migrated from Pasta-Devs/Marinara-Engine-Refactor#24: https://github.com/Pasta-Devs/Marinara-Engine-Refactor/issues/24 Original author: @Xelvanis Original created: 05/20/2026 05:23:53 Original updated: 05/24/2026 18:59:16 Original assignees: None Original state: OPEN --- ## Context A dev wants to look at bundling the optional AI sprite background cleanup dependencies into the app/install package by default, instead of requiring users to already have `backgroundremover` available on their machine. Current `main` behavior does **not** install Python, pip packages, or `backgroundremover`. It only checks for an already-available background remover command/runtime and falls back to built-in matte cleanup when optional AI cleanup is unavailable. ## Current behavior on `main` Relevant current-code anchors from `main`: - Cleanup first tries optional `backgroundremover`, then falls back to built-in cleanup unless AI cleanup was explicitly required: https://github.com/Pasta-Devs/Marinara-Engine-Refactor/blob/9ca5d9e7d35dbd753d025b88fa381c9cb0fd74d7/src-tauri/src/commands/storage/sprites.rs#L906-L925 - Runtime discovery checks env vars, a local `.venv`, then `PATH`: https://github.com/Pasta-Devs/Marinara-Engine-Refactor/blob/9ca5d9e7d35dbd753d025b88fa381c9cb0fd74d7/src-tauri/src/commands/storage/sprites.rs#L1564-L1685 - The user-facing unavailable message currently comes from the Rust status payload: https://github.com/Pasta-Devs/Marinara-Engine-Refactor/blob/9ca5d9e7d35dbd753d025b88fa381c9cb0fd74d7/src-tauri/src/commands/storage/sprites.rs#L1664-L1685 - The actual CLI call writes a temp input/output image and configures model paths under the app data background-remover runtime dir: https://github.com/Pasta-Devs/Marinara-Engine-Refactor/blob/9ca5d9e7d35dbd753d025b88fa381c9cb0fd74d7/src-tauri/src/commands/storage/sprites.rs#L1723-L1786 - Tauri cleanup command entry point: https://github.com/Pasta-Devs/Marinara-Engine-Refactor/blob/9ca5d9e7d35dbd753d025b88fa381c9cb0fd74d7/src-tauri/src/commands/storage/commands/media.rs#L33-L36 - Frontend API wrapper for sprite cleanup: https://github.com/Pasta-Devs/Marinara-Engine-Refactor/blob/9ca5d9e7d35dbd753d025b88fa381c9cb0fd74d7/src/shared/api/image-generation-api.ts#L4-L10 - Generated sprite modal applies cleanup through `spriteApi.cleanup` and currently forces `engine: "builtin"` from this path: https://github.com/Pasta-Devs/Marinara-Engine-Refactor/blob/9ca5d9e7d35dbd753d025b88fa381c9cb0fd74d7/src/shared/components/ui/SpriteGenerationModal.tsx#L980-L1008 - Generated sprite modal cleanup UI/message area: https://github.com/Pasta-Devs/Marinara-Engine-Refactor/blob/9ca5d9e7d35dbd753d025b88fa381c9cb0fd74d7/src/shared/components/ui/SpriteGenerationModal.tsx#L1890-L1926 - Saved sprite cleanup in the character editor also currently forces `engine: "builtin"`: https://github.com/Pasta-Devs/Marinara-Engine-Refactor/blob/9ca5d9e7d35dbd753d025b88fa381c9cb0fd74d7/src/features/characters/components/CharacterEditor.tsx#L2287-L2305 ## Possible implementation directions - Bundle a prepared `backgroundremover` executable/runtime with the app and update discovery to prefer the bundled command before checking env vars/local app data/PATH. - Bundle or install a pinned app-managed portable Python runtime, stored and updated by Marinara without touching system Python or PATH. This would need OS-specific builds, checksum/signature verification, update/cleanup logic, and clear user messaging for large downloads. - Include the model files in the install package or manage model download explicitly, instead of relying on the external CLI/model path behavior at first use. - Update the frontend message/CTA so users know whether AI cleanup is already bundled, needs a first-run download, or is unavailable on their platform. ## Acceptance criteria - Users do not need to manually install system Python just to use bundled AI cleanup, if the chosen approach supports their platform. - The packaged runtime/dependencies are pinned and reproducible. - The app does not silently modify system Python or PATH. - Cleanup status clearly reports whether AI cleanup is bundled, downloaded, missing, disabled, or using built-in fallback. - Existing built-in cleanup remains available as the safe fallback. --- ## Original comments ### @cha1latte on 05/24/2026 18:59:16 Taking this one. Source: https://github.com/Pasta-Devs/Marinara-Engine-Refactor/issues/24#issuecomment-4529679325
Author
Owner

@cha1latte commented on GitHub (May 24, 2026):

Status update:

Phase 1 is already shipped on the refactor branch via #1172. That PR added the runtime discovery/status plumbing: Marinara now checks packaged resources/background-remover/... runtimes before env vars, app-data .venv, or PATH, and sprite cleanup UI paths request engine: "auto" so a bundled/app-managed runtime can be used when one exists.

This issue is not fully complete yet because #1172 did not bundle the actual third-party runtime, Python environment, dependencies, or model payload. That remaining work is being tracked separately in #1175 as the Phase 2 architecture/release decision.

Phase 2 needs a maintainer decision before implementation: app-managed first-run download vs fully bundled installer runtime, including hosting, checksums/signatures, supported platforms, model files, update/removal behavior, license/security review, and installer size.

So the current split is:

  • #1172: shipped Phase 1 discovery/status plumbing
  • #1175: open Phase 2 distribution decision
  • #1155: original umbrella request remains open until the runtime distribution path is decided and implemented
<!-- gh-comment-id:4530160116 --> @cha1latte commented on GitHub (May 24, 2026): Status update: Phase 1 is already shipped on the `refactor` branch via #1172. That PR added the runtime discovery/status plumbing: Marinara now checks packaged `resources/background-remover/...` runtimes before env vars, app-data `.venv`, or PATH, and sprite cleanup UI paths request `engine: "auto"` so a bundled/app-managed runtime can be used when one exists. This issue is not fully complete yet because #1172 did **not** bundle the actual third-party runtime, Python environment, dependencies, or model payload. That remaining work is being tracked separately in #1175 as the Phase 2 architecture/release decision. Phase 2 needs a maintainer decision before implementation: app-managed first-run download vs fully bundled installer runtime, including hosting, checksums/signatures, supported platforms, model files, update/removal behavior, license/security review, and installer size. So the current split is: - #1172: shipped Phase 1 discovery/status plumbing - #1175: open Phase 2 distribution decision - #1155: original umbrella request remains open until the runtime distribution path is decided and implemented
Author
Owner

@ghost commented on GitHub (May 25, 2026):

ohh hmmm, this one is tricky. We can't have local sidecars or anything on mobile at all since its a packaged app. There are alternatives, but we'll need to figure out feature gating first, where we can disable certain things both on the UI and the backend depending on what platform we are on. I would personally wait for this and figure that out first (which I can tackle this week, but its a tricky one)

<!-- gh-comment-id:4536588544 --> @ghost commented on GitHub (May 25, 2026): ohh hmmm, this one is tricky. We can't have local sidecars or anything on mobile at all since its a packaged app. There are alternatives, but we'll need to figure out feature gating first, where we can disable certain things both on the UI and the backend depending on what platform we are on. I would personally wait for this and figure that out first (which I can tackle this week, but its a tricky one)
Author
Owner

@cha1latte commented on GitHub (May 25, 2026):

@munimunigamer (From my AI):

I'd suggest we make the next step a small platform capability manifest rather than solving AI cleanup directly. The server should expose a typed capability/status payload for local-process/runtime features, and the frontend should use that to hide or disable unsupported controls. The backend still enforces the same gates.

Initial capabilities could be:

  • sidecar runtime install / local process execution
  • native image processing
  • AI sprite cleanup runtime availability/installability
  • custom script tools

That gives mobile packaged builds a clean way to say "unsupported here" while desktop/source installs can still report "available", "missing dependency", "disabled by config", or "requires admin". Once that contract exists, #1175 can choose the actual AI cleanup distribution path without guessing how mobile/desktop gating should work.

<!-- gh-comment-id:4536667547 --> @cha1latte commented on GitHub (May 25, 2026): @munimunigamer (From my AI): I'd suggest we make the next step a small platform capability manifest rather than solving AI cleanup directly. The server should expose a typed capability/status payload for local-process/runtime features, and the frontend should use that to hide or disable unsupported controls. The backend still enforces the same gates. Initial capabilities could be: - sidecar runtime install / local process execution - native image processing - AI sprite cleanup runtime availability/installability - custom script tools That gives mobile packaged builds a clean way to say "unsupported here" while desktop/source installs can still report "available", "missing dependency", "disabled by config", or "requires admin". Once that contract exists, #1175 can choose the actual AI cleanup distribution path without guessing how mobile/desktop gating should work.
Author
Owner

@cha1latte commented on GitHub (May 25, 2026):

Triage note: labeling this as scope-risk because bundled AI sprite cleanup is aligned, but runtime packaging touches platform support, installer size, mobile gating, downloads, checksums, model files, and license/security review.

The least risky next step is to keep this as the umbrella and let #1175 drive the distribution decision before more packaging work starts.

<!-- gh-comment-id:4536672359 --> @cha1latte commented on GitHub (May 25, 2026): Triage note: labeling this as `scope-risk` because bundled AI sprite cleanup is aligned, but runtime packaging touches platform support, installer size, mobile gating, downloads, checksums, model files, and license/security review. The least risky next step is to keep this as the umbrella and let #1175 drive the distribution decision before more packaging work starts.
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#574
No description provided.