feat(updates): auto-apply and self-restart on new dashboard versions

Adds POST /api/updates/apply (pull, rebuild, restart) plus an "Update now"
button and hourly auto-check in the UI, for checkouts that are safely
fast-forwardable. Reintroduces self-restart (previously removed in edc25ca
for cross-environment reliability concerns) per explicit user request.
This commit is contained in:
2026-08-18 16:04:27 +07:00
parent f053051a5d
commit 8e49d2b300
15 changed files with 502 additions and 19 deletions
+17
View File
@@ -557,6 +557,23 @@ export const api = {
method: "POST",
body: JSON.stringify({}),
}),
/**
* POST /api/updates/apply - fast-forward, rebuild, and restart.
*
* Only acts when the checkout is fast-forwardable (`tracking_canonical`
* or `fork_or_diverged_tracking`); a 409 response means it declined
* (`applied: false`, `reason` explains why). On success the server
* restarts itself right after responding, so the caller should poll
* `status()` until it answers again rather than expect the connection
* to outlive the call.
*
* @returns {@link UpdateStatusPayload} with `applied` set.
*/
apply: () =>
request<UpdateStatusPayload>("/updates/apply", {
method: "POST",
body: JSON.stringify({}),
}),
},
// ──────────────────────────────── Stats API ────────────────────────────────
+8
View File
@@ -1275,6 +1275,14 @@ export interface UpdateStatusPayload {
/** Set instead of a normal result when the remote fetch itself failed
* (e.g. offline) - the message text explains it in user-facing terms. */
fetch_error?: string;
/** Present only on the response from `POST /api/updates/apply` - true once
* the checkout was fast-forwarded and rebuilt (the process is about to
* restart itself). Absent from `status`/`check` responses. */
applied?: boolean;
/** Set alongside `applied: false` on an `/apply` response that declined to
* act - `"up_to_date"` or `"not_fast_forwardable"` (feature branch /
* detached HEAD, where there's no safe automatic move). */
reason?: "up_to_date" | "not_fast_forwardable";
}
// ───── Terminal run status ─────