Show turn summaries only in the transcript, not as inbox reports

This commit is contained in:
Ian Gulliver
2026-10-15 20:01:53 -07:00
parent 4ea79a0c61
commit ccd55afe13
24 changed files with 269 additions and 385 deletions
+24 -16
View File
@@ -3,8 +3,6 @@ function wants(p, item) {
switch (item.kind) {
case "question":
return item.blocking ? p.blocking_questions : p.questions;
case "report":
return p.reports;
case "session_error":
return p.errors;
case "rate_limited":
@@ -13,25 +11,35 @@ function wants(p, item) {
}
function itemText(item) {
const p = item.payload;
const text = item.kind === "question" ? String(p["question"] ?? "")
: item.kind === "report" ? String(p["text"] ?? "")
: item.kind === "session_error" ? `Error: ${String(p["error"] ?? "")}`
: "Rate limited";
const line = text.trim().split("\n")[0] ?? "";
return line.length > 200 ? `${line.slice(0, 199)}…` : line;
return item.kind === "question" ? String(p["question"] ?? "")
: item.kind === "session_error" ? `Error: ${String(p["error"] ?? "")}`
: "Rate limited";
}
export function notifyInbox(item) {
if (!("Notification" in window) || Notification.permission !== "granted" || !state.me || !wants(state.me.notification_prefs, item)) {
return;
}
const title = findTask(item.task_id)?.title;
const n = new Notification(title ? `byre · ${title}` : "byre", { body: itemText(item), tag: item.id });
function show(taskId, tag, text) {
const line = text.trim().split("\n")[0] ?? "";
const title = findTask(taskId)?.title;
const n = new Notification(title ? `byre · ${title}` : "byre", { body: line.length > 200 ? `${line.slice(0, 199)}…` : line, tag });
n.onclick = () => {
window.focus();
if (item.task_id) {
focusTask(item.task_id);
if (taskId) {
focusTask(taskId);
}
n.close();
};
}
function allowed() {
return "Notification" in window && Notification.permission === "granted" && !!state.me;
}
export function notifyInbox(item) {
if (!allowed() || !wants(state.me.notification_prefs, item)) {
return;
}
show(item.task_id, item.id, itemText(item));
}
export function notifyTurn(ev) {
if (!allowed() || !state.me.notification_prefs.reports || ev.payload["summary"] !== true || !ev.task_id) {
return;
}
show(ev.task_id, `turn-${ev.seq}`, String(ev.payload["result"] ?? ""));
}
//# sourceMappingURL=notifications.js.map