Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

fix(update): report latest builds without systemd

Rahman626cf905ff2d
diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md
index 940f22bd..dbc230a1 100644
--- a/docs/PROGRESS.md
+++ b/docs/PROGRESS.md
@@ -1,3 +1,15 @@
+## 2026-09-13 — About version detection without systemd
+
+An installation on a non-systemd host was thirteen commits behind origin/main, but
+Settings returned an empty status before querying Git and then labeled it Up to date.
+Read-only version discovery now runs independently of automatic-restart eligibility:
+running, checkout and latest fetched SHAs remain visible, while unsafe restart actions
+stay blocked with the supported terminal update path. A failed fetch is not Current;
+HTTP/auth/network errors leave a visible retry panel instead of disappearing. Overview
+also has a direct software-update action. No version number is fabricated when new
+commits ship under the same application/CLI semver. Detached installs still refuse
+mutation, while reporting the actual available changes for recovery.
+
## 2026-09-13 — README MCP entry point and practical how-to
Before: the product README linked general docs, while MCP onboarding was spread across
diff --git a/frontend/slices/os-settings/components/about-section.tsx b/frontend/slices/os-settings/components/about-section.tsx
index 3657c132..2263d362 100644
--- a/frontend/slices/os-settings/components/about-section.tsx
+++ b/frontend/slices/os-settings/components/about-section.tsx
@@ -136,6 +136,7 @@ export function AboutSection() {
{rows.map(([key, value]) => (
<SettingsValueRow key={key} label={key} value={value} />
))}
+ <SettingsActionRow label="Check software updates" icon={<Info />} onClick={() => setTab("update")} />
</SettingsSection>
)}
diff --git a/frontend/slices/os-settings/components/update-section.tsx b/frontend/slices/os-settings/components/update-section.tsx
index 4b626fd1..f679fe7c 100644
--- a/frontend/slices/os-settings/components/update-section.tsx
+++ b/frontend/slices/os-settings/components/update-section.tsx
@@ -8,20 +8,12 @@ import { SettingsActionRow, SettingsSection } from "@/features/shell-settings";
import { IS_DEMO } from "@/lib/demo";
import type { UpdateStatus } from "@/lib/host/self-update";
import { UpdateNotes } from "./update-notes";
-import { UpdateStatusCard, UpdateStatusSkeleton } from "./update-status-card";
+import { UpdateStatusCard, UpdateStatusSkeleton, UpdateStatusUnavailable } from "./update-status-card";
+import { readStatus } from "./update-status-client";
-// Settings → About → Update. The public route only starts the user-scoped updater;
-// the updater itself proves the candidate build before the running service is replaced.
const POLL_MS = 3_000;
const OK_MARKER = "UPDATE OK";
-async function readStatus(check: boolean): Promise<UpdateStatus | null> {
- const res = await fetch(`/api/v1/sys/update${check ? "" : "?check=0"}`, {
- cache: "no-store",
- });
- return res.ok ? ((await res.json()) as UpdateStatus) : null;
-}
-
export function UpdateSection() {
const [info, setInfo] = useState<UpdateStatus | null>(null);
const [checking, setChecking] = useState(true);
@@ -32,8 +24,12 @@ export function UpdateSection() {
const postRunRemoteCheck = useRef(false);
const refresh = useCallback(async (check: boolean) => {
- const next = await readStatus(check).catch(() => null);
+ const next = await readStatus(check).catch((cause: unknown) => {
+ setError(cause instanceof Error ? cause.message : "Could not reach the host. Try again.");
+ return null;
+ });
if (next) {
+ setError(null);
setInfo(next);
if (next.running) setSawRunning(true);
}
@@ -44,7 +40,10 @@ export function UpdateSection() {
if (IS_DEMO) return;
let alive = true;
readStatus(true)
- .catch(() => null)
+ .catch((cause: unknown) => {
+ if (alive) setError(cause instanceof Error ? cause.message : "Could not reach the host. Try again.");
+ return null;
+ })
.then((next) => {
if (!alive) return;
if (next) {
@@ -92,7 +91,17 @@ export function UpdateSection() {
}
};
- if (IS_DEMO || (!info && !checking)) return null;
+ if (IS_DEMO) return null;
+ if (!info && !checking) {
+ return (
+ <SettingsSection icon={<ArrowDownToLine />} title="Software update">
+ <UpdateStatusUnavailable error={error} onRetry={() => {
+ setChecking(true);
+ void refresh(true).finally(() => setChecking(false));
+ }} />
+ </SettingsSection>
+ );
+ }
if (!info && checking) {
return (
<SettingsSection
@@ -148,7 +157,7 @@ export function UpdateSection() {
onClick={() => void start(false)}
/>
)}
- {info.supported !== false && (
+ {(
<SettingsActionRow
label="Release notes and docs"
icon={<BookOpen />}
@@ -162,7 +171,7 @@ export function UpdateSection() {
}
/>
)}
- {info.supported !== false && !running && (
+ {!running && (
<SettingsActionRow
label="Check again"
icon={<Search />}
diff --git a/frontend/slices/os-settings/components/update-status-card.tsx b/frontend/slices/os-settings/components/update-status-card.tsx
index bcaef0fb..faadb12e 100644
--- a/frontend/slices/os-settings/components/update-status-card.tsx
+++ b/frontend/slices/os-settings/components/update-status-card.tsx
@@ -25,6 +25,17 @@ export function UpdateStatusSkeleton() {
);
}
+export function UpdateStatusUnavailable({ error, onRetry }: { error: string | null; onRetry: () => void }) {
+ return (
+ <SettingsBlock className="space-y-3 p-4">
+ <p role="alert" className="text-sm text-destructive-text">
+ {error ?? "Update status is unavailable. Try again."}
+ </p>
+ <Button type="button" variant="outline" onClick={onRetry}>Try again</Button>
+ </SettingsBlock>
+ );
+}
+
export function UpdateStatusCard({
info,
checking,
@@ -69,7 +80,9 @@ export function UpdateStatusCard({
? `${behind} update${behind > 1 ? "s" : ""} available`
: pending
? "A build is pending"
- : "Up to date";
+ : !info.remoteChecked || error
+ ? "Update status not verified"
+ : "Up to date";
const stateLabel = running
? "Running"
@@ -81,7 +94,9 @@ export function UpdateStatusCard({
? "Build required"
: behind > 0
? "Available"
- : "Current";
+ : !info.remoteChecked || error
+ ? "Not verified"
+ : "Current";
return (
<SettingsBlock className="space-y-3 p-4">
@@ -89,7 +104,10 @@ export function UpdateStatusCard({
<div className="min-w-0 space-y-1">
<p className="text-sm font-medium text-foreground">{headline}</p>
<p className="font-mono text-[11px] text-muted-foreground">
- running {info.buildSha || info.current || "—"}
+ Running {info.buildSha || "unknown"} · Checkout {info.current || "unknown"}
+ </p>
+ <p className="font-mono text-[11px] text-muted-foreground">
+ {info.remoteChecked ? "Latest" : "Last fetched"} {info.latest || "not checked"}
</p>
</div>
<span className="w-fit shrink-0 rounded-full border border-border/70 bg-secondary px-2 py-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground">
@@ -121,7 +139,7 @@ export function UpdateStatusCard({
update is blocked until it is pushed or reconciled.
</p>
)}
- {info.supported !== false && !info.remoteChecked && !running && (
+ {!info.remoteChecked && !running && (
<p className="text-[11px] leading-relaxed text-amber-500">
Could not reach the remote — this is what was last fetched, not
necessarily what is on main now.
diff --git a/frontend/slices/os-settings/components/update-status-client.ts b/frontend/slices/os-settings/components/update-status-client.ts
new file mode 100644
index 00000000..f05754ca
--- /dev/null
+++ b/frontend/slices/os-settings/components/update-status-client.ts
@@ -0,0 +1,13 @@
+import type { UpdateStatus } from "@/lib/host/self-update";
+
+export async function readStatus(check: boolean): Promise<UpdateStatus> {
+ const res = await fetch(`/api/v1/sys/update${check ? "" : "?check=0"}`, {
+ cache: "no-store",
+ signal: AbortSignal.timeout(55_000),
+ });
+ if (!res.ok) throw new Error(res.status === 401 || res.status === 403
+ ? "Sign in as an Owner to check software updates."
+ : `Could not read update status (HTTP ${res.status}). Try again.`);
+ return (await res.json()) as UpdateStatus;
+}
+
diff --git a/lib/host/self-update-status.test.ts b/lib/host/self-update-status.test.ts
new file mode 100644
index 00000000..0e8d9ede
--- /dev/null
+++ b/lib/host/self-update-status.test.ts
@@ -0,0 +1,52 @@
+import { beforeEach, describe, expect, it, vi } from "vitest";
+
+const fixture = vi.hoisted(() => ({ branch: "main", fetchFails: false, noGit: false, behind: 13 }));
+vi.mock("server-only", () => ({}));
+vi.mock("node:fs", () => ({ promises: { readFile: vi.fn(async () => "") } }));
+vi.mock("node:child_process", () => ({
+ execFile: vi.fn((command: string, args: string[], _options: unknown, done: (error: { code: number } | null, stdout: string, stderr: string) => void) => {
+ let output = "", code = 0;
+ const key = args.join(" ");
+ if (command !== "git") code = 1; // This real deployment has no systemd manager.
+ else if (key === "rev-parse --is-inside-work-tree") { output = "true"; code = fixture.noGit ? 1 : 0; }
+ else if (key === "branch --show-current") output = fixture.branch;
+ else if (key === "rev-parse --short HEAD") output = "16860d9";
+ else if (key === "rev-parse --short origin/main") output = "7cffd11";
+ else if (args[0] === "fetch") code = fixture.fetchFails ? 1 : 0;
+ else if (args[0] === "rev-list") output = `0\t${fixture.behind}`;
+ else if (key === "log -1 --format=%s") output = "installed build";
+ else if (args[0] === "log" && fixture.behind) output = "7cffd11\x1flatest update\x1f2026-09-12";
+ done(code ? { code } : null, output, "");
+ }),
+}));
+
+const { getUpdateStatus, blockingReason } = await import("./self-update");
+beforeEach(() => { fixture.branch = "main"; fixture.fetchFails = false; fixture.noGit = false; fixture.behind = 13; });
+
+describe("version discovery independent of restart support", () => {
+ it("reports incoming commits on a host without systemd rather than a false current status", async () => {
+ const result = await getUpdateStatus(true);
+ expect(result).toMatchObject({ current: "16860d9", latest: "7cffd11", behind: 13, remoteChecked: true, supported: false });
+ expect(result.reason).toContain("mso update");
+ expect(result.commits).toHaveLength(1);
+ expect(blockingReason(result, false)).toBe(result.reason);
+ });
+ it("still reports available versions on detached HEAD but refuses mutation", async () => {
+ fixture.branch = "";
+ const result = await getUpdateStatus(true);
+ expect(result).toMatchObject({ behind: 13, remoteChecked: true, supported: false });
+ expect(result.reason).toContain("detached HEAD");
+ });
+ it("does not claim a failed fetch was verified", async () => {
+ fixture.fetchFails = true;
+ fixture.behind = 0;
+ expect(await getUpdateStatus(true)).toMatchObject({ behind: 0, remoteChecked: false, supported: false });
+ });
+ it("does not claim a cached-only poll checked the remote", async () => {
+ expect(await getUpdateStatus(false)).toMatchObject({ behind: 13, remoteChecked: false });
+ });
+ it("keeps an archive deployment explicitly unknown", async () => {
+ fixture.noGit = true;
+ expect(await getUpdateStatus(true)).toMatchObject({ current: "unknown", remoteChecked: false, supported: false });
+ });
+});
diff --git a/lib/host/self-update.ts b/lib/host/self-update.ts
index 55a35963..2e416183 100644
--- a/lib/host/self-update.ts
+++ b/lib/host/self-update.ts
@@ -43,6 +43,8 @@ export interface UpdateStatus {
/** HEAD of the CHECKOUT — what a rebuild would compile. */
current: string;
currentSubject: string;
+ /** Latest fetched origin/main commit, independent of restart support. */
+ latest?: string;
/** The commit the RUNNING build was compiled from (baked in by next.config), or
* "" when the build carried no .git. Differs from `current` whenever someone
* pulled without rebuilding — the state the panel calls "a build is pending". */
@@ -170,6 +172,41 @@ async function readLog(): Promise<string> {
return raw.length > LOG_TAIL ? raw.slice(-LOG_TAIL) : raw;
}
+/** Restart authority must never suppress read-only version discovery. */
+async function automaticUpdateReason(): Promise<string | null> {
+ const branch = await git(["branch", "--show-current"]);
+ const branchReason = updateBranchReason(branch.stdout);
+ if (branch.code !== 0 || branchReason) {
+ return branch.code === 0 ? branchReason : "could not determine the checkout branch";
+ }
+
+ // The installer enables linger and gives mso.service XDG_RUNTIME_DIR precisely
+ // so the service can reach this per-user manager. Unlike the old sudo path, this
+ // is both non-interactive and non-root.
+ const userManager = await run("systemctl", ["--user", "show-environment"], 10_000);
+ if (userManager.code !== 0) {
+ return "Automatic restart is unavailable on this host. Run mso update from a terminal; version checks still work.";
+ }
+
+ const [loadState, serviceUser, restartPolicy] = await Promise.all([
+ run("systemctl", ["show", "-p", "LoadState", "--value", "mso.service"], 10_000),
+ run("systemctl", ["show", "-p", "User", "--value", "mso.service"], 10_000),
+ run("systemctl", ["show", "-p", "Restart", "--value", "mso.service"], 10_000),
+ ]);
+ if (loadState.code !== 0 || loadState.stdout.trim() !== "loaded") {
+ return "mso.service is not installed; run mso update from a terminal for this host.";
+ }
+ if (restartPolicy.code !== 0 || restartPolicy.stdout.trim() === "no") {
+ return "mso.service has no automatic restart policy; refusing to stop the running process during self-update";
+ }
+ const owner = os.userInfo().username;
+ if (serviceUser.code !== 0 || serviceUser.stdout.trim() !== owner) {
+ return `mso.service runs as ${serviceUser.stdout.trim() || "an unknown user"}, not ${owner}; refusing a cross-user update`;
+ }
+
+ return null;
+}
+
/**
* @param fetchRemote when true, ask the remote first. A check costs a network
* round trip, so the panel asks for one and the poller during an update does not.
@@ -200,46 +237,6 @@ export async function getUpdateStatus(fetchRemote = true): Promise<UpdateStatus>
return { ...base, reason: "this deployment is not a git checkout, so there is nothing to pull" };
}
- const branch = await git(["branch", "--show-current"]);
- const branchReason = updateBranchReason(branch.stdout);
- if (branch.code !== 0 || branchReason) {
- return { ...base, reason: branch.code === 0 ? branchReason : "could not determine the checkout branch" };
- }
-
- // The installer enables linger and gives mso.service XDG_RUNTIME_DIR precisely
- // so the service can reach this per-user manager. Unlike the old sudo path, this
- // is both non-interactive and non-root.
- const userManager = await run("systemctl", ["--user", "show-environment"], 10_000);
- if (userManager.code !== 0) {
- return {
- ...base,
- reason:
- "the per-user systemd manager is unavailable — re-run scripts/install.sh once to restore linger and the user bus",
- };
- }
-
- const [loadState, serviceUser, restartPolicy] = await Promise.all([
- run("systemctl", ["show", "-p", "LoadState", "--value", "mso.service"], 10_000),
- run("systemctl", ["show", "-p", "User", "--value", "mso.service"], 10_000),
- run("systemctl", ["show", "-p", "Restart", "--value", "mso.service"], 10_000),
- ]);
- if (loadState.code !== 0 || loadState.stdout.trim() !== "loaded") {
- return { ...base, reason: "mso.service is not installed as a systemd service, so it cannot safely restart itself" };
- }
- if (restartPolicy.code !== 0 || restartPolicy.stdout.trim() === "no") {
- return {
- ...base,
- reason: "mso.service has no automatic restart policy; refusing to stop the running process during self-update",
- };
- }
- const owner = os.userInfo().username;
- if (serviceUser.code !== 0 || serviceUser.stdout.trim() !== owner) {
- return {
- ...base,
- reason: `mso.service runs as ${serviceUser.stdout.trim() || "an unknown user"}, not ${owner}; refusing a cross-user update`,
- };
- }
-
const running = await isRunning();
const [head, subject, status] = await Promise.all([
git(["rev-parse", "--short", "HEAD"]),
@@ -255,29 +252,33 @@ export async function getUpdateStatus(fetchRemote = true): Promise<UpdateStatus>
remoteChecked = fetched.code === 0;
}
- const [relationCount, commitLog] = await Promise.all([
+ const [relationCount, commitLog, latest] = await Promise.all([
git(["rev-list", "--left-right", "--count", "HEAD...origin/main"]),
git(["log", "--format=%h%x1f%s%x1f%cs", `-${MAX_COMMITS}`, "HEAD..origin/main"]),
+ git(["rev-parse", "--short", "origin/main"]),
]);
const [aheadRaw = "0", behindRaw = "0"] = relationCount.stdout.trim().split(/\s+/);
const ahead = relationCount.code === 0 ? Number(aheadRaw) || 0 : 0;
const behind = relationCount.code === 0 ? Number(behindRaw) || 0 : 0;
const current = head.stdout.trim() || "unknown";
+ const reason = await automaticUpdateReason();
return {
...base,
- supported: true,
+ supported: reason === null,
+ reason,
current,
+ latest: latest.code === 0 ? latest.stdout.trim() : "",
currentSubject: subject.stdout.trim(),
// Only when we know both: a build with no sha baked in (an archive export, a
// dev server) must not be reported as permanently stale.
- pendingBuild: Boolean(buildSha) && current !== "unknown" && buildSha !== current,
+ pendingBuild: Boolean(buildSha) && current !== "unknown" && !buildSha.startsWith(current) && !current.startsWith(buildSha),
ahead,
behind,
commits: commitLog.code === 0 ? parseCommits(commitLog.stdout) : [],
dirty: status.stdout.trim().length > 0,
running,
- remoteChecked,
+ remoteChecked: remoteChecked && relationCount.code === 0 && latest.code === 0,
log,
};
}
diff --git a/scripts/mso-about-update-visibility.test.ts b/scripts/mso-about-update-visibility.test.ts
new file mode 100644
index 00000000..b382c9e5
--- /dev/null
+++ b/scripts/mso-about-update-visibility.test.ts
@@ -0,0 +1,26 @@
+import { readFileSync } from "node:fs";
+import { describe, expect, it } from "vitest";
+const read = (name: string) => readFileSync(`frontend/slices/os-settings/components/${name}.tsx`, "utf8");
+describe("About update visibility contract", () => {
+ it("offers a software update action from Overview", () => {
+ expect(read("about-section")).toContain('label="Check software updates"');
+ });
+ it("does not disappear on authentication/network failure", () => {
+ const source = read("update-section");
+ expect(source).not.toContain('IS_DEMO || (!info && !checking)');
+ expect(read("update-status-card")).toContain('role="alert"');
+ expect(read("update-status-card")).toContain('>Try again</Button>');
+ expect(readFileSync("frontend/slices/os-settings/components/update-status-client.ts", "utf8")).toContain('res.status === 401 || res.status === 403');
+ });
+ it("keeps version checks available even without a restart manager", () => {
+ expect(read("update-section")).toContain('{!running && (');
+ expect(read("update-section")).not.toContain('{info.supported !== false && !running && (');
+ });
+ it("distinguishes running/checkout/upstream identity and unknown freshness", () => {
+ const source = read("update-status-card");
+ expect(source).toContain('!info.remoteChecked || error');
+ expect(source).toContain('Update status not verified');
+ expect(source).toContain('Checkout {info.current');
+ expect(source).toContain('info.latest || "not checked"');
+ });
+});