Keep quiet lead signal turns off-screen until they show something

This commit is contained in:
Ian Gulliver
2026-10-16 23:17:44 -07:00
parent 35184dc081
commit 9a24e1c9b7
4 changed files with 24 additions and 12 deletions
+12 -6
View File
@@ -80,7 +80,7 @@ type Ctx = {
run: Run | undefined;
root: () => string;
taskId: string | undefined;
held: HTMLElement | undefined;
held: DocumentFragment | undefined;
open: boolean;
drawn: HTMLElement[] | undefined;
quiet: boolean;
@@ -297,7 +297,7 @@ export function mountChat(root: HTMLElement, src: ChatSource, makeHead: (rerende
transcript.classList.toggle("running", running);
scanner.hidden = !running;
};
const putBefore = (el: HTMLElement, anchor: HTMLElement | undefined) => {
const putBefore = (el: Node, anchor: HTMLElement | undefined) => {
if (sink) {
sink.append(el);
return;
@@ -310,11 +310,13 @@ export function mountChat(root: HTMLElement, src: ChatSource, makeHead: (rerende
};
const syncRunning = () => setRunning(src.session()?.state === "running" && ctx.open);
const release = () => {
if (!ctx.held) {
const buffered = ctx.held;
if (!buffered) {
return;
}
ctx.held = undefined;
ctx.open = true;
putBefore(buffered, pending[0]?.el);
syncRunning();
};
const put = (el: HTMLElement, keepHeld = false) => {
@@ -326,6 +328,10 @@ export function mountChat(root: HTMLElement, src: ChatSource, makeHead: (rerende
release();
}
ctx.drawn?.push(el);
if (ctx.held) {
ctx.held.append(el);
return;
}
putBefore(el, pending[0]?.el);
};
const fold = () => {
@@ -414,7 +420,7 @@ export function mountChat(root: HTMLElement, src: ChatSource, makeHead: (rerende
sub.run = extendRun(sub.run, el, call, parent, (e) => sub.body.append(e));
return;
}
ctx.run = extendRun(ctx.run, el, call, parent, put);
ctx.run = extendRun(ctx.run, el, call, parent, (e) => put(e, true));
};
const extendRun = (run: Run | undefined, el: HTMLElement, call: Call | undefined, parent: string, place: (el: HTMLElement) => void): Run => {
@@ -546,7 +552,7 @@ export function mountChat(root: HTMLElement, src: ChatSource, makeHead: (rerende
continue;
}
ctx.run = undefined;
put(el);
put(el, true);
continue;
}
if (ev.kind === "agent.tool_call") {
@@ -591,7 +597,7 @@ export function mountChat(root: HTMLElement, src: ChatSource, makeHead: (rerende
ctx.drawn = undefined;
}
if (ev.kind === "user.message" && ev.actor === "byre" && ev.owner && p["mid_turn"] !== true && p["handoff"] !== true) {
ctx.held = el;
ctx.held = document.createDocumentFragment();
ctx.open = false;
ctx.drawn = [];
continue;