let agent decide
This commit is contained in:
Vendored
+8
-10
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user