Lorebook Entry Images — Design Document
Status:
- Phase 1 (creator-side: picture FK on entries, repo, endpoints, entry-editor picker) — shipped
- Phase 2a (Side A:
Features.EnableLorebookImagessetting +ConversationFeatureStateplumbing + HowDrawer row) — shipped - Phase 2b (Side A: search/expand surfacing picture columns +
LorebookImagesstreaming token + SSE wire +TriggeredEntryImagesPanel+ ReportModal wiring) — shipped - Phase 3 (Side B: LLM vision injection) — not started
- Phase 4 (Side A v2: multi-image carousel) — not started
User-facing docs for the live (Side A) feature live at /features/picture-entries. This document is the design source of truth and tracks Side B + carousel + open seams.
Overview
Lorebook entries describe world-building concepts — characters, locations, items, factions, etc. Adding an image to an entry gives visual context to that world-building data.
Two independent features, two independent toggles
When entries trigger during a conversation, their images have two unrelated payoffs, and we treat them as two separate features that ship in two separate phases with two separate user toggles:
| Side A — UI display | Side B — Vision injection | |
|---|---|---|
| What it does | Shows the triggered entry's image to the user in the chat UI | Sends the image into the LLM prompt as multimodal content |
| Who it's for | Every user — visual context for the human reader | Users on vision-capable models who want the AI to "see" the image |
| Cost | Bandwidth only | Significant token cost per turn |
| Default | On | Off |
| Toggle key | Features.EnableLorebookImages |
Features.SendLorebookImagesToLlm |
| HowDrawer row | "Picture entries" (existing placeholder, repurposed) | New coming-soon row added in Side A's phase, wired in Side B's phase |
| Shipping order | First | Second (independent — Side B can ship months later) |
The two toggles are independent. A user can enable UI display without vision injection (default), enable vision without UI, or enable / disable both. Side B may add a soft hint in the UI ("you have vision injection on but not display — you can't see what the AI sees"), but neither toggle is hard-dependency-locked on the other. Both, however, are dependency-locked on Features.EnableLorebook — turning off lorebooks turns off both image features.
The shared backend work — gallery FK, upsert, search/expand returning picture_image_id, creator-side picker — happens once in Phase 1 and serves both sides. Everything after that splits.
Core Goals
- Let creators attach a single image to any lorebook entry (Phase 1)
- Reuse the existing gallery system — no per-entity storage service, no bespoke columns
- Side A first: display triggered entry images in the chat UI during conversations, with a feature toggle (Phase 2)
- Side B later: optionally send entry images to the LLM as multimodal content (Phase 3) — independent toggle
- Keep it lightweight — one image per entry, not a gallery per entry
What's Already in Place
The unified gallery system that this feature plugs into is already shipped and in use elsewhere:
| Piece | Location |
|---|---|
gallery_images table |
database/v1/31_* (table family) |
gallery_image_entity_links join table |
database/v1/31d_entity_avatar_image_links.sql |
*_image_id FK pattern on entities |
characters, lorebooks (picture_image_id), users, personas |
GalleryImageStorageService |
server/EchoOfDreams.Core/Services/GalleryImageStorageService.cs |
| Presigned upload/download flow | server/EchoOfDreams.ServerAPI/Api/Endpoints/GalleryEndpoints.cs |
| Thumbnail generation, content rating, moderation | gallery pipeline |
HowDrawer coming-soon placeholder "Picture entries" |
clientConsole/src/pages/chat-v2/components/HowDrawer.tsx (line ~1034) — needs wiring to a real toggle + copy rewrite |
FeatureRow + ConversationFeatureState toggle pattern |
clientConsole/src/pages/chat-v2/components/how/FeatureRow.tsx, server/EchoOfDreams.WebChat/Services/IWebChatFeatureStateService.cs |
Shared ImagePickerModal (gallery / upload / URL tabs) |
shared/src/components/common/ImagePickerModal.tsx |
ImagePickerField (thumbnail + open-picker affordance) |
shared/src/components/common/ImagePickerField.tsx |
useImagePicker hook (data fetching + state) |
clientConsole/src/hooks/useImagePicker.ts |
ContentImage + ContentImageContext (rating-aware blur) |
shared/src/components/common/ContentImage.tsx, ContentImageContext.tsx |
ImageLightbox (full-size view) |
shared/src/components/common/ImageLightbox.tsx |
ReportModal + reportsApi |
clientConsole/src/components/common/ReportModal.tsx, clientConsole/src/api/reports.ts |
| Legacy URL → gallery migration precedent | database/v1/38_migrate_legacy_image_urls.sql (characters, lorebooks, personas) |
EntityType.Lorebook = 2, sub-entity Entry |
Core/Entities/EntityRegistry.cs |
What is not in place yet for entries:
- No image FK column on
lorebook_entries fn_upsert_lorebook_entry,fn_search_lorebook,fn_expand_lorebook_entriesdon't return image data- No upload/link endpoints for entry images (top-level lorebook has
SetPictureImageAsync; entries have nothing) LorebookContentProviderhas no image awareness- No
Knowledge.SendEntryImagesToLlmsetting - Pipeline
IPromptContentProvider.GetContentAsyncstill returns plainstring— noPromptContentmultimodal type
Database Changes
New column on lorebook_entries
Match the existing convention (characters.avatar_image_id, lorebooks.picture_image_id):
ALTER TABLE lorebook_entries
ADD COLUMN IF NOT EXISTS picture_image_id INTEGER
REFERENCES gallery_images(id) ON DELETE SET NULL;
CREATE INDEX IF NOT EXISTS idx_lorebook_entries_picture_image
ON lorebook_entries(picture_image_id)
WHERE picture_image_id IS NOT NULL;
COMMENT ON COLUMN lorebook_entries.picture_image_id IS
'FK to gallery_images. The image and its alt text are read from gallery_images.';
Alt text, content type, content rating, dimensions, and moderation status all live on gallery_images — no duplication.
Entity-link sub-type for entries
Entries plug into gallery_image_entity_links like every other entity that uses gallery images — that's how fn_gallery_image_usage ("where is this image used?") and fn_get_entity_linked_images work, and every existing Set*ImageAsync (characters, lorebooks, personas) populates this table. Entries get the same treatment for consistency.
gallery_image_entity_links keys by (entity_type, entity_id), and EntityType.Lorebook = 2 is already taken by top-level lorebooks. So:
- Add
EntityType.LorebookEntry = 13toCore/Entities/EntityRegistry.cs - Update the
gallery_image_entity_linksentity_typeCHECK to allow the new value SetEntryPictureImageAsyncinserts(gallery_image_id, 13, entry_id)alongside setting the FK, mirroringSetPictureImageAsyncon lorebooks
Updated functions
fn_upsert_lorebook_entry— addp_picture_image_id INTEGER. Three-state semantics (omit / clear / set), same pattern as other nullable updates.fn_search_lorebook— returnpicture_image_idso the pipeline can resolve image URLs without a second query.fn_expand_lorebook_entries— same.- Entry views (
04_lorebook_view.sql) — includepicture_image_idand a join togallery_imagesforexternal_url/ bucket key / thumbnail.
API Endpoints
Reuse the existing gallery upload flow rather than building a new one:
# Existing — already shipped
POST /api/gallery/upload-url # presigned PUT
POST /api/gallery/confirm # finalize gallery_images row
# New — entry-level link/unlink (mirrors Lorebook.SetPictureImageAsync)
PUT /api/creator/lorebooks/{lorebookId}/entries/{entryId}/picture
body: { imageUuid: "…" | null }
DELETE /api/creator/lorebooks/{lorebookId}/entries/{entryId}/picture
The entry upsert endpoint also accepts an optional pictureImageUuid so creating an entry with an image is a single round-trip.
External-URL pasting is no longer entry-specific: a creator pastes a URL into the gallery uploader, gallery creates a row with external_url, the entry FKs to it. This keeps content moderation consistent.
Subscription Limits
No new entry-specific limits. Image size, allowed types, and per-user storage caps all live on the gallery system and apply uniformly. Image count is bounded by the entry count (one per entry).
Conversation Integration
This section is split into the two independent sides described in the Overview. Side A (UI display) is Phase 2 and ships first. Side B (vision injection) is Phase 3 and is independently shippable later. Each side has its own toggle in HowDrawer; they do not depend on each other.
Side A — Chat UI display (ships first, Phase 2)
When the lorebook pipeline matches entries during a conversation turn, matched entries that have a picture_image_id are included in the response metadata. The chat UI renders the triggered images using the existing ContentImage wrapper, which already implements the user's blur preferences (blurSuggestive, blurNSFW, blurIntensity from ContentImageContext). Pass the image's contentRating and moderationStatus through from gallery_images — under-review images get a non-revealable blur for free.
The thumbnail carries a small report affordance wired to the existing ReportModal (clientConsole/src/components/common/ReportModal.tsx). ReportEntityType doesn't currently include image-level reporting — add a 'GalleryImage' (or 'LorebookEntry') variant so users can flag a triggered image as miscategorized or inappropriate without leaving the chat. The button is intentionally tiny (<Button iconOnly size="xs" icon="flag">), positioned in the corner of the thumbnail container so it doesn't compete with the conversation.
v1: only the top matched entry's image is shown
Even when several matched entries have images, v1 renders exactly one — the highest-ranked match (same ranking the lorebook pipeline already computes for entry priority). Rationale:
- One image per turn keeps the panel layout trivial — no scroll, no carousel, no per-message state for "which image am I looking at"
- It cleanly forces creators toward "give your most important entry the strongest image" instead of flooding the chat
- Defers carousel UX work until we have the shared component for it
The pipeline still emits the full list of matched-with-image entries in metadata (so v2 can light up without a server change) — the UI just slices [0].
v2 — multi-image carousel. Once a shared rotating-image component lands (modeled on the existing HeroBanner carousel — shared/src/components/common/HeroBanner.tsx — with bottom dots and < / > arrows), the panel switches to that component and shows all matched-with-image entries. Don't reimplement the rotation; extract the navigation/dots from HeroBanner into a reusable primitive (e.g. <ImageCarousel>) and use it in both places. Until that primitive exists, v1 stays single-image.
Streaming the image list before the assistant text
Lorebook matching runs in ContextBuildingStageBase — a pre-LLM stage, before the first content token. The matched entries (and therefore their picture_image_ids and resolved URLs) are fully known by the time ChatPipeline.ExecuteStreamAsync enters the LLM call. We exploit that:
- Add a new
PipelineTokenType.LorebookImages(inChatPipeline.cs) carrying the per-turn list of matched-with-image entries ({ entryId, name, imageUrl, contentRating, moderationStatus, altText }[]) - The pipeline emits this token between
Startand the firstContenttoken — i.e. as soon as the system prompt is assembled and we've yielded to the LLM - Web SSE / Discord transport pass it through as a typed event (web SSE:
event: lorebook-images\ndata: {...}) - The chat UI binds the panel to this event, not to
Done— the image appears in sync with the typing indicator / first streamed character, not after the response finishes
Why this matters:
- Perceived latency — for short responses the panel would otherwise pop in only at
Done, feeling laggy - Long generations — on a 30-second response, users see the image context the entire time the AI is writing, not only after
- Consistency with status messages —
Statustokens (e.g. "thinking…") already arrive pre-Contentover the same channel; this is the same pattern with structured payload
The full list is emitted, even though v1 only renders [0]. v2's carousel lights up by changing the renderer, not the protocol.
Failure handling: if the image list is empty (no matches with images), no LorebookImages token is sent — the panel never renders. If the token never arrives (older client / pipeline error), the chat falls back to the metadata that's also attached to the assistant message on Done, so the panel still appears post-stream.
Layout (per breakpoint)
The triggered-images panel changes location based on viewport and chat layout state:
Mobile — inline, expand/collapse:
┌──────────────────────────────┐
│ AI message text here... │
│ ... │
├──────────────────────────────┤
│ ▸ Elara's Tower │ ← collapsed by default
└──────────────────────────────┘
↓ tap to expand ↓
┌──────────────────────────────┐
│ AI message text here... │
├──────────────────────────────┤
│ ▾ Elara's Tower ⚐ │
│ ┌────────────────────┐ │
│ │ 🏰 │ │
│ │ (thumbnail) │ │
│ └────────────────────┘ │
└──────────────────────────────┘
- Sits inline under the assistant message, above the next user turn
- Collapsed by default; tap the header to expand. Expansion state is per-message
- Tap the thumbnail → existing
ImageLightbox. Report button (⚐) sits in the header next to the entry name - Blur respects the user's content settings; tap-to-reveal honors per-image rating
Desktop, focus mode or one drawer collapsed — side panel:
┌────────────────────┬────────────┐
│ │ Elara's │
│ │ Tower ⚐ │
│ │ ┌────────┐ │
│ chat messages │ │ 🏰 │ │
│ │ │ tower │ │
│ │ └────────┘ │
│ │ │
└────────────────────┴────────────┘
- Renders as a slim right-rail panel when there's spare horizontal room (focus mode or one of the side drawers is collapsed)
- Pinned per assistant turn — scrolling chat history keeps the panel in sync with the visible message
- Same
ContentImageblur, sameReportModalbutton (always visible on hover, tap-target on touch)
Desktop, both drawers open — falls back to inline (mobile-style) inside the message column. The condition is "is there spare side gutter ≥ 240px" rather than a hard breakpoint.
Display is independent of vision injection — flipping Features.SendLorebookImagesToLlm (Side B) on or off changes nothing on Side A's path.
Side A toggle: Features.EnableLorebookImages
Plug into the existing feature-toggle infrastructure rather than inventing a new bespoke setting. The Features.Enable{Summaries,Memories,Lorebook} family already exists:
- Setting hierarchy (per-conversation override → user default), default-true semantics
- Server-side resolution in
WebChatFeatureStateService→ConversationFeatureState - UI rendering in
clientConsole/src/pages/chat-v2/components/how/FeatureRow.tsxwithactive/inactive/mode-locked/dependency-locked/coming-soonstates
Setting key: Features.EnableLorebookImages
Default: true
Scope: per-conversation (overridable per-channel on Discord), with user default
Dependency: Features.EnableLorebook (lorebook itself must be on)
Independence: NOT linked to Features.SendLorebookImagesToLlm — the two toggles are orthogonal
Server work — extend ConversationFeatureState with LorebookImagesEnabled (raw user toggle) and ModeSupportsLorebookImages (mirrors ModeSupportsLorebook for the dependency-lock badge). The pipeline checks the resolved-effective value before emitting the LorebookImages token; when disabled, no token is sent and no panel renders.
Client work — wire the existing "Picture entries" row in HowDrawer to Features.EnableLorebookImages. It renders dependency-locked with requires="Lorebook" when lorebook itself is off, mirroring the existing Memories-requires-Summaries behavior.
"Coming soon" row already exists
A coming-soon placeholder row labeled "Picture entries" is already rendered in HowDrawer.tsx (in the inline "Coming soon" group alongside Trackers / Journal / Living Lorebook). It has no setting key, no ConversationFeatureState wiring — it's pure UI copy at this point.
Two notes on the existing row:
Current copy is vision-focused. The placeholder description today reads "Image-bearing lorebook entries. When the entry triggers, its image goes into the prompt for vision-capable models — a way to describe a character or setting visually instead of writing every detail in text." That frames the feature as Phase 3 (LLM multimodal), not Phase 2 (chat-UI display). Rewrite the copy to lead with the visible-in-chat behavior — it ships first and is the more universally useful half — with a one-liner about the optional vision-injection follow-up.
No backfill schema work needed for the toggle to become real. Going from placeholder to functional is: add
Features.EnableLorebookImagestoSettingsKeys, surfaceLorebookImagesEnabled+ModeSupportsLorebookImagesonConversationFeatureState, replace the row's hard-codedstate={{ kind: 'coming-soon' }}with the resolved state from feature-state. No setting rename, no migration.
Practical sequencing — Phase 2 splits cleanly:
- Phase 2a — wire the existing row: add the setting key + state fields, leave the row in
coming-soonuntil the renderer lands. Optionally rewrite the placeholder copy now so users understand what's coming. - Phase 2b — land the streaming token +
TriggeredEntryImagesPaneland flip the row fromcoming-soonto interactive (active/inactivebased on the resolved toggle).
Side B — LLM vision injection (ships independently, Phase 3)
A second, separate feature with its own toggle. Side B can ship months after Side A — or never — without changing anything on Side A's path. Likewise, Side A users don't need vision-capable models, while Side B is gated on them.
Side B toggle: Features.SendLorebookImagesToLlm
Setting key: Features.SendLorebookImagesToLlm
Default: false (vision tokens are expensive)
Scope: per-conversation (overridable per-channel on Discord), with user default
Dependency: Features.EnableLorebook (lorebook itself must be on)
Independence: NOT linked to Features.EnableLorebookImages — a user can send to LLM without
seeing in chat, or vice versa, in any combination
Hard requirement: active model must support vision; toggle is disabled with a tooltip otherwise
A new HowDrawer row (separate from "Picture entries") is added in Phase 3. It ships in coming-soon state during Phase 2 if convenient, with copy that explicitly distinguishes it from Side A: "Send the matched entry's image into the prompt for vision-capable models. Increases token cost. Independent of whether you display the image in chat."
When enabled
LorebookContentProvidercollectspicture_image_ids from matched entries- Resolves them to URLs via the gallery service (presigned for uploads, direct for
external_url) - The pipeline emits multimodal content blocks (text + image) instead of text-only
- The LLM receives the image alongside the entry text
Cost transparency in the UI
- Warning callout next to the toggle: "Sending images to the AI increases token usage significantly. Each image adds ~1,000–2,000 tokens per turn depending on the model."
- If the active model doesn't support vision, the toggle is disabled with a tooltip pointing the user at vision-capable models
- The conversation's token usage indicator should reflect the image overhead
Pipeline changes (Side B only)
The LorebookContentProvider currently returns a plain string. To support multimodal:
public record PromptContent(string Text, IReadOnlyList<ContentImage>? Images = null);
public record ContentImage(string Url, string? AltText = null);
IPromptContentProvider.GetContentAsyncreturn type changes fromTask<string>toTask<PromptContent>- All existing providers return
new PromptContent(text)— backwards compatible - Only
LorebookContentProviderpopulatesImageswhen the setting is enabled and matched entries have images - The system prompt builder constructs provider-specific multimodal blocks (Anthropic, OpenAI, Google each differ)
Image caching
To avoid re-fetching/re-encoding on every turn:
- In-memory cache, ~15-minute TTL (matches presigned URL expiry)
- Key:
gallery_image_id - Value: base64 + content type
- LRU eviction, max ~100 entries
Creator UI
Entry editor
A new "Image" section in the entry form. No new UI components — drop in the existing shared ImagePickerField (which wraps ImagePickerModal via useImagePicker), the same picker already used everywhere else images are attached. It ships gallery / upload / external-URL tabs out of the box, plus thumbnail preview, clear, and showcase coverage.
<ImagePickerField value={entry.pictureImageUuid} onChange={...} />— that's the integration- Modal handles upload, gallery selection, and external-URL paste
- Thumbnail, remove, and replace affordances are built in
- Alt text is edited on the gallery image itself, not on the entry
Entry list
Entries with images show a small image indicator. Hover reveals the thumbnail.
Export / Import
LorebookEntryExportDataincludes the image's galleryexternal_url(or presigned download URL for uploads)- On import, URLs flow through the standard gallery import pipeline — they become
gallery_imagesrows withexternal_url, then linked viapicture_image_id - Same expiring-URL caveat as character avatar export: the export UI warns when uploaded images are included as temporary download links
Implementation Phases
Phase 1: Images on entries (creator feature) — shipped
What landed:
database/v1/40_lorebook_entry_picture_image.sql— addslorebook_entries.picture_image_id INTEGER REFERENCES gallery_images(id) ON DELETE SET NULL+ partial index. Wired intov1_run_all.sql.LorebookEntryRowgainspicture_image_id+ 8 joined gallery fields;EntrySelectColumnsleft-joinsgallery_images.ILorebookRepository.SetEntryPictureImageAsync(entryId, lorebookId, actorUserId, imageUuid?)— scoped to the entry's parent lorebook (the entry endpoints authorizecan_editon it, so a project editor's picture lands; until 2026-10-09 the setter was owner-only and dropped an editor's picture behind a 200), the image must be the actor's own or the entry's current picture, and it returnsfalsewhen nothing landed so the endpoint refuses withimage_not_in_gallery; populatesgallery_image_entity_linkswithentity_type = 13(literal id reserved for lorebook entries; distinct from2 = top-level lorebook).Create/UpdateLorebookEntryRequestgainGuid? PictureImageUuid(three-state: null /Guid.Empty/ value).LorebookEntryItemgainsPictureImageUuid+ content rating + moderation status + resolved URL + content type.MapToLorebookEntryItemhelper centralizes mapping.- Creator UI:
<ImagePickerField>+<ImagePickerModal>integrated intoLorebookEntriesPanel's entry editor with apictureDirtyflag so untouched entries omit the field on save.
Notably not implemented (skipped vs original plan): no separate PUT/DELETE /entries/{entryId}/picture endpoints — picture changes flow through the entry create/update endpoints' pictureImageUuid field, mirroring the lorebook precedent. No change to fn_upsert_lorebook_entry SQL — the picture is set via a follow-up SetEntryPictureImageAsync call instead.
Phase 2a — Side A: Wire the existing "Picture entries" row — shipped
What landed:
Features.EnableLorebookImagesadded toSettingsKeys+ seeded astrueby default inSettingsDefaultswith label "Picture entries" + display order 4 (right after Lorebook).ConversationFeatureStateextended withLorebookImagesEnabled+ModeSupportsLorebookImages.WebChatFeatureStateServiceresolves the user toggle and mirrorsModeSupportsLorebookfor the mode capability check.ModeSupportsDtoandFeatureTogglesDtoboth gainLorebookImages.ConversationsEndpointsplumbs them through.- Frontend:
Features.EnableLorebookImagesconstant inclientConsole/src/constants/settingKeys.ts;ModeSupports.lorebookImages+FeatureToggles.lorebookImagesadded to chat types;effectiveConversationoverlay in HowDrawer extended with the new toggle so optimistic updates work.
Phase 2a was effectively bundled with 2b in the final shipping, so the "ship as coming-soon first" interim step was skipped — by the time the toggle plumbing was complete, the renderer was right behind it. The HowDrawer row went straight from coming-soon placeholder to fully interactive in Phase 2b.
Phase 2b — Side A: Chat UI display (single image) — shipped
What landed:
fn_search_lorebookandfn_expand_lorebook_entriesextended to return 9 picture columns (picture_image_id,picture_image_uuid,picture_content_rating,picture_moderation_status,resolved_picture_url, three bucket keys,picture_content_type) plus parent lorebook identity (lorebook_id,lorebook_uuid,lorebook_name). Thegallery_imagesjoin +lorebooksjoin sit afterLIMITin the final SELECT so they only fire for result rows. Three always-include inline queries inLorebookSearchRepositorygot the same shape.LorebookSearchResultgains 11 new fields (9 picture + lorebook id/uuid/name).MatchedEntryImagerecord carries the per-turn payload to the streaming layer.IPipelineContext.MatchedEntryImages: IReadOnlyList<MatchedEntryImage>?— defaults null;LorebookContentProviderpopulates it as a by-product of building lorebook content. Defensively drops under-review images at the source (defense in depth —ContentImagealso enforces).ChatPipeline.ExecuteStreamAsyncemitsPipelineToken.LorebookImagesToken(images)immediately afterStartand before the LLM call. Triple-gated: list non-empty +Features.EnableLorebookImageson +Features.EnableLorebookon.- SSE writer in
ConversationsEndpoints.MapPipelineTokenToEventforwards as{ type: "lorebook-images", images: [...] }over the existing single SSE channel. SSEStreamCallbacks.onLorebookImages?callback inprocessSSEStream.NewChatPageuses apendingImagesRefto bridge the gap between the pre-LLM event and the eventualdone/stoppedevent when the assistant message gets its id. Both send + regenerate flows wired.Message.triggeredEntryImages?: TriggeredEntryImage[]field added.- New
TriggeredEntryImagesPanelcomponent — renders only the top match (v1), inline placement under the assistant bubble, collapsed by default on touch / expanded by default on desktop, uses<ContentImage>for blur, tap →<ImageLightbox>(single-image, no nav), report button opens<ReportModal>against the image itself (GalleryImage, shipped 2026-09-05 — see below). - HowDrawer "Picture entries" row flipped from
coming-soonto interactive:lorebookImagesState()+lorebookImagesBody()withmode-locked → dependency-locked('Lorebook') → active/inactivecascade.
Notable scope decisions vs original plan:
- Side-rail layout deferred. Inline-only for v1; the desktop side-rail variant (when one drawer collapsed / focus mode) is a polish item that hasn't shipped. Inline works in all configurations.
- Discord transport not wired. SSE event is web-only; Discord's per-turn rendering would need its own adaptation.
GalleryImageReportEntityType — shipped 2026-09-05. Reports from the panel now file against the image itself (EntityType.GalleryImage= 17,entityId={imageUuid}); the parent lorebook rides the DTO as provenance only. The same affordance is the lightbox's flag button (ImageLightbox.onReport), mounted on the public gallery page and the entity Gallery strip too. Reachability rule and the admin wiring are recorded in gallery-entity-links § Report target.- No persistence of picture metadata on historical messages. Only freshly-streamed turns carry images; loading older messages from the server doesn't show pictures even if the entry triggered then. Deferred until needed.
Phase 3 — Side B: LLM vision injection — not started
- Add
Features.SendLorebookImagesToLlmtoSettingsKeys - Extend
ConversationFeatureStatewithSendLorebookImagesToLlmEnabled; gate on vision-capable model in the resolved state - Add a second HowDrawer row (separate from "Picture entries") wired to the new toggle, with copy that explicitly distinguishes it from Side A
- Introduce
PromptContentand migrateIPromptContentProvider LorebookContentProvideropts into multimodal output- System prompt builder + provider clients gain multimodal block emission (Anthropic / OpenAI / Google formats differ)
- Image cache layer
Result: Opt-in vision-aware lorebook recall. Does not depend on Phase 2 having shipped — Side A and Side B can ship in either order, though Phase 1 (the picture FK) is a prerequisite for both.
Phase 4 — Side A v2: Multi-image carousel — not started
- Extract
HeroBanner's rotation/dots/arrows into a reusable<ImageCarousel>primitive (or equivalent) inshared/src/components/common/ TriggeredEntryImagesPanelswitches from "render[0]" to rendering the full list through the carousel- No backend change — metadata already carries the full list
Result: All matched-with-image entries are reachable from a single panel via dots / arrows.
Files
Files to create
| File | Purpose |
|---|---|
database/v1/<next>_lorebook_entry_picture_image.sql |
Migration: add picture_image_id FK + index |
Files to modify
| File | Change |
|---|---|
database/v1/v1_run_all.sql |
Register new migration |
database/v1/functions/09_lorebook_migration_functions.sql |
fn_upsert_lorebook_entry accepts p_picture_image_id |
database/v1/views/04_lorebook_view.sql |
Surface picture_image_id + joined image fields |
database/v1/functions/15_search_lorebook.sql |
Return picture_image_id |
database/v1/functions/25_expand_lorebook_entry.sql |
Return picture_image_id |
server/EchoOfDreams.Database/Interfaces/ILorebookRepository.cs |
Entry image set/clear method |
server/EchoOfDreams.Database/Repositories/LorebookRepository.cs |
Implementation (mirror SetPictureImageAsync) |
server/EchoOfDreams.Core/Storage/Interfaces/ILorebookSearchRepository.cs |
Add PictureImageId / resolved URL |
server/EchoOfDreams.Database/Repositories/LorebookSearchRepository.cs |
Map new fields |
server/EchoOfDreams.ServerAPI/Api/Endpoints/CreatorLorebookEndpoints.cs |
Entry picture endpoints + upsert field |
server/EchoOfDreams.ServerAPI/Api/Models/CreatorModels.cs |
pictureImageUuid on entry DTOs |
server/EchoOfDreams.Core/Pipeline/ChatPipeline.cs |
New PipelineTokenType.LorebookImages + PipelineToken.LorebookImages(...) factory |
server/EchoOfDreams.Core/Pipeline/Stages/ContextBuildingStageBase.cs |
Stash matched-with-image list in IPipelineContext so the streaming loop can flush it pre-LLM |
server/EchoOfDreams.WebChat/... (SSE writer) |
Forward the new token as event: lorebook-images |
server/EchoOfDreams.DiscordChat/... |
Decide whether Discord renders inline images per-turn (likely v2+) or only respects the toggle |
clientConsole/src/... (chat SSE consumer) |
Handle the new event, populate the panel before Done |
server/EchoOfDreams.Core/Pipeline/Providers/LorebookContentProvider.cs |
Multimodal support (Phase 3) |
server/EchoOfDreams.Core/Settings/SettingsKeys.cs |
Features.EnableLorebookImages (Side A, Phase 2a), Features.SendLorebookImagesToLlm (Side B, Phase 3) |
server/EchoOfDreams.WebChat/Services/IWebChatFeatureStateService.cs + impl |
Side A: LorebookImagesEnabled + ModeSupportsLorebookImages. Side B: SendLorebookImagesToLlmEnabled + vision-capable check on ConversationFeatureState |
server/EchoOfDreams.ServerAPI/Api/Models/WebChatModels.cs |
Add LorebookImages (Side A) and SendLorebookImagesToLlm (Side B) to FeatureTogglesDto |
clientConsole/src/pages/chat-v2/components/HowDrawer.tsx |
Side A: wire existing "Picture entries" row (2a coming-soon → 2b interactive). Side B: add a separate row for vision injection (Phase 3) |
clientConsole/src/api/reports.ts |
'GalleryImage' in ReportEntityType + the reportEntityLabel copy map — shipped |
clientConsole/src/pages/chat/... |
New TriggeredEntryImagesPanel (inline + side-rail layouts) |
database/v1/functions/51c_content_report_functions.sql |
fn_resolve_reportable_entity arm 17 (gallery image) — shipped; reports.entity_type needed no schema change |
Notably no longer required: LorebookImageStorageService (use GalleryImageStorageService), bespoke image_url / image_source / image_bucket_key / image_alt_text columns, entry-specific upload endpoints.
Future Considerations
- Multiple images per entry — if a single image proves limiting (e.g. multiple expressions, multi-view locations), add a junction table; gallery rows themselves already support this without schema churn on
lorebook_entries. Once the shared<ImageCarousel>primitive exists for Phase 4, this becomes a small lift on top. - Image generation — auto-generate entry images from the entry's text content via image-gen APIs; the gallery system already accepts arbitrary uploads, so the integration point is "create gallery image, link to entry."
- Sprite/expression support — for character entries, multiple expressions selected by AI based on context. Better modeled as a sibling feature on character entries than as N images per generic entry.