AI Chat: streaming, file attachments, model switcher, migration fix#150
Draft
AI Chat: streaming, file attachments, model switcher, migration fix#150
Conversation
…ons and chat Agent-Logs-Url: https://github.com/thinkdj/ottabase/sessions/cffd2878-8cbd-4e2f-b3a1-465a83a14f17 Co-authored-by: thinkdj <688055+thinkdj@users.noreply.github.com>
…ation Agent-Logs-Url: https://github.com/thinkdj/ottabase/sessions/cffd2878-8cbd-4e2f-b3a1-465a83a14f17 Co-authored-by: thinkdj <688055+thinkdj@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Implement AI chat interface for admin and demo page
feat: AI chat interface with conversation history, admin settings, and OttaORM persistence
Mar 29, 2026
Co-authored-by: thinkdj <688055+thinkdj@users.noreply.github.com>
Copilot
AI
changed the title
feat: AI chat interface with conversation history, admin settings, and OttaORM persistence
Merge latest Mar 30, 2026
origin/main into copilot/add-ai-chat-ui
…n registration - Fix AI tables (ai_conversations, ai_messages) missing from schemas-helper autoInit - Add POST /api/ai/chat/stream endpoint with SSE streaming for Workers AI - Add attachments column to ai_messages schema for multimodal file uploads - Add file attachment UI (upload via /api/upload, preview in chat) - Add model quick-switcher dropdown in chat header - Add streaming response rendering with token-by-token display - Update tests for new schema columns and migration registration Agent-Logs-Url: https://github.com/thinkdj/ottabase/sessions/abbda454-d313-4dce-8a97-2ddf57f2b60b
Copilot
AI
changed the title
Merge latest
AI Chat: streaming, file attachments, model switcher, migration fix
Mar 30, 2026
origin/main into copilot/add-ai-chat-ui
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AI chat was missing streaming support, file attachments, and the AI tables (
ai_conversations,ai_messages) were not registered inschemas-helper.ts— meaningautoInitwould never create them.Migration fix (bug)
aiConversationsTableandaiMessagesTablewere missing fromgetAllSchemas()inschemas-helper.ts. Models were registered indb-utils.tsand exported fromschema.ts, butautoInitusesschemas-helper.ts— so the tables were silently skipped duringPOST /api/ottaorm/init.Streaming responses
New
POST /api/ai/chat/streamendpoint. Workers AI uses real SSE viatextGenerationStream(); other providers (OpenAI/Anthropic via AI Gateway) fall back to non-streaming with an SSE wrapper. The assistant message is saved after the stream completes.Frontend reads the stream token-by-token with a
ReadableStreamreader, rendering incrementally with a cursor indicator. OldPOST /api/ai/chatstill works as fallback.File attachments
Added
attachmentscolumn toai_messages(nullable JSON string:Array<{ url, name, type, size? }>). Both streaming and non-streaming endpoints accept attachments. Frontend uploads via existing/api/upload, shows pending previews, and renders images inline / files as links in message bubbles.Model quick-switcher
Model list endpoint and settings panel already existed. Added a compact model dropdown directly in the chat header so users can switch without opening settings.
Files changed
ottabase/db/schemas-helper.ts— register AI tables for autoInitottabase/models/AiMessage.schema.ts— addattachmentscolumnottabase/models/AiMessage.ts— addattachmentsto writable/fieldsworker/routes/ai-chat.ts— addhandleAiChatStream, accept attachmentsworker/routes/router.ts— register/api/ai/chat/streamsrc/pages/ai/AiChatPage.tsx— streaming UI, attachment upload/preview, model switchersrc/__tests__/ai-chat.test.ts— tests for new schema columns, stream export, migration registration📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.