let agent decide

This commit is contained in:
Ian Gulliver
2026-10-16 22:18:00 -07:00
parent 6cc71b859e
commit 7e0e6d9585
5 changed files with 22 additions and 23 deletions
+8 -10
View File
@@ -181,24 +181,22 @@ function card(item) {
};
return h("div", { class: "text-entry" }, block, editor);
};
const delegate = () => clickable(h("div", { class: "pick other", role: "button", tabIndex: 0 }, "Let the agent decide"), () => {
void submit({ item_id: item.id, type: "other", text: delegateText });
});
const delegate = () => {
const button = h("button", { type: "button", class: "delegate" }, "Let the agent decide");
button.onclick = () => void submit({ item_id: item.id, type: "other", text: delegateText });
return button;
};
const renderActions = () => {
switch (item.kind) {
case "question": {
const placeholder = "Your answer, a question back, or new instructions";
if (!multiple) {
replace(actions, delegate(), textEntry("Other…", placeholder));
return;
}
const send = h("button", { type: "button", class: "primary" }, "Submit");
const typed = () => (textAnswer(item.id) ?? "").trim();
const refresh = () => {
send.disabled = !typed() && checkedAnswer(item.id).length === 0;
send.disabled = !typed() && (!multiple || checkedAnswer(item.id).length === 0);
};
const go = () => {
const options = checkedAnswer(item.id);
const options = multiple ? checkedAnswer(item.id) : [];
if (options.length > 0) {
void submit({ item_id: item.id, type: "option", options, text: typed() ? textAnswer(item.id) : undefined });
return;
@@ -210,7 +208,7 @@ function card(item) {
const other = textEntry("Other…", placeholder, { onInput: refresh, onSubmit: go });
send.onclick = go;
refresh();
replace(actions, delegate(), other, h("div", { class: "submit-row" }, send));
replace(actions, other, h("div", { class: "submit-row" }, delegate(), send));
return;
}
default: {