◐ Shell
clean mode source ↗

fix: close stream after upstream ends to prevent client hang by octo-patch · Pull Request #186 · sqlchat/sqlchat

@octo-patch

…qlchat#176)

When an LLM provider (e.g. Ollama native API) does not send a [DONE]
sentinel at the end of the stream, the ReadableStream in the API handler
was never explicitly closed. This left the client's reader.read() loop
waiting indefinitely, causing the UI to appear stuck.

Two changes:
- chat.ts: call controller.close() after exhausting the upstream body,
  wrapped in try/catch to silently ignore the case where [DONE] already
  closed it. Also guard the text encoding so undefined delta content
  (the final finish_reason chunk) is not encoded.
- ConversationView: wrap the stream-reading loop in try/catch so that
  any stream error marks the message as FAILED instead of leaving it
  stuck in LOADING state.

Co-Authored-By: Octopus <liyuan851277048@icloud.com>