feat(frontend): render Markdown answers and speak them while they stream
Two things made Jarvis feel worse than it was. Its Markdown arrived as raw syntax, because egui has no Markdown widget and the bundled fonts have a single weight per family; the renderer therefore builds its own styled LayoutJob, which keeps the bubble sizing already in place and tolerates a half-streamed answer instead of printing markers. And the voice only started once the whole answer was generated, so a long reply was read out after a silence as long as the reply itself; the stream is now cut into sentences as soon as their punctuation arrives, and the spoken text drops the Markdown and the code blocks, since nobody wants asterisks and backticks read aloud. The client also wakes the model on the first keystroke of a draft or when recording starts, so the load happens while the sentence is still being written, and it now sends a history the backend accepts: empty assistant bubbles left by an abandoned answer are dropped, and only the last fifty messages travel, which a long conversation used to overflow.
This commit is contained in:
13 files changed
+1182
-37
No files matched your search
@@ -508,6 +508,25 @@ async fn fails_when_no_token_is_set() {
|
||||
assert!(server.requests().is_empty());
|
||||
}
|
||||
|
||||
/// Warm-up: the client asks for the model to be loaded before the question that
|
||||
/// needs it, so the several-second load happens while the user is still typing.
|
||||
#[tokio::test]
|
||||
async fn warms_the_model_before_the_question() {
|
||||
let server = start_server(|_| FakeReply::json(r#"{"model":"qwen2.5:3b","warmed":true}"#));
|
||||
|
||||
server
|
||||
.client()
|
||||
.warm_model("qwen2.5:3b")
|
||||
.await
|
||||
.expect("the warm-up should be accepted");
|
||||
|
||||
let requests = server.requests();
|
||||
assert_eq!(requests.len(), 1);
|
||||
assert_eq!(requests[0].method, "POST");
|
||||
assert_eq!(requests[0].target, "/api/chat/warm");
|
||||
assert_eq!(body_json(&requests[0])["model"], "qwen2.5:3b");
|
||||
}
|
||||
|
||||
/// Guards the `StoredMessage` -> `ChatMessage` conversion used by the sidebar.
|
||||
#[test]
|
||||
fn converts_a_stored_message_into_a_chat_message() {
|
||||
|
||||
Reference in new issue
Block a user