Bouncy lead chat
This commit is contained in:
Vendored
+13
-3
@@ -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();
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+14
-3
@@ -74,6 +74,7 @@ type Ctx = {
|
||||
root: () => string;
|
||||
taskId: string | undefined;
|
||||
held: HTMLElement | undefined;
|
||||
open: boolean;
|
||||
drawn: HTMLElement[] | undefined;
|
||||
quiet: boolean;
|
||||
handoff: { summary: HTMLElement; body: HTMLElement } | undefined;
|
||||
@@ -217,6 +218,7 @@ export function mountChat(root: HTMLElement, src: ChatSource, makeHead: (rerende
|
||||
reviewButtons: new Map(),
|
||||
run: undefined,
|
||||
held: undefined,
|
||||
open: false,
|
||||
drawn: undefined,
|
||||
quiet: false,
|
||||
handoff: undefined,
|
||||
@@ -245,13 +247,14 @@ export function mountChat(root: HTMLElement, src: ChatSource, makeHead: (rerende
|
||||
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();
|
||||
@@ -273,6 +276,7 @@ export function mountChat(root: HTMLElement, src: ChatSource, makeHead: (rerende
|
||||
}
|
||||
ctx.drawn = undefined;
|
||||
ctx.held = undefined;
|
||||
ctx.open = false;
|
||||
ctx.quiet = false;
|
||||
syncRunning();
|
||||
};
|
||||
@@ -380,7 +384,7 @@ export function mountChat(root: HTMLElement, src: ChatSource, makeHead: (rerende
|
||||
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);
|
||||
}
|
||||
@@ -480,6 +484,9 @@ export function mountChat(root: HTMLElement, src: ChatSource, makeHead: (rerende
|
||||
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;
|
||||
@@ -499,12 +506,16 @@ export function mountChat(root: HTMLElement, src: ChatSource, makeHead: (rerende
|
||||
}
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user