Pithos: the update button applies the new version without a restart

On a Theseus that can apply an extension in place, the footer's update
downloads the new version and reloads Pithos on it straight away. Older
Theseus versions still offer Restart to apply.
This commit is contained in:
Local Dev 2026-10-04 15:28:26 +02:00
parent f59dced33a
commit c6c7615ae3
2 changed files with 13 additions and 1 deletions

View file

@ -131,6 +131,12 @@ module.exports = {
// Theseus asks the user before restarting. Older Theseus builds lack
// these hooks; the panel then points to Settings > Extensions.
api.onMessage("update", async ({ step = "stage" } = {}) => {
// In place, no restart (Theseus 0.3.77+): Theseus swaps the new version in,
// restarts the add-on and reloads this panel.
if (step === "apply-now") {
if (typeof api.applySelfUpdate !== "function") return { ok: false, reason: "needs a restart" };
return await api.applySelfUpdate();
}
if (step === "apply") {
if (typeof api.restartApp !== "function") return { fallback: "settings" };
return await api.restartApp();
@ -138,7 +144,7 @@ module.exports = {
if (typeof api.checkAndStageSelfUpdate !== "function") return { fallback: "settings" };
const r = await api.checkAndStageSelfUpdate();
const staged = r?.status === "staged" || r?.status === "already-staged";
return { staged, status: r?.status || "unknown", detail: r?.detail || null, current: r?.current || null, next: r?.next || null };
return { staged, status: r?.status || "unknown", detail: r?.detail || null, current: r?.current || null, next: r?.next || null, inPlace: typeof api.applySelfUpdate === "function" };
});
api.onMessage("open-settings", ({ section = "" } = {}) => { api.openSettings?.(String(section)); return { ok: true }; });

View file

@ -2482,6 +2482,12 @@ function setupFooter() {
return r?.status === 'up-to-date' ? flash('✓ Up to date', 'ok', '') : flash('⚠ Update failed', 'err', r?.detail || r?.status || '');
}
const next = r.next ? ` v${r.next}` : '';
// Newer Theseus applies it in place: the panel reloads on the new version.
if (r.inPlace) {
showChip(`Updating to${next}…`, 'wait', 'Pithos reloads on the new version in a moment', null);
const a = await bridge.invoke('update', { step: 'apply-now' }).catch(() => null);
if (a?.ok) return;
}
showChip(`↻ Restart to apply${next}`, '', `Pithos${next} is ready. Theseus restarts to apply it and reopens your tabs.`, async () => {
try {
const a = await bridge.invoke('update', { step: 'apply' });