SSE reconnect, task switcher state/inbox/new task, stream throttle

This commit is contained in:
Ian Gulliver
2026-10-14 22:28:25 -07:00
parent 8e4c40eb5f
commit 33e682a9d5
27 changed files with 418 additions and 182 deletions
+6 -6
View File
@@ -155,31 +155,31 @@ export function mountTranscript(root) {
if (!stream) {
return;
}
cancelAnimationFrame(stream.frame);
clearTimeout(stream.timer);
stream.el.remove();
stream = undefined;
};
const appendDelta = (ev) => {
if (!stream) {
stream = { el: h("div", { class: "msg agent" }), text: "", frame: 0 };
stream = { el: h("div", { class: "msg agent" }), text: "", timer: 0 };
ctx.run = undefined;
put(stream.el);
}
stream.text += String(ev.payload["text"] ?? "");
if (stream.frame) {
if (stream.timer) {
return;
}
stream.frame = requestAnimationFrame(() => {
stream.timer = setTimeout(() => {
if (!stream) {
return;
}
stream.frame = 0;
stream.timer = 0;
const pinned = transcript.scrollHeight - transcript.scrollTop - transcript.clientHeight < 80;
replace(stream.el, markdown(stream.text, "text md"));
if (pinned) {
transcript.scrollTop = transcript.scrollHeight;
}
});
}, 100);
};
const foldTurn = (start, end) => {
const summary = h("summary");