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(assets): refresh the wallpaper cache hashes, and gate them

Abdurrahman Fakhrul575e7ee5b5bb
diff --git a/.gitignore b/.gitignore
index a219687e..a5909656 100644
--- a/.gitignore
+++ b/.gitignore
@@ -55,3 +55,10 @@ __pycache__/
# Isolated fake HOME for tenancy regression tests; never stage generated state.
.tenant-test-home/
+
+# lib/forge/forge.test.ts creates its fixture with mkdtemp(process.cwd(), ".mso-forge-test-"),
+# inside the repo on purpose: the Docker sandbox bind-mounts the project by realpath, and a
+# /tmp path is a different filesystem here. A suite killed by SIGPIPE (piped through `head`)
+# never reaches afterEach, so the dir survives — as an untracked change that blocks
+# scripts/pr-preflight.sh. Ignoring the pattern keeps that from looking like a real file.
+.mso-forge-test-*/
diff --git a/app/globals.css b/app/globals.css
index 9fd682ff..cae95b1e 100644
--- a/app/globals.css
+++ b/app/globals.css
@@ -245,12 +245,12 @@ body {
ShellDescriptor.wallpaper; a per-shell override or custom image wins. graphite
(Dashboard) stays a pure gradient — a photo backdrop fights data widgets. */
.wp-aurora { background:
- url("/wallpapers/aurora.webp?v=933abb0485f5") center/cover no-repeat,
+ url("/wallpapers/aurora.webp?v=ad083c6c2ccb") center/cover no-repeat,
radial-gradient(110% 120% at 16% 16%, #f4d6a0 0%, rgba(244,214,160,0) 46%),
radial-gradient(110% 110% at 82% 18%, #f2eee9 0%, rgba(242,238,233,0) 44%),
linear-gradient(145deg, #d3c5bd 0%, #d9dce7 56%, #b7c8dc 100%); }
[data-theme="dark"] .wp-aurora { background:
- url("/wallpapers/aurora-dark.webp?v=8b6e434e3409") center/cover no-repeat,
+ url("/wallpapers/aurora-dark.webp?v=b24824de9799") center/cover no-repeat,
radial-gradient(110% 120% at 18% 14%, #30386f 0%, rgba(48,56,111,0) 46%),
radial-gradient(110% 110% at 84% 20%, #263d67 0%, rgba(38,61,103,0) 44%),
linear-gradient(145deg, #161629 0%, #10152c 58%, #0b1223 100%); }
diff --git a/app/hashed-asset-urls.test.ts b/app/hashed-asset-urls.test.ts
new file mode 100644
index 00000000..305c4137
--- /dev/null
+++ b/app/hashed-asset-urls.test.ts
@@ -0,0 +1,38 @@
+import { createHash } from "node:crypto";
+import { existsSync, readFileSync } from "node:fs";
+import path from "node:path";
+import { describe, expect, it } from "vitest";
+
+// Wallpaper URLs carry a content hash: `url("/wallpapers/aurora.webp?v=ad083c6c2ccb")`, and
+// next.config.mjs serves /wallpapers/* as `immutable` for a year. That combination means a wrong
+// hash is not a cosmetic mistake — clients that already cached the old URL never re-fetch, so a
+// re-encoded image stays invisible to them for twelve months.
+//
+// app/wallpaper-cache.test.ts checks the two default wallpapers. This one checks EVERY hashed
+// asset URL in the stylesheet, so a future re-encode of any of them is caught the same way.
+// It exists because the hash did go stale: commit a7933d94 re-encoded five wallpapers and left
+// globals.css pointing at the previous bytes, and nothing failed.
+
+const CSS = path.resolve(__dirname, "globals.css");
+
+describe("hashed asset URLs in globals.css", () => {
+ const css = readFileSync(CSS, "utf8");
+ const hashed = [...css.matchAll(/url\("(\/[^"?]+)\?v=([0-9a-f]{8,64})"\)/g)].map((m) => ({ url: m[1], hash: m[2] }));
+
+ it("finds the hashed URLs it is meant to guard", () => {
+ // If someone removes the ?v= scheme, this suite must fail loudly rather than silently
+ // checking nothing.
+ expect(hashed.length, "expected at least one ?v= asset URL in globals.css").toBeGreaterThan(0);
+ });
+
+ it.each(hashed.map((h) => [h.url, h.hash] as const))("%s?v matches the file on disk", (url, hash) => {
+ const file = path.resolve(__dirname, "..", "public", url.replace(/^\//, ""));
+ expect(existsSync(file), `${url} is referenced from globals.css but does not exist`).toBe(true);
+ const digest = createHash("sha256").update(readFileSync(file)).digest("hex");
+ expect(
+ digest.startsWith(hash),
+ `${url} carries ?v=${hash} but its sha256 is ${digest.slice(0, 12)}. Re-encoding the asset ` +
+ `requires updating the hash, or clients with the old URL cached will never fetch the new bytes.`,
+ ).toBe(true);
+ });
+});