From 5603d9a2f2707ee5f06be5a349cbe829b258cd2d Mon Sep 17 00:00:00 2001 From: weronikakolodziej Date: Wed, 8 Jul 2026 13:06:20 +0200 Subject: [PATCH] fixes --- sampleshr-frontend/src/api.ts | 3 ++- sampleshr-frontend/src/components/ChatInterface.tsx | 5 ++++- sampleshr-frontend/src/index.css | 5 +++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sampleshr-frontend/src/api.ts b/sampleshr-frontend/src/api.ts index 0bb7628..35b438e 100644 --- a/sampleshr-frontend/src/api.ts +++ b/sampleshr-frontend/src/api.ts @@ -110,7 +110,8 @@ export const hrApi = { reject(new Error(`HTTP ${response.status}`)); }, onmessage(ev: EventSourceMessage) { - if (ev.event === 'final') { + if (ev.event === 'final' || ev.event === 'error') { + ctrl.abort(); resolve(JSON.parse(ev.data)); } else { onChunk(ev.data); diff --git a/sampleshr-frontend/src/components/ChatInterface.tsx b/sampleshr-frontend/src/components/ChatInterface.tsx index 12964f3..b6f27d9 100644 --- a/sampleshr-frontend/src/components/ChatInterface.tsx +++ b/sampleshr-frontend/src/components/ChatInterface.tsx @@ -216,7 +216,10 @@ Hello, **${employee.name}**, how can I help you today?`, return await hrApi.chat( requestBody, (chunk: string) => { - botText += JSON.parse(chunk); + const parsed = JSON.parse(chunk); + botText = (parsed !== null && typeof parsed === 'object') + ? (parsed.answer ?? botText) + : botText + String(parsed); setMessages(prev => prev.map(m => m.id === botMessageId ? { ...m, text: botText } : m )); diff --git a/sampleshr-frontend/src/index.css b/sampleshr-frontend/src/index.css index 157dfbd..a950aad 100644 --- a/sampleshr-frontend/src/index.css +++ b/sampleshr-frontend/src/index.css @@ -8,8 +8,9 @@ body { margin: 0; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', - 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Segoe UI Emoji', 'Segoe UI Symbol', + 'Apple Color Emoji', 'Noto Color Emoji', + 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;