fix(streaming): set streamActive only after successful Finalize

Move onFinalize hook to run after Streamer.Finalize succeeds, so that
if Finalize fails the streamActive flag stays false and the regular
placeholder fallback path remains available.

Addresses review feedback from @alexhoshina.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Amir Mamaghani 2026-03-20 13:50:08 +01:00
parent ac68b6d53c
commit aabe47ac39

View file

@ -269,8 +269,11 @@ type finalizeHookStreamer struct {
}
func (s *finalizeHookStreamer) Finalize(ctx context.Context, content string) error {
if err := s.Streamer.Finalize(ctx, content); err != nil {
return err
}
s.onFinalize()
return s.Streamer.Finalize(ctx, content)
return nil
}
// initChannel is a helper that looks up a factory by name and creates the channel.