feat(app): update the app from the project's Gitea releases

- update.rs finds the newest app-v<version> release above the running
  version (v1 tags, drafts, prereleases, incomplete releases and files on
  another server are skipped), downloads Jarvis-Setup-<version>.exe into
  cache/updates checked against its .sha256, and hands it over.
- update_install hashes the file again, stops what runs, starts the
  installer with /S /RUN as administrator and the window quits; a declined
  administrator prompt keeps the app with the services stopped.
- New 업데이트 screen; the app checks once when the main screens open.
- tauri.conf.json no longer sets its own version, so the program file
  carries the Cargo.toml version the update compares.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-14 11:52:49 +09:00
parent b4ea9a6af4
commit 511791f39b
9 changed files with 599 additions and 7 deletions

View File

@@ -545,6 +545,50 @@ function logsScreen() {
return { view, tick: poll };
}
// ---- update -------------------------------------------------------------------------------------
/** The update screen: the version here, the newest release, its download and install. */
function updateScreen() {
const body = h("div");
let key = null;
async function tick() {
let u;
try { u = await api("update_status"); } catch (e) { return; }
const k = JSON.stringify([u.phase, u.latest?.version, u.error, u.phase === "downloading" ? u.done : 0]);
if (k === key) return;
key = k;
const act = (cmd, text, primary) => h("button", { class: "btn" + (primary ? " primary" : ""), onclick: async (e) => {
e.target.disabled = true;
try { await api(cmd); } catch (err) { fail(err); }
key = null; tick();
} }, text);
const pct = u.total ? Math.floor((u.done / u.total) * 100) : null;
const line = { idle: "아직 확인하지 않았습니다", checking: "확인하는 중…", upToDate: "최신 버전입니다",
available: `새 버전 ${u.latest?.version}이 있습니다`, downloading: `받는 중${pct != null ? ` ${pct}%` : ""}`,
ready: `${u.latest?.version}을 설치할 준비가 됐습니다`, failed: u.error ?? "실패했습니다" }[u.phase] ?? u.phase;
body.replaceChildren(h("div", { class: "card" },
h("div", { class: "kv" }, h("span", { class: "k" }, "현재 버전"), h("span", {}, u.current),
h("span", { class: "k" }, "상태"), h("span", { style: u.phase === "failed" ? "color:var(--bad)" : "" }, line)),
h("div", { class: "row", style: "margin-top:12px" },
u.phase !== "checking" && u.phase !== "downloading" ? act("update_check", "다시 확인") : null,
(u.phase === "available" || (u.phase === "failed" && u.latest)) ? act("update_download", "받기", true) : null,
u.phase === "ready" ? act("update_install", "설치하고 다시 시작", true) : null),
u.phase === "ready" ? h("p", { class: "small muted" }, "설치하면 봇과 서비스를 멈추고 Jarvis를 닫은 뒤 새 버전을 설치하고 다시 켭니다. Windows가 관리자 권한을 한 번 묻습니다.") : null),
u.latest?.notes ? h("div", { class: "card" }, h("h2", {}, `${u.latest.version} 바뀐 점`),
h("pre", { class: "small", style: "white-space:pre-wrap" }, u.latest.notes)) : null);
}
tick();
return { view: h("div", {}, h("h1", {}, "업데이트"), body), tick };
}
/** Look for a new version once when the app opens; the nav button says so when there is one. */
async function checkUpdate() {
try {
const u = await api("update_check");
if (u.latest) { $("#nav-update").textContent = "업데이트 (새 버전)"; toast(`새 버전 ${u.latest.version}이 있습니다. 업데이트 화면에서 설치할 수 있습니다.`); }
} catch (e) { /* offline: the update screen shows why */ }
}
// ---- navigation ---------------------------------------------------------------------------------
let current = null, ticker = null;
@@ -578,6 +622,7 @@ async function show(name) {
try {
if (name === "dashboard") { screen.replaceChildren(); await refresh(); ticker = setInterval(refresh, 1000); return; }
if (name === "logs") { const l = logsScreen(); screen.replaceChildren(l.view); ticker = setInterval(l.tick, 1000); return; }
if (name === "update") { const u = updateScreen(); screen.replaceChildren(u.view); ticker = setInterval(u.tick, 1000); return; }
const titles = { bot: "봇", channels: "채널·호출", chat: "채팅 채널", memory: "대화 기억", model: "모델", features: "기능",
collect: "백그라운드 수집", game: "게임 모드" };
const extra = name === "bot" ? await tokenCard() : name === "features" ? await displayDriverCard() : null;
@@ -755,6 +800,7 @@ async function start() {
$("#main").hidden = false;
for (const b of document.querySelectorAll(".nav")) b.onclick = () => show(b.dataset.screen);
show("dashboard");
checkUpdate();
}
// The window tells what closing does: stopping what runs first, or that it could not.
if (window.__TAURI__?.event) {

View File

@@ -21,6 +21,7 @@
<button data-screen="collect" class="nav">백그라운드 수집</button>
<button data-screen="game" class="nav">게임 모드</button>
<button data-screen="logs" class="nav">로그</button>
<button data-screen="update" class="nav" id="nav-update">업데이트</button>
<div class="side-foot" id="version"></div>
</nav>
<main id="screen" class="screen"></main>