Bouncy lead chat

This commit is contained in:
Ian Gulliver
2026-10-15 20:41:42 -07:00
parent f84b1788ae
commit cb2188e3cf
4 changed files with 30 additions and 9 deletions
+13 -3
View File
@@ -148,6 +148,7 @@ export function mountChat(root, src, makeHead) {
reviewButtons: new Map(),
run: undefined,
held: undefined,
open: false,
drawn: undefined,
quiet: false,
handoff: undefined,
@@ -177,13 +178,14 @@ export function mountChat(root, src, makeHead) {
transcript.append(el);
}
};
const syncRunning = () => setRunning(src.session()?.state === "running" && !ctx.held);
const syncRunning = () => setRunning(src.session()?.state === "running" && ctx.open);
const release = () => {
const el = ctx.held;
if (!el) {
return;
}
ctx.held = undefined;
ctx.open = true;
ctx.drawn?.push(el);
putBefore(el, stream?.el ?? pending[0]?.el);
syncRunning();
@@ -205,6 +207,7 @@ export function mountChat(root, src, makeHead) {
}
ctx.drawn = undefined;
ctx.held = undefined;
ctx.open = false;
ctx.quiet = false;
syncRunning();
};
@@ -301,7 +304,7 @@ export function mountChat(root, src, makeHead) {
return;
}
if (!stream) {
stream = { el: h("div", { class: "msg agent" }), text: "", timer: 0 };
stream = { el: h("div", { class: "msg agent", hidden: true }), text: "", timer: 0 };
ctx.run = undefined;
put(stream.el, true);
}
@@ -400,6 +403,9 @@ export function mountChat(root, src, makeHead) {
continue;
}
ctx.run = undefined;
if (ev.kind === "turn.ended") {
ctx.open = false;
}
if (ev.kind === "turn.ended" && p["handoff"] === true && ctx.handoff) {
closeHandoff(el);
continue;
@@ -419,12 +425,16 @@ export function mountChat(root, src, makeHead) {
}
if (ev.kind === "user.message" && ev.actor === "byre" && ev.owner && p["mid_turn"] !== true && p["handoff"] !== true) {
ctx.held = el;
ctx.open = false;
ctx.drawn = [];
syncRunning();
continue;
}
if (ev.kind === "user.message" && p["mid_turn"] !== true) {
ctx.open = true;
}
put(el);
}
syncRunning();
if (contextChanged) {
renderHead();
const sess = src.session();
+1 -1
View File
File diff suppressed because one or more lines are too long