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>
This commit is contained in:
WolfandClaude Fable 5.1 committed 2026-09-28 12:53:41 +02:00
1 parent 515d2250fc
commit a0772519b3
28 files changed
+1461 -668

No files matched your search

+12 -6
View File
@@ -17,6 +17,10 @@
* `count`, `cell`, `debounce`, and the company list with its affinity control
* (`loadCompanies`, `companies`, `affinityControl`, `setAffinity`). One copy
* each, since two copies of a helper is one of them being fixed.
*
* Affinity is per search agent. The three company helpers take the agent's
* id as an optional last argument and send it along; a caller that passes
* none gets the server's default agent, the enabled one with the lowest id.
*/
(function () {
@@ -106,8 +110,9 @@
Map, refilled in place, so a script holding it sees every reload. */
const companies = new Map();
async function loadCompanies() {
const rows = await api("/api/companies");
async function loadCompanies(agent) {
const query = agent == null ? "" : `?agent=${encodeURIComponent(agent)}`;
const rows = await api(`/api/companies${query}`);
companies.clear();
for (const c of rows) companies.set(c.key, c);
return companies;
@@ -127,7 +132,7 @@
/* `onChange` runs after the server accepted the change, so each page
decides what a change means for it: the role list refetches, since a
hidden company's roles come out of it, and the company list redraws. */
function affinityControl(companyKey, current, onChange) {
function affinityControl(companyKey, current, onChange, agent) {
const span = document.createElement("span");
span.className = "affinity";
span.setAttribute("role", "group");
@@ -142,18 +147,19 @@
button.setAttribute("aria-label", level.label);
button.setAttribute("aria-pressed", String(pressed));
button.addEventListener("click", () =>
setAffinity(companyKey, pressed ? 0 : level.value, onChange));
setAffinity(companyKey, pressed ? 0 : level.value, onChange, agent));
span.appendChild(button);
}
return span;
}
async function setAffinity(companyKey, affinity, onChange) {
async function setAffinity(companyKey, affinity, onChange, agent) {
if (!companyKey) return;
const body = agent == null ? { affinity } : { affinity, agent };
let updated;
try {
updated = await api(`/api/companies/${encodeURIComponent(companyKey)}/affinity`, {
method: "POST", body: { affinity },
method: "POST", body,
});
} catch (err) {
return;