mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #4522] [MERGED] feat(gallery): portable card://self/gallery references for chat images #6409
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#6409
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4522
Author: @kolacheee
Created: 8/3/2026
Status: ✅ Merged
Merged: 8/3/2026
Merged by: @kolacheee
Base:
staging← Head:feat/card-self-gallery📝 Commits (7)
2207d52feat(gallery): portable card://self/gallery references for chat images6011227fix(gallery): address multi-agent review of portable referencescd22b20feat(gallery): resolve card://self from any chat character's gallery on miss8070b4ddocs(gallery): system messages show self refs as literal text, not broken imagesb365d8fdocs(gallery): remove em dashes from the new prose0121141Merge branch 'staging' into feat/card-self-galleryf4f62b8fix(gallery): no cross-character fallback while the speaker's gallery is loading📊 Changes
19 files changed (+377 additions, -30 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
docs/characters/creating-and-editing-characters.md(+2 -0)📝
docs/characters/galleries.md(+30 -0)📝
docs/chats/sending-and-streaming.md(+14 -0)📝
packages/client/src/components/characters/CharacterEditor.tsx(+39 -0)📝
packages/client/src/components/chat/ChatCharacterDropOptions.tsx(+1 -0)📝
packages/client/src/components/chat/ChatMessage.tsx(+27 -8)📝
packages/client/src/components/chat/ChatSettingsDrawer.tsx(+1 -0)📝
packages/client/src/components/chat/ConversationMessage.tsx(+30 -6)📝
packages/client/src/components/chat/ConversationMessageBubble.tsx(+14 -0)📝
packages/client/src/components/chat/ConversationMessageGrouped.tsx(+14 -0)📝
packages/client/src/components/chat/ConversationMessageLine.tsx(+4 -2)📝
packages/client/src/components/chat/ConversationMessageShared.tsx(+23 -3)📝
packages/client/src/components/ui/MacroTextarea.tsx(+5 -1)📝
packages/client/src/hooks/use-characters.ts(+41 -1)📝
packages/client/src/lib/card-asset-links.ts(+79 -0)📝
packages/client/src/localization/locales/en.json(+3 -0)📝
packages/server/src/routes/characters.routes.ts(+9 -7)📝
packages/server/src/services/import/marinara.importer.ts(+40 -2)📄 Description
Linked issue
No filed issue — direct maintainer request from using the feature gap: embedding a gallery image in a greeting required an absolute URL (breaks off-host) or an id-baked
card://characters/<id>/...link (breaks on import, since character ids are regenerated). Happy to open a tracking issue if maintainers prefer one on record.Why this change
Character creators who put gallery images in greetings or messages currently ship broken images to everyone who imports their card: absolute URLs point at the author's host, and id-baked
card://links point at an id that no longer exists after import. The one identifier that can survive a native export round trip is the gallery filename — this PR makes a reference form that keys on it, and fixes the two export/import defects that would otherwise quietly break the promise.What changed
The portable form:
card://self/gallery/<filename>—selfresolves at render time to the character speaking the message.MessageContent(one chat-only component covering all render sites), with a new name-to-id map alongsidecharByNameso group-chat multi-speaker replies resolveselfper speaker segment — each character's line shows that character's own gallery.useChatGalleryFilenameIndexhook — group chats only, shares the per-character gallery cache, refetch-stable identity) lets aselfreference resolve to whichever chat character owns the file when the speaker's gallery doesn't have it — so Roleplay merged group replies and mis-attributed segments still show the right art. The speaker always wins on filename collisions; otherwise first match in chat order (documented). When the index knows no owner (or isn't loaded), the speaker rewrite is kept, so a stale cache can never break what works today.renderContent, covering messages, translations, and greeting previews (both the markdown and embedded-HTML branches). Greeting pickers (ChatCharacterDropOptions, chat-settings greeting confirm) preview with the same character id the created message will carry.MacroTextarea's markdown preview resolvesselfagainst the edited character for First Message, Alternate Greetings, Example Dialogue, Description, Creator Notes, and the Advanced prompt fields.self(deliberateisUser || isSystemgates in both modes) — the reference shows as a broken image, identical to any other unresolvablecard://scope. The resolver gains a documentaryselfcase so nobody "fixes" it by wiring in an arbitrary participant.. Three new localization keys inen.json(sorted; key-reference regression passes).Export/import fixes that make the promise true (found by recon + adversarial review):
..-proof including dot-run/trailing-dot recombination — property-tested), extension always derived from the decoded image (never the envelope), with the one allowed alias (.jpeg/.jpg) keeping its original spelling so references don't break, and collision suffixes for merged galleries.shared/or chat-scoped paths; the reader hardcoded the character directory). It now resolves throughresolveStoredGalleryFile— the same helper the serving route uses — so generated images export and re-import like uploads.Documentation (this was undocumented entirely — zero mentions of
card://or putting gallery images in chat anywhere indocs/):docs/characters/galleries.md— new Reuse a gallery image in messages and greetings: the copy button, theselfrule, where it works and deliberately doesn't (own messages, personas), the group-chat fallback with its collision rule (speaker first, then first match in chat order), whyselfbeats the id form, and the honest PNG-export caveat.docs/chats/sending-and-streaming.md— new Insert a gallery image into a message: attachments (for the AI to see) vs gallery references (for the reader to see), the markdown/card://forms, cross-link to the galleries guide.docs/characters/creating-and-editing-characters.md— cross-reference from Dialogue & Greetings.[Unreleased].Out of scope, per maintainer: PNG card exports (no gallery payload — documented as a caveat, not fixed). Persona-gallery portability would need its own scope and audit — untouched.
Review process
Tiered multi-agent pipeline: recon scanners mapped the render pipeline (every markdown site + id availability), gallery UI producers, the full
card://ecosystem, and docs coverage; a synthesis pass produced the design — and caught the importer filename-discard blocker that would have shipped the feature broken. After implementation, four adversarial reviewers (resolution correctness, regressions, hostile inputs, importer security + docs accuracy) produced 11 findings, each independently double-verified: 8 confirmed (deduplicating to 4 real issues — all fixed in the follow-up commit), 3 refuted with proof the flagged path is unreachable dead code.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Automated on the dev machine: full
pnpm lint(shared + server + client typechecks + eslint) clean; client production build clean;pnpm regression:localization,pnpm regression:docs(all 11 language packs), andpnpm regression:backuppass; the stem sanitizer property-tested against hostile filenames (beach..sunset.png,a/../../b.png, dot-runs, 120-char names — none can produce..).To verify in a real browser before merge (server pieces need a server rebuild):
selfref renders; greeting picker preview matches.card://self/gallery/...(include a.jpegupload and a generated selfie in the gallery), import on a clean profile — gallery filenames preserved, greeting images render. This exercises both export/import fixes.Docs and release impact
Docs touched:
docs/characters/galleries.md,docs/chats/sending-and-streaming.md,docs/characters/creating-and-editing-characters.md,CHANGELOG.md. No version bump. A[docs-i18n]follow-up issue will be filed for the translated language packs (no renames/deletions, so a follow-up issue suffices perCONTRIBUTING.md).UI evidence (if applicable)
Summary by CodeRabbit
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.