pediatric-ai-scribe-v3/public/js/assistant
Daniel 2096057ebd perf: cache generated images for the session and decode thumbnails, not originals
Generated assets are served `private, no-store`, which is right for a clinical
app on a shared workstation — but it meant every gallery render re-downloaded
every image. Measured: 26 images averaging 279kB, so 7.2MB fetched to draw 56px
tiles, on every open of the Create image popup.

Two changes, both reusable anywhere in the app:

- A session cache holding decoded blobs in MEMORY ONLY, so nothing is written to
  disk and the no-store posture is unchanged. Entries are keyed by owner ticket
  as well as asset, and cleared when the account boundary moves, so one account
  can never read another's bytes out of memory. Concurrent tiles asking for the
  same asset share one request rather than racing.
- Any img carrying data-image-thumb gets a downscaled copy instead of the
  original, so a 56px tile no longer decodes a 300kB image. The gallery asks for
  256px and the in-chat preview for 640px; opening the full view still gets the
  original. Browsers without OffscreenCanvas, and any decode failure, fall back
  to the full image rather than showing nothing.

This does not reduce the first fetch. Serving genuinely smaller bytes needs
server-side resizing, which needs an image library this project does not carry —
worth a deliberate decision rather than adding a native dependency in passing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GmpYHPSLGmXGZMyLpn2Lbe
2026-09-10 05:20:10 +02:00
..
api.js feat: model selection in chat (composer pill + popup image model), deterministic image dispatch when the model writes text instead of calling the tool, markdown-rendered email, OWUI stacked composer, left mobile drawer, Go back in topbar, DeepL removed, image history inside the Create image popup 2026-09-09 02:55:28 +02:00
citations.js fix: translate as HTML so tables and emphasis survive; stop repeat image generation 2026-09-09 18:49:58 +02:00
data.js feat: diversify assistant starter prompts 2026-05-07 03:19:51 +02:00
export.js feat: Open WebUI presentation — unboxed assistant messages, hairline OWUI tables without card containers 2026-09-08 23:46:29 +02:00
images.js perf: cache generated images for the session and decode thumbnails, not originals 2026-09-10 05:20:10 +02:00
sharing.js fix: bind clinical image and export actions to their original account 2026-09-07 07:45:48 +02:00
sources.js refactor: retrieval is text-only; admins can add model ids discovery never returns 2026-09-09 23:35:06 +02:00