fix(pitch-deck): Stale-Closure-Bug im Waiting-Indicator behoben
All checks were successful
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-consent (push) Successful in 27s
CI / test-python-voice (push) Successful in 30s
CI / test-bqas (push) Successful in 25s
All checks were successful
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-consent (push) Successful in 27s
CI / test-python-voice (push) Successful in 30s
CI / test-bqas (push) Successful in 25s
isWaiting im async Closure war immer true — lokale Variable firstChunk ersetzt den State-Check zuverlaessig. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -48,16 +48,16 @@ export default function ChatInterface({ lang }: ChatInterfaceProps) {
|
|||||||
const reader = res.body!.getReader()
|
const reader = res.body!.getReader()
|
||||||
const decoder = new TextDecoder()
|
const decoder = new TextDecoder()
|
||||||
let content = ''
|
let content = ''
|
||||||
|
let firstChunk = true
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
const { done, value } = await reader.read()
|
const { done, value } = await reader.read()
|
||||||
if (done) break
|
if (done) break
|
||||||
|
|
||||||
const chunk = decoder.decode(value, { stream: true })
|
content += decoder.decode(value, { stream: true })
|
||||||
content += chunk
|
|
||||||
|
|
||||||
if (isWaiting || content.length === chunk.length) {
|
if (firstChunk) {
|
||||||
// First chunk arrived — replace waiting indicator with real content
|
firstChunk = false
|
||||||
setIsWaiting(false)
|
setIsWaiting(false)
|
||||||
setMessages(prev => [...prev, { role: 'assistant', content }])
|
setMessages(prev => [...prev, { role: 'assistant', content }])
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user