Files
WolfandClaude Fable 5.1 a0772519b3 Per-agent ranking: votes, affinity and a taste term; settings are three sub-tabs
Votes on roles and company affinity move to role_votes and agent_companies,
one row per search agent, so two agents rank the same roles differently. The
score gains taste, the cosine to mean(liked) - mean(passed) of the agent's
votes, as newsdesk ranks articles. The API takes agent on roles, votes and
companies and falls back to the default agent, the enabled one with the
lowest id.

Settings become Search agents (a list again, with New and Delete), Sources
(job boards, company boards and runs with the message log, one section per
plugin) and Account. Old paths answer 301 to their section.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-28 12:53:41 +02:00

86 lines
2.6 KiB
JavaScript

/* The message log at the end of Sources' Runs section.
*
* `/api/notices` is the queue's own route (`pipeline/web/jobs.py`) -- the log
* belongs to the queue, the wording belongs to the app, and this is only the
* reading of it. It redraws on `app:notice` so a failure that happens while
* you are looking at the page appears without a reload.
*/
(function () {
"use strict";
const host = document.getElementById("notices");
const clearAll = document.getElementById("clear-all");
if (!host) return;
const esc = window.esc;
function when(iso) {
if (!iso) return "";
const d = new Date(iso);
return isNaN(d) ? iso : d.toLocaleString();
}
function row(n) {
const count = n.count > 1 ? `<span class="badge">x${n.count}</span>` : "";
return `
<article class="notice ${esc(n.level)}" data-id="${n.id}">
<div class="notice-head">
<span class="notice-text">${esc(n.text)} ${count}</span>
<button type="button" class="secondary" data-clear="${n.id}">Clear</button>
</div>
<div class="small muted">${esc(n.code)}${n.key ? " / " + esc(n.key) : ""}
-- last said ${esc(when(n.last_at))}
${n.kind === "bug" ? "-- looks like a bug rather than a bad day" : ""}</div>
${n.fix ? `<div class="small">${esc(n.fix)}</div>` : ""}
${n.detail ? `<details class="small"><summary>details</summary>
<pre>${esc(n.detail)}</pre></details>` : ""}
</article>`;
}
async function draw() {
let list;
try {
list = await window.api("/api/notices");
} catch (e) {
host.innerHTML = '<span class="muted">could not read the log</span>';
return;
}
if (!list.length) {
host.innerHTML = '<span class="muted">Nothing to report.</span>';
return;
}
host.innerHTML = list.map(row).join("");
}
host.addEventListener("click", async (e) => {
const id = e.target.dataset && e.target.dataset.clear;
if (!id) return;
e.target.disabled = true;
try {
await window.api(`/api/notices/${id}`, { method: "DELETE" });
await draw();
} catch (err) {
e.target.disabled = false;
}
});
if (clearAll) {
clearAll.addEventListener("click", async () => {
clearAll.disabled = true;
try {
const out = await window.api("/api/notices", { method: "DELETE" });
window.toast.good(`Cleared ${out.cleared}.`);
await draw();
} catch (e) {
/* already toasted */
} finally {
clearAll.disabled = false;
}
});
}
document.addEventListener("app:notice", draw);
document.addEventListener("DOMContentLoaded", draw);
})();