Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions console/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<span class="status" id="poll-status"></span>
<button class="theme-btn" id="theme-btn" type="button" title="Appearance — click to cycle System / Light / Dark">System</button>
<button class="update-btn" id="update-btn" hidden>Check for updates</button>
<button class="update-dismiss" id="update-dismiss" type="button" hidden title="Keep the current build — check again later">Later</button>
</div>
</header>
<main class="content">
Expand Down
22 changes: 19 additions & 3 deletions console/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,13 +596,22 @@ interface UpdateInfo {
}
function setupUpdater(): void {
const el = document.getElementById("update-btn") as HTMLButtonElement | null;
const dismissEl = document.getElementById("update-dismiss") as HTMLButtonElement | null;
const invoke = tauriInvoke();
if (!el || !invoke) return; // browser build — no updater
el.hidden = false;
let pending: UpdateInfo | null = null;

// Finding an update must not force installing it (you may want to keep working
// or wait for a later nightly). The install button + this dismiss share the
// pending state; dismiss clears it back to "Check for updates".
const setPending = (info: UpdateInfo | null): void => {
pending = info;
if (dismissEl) dismissEl.hidden = info === null;
};

const reset = (): void => {
pending = null;
setPending(null);
el.textContent = "Check for updates";
el.classList.remove("has-update");
};
Expand All @@ -613,10 +622,10 @@ function setupUpdater(): void {
try {
const info = await inv<UpdateInfo | null>("check_update");
if (info) {
pending = info;
setPending(info);
btn.textContent = `Update to v${info.version} ↻`;
btn.classList.add("has-update");
note("info", `update: v${info.version} available (current v${info.current}) — click to install`);
note("info", `update: v${info.version} available (current v${info.current}) — click to install, or Later to keep this build`);
} else {
note("info", "update: already up to date");
btn.textContent = "Up to date";
Expand All @@ -633,17 +642,24 @@ function setupUpdater(): void {
async function install(btn: HTMLButtonElement, inv: Invoke): Promise<void> {
btn.disabled = true;
btn.textContent = "Installing…";
if (dismissEl) dismissEl.hidden = true;
try {
// On success the backend restarts the app, so this may never resolve.
await inv("install_update");
} catch (e) {
btn.disabled = false;
btn.textContent = pending ? `Update to v${pending.version} ↻` : "Check for updates";
if (dismissEl) dismissEl.hidden = pending === null;
note("error", `update: install failed — ${errText(e)}`);
}
}

el.addEventListener("click", () => void (pending ? install(el, invoke) : check(el, invoke)));
dismissEl?.addEventListener("click", () => {
const skipped = pending?.version;
reset();
if (skipped) note("info", `update: skipped v${skipped} — staying on the current build`);
});
}

// Live remote-connection status: the backend pushes `remote-status` events as the
Expand Down
16 changes: 16 additions & 0 deletions console/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,22 @@ body {
background: var(--s-starting);
border-color: var(--s-starting);
}
/* Skip an available update and keep the current build (shown only while an
update is pending) — so finding a nightly doesn't force installing it. */
.update-dismiss {
appearance: none;
border: 0;
background: transparent;
color: var(--muted);
font: inherit;
font-size: 12px;
padding: 3px 6px;
cursor: pointer;
text-decoration: underline;
}
.update-dismiss:hover {
color: var(--text);
}

/* Appearance toggle — cycles System / Light / Dark. Mirrors the update button;
fixed min-width so the label swap doesn't shift the toolbar. */
Expand Down
Loading