Files
jobboard/app/static/jobs.js
T
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

77 lines
2.6 KiB
JavaScript

/* The Runs section of Sources: Pull now on top, one button per remaining
* kind under "Run one stage".
*
* The list comes from `/api/jobs/kinds`, which is the registry, so a new
* `@job` in `app/jobs.py` is a new button and this file is not edited --
* except that `pull` itself is pulled out of the list and wired to the
* dedicated button instead of appearing twice. What the queue is doing is
* `<desk-jobs>`'s business, and it draws itself.
*
* Failures are the server's sentence through `api()`, which toasts it -- so
* there is no error handling here beyond keeping the button usable.
*/
(function () {
"use strict";
const host = document.getElementById("kinds");
const pullButton = document.getElementById("pull-now");
async function start(kind, button) {
button.disabled = true;
try {
const job = await window.api("/api/jobs", { method: "POST", body: { kind } });
window.toast.good(`${job.label || kind}: queued.`);
} catch (e) {
/* already toasted */
} finally {
button.disabled = false;
}
}
if (pullButton) {
pullButton.addEventListener("click", () => start("pull", pullButton));
}
async function draw() {
if (!host) return;
let kinds;
try {
kinds = await window.api("/api/jobs/kinds");
} catch (e) {
host.innerHTML = '<span class="muted">could not read the job kinds</span>';
return;
}
kinds = kinds.filter((k) => k.kind !== "pull");
if (!kinds.length) {
host.innerHTML = '<span class="muted">nothing is registered</span>';
return;
}
host.innerHTML = "";
kinds.forEach((k) => {
const button = document.createElement("button");
button.type = "button";
button.className = "secondary";
button.textContent = k.label || k.kind;
button.title = k.solo ? `${k.kind} -- one at a time` : k.kind;
button.dataset.kind = k.kind;
button.addEventListener("click", () => start(k.kind, button));
host.appendChild(button);
});
}
/* `<desk-jobs>` takes up no space while the queue is idle, so the line that
says so is the app's to show and hide. Off the same socket the element
reads, through live.js, rather than by asking the element: it keeps to a
shadow root and owes nobody an answer about its own height. */
document.addEventListener("app:jobs", (e) => {
const idle = document.getElementById("idle");
if (!idle) return;
const state = e.detail || {};
const busy = (state.running || []).length + (state.queued || []).length;
idle.hidden = busy > 0;
});
document.addEventListener("DOMContentLoaded", draw);
})();