Add start-after-update options and clarify the always-max-skills setting

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ДмитрийandClaude Sonnet 5.5 committed 2026-10-08 07:11:08 +05:00
1 parent 017b977bfa
commit 0a050a40a2
18 files changed
+72 -6

No files matched your search

+2
View File
@@ -1,3 +1,4 @@
import { startAfterUpdate } from "./updatePrefs";
import { useSyncExternalStore } from "react";
import { listen } from "@tauri-apps/api/event";
import { api, asUiError, type ClientPlan, type ClientStep, type UiError } from "@/lib/api";
@@ -85,6 +86,7 @@ export async function syncClient(id: string, keepModified: boolean): Promise<voi
try {
await api.clientSync(id, keepModified);
set(id, { phase: "done", step: null });
if (startAfterUpdate("client", id)) void api.play(id).catch(() => undefined);
void refresh(id);
setTimeout(() => {
if (get(id).phase === "done") set(id, { phase: "idle" });
+3
View File
@@ -2,6 +2,7 @@ import { useSyncExternalStore } from "react";
import { listen } from "@tauri-apps/api/event";
import { api, asUiError, type UiError, type UpdatePreview, type UpdateTxn } from "@/lib/api";
import { isUpdateCurrent } from "./serverUpdateStatus";
import { startAfterUpdate } from "./updatePrefs";
/**
* Server update status for the main screen and the navigation: checked when the app starts and every five minutes,
@@ -95,6 +96,8 @@ export async function applyServerUpdate(id: string, opts?: { choices: Record<str
try {
const out = await api.applyUpdate(id, opts?.choices ?? {}, opts?.source);
set(id, { result: out.txn.state === "committed" ? { committed: out.txn.to_version ?? "" } : { pending: out.txn } });
// The update proved the new build starts and left it running; the owner may prefer it stopped again.
if (out.txn.state === "committed" && !startAfterUpdate("server", id)) await api.stop(id).catch(() => undefined);
return true;
} catch (e) {
const ui = asUiError(e);
+28
View File
@@ -0,0 +1,28 @@
import { useState } from "react";
/**
* What to do when an update has finished: leave the server running (the default, as the update proves the new build
* starts) or stop it again, and whether to open the game after a client update (off by default).
*/
export type AfterUpdate = "server" | "client";
const key = (kind: AfterUpdate, id: string) => `coa-start-after-${kind}-update:${id}`;
const fallback = (kind: AfterUpdate) => kind === "server";
export function startAfterUpdate(kind: AfterUpdate, id: string): boolean {
try {
const value = localStorage.getItem(key(kind, id));
return value === null ? fallback(kind) : value === "1";
} catch {
return fallback(kind);
}
}
export function setStartAfterUpdate(kind: AfterUpdate, id: string, on: boolean) {
try { localStorage.setItem(key(kind, id), on ? "1" : "0"); } catch { /* storage unavailable: the default applies */ }
}
export function useStartAfterUpdate(kind: AfterUpdate, id: string): [boolean, (on: boolean) => void] {
const [on, setOn] = useState(() => startAfterUpdate(kind, id));
return [on, (next) => { setStartAfterUpdate(kind, id, next); setOn(next); }];
}