SSE reconnect, task switcher state/inbox/new task, stream throttle
This commit is contained in:
Vendored
+6
-6
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user