Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions crates/daemon/assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2888,10 +2888,25 @@
}

function appendMessage(role, text) {
const normalizedRole = role || "assistant";
if (normalizedRole === "assistant") {
const last = transcriptEl.lastElementChild;
if (
last &&
last.classList.contains("row") &&
last.dataset.kind === "message" &&
last.dataset.role === normalizedRole
) {
last.querySelector(".bubble").textContent += text;
return;
}
}
const row = document.createElement("div");
row.className = `row role-${escape(role)}`;
row.className = `row role-${escape(normalizedRole)}`;
row.dataset.kind = "message";
row.dataset.role = normalizedRole;
row.innerHTML = `
<div class="meta">${escape(role)}</div>
<div class="meta">${escape(normalizedRole)}</div>
<div class="bubble"></div>`;
row.querySelector(".bubble").textContent = text;
transcriptEl.appendChild(row);
Expand Down
50 changes: 50 additions & 0 deletions crates/e2e/tests/web_smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,56 @@ async fn web_client_loads_and_websocket_connects() {
"expected editor_state mirror content, got:\n{editor_text}"
);

// Headless zarvis streams assistant prose as many Message deltas.
// Chat-mode rendering should aggregate adjacent assistant deltas
// into one bubble, while a structured event boundary starts a new
// assistant bubble for later prose.
let chat_deltas: serde_json::Value = page
.evaluate(
r#"
(() => {
state.mode = 'chat';
state.currentId = 's-chat-deltas';
transcriptEl.innerHTML = '';
renderEvent({ type: 'message', role: 'assistant', text: 'Hel' });
renderEvent({ type: 'message', role: 'assistant', text: 'lo ' });
renderEvent({ type: 'message', role: 'assistant', text: 'there' });
renderEvent({ type: 'tool_use', tool: 'shell', args: { command: 'true' } });
renderEvent({ type: 'message', role: 'assistant', text: 'Done' });
renderEvent({ type: 'message', role: 'assistant', text: '.' });
return Array.from(transcriptEl.children).map((row) => ({
kind: row.dataset.kind || '',
role: row.dataset.role || '',
text: row.textContent.trim(),
}));
})()
"#,
)
.await
.expect("evaluate chat delta aggregation")
.into_value::<serde_json::Value>()
.expect("json array");
let chat_rows = chat_deltas.as_array().cloned().unwrap_or_default();
assert_eq!(
chat_rows.len(),
3,
"expected assistant deltas to coalesce around tool boundary: {chat_deltas:?}"
);
assert_eq!(chat_rows[0]["kind"].as_str(), Some("message"));
assert_eq!(chat_rows[0]["role"].as_str(), Some("assistant"));
assert!(
chat_rows[0]["text"]
.as_str()
.unwrap_or_default()
.contains("Hello there"),
"first assistant bubble should contain concatenated deltas: {chat_deltas:?}"
);
let second_assistant = chat_rows[2]["text"].as_str().unwrap_or_default();
assert!(
second_assistant.contains("Done."),
"second assistant bubble should aggregate after boundary: {chat_deltas:?}"
);

// Tool-call rendering in terminal mode (issue #134): zarvis emits
// tool calls as structured events, not PTY bytes, so the xterm view
// showed nothing for them. `renderEvent` now synthesizes an inline
Expand Down
Loading