Root causes:
1. Auto-reset calls store.clearMessages(), wiping messages from
localStorage. Any subsequent loadConversation() (sidebar click,
new chat then back) read from the now-empty store, losing the
video.
2. Large video base64 dataUrls can exceed localStorage quota; the
message is never persisted, so it vanishes on any reload.
Fix: add this._sessionMessages (Map<convId, messages[]>) as an
in-memory cache for the current page session.
- Every user/assistant message is pushed to _sessionMessages in
addition to (or instead of, when quota fails) localStorage.
- _selectConversation and _loadCurrentConversation use
_sessionConvFor(conv) which substitutes the in-memory messages
when available, so media dataUrls survive auto-resets and quota
failures for the lifetime of the page.
- Auto-reset (store.clearMessages) does NOT clear _sessionMessages —
it only resets the API context, not the visual history.
- /clean explicitly calls _clearSessionMsgs so the user's manua…
Bug: showError() appended the error element to #chat-messages with no
reference, so it was never removed. A successful subsequent send left
the old error visible at the top of the conversation.
Fix:
- Track the error element as this._errorEl in Chat
- Add clearError() to remove it; call it at the start of each new
send in app.js (right before the user bubble is rendered)
- Also clear _errorEl in clear() to avoid stale refs after /clean
Styling: the previous error used dark-mode-only Tailwind classes
(bg-red-950/40, text-red-400) which produced a muted brownish
background with near-invisible text in light mode. Replaced with
proper dark:-prefixed variants:
light: bg-red-50 / border-red-200 / text-red-700
dark: bg-red-950/40 / border-red-900/40 / text-red-400
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
marked v12 uses the legacy renderer function signature:
code(code, lang, escaped) — three string/bool args
codespan(code) — one string arg
The previous code treated the first argument as a token object and
accessed .text / .lang properties, which are undefined on a string,
causing both inline code and fenced code blocks to render as empty
elements (visible capsule/box with no text content).
Fixed both renderers to use the correct positional arguments.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
feat: keep bouncing dots until first streaming chunk arrives
Previously startAssistantMessage() was called immediately before the
stream loop, replacing the typing indicator with an empty bubble at
once. Now it is called lazily on the first actual chunk, so the three
bouncing dots remain visible for the full backend think/TTFB period.
If the stream completes with zero chunks (empty response), the
assistant bubble is still started so finalizeAssistantMessage has a
valid element to work with.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
fix: silent failure when sending image after video
- formatMessagesForApi: strip video_url dataUrls from historical
messages (all but the latest user message), replacing them with
'[Video attachment]' text. Prevents oversized API payloads and
invalid content types reaching the backend.
- app.js: build apiMessages from preConv.messages + userMessage
directly (captured before the store write) instead of re-reading
from localStorage. The current message is always included even if
the localStorage save failed due to quota limits.
- app.js: wrap store.addMessage + appendUserMessage in try/catch so
any remaining failure is shown as a visible error instead of a
silent no-op (input cleared, no output).
- store.js: catch QuotaExceededError in save() to prevent an
unhandled exception when large video dataUrls fill localStorage.
- chat.js: fix video.map(() => videos[0]) bug — use the loop
variable (vid) instead of always referencing the first element.
All 103 tests pass.
Co-authored-by: Copilot <223556219+Copilot@users.n…