Make Company and Place chip inputs, add Seniority levels and Pay counts to the rail, and keep every filter on a company click

Company and Place are chipInputs on the suggest routes, their chips sent as company_keys and places and read back from the address, place tokens named through /api/places/labels. The old ?company= and ?place= show as a plain chip to take off. Seniority is a row of level chips with "and roles with no level", Pay keeps its select with "and roles that state no pay", each with its count from /api/roles/facets, asked after every reload. Feed rows show the seniority badge. More filters opens by default beside the feed and stays shut on a phone.

A company's name now links to the list on screen with that company as its one chip. The strip's sentence says what ★ does, or did. setAffinity passes the route's answer to onChange, so the strip waits on its score_job. The rail's tag chips get their pill border back, which the quiet rail button rule had taken.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-29 22:29:23 +02:00
1 parent fd89381caa
commit ae7c0eeb0e
4 files changed
+359 -77

No files matched your search

+20 -3
View File
@@ -531,13 +531,18 @@ body[data-reader="open"][data-rail="shut"] .shell {
/* Tags are chips, not rows: they're multi-select, and seeing them wrap into a
block makes the "pick two" affordance obvious. */
#tags { display: flex; flex-wrap: wrap; gap: .25rem; padding: 0 .3rem; }
.tag, #rail .tag {
/* `button...:not(.linky)` to outweigh the rail's quiet button above, which
would square the chips and take their border. */
.tag, #rail button.tag:not(.linky) {
font: inherit; cursor: pointer;
color: var(--dim); background: none;
border: 1px solid var(--line); border-radius: 999px;
padding: .14rem .6rem; font-size: .82rem;
}
.tag[aria-pressed="true"], #rail .tag[aria-pressed="true"] {
@media (hover: hover) {
#rail button.tag:not(.linky):hover { color: var(--fg); background: var(--panel); }
}
.tag[aria-pressed="true"], #rail button.tag[aria-pressed="true"]:not(.linky) {
color: var(--panel); background: var(--accent); border-color: var(--accent);
}
#rail .tag[aria-pressed="true"] .count { color: var(--accent-weak); }
@@ -639,6 +644,18 @@ kbd {
.rail-fields { display: flex; flex-direction: column; gap: .45rem; padding-top: .6rem; }
.rail-fields input[type="text"], .rail-fields select { width: auto; }
.rail-fields .check { padding: 0 .3rem; white-space: normal; }
/* A filter and what widens it: Seniority's heading, its levels and "no
level"; Pay's select and "no pay". Closer together than the fields. */
.rail-facet { display: flex; flex-direction: column; gap: .3rem; }
.rail-fields .rail-field { margin: .25rem .3rem 0; }
.rail-facet .check { font-size: .84rem; }
/* The levels are the tags' chips, and wrap as they do. */
#f-seniority:not(:empty) { display: flex; flex-wrap: wrap; gap: .25rem; padding: 0 .3rem; }
/* `?company=` and `?place=` from another page's link: a plain chip under
its field, which takes it off. */
.rail-legacy { padding: 0 .3rem; }
.rail-legacy .tag { max-width: 100%; overflow-wrap: anywhere; text-align: left; }
.rail-legacy .chip-x { margin-left: .35rem; color: var(--faint); }
/* -- the feed -- */
@@ -1030,7 +1047,7 @@ table.applications td[data-label="Saved"] { white-space: nowrap; color: var(--di
#rail-toggle { min-height: 2.75rem; }
.actions button { padding: .5rem .7rem; font-size: 1.15rem; }
#rail .rail-row { align-items: center; min-height: 2.75rem; }
#rail .tag { padding: .45rem .8rem; }
#rail button.tag:not(.linky) { padding: .45rem .8rem; }
#rail .seg button { min-height: 2.75rem; }
.rail-select, .rail-fields input[type="text"], .rail-fields select,
#rail select.agent-pick { min-height: 2.75rem; }
+4 -2
View File
@@ -143,7 +143,9 @@
/* `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. */
hidden company's roles come out of it, and the company list redraws.
It is given the route's answer, the company with `score_job`, the id
of the `score` that carries the change, for a page that waits on it. */
function affinityControl(companyKey, current, onChange, agent) {
const span = document.createElement("span");
span.className = "affinity";
@@ -178,7 +180,7 @@
}
const company = companies.get(companyKey);
if (company) company.affinity = updated.affinity;
if (onChange) await onChange();
if (onChange) await onChange(updated);
}
Object.assign(window, {
+300 -64
View File
@@ -37,9 +37,10 @@
*
* The filters are in the query string, so a reload or a link keeps them, and
* each one set is a history entry, so back takes it off again: a tag, the
* period, Show read, a select, a checkbox, Clear, and a company. Text is the
* exception: the search box and the typed fields replace the entry, or back
* would step through a search a letter at a time. Who is viewing and the
* period, Show read, a select, a checkbox, a seniority level, a company or
* place chip picked or removed, Clear, and a company's name. Text is the
* exception: the search box replaces the entry, or back would step through a
* search a letter at a time. Who is viewing and the
* order are not filters and replace too; back and forward leave both as
* they are and write them into the entry they land on. `popstate` reads the
* address into the filter and reloads the feed, pushing nothing.
@@ -57,12 +58,20 @@
* reads as the link it is. Nothing to change (Clear with nothing set) just
* closes the reader, as Escape would.
*
* A company's name, in a row and in the reader, is a link to that company's
* roles (`?company_keys=`), keeping the agent and the order; a plain click
* filters in place and pushes. With one company filtered a strip over the
* feed names it, counts its roles, links its careers page and carries its
* ★ ▲ ⊘ for the viewing agent. `?company=`, `?company_keys=` and `?agent=`
* are how the Companies and Search agents pages link in.
* A company's name, in a row and in the reader, is a link to the list on
* screen with that company as its one company chip (`?company_keys=`); a
* plain click filters in place and pushes. With one company filtered a strip
* over the feed names it, counts its roles, links its careers page and
* carries its ★ ▲ ⊘ for the viewing agent. `?company=`, `?company_keys=` and
* `?agent=` are how the Companies and Search agents pages link in.
*
* Company and Place in the rail are chip inputs (chips.js) on the suggest
* routes: a chip is a company key or a place token (`country:DK`,
* `region:skane`), several joined by OR. `?company=` and `?place=`, the
* substrings of the links from other pages, still filter and show as a chip
* of their own to take off; nothing in the rail types a new one. Seniority
* and Pay carry the counts of `/api/roles/facets`, asked after each reload
* with the feed's own parameters, so each says what a click would add.
*
* The list is paged: 60 rows, then 60 more each time the end of the list comes
* within 600px of the screen, with the offset the rows already shown. Back to
@@ -73,7 +82,7 @@
"use strict";
const { api, esc, debounce, safeUrl, companies, loadCompanies, affinityControl, judgeButtons,
loadTracked } = window;
loadTracked, chipInput } = window;
const $ = (sel, root = document) => root.querySelector(sel);
// Below this the rail is over the feed rather than beside it, and the reader
@@ -104,16 +113,37 @@
month: { label: "This month", days: 30 },
};
// The place suggestion's kind, as its hint says it: a `place:` token is a
// town (`places.suggest`).
const PLACE_KINDS = { country: "country", region: "region", place: "town" };
// Everything `clearFilters` has to put back, in one place, so a new filter
// added here cannot be forgotten there.
// added here cannot be forgotten there. `company` and `place` are the
// substrings of links from other pages; `companyKeys` and `places` are the
// rail's chips. `seniorityUnknown` and `payUnknown` are the "and roles
// with no level / no pay" boxes, asked only while a level or a pay option
// is picked.
function blankFilter() {
return {
sort: "score", agent: null, period: "all", tags: new Set(), showRead: true,
company: "", place: "", function: "", remote: "", judged: "", pay: "",
showMuted: false, gated: false, companyKeys: [],
showMuted: false, gated: false, companyKeys: [], places: [],
seniority: [], seniorityUnknown: true, payUnknown: false,
};
}
/** How many filters are on, for the burger; `more` counts only the ones
under "More filters", for its summary. A chip or a level is one each,
as a tag is; the "no level" and "no pay" boxes widen a filter already
counted. */
function filtersOn(f = state.filter, { more = false } = {}) {
const folded = [f.company.trim(), f.place.trim(), f.function, f.remote, f.pay, f.judged,
f.showMuted, sortShown() === "score" && f.gated].filter(Boolean).length
+ f.companyKeys.length + f.places.length + f.seniority.length;
if (more) return folded;
return folded + [!f.showRead, f.period !== "all"].filter(Boolean).length + f.tags.size;
}
const state = {
filter: blankFilter(),
q: "",
@@ -132,8 +162,18 @@
summarising: null, // the uid whose summary is being waited for
listY: 0, // where the page was scrolled when the reader replaced the feed
feedError: false, // the feed's own fetch failed; the empty state offers a retry
facets: null, // {seniority, pay} counts from /api/roles/facets for this filter
};
// The chips' text, by company key and by place token: what a pick said,
// or what the server named a token read from the address. Kept for the
// page's life, so back to an earlier filter finds its chips' names.
const companyNames = new Map();
const placeLabels = new Map();
// The rail's two chip inputs, made in `wire`.
let companyChips = null;
let placeChips = null;
function ago(iso) {
const mins = (Date.now() - new Date(iso)) / 60000;
if (!Number.isFinite(mins)) return "";
@@ -161,6 +201,11 @@
if (!f.showRead) p.set("include_read", "false");
f.tags.forEach((t) => p.append("tags", t));
f.companyKeys.forEach((key) => p.append("company_keys", key));
f.places.forEach((token) => p.append("places", token));
f.seniority.forEach((level) => p.append("seniority", level));
// Each box is sent only off its default, and only while its filter is on.
if (f.seniority.length && !f.seniorityUnknown) p.set("seniority_unknown", "false");
if (f.pay && f.payUnknown) p.set("pay_unknown", "true");
if (f.agent !== null) {
p.set("agent", String(f.agent));
p.set("order", sortShown() === "score" ? "score" : "newest");
@@ -190,14 +235,48 @@
f.gated = q.get("gated") === "true" || q.get("gated") === "1";
f.tags = new Set(q.getAll("tags"));
f.companyKeys = [...new Set(q.getAll("company_keys").filter(Boolean))];
f.places = [...new Set(q.getAll("places").filter(Boolean))];
f.seniority = [...new Set(q.getAll("seniority").filter(Boolean))];
f.seniorityUnknown = q.get("seniority_unknown") !== "false";
f.payUnknown = q.get("pay_unknown") === "true";
if (!view) return;
if (q.get("sort") === "time") f.sort = "time";
// Checked against the enabled agents once they are in (`chooseAgent`).
if (q.get("agent")) f.agent = Number(q.get("agent"));
if (f.company || f.place || f.function || f.remote || f.judged || f.pay
|| f.showMuted || f.gated) {
$("#f-more").open = true;
// Open where the rail is a column of its own, which scrolls; shut where
// it is an overlay, unless a filter in it is on, which it then shows.
if (!narrow.matches || filtersOn(f, { more: true })) $("#f-more").open = true;
}
/* The chip text of place tokens read from the address, which carries only
the token. A token the server does not know is dropped from the filter
and the address, rather than sent to /api/roles for a 422. Nothing is
asked when every token already has its text. */
async function labelPlaces() {
const missing = state.filter.places.filter((t) => !placeLabels.has(t));
if (!missing.length) return;
const p = new URLSearchParams();
missing.forEach((t) => p.append("tokens", t));
let found;
try {
found = await api(`/api/places/labels?${p}`);
} catch (err) {
return; // toasted; the chips show the tokens themselves
}
for (const { token, label } of found) placeLabels.set(token, label);
const kept = state.filter.places.filter((t) => placeLabels.has(t) || !missing.includes(t));
if (kept.length !== state.filter.places.length) {
state.filter.places = kept;
writeUrl();
}
renderRail();
}
/** A company chip's text: what was picked, else the company list's name,
else a row's, else the key, until one of those has come in. */
function companyLabel(key) {
return companyNames.get(key) || companies.get(key)?.name
|| state.items.find((r) => r.company_key === key)?.company || key;
}
const here = () => location.pathname + location.search;
@@ -252,6 +331,9 @@
$("#search").value = state.q;
writeUrl();
route();
// An entry this page pushed holds only tokens it had names for, unless
// the page was reloaded since; then the names are asked again.
labelPlaces();
if (addressFor(pathFor(null)) === before) return;
reload();
if (state.filter.showMuted !== muted) loadFilters().catch(() => {});
@@ -302,6 +384,10 @@
state.selected = at >= 0 ? at : append ? state.selected : 0;
renderFeed();
renderStats();
// A company chip read from the address may only now have a name, off
// its rows; and a new list has new counts under the rail's filters.
renderChips();
if (!append) loadFacets().catch(() => {});
// Still within reach of the end after a short page: the observer only
// fires on a change, and nothing changed, so ask again here.
requestAnimationFrame(() => {
@@ -380,6 +466,18 @@
renderRail();
}
// How many roles each seniority level and each pay state would bring,
// under every other filter on screen (`Store.role_facets`). Asked after
// each reload with the feed's parameters, the newest answer only.
let facetsRequest = 0;
async function loadFacets() {
const request = ++facetsRequest;
const data = await api(`/api/roles/facets?${feedParams()}`);
if (request !== facetsRequest) return;
state.facets = data;
renderFacets();
}
// ------------------------------------------------------------ the rail
/* A filter is a question about the feed, and the role open over the old
@@ -405,6 +503,9 @@
function clearFilters() {
const kept = { agent: state.filter.agent, sort: state.filter.sort };
state.filter = Object.assign(blankFilter(), kept);
// Text half typed into a chip field goes too, and with it its list.
companyChips?.clear();
placeChips?.clear();
setFilter({}, { counts: true });
}
@@ -428,16 +529,14 @@
setFilter({}, { replace: true });
}
/** Where a company's name links: its roles, as the agent viewing them, in
the order on screen. A company this agent hid keeps Show hidden
companies, or its own name would lead to an empty list. */
/** Where a company's name links: the list on screen, every filter and the
search kept, with this company as its one company filter, in place of
any company chips and of `?company=`. A company this agent hid turns
on Show hidden companies, or its own name would lead to an empty list. */
function companyHref(key) {
const p = new URLSearchParams();
p.append("company_keys", key);
if (companies.get(key)?.affinity === -1) p.set("show_muted", "true");
const now = new URLSearchParams(location.search);
for (const name of ["agent", "sort"]) if (now.get(name)) p.set(name, now.get(name));
return `${pathFor(null)}?${p}`;
const f = Object.assign({}, state.filter, { companyKeys: [key], company: "" });
if (companies.get(key)?.affinity === -1) f.showMuted = true;
return addressFor(pathFor(null), f);
}
/** A company's name, as a link to its roles when it has a key. */
@@ -450,12 +549,17 @@
/* A plain click lists the company's roles in place, the list its link
leads to, and pushes, so back is the list it left; a modified or middle
click is the browser's, and opens the link. */
click is the browser's, and opens the link. The link is written again
first: a row drawn before the last change of filter holds the address
of the list it was drawn in. */
function companyClick(e) {
if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0) return;
e.preventDefault();
const link = e.currentTarget;
link.href = companyHref(link.dataset.company);
companyNames.set(link.dataset.company, link.textContent.trim());
const counts = state.filter.showMuted;
readUrl(new URL(e.currentTarget.href).search, { view: false });
readUrl(new URL(link.href).search, { view: false });
$("#search").value = state.q;
setFilter({}, { counts: counts !== state.filter.showMuted });
}
@@ -530,22 +634,121 @@
note.hidden = live.length > 0;
note.textContent = "No role is tagged yet.";
setValue("f-company", f.company);
setValue("f-place", f.place);
renderChips();
setValue("f-function", f.function);
setValue("f-remote", f.remote);
setValue("f-pay", f.pay);
setValue("f-judged", f.judged);
setValue("f-show-muted", f.showMuted);
setValue("f-gated", f.gated);
const more = [f.company.trim(), f.place.trim(), f.function, f.remote, f.pay, f.judged,
f.showMuted, ranked && f.gated].filter(Boolean).length + f.companyKeys.length;
renderFacets();
const more = filtersOn(f, { more: true });
$("#f-active").textContent = more ? ` · ${more}` : "";
document.body.dataset.rail = state.railOpen ? "open" : "shut";
$("#rail-toggle").setAttribute("aria-expanded", String(state.railOpen));
}
/* The chip inputs and the substring chips, from the filter: at load, on
back and forward, and after Clear. A chip input is set only when its
chips differ, since `set` draws them all again, and a pick has drawn
its own already. */
function renderChips() {
if (!companyChips) return;
const f = state.filter;
syncChips(companyChips, f.companyKeys.map((key) => ({ value: key, label: companyLabel(key) })));
syncChips(placeChips, f.places.map((t) => ({ value: t, label: placeLabels.get(t) || t })));
renderText("f-company-text", f.company.trim(), "Company", "company");
renderText("f-place-text", f.place.trim(), "Place", "place");
}
function syncChips(input, want) {
const have = input.values();
if (have.length === want.length
&& have.every((c, i) => c.value === want[i].value && c.label === want[i].label)) return;
input.set(want);
}
/* `?company=` or `?place=`, the substring a link from another page
brought: a plain chip saying what it matches, which takes it off and
pushes, as a filter does. */
function renderText(id, text, noun, key) {
const el = document.getElementById(id);
el.hidden = !text;
if (!text) {
el.replaceChildren();
delete el.dataset.text;
return;
}
if (el.dataset.text === text) return;
el.dataset.text = text;
el.innerHTML = `<button type="button" class="tag" title="Take this filter off"
aria-label="Remove the filter ${esc(noun)} contains ${esc(text)}"
>${esc(noun)} contains “${esc(text)}”<span class="chip-x" aria-hidden="true">×</span></button>`;
el.querySelector("button").onclick = () => setFilter({ [key]: "" });
}
const levelLabel = (level) => level.charAt(0).toUpperCase() + level.slice(1);
/* Which of the facet's pay states each Pay option keeps (`Store.PAY`),
so the option's count is theirs added up: 'stated' in the facet is a
line with no figure, the option "stated_only". */
const PAY_STATES = {
"": ["normalised", "stated", ""], stated: ["normalised", "stated"],
normalised: ["normalised"], stated_only: ["stated"],
};
/* Seniority and Pay with their counts. The levels are the facet's, in the
server's order; until it answers, the ones pressed, so a level read from
the address can be taken off at once. Built again only when a level,
a count or a press changed, so a pressed button keeps its focus. */
function renderFacets() {
const f = state.filter;
const facets = state.facets;
const countOf = (list, value) => list?.find((x) => x.value === value)?.count;
const shown = (n) => (n === undefined ? "" : number.format(n));
const levels = facets ? facets.seniority.map((x) => x.value).filter(Boolean) : [];
for (const level of f.seniority) if (!levels.includes(level)) levels.push(level);
const row = $("#f-seniority");
const counts = levels.map((level) => countOf(facets?.seniority, level));
const sig = JSON.stringify([levels, counts, f.seniority]);
if (row.dataset.key !== sig) {
row.dataset.key = sig;
row.innerHTML = levels.map((level, i) => `
<button type="button" class="tag" data-level="${esc(level)}"
aria-pressed="${f.seniority.includes(level)}"
>${esc(levelLabel(level))}${counts[i] === undefined ? ""
: `<span class="count">${shown(counts[i])}</span>`}</button>`).join("");
row.querySelectorAll("[data-level]").forEach((b) => {
b.onclick = () => toggleLevel(b.dataset.level);
});
}
$("#f-seniority-unknown-row").hidden = !f.seniority.length;
setValue("f-seniority-unknown", f.seniorityUnknown);
$("#f-seniority-unknown-count").textContent = shown(countOf(facets?.seniority, ""));
for (const option of $("#f-pay").options) {
const states = PAY_STATES[option.value];
const n = facets && states
? states.reduce((sum, s) => sum + (countOf(facets.pay, s) || 0), 0) : undefined;
const text = n === undefined ? option.dataset.label : `${option.dataset.label} (${shown(n)})`;
if (option.textContent !== text) option.textContent = text;
}
$("#f-pay-unknown-row").hidden = !f.pay;
setValue("f-pay-unknown", f.payUnknown);
$("#f-pay-unknown-count").textContent = shown(countOf(facets?.pay, ""));
}
/* A level pressed or let go, pushed as a filter. The last one let go
ticks "no level" again, which is how the box starts for the next. */
function toggleLevel(level) {
const f = state.filter;
const next = f.seniority.includes(level)
? f.seniority.filter((l) => l !== level) : [...f.seniority, level];
setFilter({ seniority: next, seniorityUnknown: next.length ? f.seniorityUnknown : true });
}
/* Viewing as: a select of the enabled agents, also when there is one, and
with none a sentence and the way to make one. Nothing until the agents
are in, so a page with agents never says it has none. */
@@ -576,10 +779,7 @@
number in a circle reads as "new things" on the one control that means
things are being left out (newsdesk's reasoning). */
function renderActive() {
const f = state.filter;
const on = [!f.showRead, f.period !== "all", f.company.trim(), f.place.trim(),
f.function, f.remote, f.pay, f.judged, f.showMuted, sortShown() === "score" && f.gated]
.filter(Boolean).length + f.tags.size + f.companyKeys.length;
const on = filtersOn();
const count = on === 1 ? "1 filter" : `${on} filters`;
$(".rail-toggle-label").textContent = on ? count : "Menu";
$("#rail-toggle").setAttribute("aria-label", on ? `Menu — ${count} on` : "Menu");
@@ -650,8 +850,10 @@
return "";
}
function badges(role, { seniority = false } = {}) {
const words = [role.remote, role.function, seniority ? role.seniority : ""].filter(Boolean);
/** Closed, pay, remote, function and seniority, as the row and the reader
both show them. */
function badges(role) {
const words = [role.remote, role.function, role.seniority].filter(Boolean);
const pay = payBadge(role);
return (role.closed_at ? `<span class="badge closed">closed</span>` : "")
+ (pay ? `<span class="badge">${esc(pay)}</span>` : "")
@@ -746,10 +948,7 @@
const retry = empty.querySelector("[data-retry]");
if (retry) retry.onclick = () => loadFeed();
} else {
const f = state.filter;
const filtered = state.q || f.tags.size || f.period !== "all" || !f.showRead
|| f.company.trim() || f.place.trim() || f.function || f.remote || f.pay || f.judged
|| f.companyKeys.length;
const filtered = state.q || filtersOn();
empty.innerHTML = filtered
? `<h2>Nothing matches</h2>
<p>No open role fits these filters.
@@ -805,8 +1004,7 @@
<button type="button" class="linky strip-drop"
title="Take the company filter off">All companies</button>
</div>
<p class="strip-note">★ Favourite lists its roles from every place the agent's
required gates allow, not only the agent's own places.</p>
<p class="strip-note"></p>
<p class="strip-status" role="status"></p>`;
el.querySelector(".strip-drop").onclick = dropCompany;
}
@@ -814,7 +1012,12 @@
if (slot.dataset.affinity !== String(affinity)) {
slot.dataset.affinity = String(affinity);
slot.replaceChildren(affinityControl(key, affinity,
() => affinityChanged(key, company), state.filter.agent));
(updated) => affinityChanged(key, company, updated), state.filter.agent));
// What ★ does, before; what it did, after.
el.querySelector(".strip-note").textContent = affinity === 2
? "★ Favourite: roles from every place the agent's required gates allow are listed."
: "★ Favourite also lists this company's roles outside your places, as far as the "
+ "agent's required gates allow.";
}
const n = state.total;
el.querySelector(".strip-count").textContent = state.loaded
@@ -823,26 +1026,24 @@
/* A company seen only through a search has no row until its first change
creates one, so the list is reloaded then. A change dims or undims its
rows at once; where they rank waits on the `score` it queued, and the
feed reloads when that has finished. */
async function affinityChanged(key, company) {
rows at once; where they rank waits on the `score` it queued, whose id
the affinity route answers with (`updated.score_job`), and the feed
reloads when that has finished. */
async function affinityChanged(key, company, updated) {
if (!company) await loadCompanies(state.filter.agent).catch(() => {});
renderFeed();
const status = () => $("#company-strip .strip-status");
if (status()) status().textContent = "Scoring again; the list reloads when that is done.";
await scored();
await scored(updated?.score_job);
if (status()) status().textContent = "";
if (state.filter.companyKeys.includes(key)) reload();
}
/* Wait for the `score` that carries a change just made, the way agents.js's
`rescore` waits. The affinity route answers with that job's id
(`score_job`), but app.js's `setAffinity` keeps the answer to itself,
so the job is read off the queue: right after the change it is the
newest `score` queued or running, which is what `_score_after_change`
answers with. None there means it has already finished. */
async function scored() {
let job;
/* Wait for the `score` job `job`, the way agents.js's `rescore` waits:
until the queue holds it neither running nor queued. None, when the
route could queue no job, is nothing to wait for. */
async function scored(job) {
if (job == null) return;
for (let i = 0; i < 300; i += 1) {
let snapshot;
try {
@@ -850,9 +1051,7 @@
} catch (err) {
return;
}
const live = [...snapshot.running, ...snapshot.queued].filter((j) => j.kind === "score");
if (job === undefined) job = Math.max(-1, ...live.map((j) => j.id));
if (!live.some((j) => j.id === job)) return;
if (![...snapshot.running, ...snapshot.queued].some((j) => j.id === job)) return;
await new Promise((resolve) => setTimeout(resolve, 1000));
}
}
@@ -1041,7 +1240,7 @@
<span class="affinity-slot"></span>
${r.place ? `<span>${esc(r.place)}</span>` : ""}
${r.first_seen ? `<span title="First seen">${ago(r.first_seen)}</span>` : ""}
${badges(r, { seniority: true })}
${badges(r)}
${tagChips(r.tags)}
</div>
<h1>${esc(r.title || "")}</h1>
@@ -1315,13 +1514,47 @@
$("#period").addEventListener("change", (e) => setFilter({ period: e.target.value }));
$("#clear-tags").addEventListener("click", () => { state.filter.tags.clear(); setFilter({}); });
const typed = debounce(() => setFilter({}, { replace: true }), 300);
for (const key of ["company", "place"]) {
$(`#f-${key}`).addEventListener("input", (e) => { state.filter[key] = e.target.value; typed(); });
}
for (const key of ["function", "remote", "pay", "judged"]) {
// A pick or a removal is a filter set, pushed; the text typed to find
// it is the chip input's own and never reaches the address.
companyChips = chipInput($("#f-company"), {
suggest: (q) => {
const p = new URLSearchParams({ q });
if (state.filter.agent !== null) p.set("agent", String(state.filter.agent));
return api(`/api/suggest/companies?${p}`).then((rows) => rows.map((c) => ({
value: c.key, label: c.name,
hint: c.affinity === 2 ? `★ ${number.format(c.count)}` : c.count,
})));
},
onChange: (items) => {
items.forEach((i) => companyNames.set(i.value, i.label));
setFilter({ companyKeys: items.map((i) => i.value) });
},
placeholder: "Company", label: "Company",
});
placeChips = chipInput($("#f-place"), {
suggest: (q) => api(`/api/suggest/places?${new URLSearchParams({ q })}`)
.then((rows) => rows.map((s) => ({
value: s.token, label: s.label,
hint: `${PLACE_KINDS[s.kind] || s.kind} · ${number.format(s.count)}`,
}))),
onChange: (items) => {
items.forEach((i) => placeLabels.set(i.value, i.label));
setFilter({ places: items.map((i) => i.value) });
},
placeholder: "Place", label: "Place",
});
for (const key of ["function", "remote", "judged"]) {
$(`#f-${key}`).addEventListener("change", (e) => setFilter({ [key]: e.target.value }));
}
// "No pay stated" starts unticked for each pay picked anew.
$("#f-pay").addEventListener("change", (e) => setFilter({
pay: e.target.value, payUnknown: e.target.value ? state.filter.payUnknown : false,
}));
$("#f-pay-unknown").addEventListener("change",
(e) => setFilter({ payUnknown: e.target.checked }));
$("#f-seniority-unknown").addEventListener("change",
(e) => setFilter({ seniorityUnknown: e.target.checked }));
$("#f-show-muted").addEventListener("change",
(e) => setFilter({ showMuted: e.target.checked }, { counts: true }));
$("#f-gated").addEventListener("change", (e) => setFilter({ gated: e.target.checked }));
@@ -1369,6 +1602,9 @@
wire();
renderRail();
renderActive();
// Named before the first request, which a token the server does not
// know would turn into a 422 rather than a list.
await labelPlaces();
// The feed is the page; agents and companies are enhancements that fill
// in when they arrive, not something it waits on — a slow or failed