[PR #7125] [MERGED] fix: stream native exports and save them on every device (#7115) #7487

Closed
opened 2026-10-23 04:20:18 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7125
Author: @SpicyMarinara
Created: 10/5/2026
Status: ✅ Merged
Merged: 10/5/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/ios-export-7115


📝 Commits (6)

  • 718e292 fix: stream native character and persona exports (#7115)
  • 13adfcf fix: save exports on iPhone and report failed exports (#7115)
  • cd9a6be Merge remote-tracking branch 'origin/staging' into fix/ios-export-7115
  • 51749c1 fix: report export save outcomes and keep failed writes from downloading twice (#7115)
  • 0fa73d1 fix(agents): finish saving the agent export before clearing its loading state (#7115)
  • e7329c5 Merge branch 'staging' into fix/ios-export-7115

📊 Changes

34 files changed (+1496 additions, -374 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 e2e/afternoon-sweep.e2e.ts (+5 -3)
📝 e2e/chat-insights.e2e.ts (+4 -3)
📝 e2e/core-flows.e2e.ts (+4 -3)
➕ e2e/export-save.ts (+16 -0)
➕ e2e/ios-export-save.e2e.ts (+137 -0)
📝 e2e/subscription-cache.e2e.ts (+4 -3)
📝 packages/client/src/components/characters/CharacterEditor.tsx (+17 -16)
📝 packages/client/src/components/characters/CharacterRegexSection.tsx (+10 -8)
📝 packages/client/src/components/chat/CharacterScheduleEditorModal.tsx (+4 -3)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+4 -2)
📝 packages/client/src/components/connections/ConnectionEditor.tsx (+9 -7)
📝 packages/client/src/components/game/GameSetupSummary.tsx (+4 -3)
📝 packages/client/src/components/game/GameWidgetSetupEditor.tsx (+9 -14)
📝 packages/client/src/components/layout/ChatSidebar.tsx (+2 -0)
📝 packages/client/src/components/panels/AgentsPanel.tsx (+8 -7)
📝 packages/client/src/components/panels/CharactersPanel.tsx (+10 -7)
📝 packages/client/src/components/panels/ConnectionsPanel.tsx (+16 -14)
📝 packages/client/src/components/panels/LorebooksPanel.tsx (+10 -7)
📝 packages/client/src/components/panels/PersonasPanel.tsx (+10 -7)

...and 14 more files

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #7115

Why this change

  • Exporting a character or persona (for example Marinara native) did nothing: no file and no message, on desktop and iPhone. The main cause was the server. Native exports loaded every gallery image as base64 at once and built one JSON string, so a large gallery ran the server out of memory. It restarted, and the browser got a 502.
  • The client ignored export failures, so nothing appeared.
  • On iPhone, exports used a plain link download after fetching. iOS drops that, especially in a Home Screen app or over http.

What changed

  • Server:
    • Native character and persona exports, single and bulk, now stream one image at a time with backpressure (new utils/export-stream.ts). Memory no longer grows with gallery size.
    • Single exports keep exactly the same compact JSON. Bulk ZIPs stream compressed files with the same indented JSON.
    • Filenames and Content-Disposition are unchanged.
    • Repeated names inside a bulk ZIP are numbered instead of replacing each other.
  • Client:
    • Every export saves through one helper (saveExportFile), which reports saved, prompted, cancelled or failed.
    • Success toasts appear only when the file was actually saved.
    • iPhone/iPad: the share sheet opens with the file. If iOS can't open it from the original tap, a "Your file is ready." message stays until the user taps Save file. That opens the share sheet, or downloads the file over plain http.
    • Desktop: behaviour is unchanged (save dialog or download), and the file stays available for 60 seconds. A write failure after choosing a file shows one error instead of starting a second download.
    • Android app: exports now save through its native file saver.
  • Errors: any failed export (4xx, 5xx, 502, dropped connection) shows "Couldn't export the file." with the reason, once.
  • Import: an import over the existing 256 MB limit gets a plain 413; the regression now checks this.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Agent-run checks (not a substitute for the boxes above):

  • pnpm check and pnpm localization:check pass.
  • New scripts/regressions/native-export-memory.regression.ts:
    • The server runs with a 112 MB heap and exports 64 MB galleries; peak heap stays around 100 MB.
    • Staging's exporter crashes under the same limit (JavaScript heap out of memory).
    • The output is byte-identical to the old format and imports back with every image intact.
  • New scripts/regressions/export-file-save.regression.ts: tests every save path and status on iOS, desktop and Android, plus error toasts and dropped connections. Fails on staging.
  • New e2e/ios-export-save.e2e.ts (desktop-chromium and mobile-webkit) passes. Updated export e2e (subscription-cache, agent export, character schedules export) pass.
  • Local CodeRabbit raised four points:
    • Fixed: the success toast now waits for a real save.
    • Fixed: a failed write after the save dialog no longer starts a second download.
    • Partly fixed: in-helper failures now return failed.
    • Declined: shortening the persistent-toast e2e wait. The app's toasts last 6 s, so a shorter wait wouldn't prove the Save file toast stays.

Manual verification notes

  • On a real iPhone in Safari over https: export a character as Marinara native. The share sheet opens and Save to Files works.
  • On a real iPhone, as a Home Screen app over https: same check.
  • On a real iPhone, as a Home Screen app over plain http on the LAN: export, tap Save file, and check the file saves and the app is not left stuck on a preview.
  • On a real iPhone, check a persona export and a bulk ZIP export from the Characters panel.
  • Export a character with a large gallery (hundreds of MB) from the Docker build. The server stays up and the file downloads.
  • Re-import that large export. A file under 256 MB imports; a larger one shows a plain error.
  • Stop the server or force a 502 while exporting, and check one error toast appears.
  • Desktop Chrome: the save dialog still appears for character exports.
  • Desktop Safari and Firefox: exports download normally, with no stray tab.
  • Android app: character, persona and bulk exports land in Downloads/Marinara.
  • The bulk ZIP opens in macOS Archive Utility, Windows Explorer and the iOS Files app.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

CHANGELOG updated. No user docs describe exporting on mobile. The four new UI strings are translated in #7123.

UI evidence (if applicable)

Not applicable (save behaviour and error toasts).

Summary by CodeRabbit

  • Bug Fixes
    • Character and persona exports with large galleries are more reliable and use less memory.
    • ZIP exports preserve files with duplicate names by assigning distinct filenames.
    • Export success messages appear only after a file is saved or its download starts; failures display clearer error messages.
    • iPhone and iPad exports support sharing files, with a “Save file” fallback when sharing can’t complete.

🔄 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/7125 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/5/2026 **Status:** ✅ Merged **Merged:** 10/5/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/ios-export-7115` --- ### 📝 Commits (6) - [`718e292`](https://github.com/Pasta-Devs/Marinara-Engine/commit/718e2927c7783f80af173f425586ac1d73ff4752) fix: stream native character and persona exports (#7115) - [`13adfcf`](https://github.com/Pasta-Devs/Marinara-Engine/commit/13adfcfdacc861c2dbf270071427c474913e1918) fix: save exports on iPhone and report failed exports (#7115) - [`cd9a6be`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cd9a6bef3dc91987787cfc38d2ca9843b535da35) Merge remote-tracking branch 'origin/staging' into fix/ios-export-7115 - [`51749c1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/51749c1835637c07bf2f3f8a5788cacfa354b106) fix: report export save outcomes and keep failed writes from downloading twice (#7115) - [`0fa73d1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0fa73d1c82a9c22b374af03bb12ea028f57ed12e) fix(agents): finish saving the agent export before clearing its loading state (#7115) - [`e7329c5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e7329c5ffc66c48cd525ebf902b4ae278b2f206c) Merge branch 'staging' into fix/ios-export-7115 ### 📊 Changes **34 files changed** (+1496 additions, -374 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `e2e/afternoon-sweep.e2e.ts` (+5 -3) 📝 `e2e/chat-insights.e2e.ts` (+4 -3) 📝 `e2e/core-flows.e2e.ts` (+4 -3) ➕ `e2e/export-save.ts` (+16 -0) ➕ `e2e/ios-export-save.e2e.ts` (+137 -0) 📝 `e2e/subscription-cache.e2e.ts` (+4 -3) 📝 `packages/client/src/components/characters/CharacterEditor.tsx` (+17 -16) 📝 `packages/client/src/components/characters/CharacterRegexSection.tsx` (+10 -8) 📝 `packages/client/src/components/chat/CharacterScheduleEditorModal.tsx` (+4 -3) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+4 -2) 📝 `packages/client/src/components/connections/ConnectionEditor.tsx` (+9 -7) 📝 `packages/client/src/components/game/GameSetupSummary.tsx` (+4 -3) 📝 `packages/client/src/components/game/GameWidgetSetupEditor.tsx` (+9 -14) 📝 `packages/client/src/components/layout/ChatSidebar.tsx` (+2 -0) 📝 `packages/client/src/components/panels/AgentsPanel.tsx` (+8 -7) 📝 `packages/client/src/components/panels/CharactersPanel.tsx` (+10 -7) 📝 `packages/client/src/components/panels/ConnectionsPanel.tsx` (+16 -14) 📝 `packages/client/src/components/panels/LorebooksPanel.tsx` (+10 -7) 📝 `packages/client/src/components/panels/PersonasPanel.tsx` (+10 -7) _...and 14 more files_ </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. ## Linked issue Closes #7115 ## Why this change - Exporting a character or persona (for example **Marinara native**) did nothing: no file and no message, on desktop and iPhone. The main cause was the server. Native exports loaded every gallery image as base64 at once and built one JSON string, so a large gallery ran the server out of memory. It restarted, and the browser got a 502. - The client ignored export failures, so nothing appeared. - On iPhone, exports used a plain link download after fetching. iOS drops that, especially in a Home Screen app or over http. ## What changed - **Server:** - Native character and persona exports, single and bulk, now stream one image at a time with backpressure (new `utils/export-stream.ts`). Memory no longer grows with gallery size. - Single exports keep exactly the same compact JSON. Bulk ZIPs stream compressed files with the same indented JSON. - Filenames and `Content-Disposition` are unchanged. - Repeated names inside a bulk ZIP are numbered instead of replacing each other. - **Client:** - Every export saves through one helper (`saveExportFile`), which reports `saved`, `prompted`, `cancelled` or `failed`. - Success toasts appear only when the file was actually saved. - **iPhone/iPad:** the share sheet opens with the file. If iOS can't open it from the original tap, a "Your file is ready." message stays until the user taps **Save file**. That opens the share sheet, or downloads the file over plain http. - **Desktop:** behaviour is unchanged (save dialog or download), and the file stays available for 60 seconds. A write failure after choosing a file shows one error instead of starting a second download. - **Android app:** exports now save through its native file saver. - **Errors:** any failed export (4xx, 5xx, 502, dropped connection) shows "Couldn't export the file." with the reason, once. - **Import:** an import over the existing 256 MB limit gets a plain 413; the regression now checks this. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` Agent-run checks (not a substitute for the boxes above): - `pnpm check` and `pnpm localization:check` pass. - New `scripts/regressions/native-export-memory.regression.ts`: - The server runs with a 112 MB heap and exports 64 MB galleries; peak heap stays around 100 MB. - Staging's exporter crashes under the same limit (`JavaScript heap out of memory`). - The output is byte-identical to the old format and imports back with every image intact. - New `scripts/regressions/export-file-save.regression.ts`: tests every save path and status on iOS, desktop and Android, plus error toasts and dropped connections. Fails on staging. - New `e2e/ios-export-save.e2e.ts` (desktop-chromium and mobile-webkit) passes. Updated export e2e (subscription-cache, agent export, character schedules export) pass. - Local CodeRabbit raised four points: - Fixed: the success toast now waits for a real save. - Fixed: a failed write after the save dialog no longer starts a second download. - Partly fixed: in-helper failures now return `failed`. - Declined: shortening the persistent-toast e2e wait. The app's toasts last 6 s, so a shorter wait wouldn't prove the Save file toast stays. ### Manual verification notes - [ ] On a real iPhone in Safari over https: export a character as Marinara native. The share sheet opens and Save to Files works. - [ ] On a real iPhone, as a Home Screen app over https: same check. - [ ] On a real iPhone, as a Home Screen app over plain http on the LAN: export, tap **Save file**, and check the file saves and the app is not left stuck on a preview. - [ ] On a real iPhone, check a persona export and a bulk ZIP export from the Characters panel. - [ ] Export a character with a large gallery (hundreds of MB) from the Docker build. The server stays up and the file downloads. - [ ] Re-import that large export. A file under 256 MB imports; a larger one shows a plain error. - [ ] Stop the server or force a 502 while exporting, and check one error toast appears. - [ ] Desktop Chrome: the save dialog still appears for character exports. - [ ] Desktop Safari and Firefox: exports download normally, with no stray tab. - [ ] Android app: character, persona and bulk exports land in Downloads/Marinara. - [ ] The bulk ZIP opens in macOS Archive Utility, Windows Explorer and the iOS Files app. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) CHANGELOG updated. No user docs describe exporting on mobile. The four new UI strings are translated in #7123. ## UI evidence (if applicable) Not applicable (save behaviour and error toasts). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Character and persona exports with large galleries are more reliable and use less memory. * ZIP exports preserve files with duplicate names by assigning distinct filenames. * Export success messages appear only after a file is saved or its download starts; failures display clearer error messages. * iPhone and iPad exports support sharing files, with a “Save file” fallback when sharing can’t complete. <!-- 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-23 04:20:18 +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#7487
No description provided.