ai: the Chat tab — SSE streaming chat with modes

The app's first streaming client: sse.js reads the /api/chat POST body
with fetch + a stream reader (apiCall's 60s JSON path cannot stream),
parsing SSE events with abort support.  AiChatContext holds the
conversation (browser-only, per design) so it survives visiting the
Manage tab; switching modes starts a fresh conversation.  The Chat tab
has the three-button mode picker, per-mode suggestion chips, streamed
answers with clickable relative WROLPi links, tool-activity indicators,
a slow-hardware banner, and a "not ready" state pointing at Manage.
ChatMessage states are in the theme-sample gallery.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Roland 2026-08-25 22:01:25 -06:00
parent 15552c2da7
commit a123794f19
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
6 changed files with 488 additions and 11 deletions

View file

@ -3,7 +3,9 @@ import {Route, Routes} from 'react-router';
import {getAiCatalog, postAiSettings, postDownload} from '../api';
import {getServiceStatus, startService, stopService} from '../api/controller';
import {AiChatProvider} from '../contexts/AiChatContext';
import {StatusContext} from '../contexts/contexts';
import {AiChat} from './AiChat';
import {APIButton, humanFileSize, InfoMessage, PageContainer, TabLinks, useTitle, WROLModeMessage} from './Common';
import {SortableTable} from './SortableTable';
import {Button, Divider, Group, Header, NumberInput, Select, Table, Text, Toggle, toast} from './ui';
@ -186,10 +188,6 @@ export function ManageAi() {
</>;
}
function ChatPlaceholder() {
return <Text>Chat is coming soon. Configure the assistant on the Manage tab.</Text>;
}
export function AiRoute() {
useTitle('AI');
@ -198,11 +196,14 @@ export function AiRoute() {
{text: 'Manage', to: '/ai/manage', key: 'manage'},
];
return <PageContainer>
<TabLinks links={links}/>
<Routes>
<Route path='/' exact element={<ChatPlaceholder/>}/>
<Route path='manage' exact element={<ManageAi/>}/>
</Routes>
</PageContainer>;
// The provider wraps both tabs so the conversation survives visiting Manage.
return <AiChatProvider>
<PageContainer>
<TabLinks links={links}/>
<Routes>
<Route path='/' exact element={<AiChat/>}/>
<Route path='manage' exact element={<ManageAi/>}/>
</Routes>
</PageContainer>
</AiChatProvider>;
}