feat(chat): Add rich text formatting support and update TypeScript types for chat messages and TextInput component

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
Claude Code 2026-04-04 03:53:39 -07:00
parent 9ab8f2522a
commit 6d05bc35ea
2 changed files with 11 additions and 3 deletions

View file

@ -127,13 +127,13 @@ export function TextInput({
}
onTranscript(text);
await onWillSend?.();
abortRef.current?.abort();
const controller = new AbortController();
abortRef.current = controller;
try {
await onWillSend?.();
const response = await chatWithRecovery(apiBaseUrl, sessionId, text, controller.signal);
if (!response.ok) {
@ -228,9 +228,13 @@ async function parseSSEStream(
} else if (line === '') {
if (eventData && eventData !== '[DONE]') {
try {
const parsed = JSON.parse(eventData) as SegmentEvent & { type?: string };
const parsed = JSON.parse(eventData) as SegmentEvent & { type?: string; message?: string };
if (eventType === 'segment' || parsed.type === 'segment') {
onSegment(parsed);
} else if (parsed.type === 'error') {
onError(parsed.message ?? 'Response error');
void reader.cancel();
return;
}
consecutiveParseErrors = 0;
} catch {

View file

@ -111,7 +111,11 @@ export function chatReducer(state: ChatState, action: ChatAction): ChatState {
}
case 'CLEAR_ACTIVE_ASSISTANT': {
return { ...state, activeAssistantId: null };
// Remove the assistant message if it received no segments (empty bubble would show typing indicator forever)
const messages = state.activeAssistantId
? state.messages.filter((m) => !(m.id === state.activeAssistantId && m.parts.length === 0))
: state.messages;
return { ...state, messages, activeAssistantId: null };
}
case 'LOAD_HISTORY': {