Keep chat answers through the markdown toggle and report chat_ready only when the engine can serve#533
Merged
Merged
Conversation
Toggling ctrl+r to plain text and back blanked every assistant answer. The rebuilt Markdown widget was filled via update() before mounting, and Textual's Markdown re-renders from its constructor argument on mount, which wiped the pre-mount update. Pass the accumulated text to the widget constructor instead so the mount lifecycle renders it.
RoutingProvider.role_ready returned True for native refs when no local engine had been built yet, so /api/health advertised chat_ready:true on a fresh serve before anything could produce a token; a client that gated on the flag then got a 503 from the backend on its first /api/chat. Readiness is now positive: a native ref with no engine reports False, which also routes the TUI's first prompt onto its designed warm-wait path and lets the CLI announce the cold start.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two readiness-and-rendering bugs observed live:
In the TUI, toggling chat rendering with ctrl+r from Markdown to plain text and back blanked every assistant answer. The rebuilt Markdown widget was filled via update() before being mounted, and Textual's Markdown re-renders from its constructor argument on mount, which wiped the pre-mount update and left an empty bubble.
On a fresh
lilbee serve, /api/health reported chat_ready:true before any engine existed. RoutingProvider.role_ready returned True for native refs when no local engine had been built yet, so a client that gated on the flag and then POSTed /api/chat got a 503 from the backend while llama-swap was still coming up.Solution
Pass the accumulated answer text to the content widget's constructor instead of updating it pre-mount, so the mount lifecycle renders it. A regression test covers the plain-to-markdown round trip, and streaming into a plain-text message is pinned as literal content.
role_ready is now positive readiness: a native ref with no local engine reports False instead of True. Health's chat_ready and chat_status become truthful during startup (loading, then ready), the RAG stream emits its warming notice when the engine is genuinely cold, the CLI announces cold starts, and the TUI's first prompt lands on its designed warm-wait path. Verified live: a fresh serve holds chat_ready:false while warming, and the first /api/chat sent the moment the flag flips returns a cited answer instead of 503.