[PR #4005] [MERGED] Read zTXt character-card chunks so Character Tavern imports work #6198

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4005
Author: @SpicyMarinara
Created: 7/23/2026
Status: ✅ Merged
Merged: 7/23/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/4002-chartavern-ztxt


📝 Commits (2)

  • bf77bab Read zTXt character-card chunks from Character Tavern PNGs
  • d02f87e Bound zTXt card decompression

📊 Changes

6 files changed (+228 additions, -15 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/client/src/lib/png-parser.ts (+75 -9)
📝 packages/server/src/routes/characters.routes.ts (+4 -1)
📝 packages/server/src/routes/import.routes.ts (+36 -3)
📝 packages/server/src/services/import/st-bulk.importer.ts (+25 -2)
📝 scripts/regressions/open-issues.regression.ts (+87 -0)

📄 Description

Linked issue

Fixes #4002

Why this change

Every card imported from Character Tavern through the Card Browser failed with "No character data found in PNG — this doesn't appear to be a SillyTavern character card". Reproduced against their live CDN: Character Tavern now embeds the chara/ccv3 card JSON in zTXt (zlib-compressed) PNG chunks. Marinara's card parsers only read tEXt and iTXt, so the PNG parsed fine but no card data was ever found.

What changed

All four chunk-reading paths now handle zTXt (compression method 0 / zlib), preferring ccv3 over chara exactly as before:

  • Client Card Browser parser (png-parser.ts) — inflates via DecompressionStream("deflate") (the Compression Streams zlib format; supported by all browsers Marinara targets). Its data-URL step now builds from the bytes already in memory instead of FileReader, which also lets the parser run under Node-based regressions.
  • Server single import (import.routes.ts) and SillyTavern bulk import (st-bulk.importer.ts) — inflate via node:zlib.
  • Export chunk stripping (characters.routes.ts) — recognizes zTXt keywords, so re-exporting a Character Tavern character strips its stale compressed card data instead of shipping outdated JSON alongside the fresh tEXt chunk.

Regression: the open-issues lane builds a synthetic zTXt card PNG and asserts client extraction, server extraction, and export stripping. Both parsers were additionally verified against a real downloaded Character Tavern card (extracted chara_card_v3 with correct name from both).

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

Manual verification notes

  • Manually import a Character Tavern card end-to-end through the Card Browser UI and confirm the character is created with correct fields and avatar.
  • Manually re-export that character as PNG and re-import it, confirming the exported card carries the current (not stale) data.
  • Manually confirm ChubAI imports still work (tEXt path unchanged).

pnpm check and the open-issues regression lane were run by the preparing agent and passed; real-card extraction was verified programmatically. The browser UI flow needs the human check above. Checkboxes left unchecked per repository policy.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

CHANGELOG.md updated; no version bump.

UI evidence

No UI changes — the existing import flow simply succeeds where it previously errored.

Summary by CodeRabbit

  • Bug Fixes
    • Character cards imported from the Card Browser now support compressed PNG metadata.
    • Re-exported cards remove outdated embedded character data, preventing stale card information.
    • Improved handling of malformed compressed metadata without interrupting imports.
  • Tests
    • Added regression coverage for importing, exporting, and cleaning compressed character-card data.

🔄 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/4005 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 7/23/2026 **Status:** ✅ Merged **Merged:** 7/23/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/4002-chartavern-ztxt` --- ### 📝 Commits (2) - [`bf77bab`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bf77babe527cd2353d445a6240c9e09ab3c8f06b) Read zTXt character-card chunks from Character Tavern PNGs - [`d02f87e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d02f87e5beab18cb1079d296ff6d82b1e922c620) Bound zTXt card decompression ### 📊 Changes **6 files changed** (+228 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/client/src/lib/png-parser.ts` (+75 -9) 📝 `packages/server/src/routes/characters.routes.ts` (+4 -1) 📝 `packages/server/src/routes/import.routes.ts` (+36 -3) 📝 `packages/server/src/services/import/st-bulk.importer.ts` (+25 -2) 📝 `scripts/regressions/open-issues.regression.ts` (+87 -0) </details> ### 📄 Description ## Linked issue Fixes #4002 ## Why this change Every card imported from Character Tavern through the Card Browser failed with "No character data found in PNG — this doesn't appear to be a SillyTavern character card". Reproduced against their live CDN: Character Tavern now embeds the `chara`/`ccv3` card JSON in **zTXt** (zlib-compressed) PNG chunks. Marinara's card parsers only read `tEXt` and `iTXt`, so the PNG parsed fine but no card data was ever found. ## What changed All four chunk-reading paths now handle zTXt (compression method 0 / zlib), preferring `ccv3` over `chara` exactly as before: - **Client Card Browser parser** (`png-parser.ts`) — inflates via `DecompressionStream("deflate")` (the Compression Streams zlib format; supported by all browsers Marinara targets). Its data-URL step now builds from the bytes already in memory instead of `FileReader`, which also lets the parser run under Node-based regressions. - **Server single import** (`import.routes.ts`) and **SillyTavern bulk import** (`st-bulk.importer.ts`) — inflate via `node:zlib`. - **Export chunk stripping** (`characters.routes.ts`) — recognizes zTXt keywords, so re-exporting a Character Tavern character strips its stale compressed card data instead of shipping outdated JSON alongside the fresh `tEXt` chunk. Regression: the open-issues lane builds a synthetic zTXt card PNG and asserts client extraction, server extraction, and export stripping. Both parsers were additionally verified against a **real downloaded Character Tavern card** (extracted `chara_card_v3` with correct name from both). ## 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` ### Manual verification notes - Manually import a Character Tavern card end-to-end through the Card Browser UI and confirm the character is created with correct fields and avatar. - Manually re-export that character as PNG and re-import it, confirming the exported card carries the current (not stale) data. - Manually confirm ChubAI imports still work (tEXt path unchanged). `pnpm check` and the open-issues regression lane were run by the preparing agent and passed; real-card extraction was verified programmatically. The browser UI flow needs the human check above. Checkboxes left unchecked per repository policy. ## Docs and release impact - [ ] No docs changes needed - [x] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) CHANGELOG.md updated; no version bump. ## UI evidence No UI changes — the existing import flow simply succeeds where it previously errored. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Character cards imported from the Card Browser now support compressed PNG metadata. * Re-exported cards remove outdated embedded character data, preventing stale card information. * Improved handling of malformed compressed metadata without interrupting imports. * **Tests** * Added regression coverage for importing, exporting, and cleaning compressed character-card data. <!-- 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:08:04 +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#6198
No description provided.