Show immediate loading feedback on action buttons
I've fixed it so the Merge button in the conversation now shows a spinner right away, but I couldn't run any tests: Go isn't installed here and running node or Chromium was blocked. **Why nothing happened when you clicked Merge:** the loader was being drawn, then removed almost straight away. The conversation sends card actions (Merge, Retry, card answers) itself instead of letting the browser do it. The existing loader code treats that as "someone else is handling this" and takes its spinner off at once. The button was disabled, but it looked the same, so the screen didn't change even though the request had gone. **What changed:** - **Conversation card actions:** the clicked button's text is swapped for the spinner at the same size, and screen readers still hear the button's name. It stays that way for at least 650 ms, or until the card is redrawn with what the server accepted, whichever is later. The request still goes out immediately. Double clicks are ignored, and the server's existing protection against duplicates is unchanged. - **Live updates during a click:** while a card action is on its way, the conversation doesn't redraw itself. Otherwise an update arriving at the same moment could bring back an idle Merge button under your click. - **Accepted versus finished:** the loader ends when the server has accepted the merge. The card then shows the task's own state, which moves to "merged" later. - **Errors:** if the request fails, the button comes back usable with "Tha Equipo task tkbadarq3dds, Engineering step attempt 1.
7 files changed,
+103
−14
docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md+1 −0internal/equipo/copy.go+2 −0internal/equipo/static/busy.js+15 −3internal/equipo/static/chat-stream.js+67 −8internal/equipo/static/equipo.css+12 −0internal/equipo/static/work-stream.js+5 −2internal/equipo/templates/chat.html+1 −1
CI failed — run details
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md| index e83b783c..2995b260 100644 |
| --- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| @@ -6480,6 +6480,7 @@ records remain unchanged. |
| | `assistant.outcome.publish_declined` | Your site was not published. | Assistant Publish card's result after Not now (assistant, 2026-11-13) | Runtime; COPY APPROVED (Paul, 2026-11-13, copy-review jbltdd2mvwblrz4en6xfhv6d2y, unchanged) | |
| | `assistant.outcome.publish_site` | Open your site | Assistant Publish card: the published site link's label (assistant, 2026-11-13) | Runtime; COPY APPROVED (Paul, 2026-11-13, copy-review jbltdd2mvwblrz4en6xfhv6d2y, unchanged) | |
| | `docs/api/equipo-v1.md / Talk to the Assistant` | ## Talk to the Assistant<br><br>The routes under `/api/v1/assistant` serve Base's chat with the Assistant. Every route, `events` included, takes only `Authorization: Bearer <token>` with a person device token (audience `equipo.person.v1`). A session cookie is not accepted, and a request without a bearer gets `401 unauthenticated`. Every response has `Cache-Control: no-store`. Errors have the same body as the rest of this API: `code`, `copy_key`, `request_id` and, where it applies, `current_revision`.<br><br>The Assistant keeps its own conversation. Its messages, turns, cards and events never appear in the Coordinator's, and an ID from the Coordinator's conversation is `404 not_found` on every Assistant route.<br><br>Start with `GET /api/v1/assistant/snapshot`. It returns `me`, the newest messages and their turns, the cards, the event `cursor`, and `available`. `available` is false when you have no runner of your own, or when your runner needs an update before it can answer the Assistant. Read older messages with `GET /api/v1/assistant/messages?before=<message ID>&limit=<count>`. `limit` is 1 to 200 and defaults to 50. The `before` in the response is the cursor for the page before; it is empty at the start of the conversation.<br><br>Send a message with `POST /api/v1/assistant/messages` and a key of your choosing, 1 to 128 bytes, in the body:<br><br>```json<br>{"text":"What can I do here?","idempotency_key":"<a new key for each message>"}<br>```<br><br>A new message is `201`, with the message and its turn. The same key and text again return `200` with the same result; the same key with other text is `409 idempotency_conflict`. Without a runner of your own the answer is `409 no_runner`, and with a runner that needs an update it is `409 runner_too_old`. Nothing is stored in either case. The Assistant takes words only, so a message with `attachments` is `422 invalid_input`.<br><br>Follow the conversation with `GET /api/v1/assistant/events?after=<cursor>`, a stream of Server-Sent Events. `after` wins over `Last-Event-ID`. With neither, the stream starts at the newest event. The stream opens with `retry: 2000`, then sends each event as `id: <cursor>`, `event: <type>` and `data:` with the event as JSON, whose own `data` field holds the message, turn, delta, card or activity. The types are `message`, `turn`, `delta`, `card` and `activity`, and a `ping` comes every 20 seconds. A cursor that is too old is `410 cursor_expired`. Read the snapshot again and follow from its cursor.<br><br>A message has `role` `person` or `assistant`. A turn's `kind` is empty when it answers you, and `team_update` when the Assistant tells you, on its own, what the team did with something you asked for. Cancel a turn in flight with `POST /api/v1/assistant/turns/{id}/cancel` and an empty JSON object. The answer is `202` with the turn's `attempt`, or `409 turn_ended` once the turn has ended.<br><br>A card has `id`, `revision`, `kind`, `state`, `question`, `options`, `links` and `result`. Its kind is `question`, `confirm`, `outcome` or `connect`, and its state is `open`, `answered` or `resolved`. `options` and `links` are always arrays, never null. Answer an open card with `POST /api/v1/assistant/cards/{id}/answer`, one option's `value` and the card's revision:<br><br>```json<br>{"choice":"Yes","revision":2}<br>```<br><br>The answer is `200` with the card, your answer as a message, and its turn. When the answer starts no turn, `message` and `turn` are empty, with zero times: treat that as no new turn. A stale revision is `409` with code `card_stale`, and a card already answered is `409` with code `card_answered`. Both bodies carry the card as it is now in `card`. Answering a `question` card also needs your runner, so it can be `409 no_runner` or `409 runner_too_old`.<br><br>Tell Equipo where your Base operations live with `PUT /api/v1/assistant/host`:<br><br>```json<br>{"origin":"https://base.example","token":"<token from Base>"}<br>```<br><br>The origin is `https://` and a host name with no path, or `http://` on loopback only. It must be on the instance's `EQUIPO_ASSISTANT_HOSTS` list, or the answer is `403 host_not_allowed`. The token is 20 to 512 visible ASCII characters, with no spaces. The answer is `200` with `origin` and `revision`; the token is never given back. A second `PUT` replaces the first. | API doc: the Assistant's routes under /api/v1/assistant, for Base (assistant, 2026-11-13) | API; COPY APPROVED (Paul, 2026-11-13, copy-review 64nswfjbrpsw2pezhyi7y3nenq, unchanged) | |
| +| `chat.card.failed` | That did not go through. Try again. | Conversation card: under a card action (Merge, Retry, an answer) whose background post failed (busy feedback, 2026-11-13) | Runtime; COPY REVIEW REQUIRED | |
| ## Task 21 |
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go| index c5db7f2d..d97f8f27 100644 |
| --- a/internal/equipo/copy.go |
| +++ b/internal/equipo/copy.go |
| @@ -1483,6 +1483,8 @@ var pageCopy = map[string]string{ |
| "conversation.age_days": "%d d", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): conversation.sending |
| "conversation.sending": "Sending", |
| + // COPY REVIEW REQUIRED: chat.card.failed, a card action's post that failed |
| + "chat.card.failed": "That did not go through. Try again.", |
| // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): conversation.retry |
| "conversation.retry": "Retry", |
| "conversation.send_short": "Send", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
diff --git a/internal/equipo/static/busy.js b/internal/equipo/static/busy.js| index 5f7228a8..9600f7d0 100644 |
| --- a/internal/equipo/static/busy.js |
| +++ b/internal/equipo/static/busy.js |
| @@ -33,7 +33,12 @@ |
| A script that handles a submit itself (a fetch, say) cancels it in a |
| listener on the form or the document, as it would anyway: those run |
| before this file's window listener, which then sees the cancelled |
| - submit and leaves it — and its feedback — to that script. Two edges |
| + submit and leaves it — and its feedback — to that script. A script |
| + that would rather keep this file's feedback sets e.busyUntil to a |
| + promise as it cancels: the button stays busy and the form guarded |
| + until that promise settles and HOLD_MS have passed since the click, |
| + then both are handed back (a form the script has replaced meanwhile |
| + has nothing left to hand back). Two edges |
| of the hold, on purpose: a handler that stops the submit event's |
| propagation keeps it from the window, so that submit goes at once, |
| unheld; and a form removed from the page during the hold (a polled |
| @@ -137,6 +142,7 @@ |
| if (form === releasing) return; // the hold sending the submit it held |
| if (form.getAttribute("aria-busy") === "true") { e.preventDefault(); return; } |
| form.setAttribute("aria-busy", "true"); |
| + var start = Date.now(); |
| if (!btn || btn.getAttribute("data-busy") === "false") btn = null; |
| var label = btn && (btn.getAttribute("data-busy-label") || |
| form.getAttribute("data-busy-label")); |
| @@ -161,8 +167,14 @@ |
| // Someone downstream cancelled the submit — an app handler doing |
| // the work itself, most likely. Nothing is on its way anywhere, |
| // so hand the form back, guard included, and let whoever took the |
| - // job own the feedback too. |
| - if (e.defaultPrevented && !held.has(e)) { busyOff(form); return; } |
| + // job own the feedback too — unless it asked to keep this file's |
| + // (e.busyUntil), which is handed back once its work is done. |
| + if (e.defaultPrevented && !held.has(e)) { |
| + if (!e.busyUntil) { busyOff(form); return; } |
| + var hold = new Promise(function (r) { setTimeout(r, Math.max(0, start + HOLD_MS - Date.now())); }); |
| + Promise.all([Promise.resolve(e.busyUntil).catch(function () {}), hold]) |
| + .then(function () { busyOff(form); }); |
| + } |
| if (!btn) return; |
| if (label && btn.tagName === "INPUT") { |
| btn.setAttribute("data-idle-label", btn.value); |
diff --git a/internal/equipo/static/chat-stream.js b/internal/equipo/static/chat-stream.js| index c9c2617a..cda036ad 100644 |
| --- a/internal/equipo/static/chat-stream.js |
| +++ b/internal/equipo/static/chat-stream.js |
| @@ -660,6 +660,9 @@ |
| // drafts are put back. Refreshes run one at a time (a request during one |
| // runs once after it), and a page older than the one shown is dropped. |
| var inflight = null, again = false; |
| + // Card posts on their way, and started, and whether a refresh was held |
| + // back for them: see the card actions below. |
| + var cardsOut = 0, cardsSent = 0, missed = false; |
| // shape is the cursor of the newest event that changes what the page |
| // shows (a turn, a message, a card): a page rendered before it is |
| // stale, and is followed by another. |
| @@ -770,6 +773,7 @@ |
| return inflight ? inflight.then(refreshed, refreshed) : refresh(); |
| } |
| function load() { |
| + var sent = cardsSent; |
| return fetch(pageURL(), { credentials: "same-origin", headers: { "Accept": "text/html" } }) |
| .then(function (r) { if (!r.ok) throw new Error("refresh"); return r.text(); }) |
| .then(function (body) { |
| @@ -777,6 +781,14 @@ |
| var next = doc.querySelector("[equipo-feed]"); |
| var page = doc.querySelector("[data-chat-stream]"); |
| if (!next || !page) return; |
| + // Never under a card post, nor with a page that may predate one: |
| + // it would put the card back idle under the click. Each post |
| + // refreshes once it settles. |
| + if (cardsOut || sent !== cardsSent) { |
| + missed = true; |
| + return; |
| + } |
| + missed = false; |
| var build = newer(doc); |
| if (build) reloadWhenQuiet(build); |
| var at = Number(page.dataset.cursor) || 0; |
| @@ -798,6 +810,7 @@ |
| if (more) more.setAttribute("aria-expanded", "true"); |
| }); |
| feed.querySelectorAll("[data-message]").forEach(function (el) { shown[el.dataset.message] = true; }); |
| + var failed = feed.querySelectorAll("[data-card-failed]"); |
| feed.replaceChildren.apply(feed, Array.from(next.children).map(function (el) { |
| var fresh = el.matches('[equipo-message="incoming"][data-turn-id]') && !shown[el.dataset.message]; |
| var turn = el.hasAttribute("equipo-thinking") ? el.dataset.turn : fresh ? el.dataset.turnId : ""; |
| @@ -832,6 +845,12 @@ |
| } |
| return settle(old, el); |
| }).filter(Boolean)); |
| + // A card action that failed says so while its card still offers it. |
| + failed.forEach(function (note) { |
| + var f = feed.querySelector('[data-card-form][action="' + CSS.escape(note.dataset.cardFailed) + '"]'); |
| + note.removeAttribute("role"); |
| + if (f) f.after(note); |
| + }); |
| // A stale page lacks lines for turns that started since: they stay. |
| if (stale) Object.keys(keep).forEach(function (turn) { if (!ended[turn] && !queued[turn]) feed.append(keep[turn]); }); |
| local.forEach(function (el) { place(el); }); |
| @@ -1034,18 +1053,58 @@ |
| toggle.removeAttribute("aria-busy"); |
| }); |
| }); |
| - // Card actions (Change, Remove, answers) post in the background and the |
| - // card events re-render the feed; without script the forms still work. |
| + // Card actions (Change, Remove, answers, Merge) post in the background |
| + // and the card events re-render the feed; without script the forms |
| + // still work. The post goes at once. The clicked button keeps busy.js's |
| + // spinner and its form busy.js's guard (e.busyUntil) until the feed |
| + // shows what the server accepted, and for at least HOLD_MS, busy.js's |
| + // beat: the feed is not swapped meanwhile. A merge accepted is not a |
| + // merge done; the card says which once it is drawn again. A post that |
| + // failed hands the button back and says so. |
| + var HOLD_MS = 650; |
| feed.addEventListener("submit", function (event) { |
| var f = event.target.closest("[data-card-form]"); |
| - if (!f) return; |
| + // Cancelled already: busy.js refusing a second submit of a busy form. |
| + if (!f || event.defaultPrevented) return; |
| event.preventDefault(); |
| - var body = new URLSearchParams(new FormData(f, event.submitter)); |
| - f.querySelectorAll("button").forEach(function (b) { b.disabled = true; }); |
| - fetch(f.action, { method: "POST", credentials: "same-origin", headers: { "Accept": "application/json" }, body: body }) |
| - .then(function (r) { if (!r.ok) throw new Error("card"); return refresh(); }) |
| - .catch(function () { refreshSoon(); }); |
| + var btn = event.submitter, had = !!btn && document.activeElement === btn; |
| + var body = new URLSearchParams(new FormData(f, btn)); |
| + var was = f.nextElementSibling; |
| + if (was && was.hasAttribute("data-card-failed")) was.remove(); |
| + var hold = new Promise(function (r) { setTimeout(r, HOLD_MS); }); |
| + cardsOut++; |
| + cardsSent++; |
| + var sent = fetch(f.action, { method: "POST", credentials: "same-origin", headers: { "Accept": "application/json" }, body: body }) |
| + .then(function (r) { if (!r.ok) throw new Error("card"); }); |
| + event.busyUntil = Promise.all([sent, hold]).then(function () { |
| + cardsOut--; |
| + // refreshed: a refresh already under way may have held its swap. |
| + return refreshed(); |
| + }, function () { |
| + return hold.then(function () { |
| + cardsOut--; |
| + cardFailed(f, btn, had); |
| + // Only for what the stream asked meanwhile: a swap would take |
| + // the handed-back button from under the keyboard. |
| + if (missed && !cardsOut) return refresh(); |
| + }); |
| + }); |
| + event.busyUntil.catch(function () { refreshSoon(); }); |
| }); |
| + function cardFailed(f, btn, had) { |
| + if (!f.isConnected) return; |
| + var note = document.createElement("p"); |
| + note.setAttribute("equipo-card-note", ""); |
| + note.setAttribute("role", "alert"); |
| + note.dataset.cardFailed = f.getAttribute("action"); |
| + note.textContent = root.dataset.cardFailed; |
| + f.after(note); |
| + // Disabling the focused button dropped focus: once busy.js has |
| + // handed it back, a keyboard is where it was. |
| + setTimeout(function () { |
| + if (had && btn.isConnected && (!document.activeElement || document.activeElement === document.body)) btn.focus(); |
| + }, 0); |
| + } |
| // Sending stays on this page: no navigation, so no page transition. The |
| // bubble shows at once; the background post uses the form's own action |
| // (the person API's POST is for device bearers) with a fresh request id, |
diff --git a/internal/equipo/static/equipo.css b/internal/equipo/static/equipo.css| index 2e2f0135..fc3ce1d0 100644 |
| --- a/internal/equipo/static/equipo.css |
| +++ b/internal/equipo/static/equipo.css |
| @@ -644,6 +644,18 @@ a[equipo-source]:hover { color: var(--rst-text); text-decoration: underline; tex |
| [equipo-btn][data-primary]:hover { background: var(--rst-accent-fill-hover); } |
| [equipo-d-actions] [equipo-link] { appearance: none; background: none; border: 0; padding: 0; font: inherit; font-size: var(--rst-fs-sm); color: var(--rst-text-muted); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; } |
| [equipo-d-actions] [equipo-link]:hover { color: var(--rst-text); } |
| +/* busy.js's busy state on Equipo's own buttons (Merge, Retry, a menu's |
| + actions), drawn as tokens.css draws it on rst-btn: the spinner takes |
| + the label's place at the button's own size, and the label, unpainted, |
| + stays what a screen reader reads. Under reduced motion or forced |
| + colours the spinner sits beside the label instead. */ |
| +:is([equipo-btn], [equipo-act], [equipo-link], [equipo-menu] button)[aria-busy="true"] { cursor: default; } |
| +@media (prefers-reduced-motion: no-preference) and (forced-colors: none) { |
| + :is([equipo-btn], [equipo-act], [equipo-link], [equipo-menu] button)[aria-busy="true"]:not([data-idle-label]):has(> [rst-spin]) { -webkit-text-fill-color: transparent; text-decoration-color: transparent; } |
| + :is([equipo-btn], [equipo-act], [equipo-link], [equipo-menu] button)[aria-busy="true"]:not([data-idle-label]):has(> [rst-spin]) > :not([rst-spin]) { opacity: 0; } |
| + :is([equipo-btn], [equipo-act], [equipo-link], [equipo-menu] button)[aria-busy="true"]:not([data-idle-label]) > [rst-spin] { inset: 0; margin: auto; position: absolute; } |
| + :where([equipo-btn], [equipo-act], [equipo-link], [equipo-menu] button):where([aria-busy="true"]:not([data-idle-label])) { position: relative; } |
| +} |
| /* Quiet, beside the decision and not one: set up a Mac, ask about it. */ |
| [equipo-d-quiet] { display: inline-flex; flex-wrap: wrap; gap: var(--rst-sp-1) var(--rst-sp-4); margin-inline-start: auto; } |
| /* The task page. */ |
diff --git a/internal/equipo/static/work-stream.js b/internal/equipo/static/work-stream.js| index 2b32690f..56d127e6 100644 |
| --- a/internal/equipo/static/work-stream.js |
| +++ b/internal/equipo/static/work-stream.js |
| @@ -9,8 +9,11 @@ |
| if (!document.querySelector("[data-work-live]") || !window.fetch) return; |
| var inflight = null, again = false, timer = 0; |
| function busy() { |
| - // Never swap a menu or a filter out from under the person. |
| - return !!document.querySelector("[data-work-region] [equipo-menu][open], [data-work-region] [equipo-filter][open]") || |
| + // Never swap a menu or a filter out from under the person, nor a |
| + // form busy.js is holding or sending: the swap would take its spinner |
| + // and, during the hold, its submit (a clicked button is not focused |
| + // in Safari, so the focus test below misses it). |
| + return !!document.querySelector("[data-work-region] [equipo-menu][open], [data-work-region] [equipo-filter][open], [data-work-region] form[aria-busy=\"true\"]") || |
| !!(document.activeElement && document.activeElement.closest && document.activeElement.closest("[data-work-region] form")); |
| } |
| function load() { |
diff --git a/internal/equipo/templates/chat.html b/internal/equipo/templates/chat.html| index aecff5a9..a7d0c0f4 100644 |
| --- a/internal/equipo/templates/chat.html |
| +++ b/internal/equipo/templates/chat.html |
| @@ -39,7 +39,7 @@ |
| </li>{{end}} |
| {{define "day-row"}}<div equipo-day-row data-row="{{.Key}}"><dt>{{.Label}}</dt><dd{{if .Stack}} data-stack{{end}}>{{range $i, $it := .Items}}{{if and $i (not $.Stack)}}, {{end}}<span equipo-day-item>{{if .TaskID}}<a href="/tasks/{{.TaskID}}">{{.Text}}</a>{{else}}{{.Text}}{{end}}{{with .Note}}: <span equipo-day-decision>{{.}}</span>{{end}}</span>{{end}}{{with .More}} <span equipo-day-more>{{.}}</span>{{end}}</dd></div>{{end}} |
| {{define "content"}} |
| -<div equipo-conversation data-chat-stream data-thinking-set="{{.ThinkingSet}}" data-thinking-words="{{.ThinkingWords}}" data-cursor="{{.Chat.Cursor}}" data-person="{{.Address}}" data-elapsed="{{copy "chat.elapsed"}}" data-moving-in="{{copy "chat.moving_in"}}" data-exploring="{{copy "chat.exploring"}}" data-queued-note="{{copy "chat.queued"}}"> |
| +<div equipo-conversation data-chat-stream data-thinking-set="{{.ThinkingSet}}" data-thinking-words="{{.ThinkingWords}}" data-cursor="{{.Chat.Cursor}}" data-person="{{.Address}}" data-elapsed="{{copy "chat.elapsed"}}" data-moving-in="{{copy "chat.moving_in"}}" data-exploring="{{copy "chat.exploring"}}" data-queued-note="{{copy "chat.queued"}}" data-card-failed="{{copy "chat.card.failed"}}"> |
| <header equipo-chat-header><h1>{{copy "conversation.title"}}</h1><a href="/conversation/settings/notebook" equipo-header-button aria-label="{{copy "chat.notebook.link"}}" title="{{copy "chat.notebook.link"}}">{{icon "notebook"}}</a><a href="/housekeeping" equipo-header-button aria-label="{{copy "chat.housekeeping.link"}}" title="{{copy "chat.housekeeping.link"}}" data-housekeeping-link>{{icon "list-checks"}}</a><a href="/conversation/settings/connections" equipo-header-button aria-label="{{copy "chat.connections.title"}}" title="{{copy "chat.connections.title"}}" data-connections-link>{{icon "plug"}}</a></header> |
| <p equipo-offline role="status"{{if not .Chat.Offline}} hidden{{end}}>{{copy "chat.offline"}}</p> |
| <div equipo-scroll tabindex="0" role="region" aria-label="{{copy "conversation.title"}}"> |