Ask before a destructive board or search switch; queue a pull after a reopening one

Switching a company's board or a job board search off, replacing a
company's board and detaching one all close open roles in a tap; each
now asks first, naming the count (a replace also names the old and the
new board), the same as removing a search and deleting an agent
already do.

Switching a target back on, following a board, setting a board and
saving a search used to show nothing until the schedule's next pull,
up to six hours later. Each now queues a pull job right in the API
route, so the CLI and any other caller of the same endpoint behave
like the page; the queued pull's own refusal while one is already
running is not surfaced as an error.

Co-Authored-By: Claude Sonnet <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Sonnet committed 2026-09-29 15:18:16 +02:00
1 parent 92ff2bc069
commit e6be593542
6 files changed
+143 -23

No files matched your search

+41 -6
View File
@@ -147,13 +147,22 @@
form.addEventListener("submit", async (event) => {
event.preventDefault();
const board = `${host.value}:${slug.value.trim()}`;
// Replacing a different board closes its roles (see set_board in
// app/jobs/sources.py); ask first, naming both boards and the count,
// the same as Detach and a removed search already do.
if (company.board && company.board !== board
&& !window.confirm(`Replace ${company.name}'s board (${company.board}) `
+ `with ${board}? Its ${count(company.open_roles, "open role")} close.`)) {
return;
}
save.disabled = true;
try {
const result = await api(`/api/companies/${encodeURIComponent(company.key)}/board`,
{ method: "POST", body: { board: `${host.value}:${slug.value.trim()}` } });
{ method: "POST", body: { board } });
const closed = result.closed ? `, ${count(result.closed, "old role")} closed` : "";
window.toast.info(`${company.name}: reading ${result.source.target}, `
+ `${count(result.found, "role")} listed${closed}.`);
window.toast.info(`${company.name}: ${result.source.target} listed `
+ `${count(result.found, "role")}${closed}. Reading now, or with the pull right after.`);
await done();
} catch (err) {
save.disabled = false;
@@ -165,6 +174,11 @@
detach.className = "linky";
detach.textContent = "Detach";
detach.addEventListener("click", async () => {
if (company.open_roles
&& !window.confirm(`Detach ${company.name}'s board (${company.board})? `
+ `Its ${count(company.open_roles, "open role")} close.`)) {
return;
}
detach.disabled = true;
try {
const result = await api(`/api/companies/${encodeURIComponent(company.key)}/board`,
@@ -190,6 +204,14 @@
box.checked = Boolean(company.on);
box.setAttribute("aria-label", `Read ${company.name}'s board`);
box.addEventListener("change", async () => {
// Switching off closes every open role in one tap; ask first, naming
// the count, as removing a search and deleting an agent already do.
if (!box.checked && company.open_roles
&& !window.confirm(`Switch off ${company.name}'s board? `
+ `Its ${count(company.open_roles, "open role")} close.`)) {
box.checked = true;
return;
}
box.disabled = true;
try {
const result = await api(`/api/sources/${company.subscription_id}/switch`,
@@ -197,6 +219,8 @@
company.on = result.source.on;
if (!box.checked && result.closed) {
window.toast.info(`${company.name}: ${count(result.closed, "open role")} closed.`);
} else if (box.checked) {
window.toast.info(`${company.name}: reading now, or with the pull right after.`);
}
} catch (err) {
box.checked = !box.checked;
@@ -260,19 +284,30 @@
event.preventDefault();
const status = $("#board-status");
const button = $("#board-form button[type=submit]");
const name = $("#b-name").value.trim();
const board = `${$("#b-host").value}:${$("#b-slug").value.trim()}`;
// This name may already be a company with a different board: `set_board`
// would replace it and close its roles, the same as the row's own
// editor does, so it asks first too.
const existing = [...companies.values()]
.find((c) => c.name.toLowerCase() === name.toLowerCase());
if (existing && existing.board && existing.board !== board
&& !window.confirm(`Replace ${existing.name}'s board (${existing.board}) `
+ `with ${board}? Its ${count(existing.open_roles, "open role")} close.`)) {
return;
}
button.disabled = true;
status.textContent = "Reading the board once before following it…";
const board = `${$("#b-host").value}:${$("#b-slug").value.trim()}`;
try {
const result = await api("/api/boards", {
method: "POST",
body: { board, name: $("#b-name").value.trim() },
body: { board, name },
});
await loadCompanies(agentId());
render();
$("#board-form").reset();
status.textContent = `Following ${result.source.label}: `
+ `${count(result.found, "role")} listed. They arrive with the next pull.`;
+ `${count(result.found, "role")} listed. Reading now, or with the pull right after.`;
} catch (err) {
status.textContent = "";
}
+11 -1
View File
@@ -34,6 +34,14 @@
box.checked = source.on;
box.setAttribute("aria-label", `Run ${source.label}`);
box.addEventListener("change", async () => {
// Switching off closes every open role in one tap; ask first, naming
// the count, as removing a search and deleting an agent already do.
if (!box.checked && source.open_roles
&& !window.confirm(`Switch off ${source.label}? `
+ `Its ${count(source.open_roles, "open role")} close.`)) {
box.checked = true;
return;
}
box.disabled = true;
try {
const result = await api(`/api/sources/${source.id}/switch`,
@@ -41,6 +49,8 @@
Object.assign(source, result.source);
if (!box.checked && result.closed) {
window.toast.info(`${source.label}: ${count(result.closed, "open role")} closed.`);
} else if (box.checked) {
window.toast.info(`${source.label}: reading now, or with the pull right after.`);
}
} catch (err) {
box.checked = !box.checked;
@@ -184,7 +194,7 @@
renderSearches();
fillSearchForm(null);
status.textContent = `Saved ${result.source.label}. ${found(result)} `
+ "Its roles arrive with the next pull.";
+ "Reading now, or with the pull right after.";
} catch (err) {
status.textContent = "";
}