diff --git a/app/static/roles.js b/app/static/roles.js index ca76288..d6d9b53 100644 --- a/app/static/roles.js +++ b/app/static/roles.js @@ -107,6 +107,7 @@ pushedReader: false, // we own a history entry, so closing is `history.back()` 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 }; const safeUrl = (u) => (/^https?:\/\//i.test(u || "") ? u : ""); @@ -201,11 +202,20 @@ try { data = await api(`/api/roles?${params}`); } catch (err) { + // An append failure leaves what is already on screen; a first load or + // a reload has nothing to show, so the empty state offers a retry + // rather than leaving the feed blank for good. + if (!append && request === feedRequest) { + state.feedError = true; + state.loaded = false; + renderFeed(); + } return; } finally { if (request === feedRequest) state.loading = false; } if (request !== feedRequest) return; + state.feedError = false; const held = append ? state.items[state.selected]?.uid : state.readingUid; state.total = data.total; @@ -579,21 +589,29 @@ sync($("#roles-list"), state.items.map((role, i) => [role.uid, { role, i }]), makeRow, fillRow); const empty = $("#feed-empty"); - empty.hidden = !(state.loaded && !state.items.length); + empty.hidden = !((state.loaded || state.feedError) && !state.items.length); if (!empty.hidden) { - 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.judged; - empty.innerHTML = filtered - ? `
No open role fits these filters. - and start again.
` - : `Nothing has been pulled yet. Runs starts one; - Job boards and - Company boards decide what it brings in.
`; - const clear = empty.querySelector("[data-clear]"); - if (clear) clear.onclick = () => { state.q = ""; $("#search").value = ""; clearFilters(); }; + if (state.feedError) { + empty.innerHTML = `The server did not answer. .
`; + 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.judged; + empty.innerHTML = filtered + ? `No open role fits these filters. + and start again.
` + : `Nothing has been pulled yet. Runs starts one; + Job boards and + Company boards decide what it brings in.
`; + const clear = empty.querySelector("[data-clear]"); + if (clear) clear.onclick = () => { state.q = ""; $("#search").value = ""; clearFilters(); }; + } } // The end of the list says which end it is: a list that has run out and @@ -1092,19 +1110,41 @@ wire(); renderRail(); renderActive(); - // The agent first: the companies, the feed and the counts are its. - try { - await Promise.all([loadTracked(), loadAgents()]); - chooseAgent(); - await loadCompanies(state.filter.agent); - } catch (err) { - return; - } - renderRail(); - renderActive(); - loadFilters().catch(() => {}); + + // 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 + // /api/agents or /api/companies must not leave it blank. Each one drawn + // here is greyed or missing until `enhance` lands, which is what "no + // agent" (renderAgent), an unjoined company (paintRow) and the tag row + // being empty already mean, so nothing here is a new state to handle. + const before = state.filter.agent; + const enhance = (async () => { + try { + await Promise.all([loadTracked(), loadAgents()]); + chooseAgent(); + await loadCompanies(state.filter.agent); + } catch (err) { + return; + } + renderRail(); + renderActive(); + loadFilters().catch(() => {}); + // The feed's first request went out with whatever agent `readUrl` had + // (often none): reload for the score and votes once the real one is + // known, and either way bring the reader's affinity control and judge + // buttons up to date, since `companies` was still empty when it first + // painted. + if (state.filter.agent !== before) reload(); + else renderFeed(); + if (state.readingUid) { + if (state.filter.agent !== before) refreshReader(state.readingUid); + else renderReader(); + } + })(); + route(); await loadFeed({ keep: was ? was.count : 0 }); if (was && !state.readingUid) window.scrollTo(0, was.y || 0); + await enhance; }); })(); diff --git a/docs/decisions.md b/docs/decisions.md index d7c8a5e..ea1ed3c 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -122,6 +122,8 @@ What was decided for roledesk and the one reason for each. The longer reasoning **Each roledesk tab renders an empty shell; `static/roles.js` fills it and drives every action.** Roles, Applications, Agents and Companies extend the boilerplate's `base.html`; the server renders only select options (from `app.models`, `plugins.ats.FUNCTIONS` and `plugins.ats.HOSTS`, so they cannot drift from what the store and the plugin accept). One code path for "show this" beats a server-rendered first page plus a client re-render after every filter change. +**The feed loads whether or not its enhancements do.** `/api/agents` and `/api/companies` only dim hidden companies, draw the affinity control and pick the viewing agent's score order; the init block used to await both before ever calling `loadFeed`, so a slow or failed one left the feed blank for good behind a silent `catch (err) { return; }`. Now the feed's own request goes out alongside them rather than after, agents and companies fill in and redraw what they touch (the rail, the feed's dimming, the reader's affinity slot) whenever they land, and a feed already fetched with no agent known reloads once the real one is. A failed feed fetch of its own gets an empty state with a retry (`state.feedError`) instead of the same silent blank. + **`roles(company=, place=)` match a case-insensitive substring of what the board wrote.** The API's company and place fields are free text a person types, not a slug, so "Trade Republic" finds `trade-republic-bank` without knowing the key. **A muted company is excluded in SQL, before `LIMIT`.** Filtering after `LIMIT` shipped first and showed nothing once Databricks' 884 freshly pulled roles filled the newest 200 rows and Databricks was muted.