Viewing as leads the Roles rail; settings get a rail, agent cards, one Sources section at a time
A search agent is a persona, and every like or pass belongs to the one being viewed. The rail now opens on Viewing as: a full-width chooser, the name alone with one agent, a note with none, remembered in the URL and localStorage. The vote buttons, the reader's affinity control, the feed, the tag counts and the reader fetch all carry that agent; before, votes sent none and every one landed on the default agent. Best first and Newest first are back as the segmented control under Order, independent of the agent. The rail selects no longer clip descenders: Chrome ignores line-height on a select, so the fixed box is gone in favour of padding and a min-height. Settings render inside a sticky rail (Search agents; Sources with Job boards, Company boards, Runs, Messages; Account), a strip under the header on a phone, so Runs is one click away however long the company list gets. Sources shows one section at a time, chosen by the fragment, so the old redirects still land. Search agents are cards, newest first: name, an On/Off switch with its word, the intent in full, the weights, Edit in place, New agent on top, and a link to Roles as that agent. Switching one on rescores it. replace_scores writes nothing for an agent deleted while score was running, instead of failing the run on the foreign key. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
063771d617
commit
c4f2bcc0c9
20 files changed
+836
-326
No files matched your search
+23
-13
@@ -14,15 +14,22 @@
|
||||
* Both are optimistic: the button changes before the request and changes back
|
||||
* if it fails. `api()` has already toasted the failure by then.
|
||||
*
|
||||
* A vote is a search agent's: `{agent}` names whose, and is sent with the POST
|
||||
* and the DELETE. Without it the server's default agent takes the vote, which
|
||||
* is right on a page that picks none. Save is not an agent's; it is the same
|
||||
* application whoever is viewing.
|
||||
*
|
||||
* One role can have two sets of these on screen at once, its feed row's and
|
||||
* the reader bar's, each bound to its own copy of the role. A change in one is
|
||||
* echoed to every other set for the same uid (`echo`), which copies the vote
|
||||
* and the read mark across and repaints it, so the row never shows a stance
|
||||
* the reader has taken back. A vote marks the role read on the server, and the
|
||||
* answer's `read_at` is copied onto the role with the vote.
|
||||
* the reader has taken back. Only sets for the same agent are echoed to,
|
||||
* since another agent can hold a different stance on the same role. A vote
|
||||
* marks the role read on the server, and the answer's `read_at` is copied onto
|
||||
* the role with the vote.
|
||||
*
|
||||
* await loadTracked();
|
||||
* container.append(judgeButtons(role, (role) => row.classList.toggle(...)));
|
||||
* container.append(judgeButtons(role, (role) => row.classList.toggle(...), { agent: 2 }));
|
||||
*/
|
||||
(function () {
|
||||
"use strict";
|
||||
@@ -44,10 +51,10 @@
|
||||
next time a change is echoed. */
|
||||
const groups = new Set();
|
||||
|
||||
function echo(from) {
|
||||
function echo(from, agent) {
|
||||
for (const group of groups) {
|
||||
if (!group.star.isConnected) { groups.delete(group); continue; }
|
||||
if (group.role === from || group.role.uid !== from.uid) continue;
|
||||
if (group.role === from || group.role.uid !== from.uid || group.agent !== agent) continue;
|
||||
group.role.vote = from.vote;
|
||||
group.role.voted_at = from.voted_at;
|
||||
if (from.read_at !== undefined) group.role.read_at = from.read_at;
|
||||
@@ -72,8 +79,9 @@
|
||||
/* The four buttons as a fragment, bound to `role`, which they read and
|
||||
write in place (`role.vote`), so the caller's copy is always current.
|
||||
`onChange(role)` runs after every change, optimistic or reverted: the
|
||||
feed dims a passed row with it. */
|
||||
function judgeButtons(role, onChange) {
|
||||
feed dims a passed row with it. `agent` is whose vote, the server's
|
||||
default agent when absent. */
|
||||
function judgeButtons(role, onChange, { agent = null } = {}) {
|
||||
const fragment = document.createDocumentFragment();
|
||||
const votes = STANCES.map((s) => {
|
||||
const b = button(s.cls, s.glyph);
|
||||
@@ -106,12 +114,14 @@
|
||||
const clearing = before === value;
|
||||
role.vote = clearing ? null : value;
|
||||
paint();
|
||||
echo(role);
|
||||
echo(role, agent);
|
||||
const path = `/api/roles/${encodeURIComponent(role.uid)}/vote`;
|
||||
const byDefault = agent == null;
|
||||
try {
|
||||
const updated = clearing
|
||||
? await api(path, { method: "DELETE" })
|
||||
: await api(path, { method: "POST", body: { value } });
|
||||
? await api(byDefault ? path : `${path}?agent=${encodeURIComponent(agent)}`,
|
||||
{ method: "DELETE" })
|
||||
: await api(path, { method: "POST", body: byDefault ? { value } : { value, agent } });
|
||||
role.vote = updated.vote;
|
||||
role.voted_at = updated.voted_at;
|
||||
if (updated.read_at !== undefined) role.read_at = updated.read_at;
|
||||
@@ -119,7 +129,7 @@
|
||||
role.vote = before;
|
||||
}
|
||||
paint();
|
||||
echo(role);
|
||||
echo(role, agent);
|
||||
}
|
||||
|
||||
// One request at a time: a second tap while the first is in flight would
|
||||
@@ -148,10 +158,10 @@
|
||||
star.disabled = false;
|
||||
}
|
||||
paint();
|
||||
echo(role);
|
||||
echo(role, agent);
|
||||
}
|
||||
|
||||
groups.add({ role, star, paint });
|
||||
groups.add({ role, star, paint, agent });
|
||||
paint();
|
||||
return fragment;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user