dashboard: /op-send returns 200; client relies on SSE for visual update

This commit is contained in:
müde 2026-05-17 12:41:04 +02:00
parent a478792914
commit 616ca38199
2 changed files with 12 additions and 5 deletions

View file

@ -1143,14 +1143,15 @@
fd.append('body', body);
input.disabled = true;
try {
// /op-send now returns 200 (no more 303-to-/). The SSE channel
// carries the resulting MessageEvent → the terminal renders the
// sent row + the inbox updates on its own; no /api/state
// refetch needed.
const resp = await fetch('/op-send', {
method: 'POST',
body: new URLSearchParams(fd),
redirect: 'manual',
});
const ok = resp.ok || resp.type === 'opaqueredirect'
|| (resp.status >= 200 && resp.status < 400);
if (!ok) {
if (!resp.ok) {
flashError(`send failed: http ${resp.status}`);
return;
}

View file

@ -1141,7 +1141,13 @@ async fn post_op_send(State(state): State<AppState>, Form(form): Form<OpSendForm
}) {
return error_response(&format!("op-send to {to} failed: {e:#}"));
}
Redirect::to("/").into_response()
// 200 instead of 303 → the client doesn't refetch /api/state. The
// broker `send` already emitted a `MessageEvent` which the
// dashboard channel forwarder mirrors as `DashboardEvent::Sent`,
// and the page's terminal + inbox derive from that stream — so the
// operator's send shows up the same way an agent's send does, with
// no full-state refresh in between.
(axum::http::StatusCode::OK, "ok").into_response()
}
async fn post_request_spawn(