dashboard: /op-send returns 200; client relies on SSE for visual update
This commit is contained in:
parent
a478792914
commit
616ca38199
2 changed files with 12 additions and 5 deletions
|
|
@ -1143,14 +1143,15 @@
|
||||||
fd.append('body', body);
|
fd.append('body', body);
|
||||||
input.disabled = true;
|
input.disabled = true;
|
||||||
try {
|
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', {
|
const resp = await fetch('/op-send', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: new URLSearchParams(fd),
|
body: new URLSearchParams(fd),
|
||||||
redirect: 'manual',
|
|
||||||
});
|
});
|
||||||
const ok = resp.ok || resp.type === 'opaqueredirect'
|
if (!resp.ok) {
|
||||||
|| (resp.status >= 200 && resp.status < 400);
|
|
||||||
if (!ok) {
|
|
||||||
flashError(`send failed: http ${resp.status}`);
|
flashError(`send failed: http ${resp.status}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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:#}"));
|
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(
|
async fn post_request_spawn(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue