A local-first multi-agent app development platform, built on PenguinHarness
feat(desktop): Windows 安装器带上 Adelie 自己的侧栏与页眉图
lmlihengec49bdddc1c7
diff --git a/changelog/unreleased/2026-10-06-desktop-installer-artwork.md b/changelog/unreleased/2026-10-06-desktop-installer-artwork.mdnew file mode 100644index 00000000..2bfca9ee--- /dev/null+++ b/changelog/unreleased/2026-10-06-desktop-installer-artwork.md@@ -0,0 +1,31 @@+# Desktop: the Windows installer carries Adelie's own sidebar and header artwork++- **Date:** 2026-10-06+- **Type:** feature+- **Scope:** `desktop`++[中文版](2026-10-06-desktop-installer-artwork.zh.md)++The NSIS assisted installer draws two images, and neither of them was Adelie's: the welcome and+finish pages fell back to NSIS's own stock graphic (`${NSISDIR}/Contrib/Graphics/Wizard/nsis3-metro.bmp`)+and the inner pages' header bar stayed empty. Anyone installing Adelie on Windows therefore saw+NSIS's branding — a dated, low-resolution bitmap — around Adelie's name, and no brand of ours in the+header at all.++Both images are now rendered from the same immutable brand mark the app icon comes from+(`packages/web/public/adelie-icon.svg`): a navy sidebar with the mark, the wordmark and a short+tagline, and a light header chip with the mark and the wordmark. They are committed as 24-bit BMPs+under `packages/desktop/build/nsis/`, wired into `electron-builder.yml` (`nsis.installerSidebar`,+`nsis.installerHeader`; the uninstaller reuses the sidebar), and pinned by+`packages/desktop/test/installer-art.test.ts`.++## Desktop++- `scripts/render-installer-art.mjs` draws each image at its exact target size — 164×314 for the+ sidebar, 150×57 for the header — on a canvas and encodes the BMP itself (no image library, no+ downscaling). Both sizes and the 24-bit depth are NSIS's own requirements: a bitmap of any other+ size, or a 32-bit one, is ignored **in silence**, leaving the stock graphic and the blank header+ back in place. `test/installer-art.test.ts` reads the committed headers and fails on any+ drift, and also checks that the config still names those two files.+- Regenerating is manual (`node packages/desktop/scripts/render-installer-art.mjs`) and+ byte-reproducible; it needs the Playwright chromium the Web App's tests already install.diff --git a/changelog/unreleased/2026-10-06-desktop-installer-artwork.zh.md b/changelog/unreleased/2026-10-06-desktop-installer-artwork.zh.mdnew file mode 100644index 00000000..bb3a7eb5--- /dev/null+++ b/changelog/unreleased/2026-10-06-desktop-installer-artwork.zh.md@@ -0,0 +1,26 @@+# 桌面端:Windows 安装器带上 Adelie 自己的侧栏与页眉图++- **Date:** 2026-10-06+- **Type:** feature+- **Scope:** `desktop`++[English](2026-10-06-desktop-installer-artwork.md)++NSIS 的助式安装器要画两张图,而这两张原先都不是 Adelie 的:欢迎页与完成页的侧栏回落到 NSIS 自带的+`${NSISDIR}/Contrib/Graphics/Wizard/nsis3-metro.bmp`,内页的页眉栏则一片空白。于是在 Windows 上装+Adelie 的人,看到的是 NSIS 自己的品牌标识 —— 一张过时、分辨率不高的位图 —— 围着 Adelie 的名字,+而页眉上没有我们任何标识。++现在两张图都由应用图标那一份不可变品牌标记渲染(`packages/web/public/adelie-icon.svg`):深蓝侧栏带+标记、字标与一行小字,浅色页眉条带标记与字标。它们以 24 位 BMP 提交在+`packages/desktop/build/nsis/` 下,在 `electron-builder.yml` 里接线(`nsis.installerSidebar`、+`nsis.installerHeader`;卸载器复用侧栏),并由 `packages/desktop/test/installer-art.test.ts` 钉住。++## Desktop++- `scripts/render-installer-art.mjs` 按目标尺寸原样绘制 —— 侧栏 164×314、页眉 150×57 —— 画在 canvas+ 上,BMP 由脚本自己编码(不引图片库、不做缩放)。这两个尺寸与 24 位深度都是 NSIS 自己的要求:尺寸+ 不对、或 32 位的位图会被**静默忽略**,回落成自带图与空白页眉。`test/installer-art.test.ts` 读这两份+ 已提交的位图头,尺寸一有偏差就失败,同时校验配置里指的仍是这两个文件。+- 重新生成是手工步骤(`node packages/desktop/scripts/render-installer-art.mjs`),逐字节可复现;+ 它用的是 Web 包测试本来就装的 Playwright chromium。diff --git a/packages/desktop/build/nsis/installerHeader.bmp b/packages/desktop/build/nsis/installerHeader.bmpnew file mode 100644index 00000000..d0e75b9aBinary files /dev/null and b/packages/desktop/build/nsis/installerHeader.bmp differdiff --git a/packages/desktop/build/nsis/installerSidebar.bmp b/packages/desktop/build/nsis/installerSidebar.bmpnew file mode 100644index 00000000..0bb79858Binary files /dev/null and b/packages/desktop/build/nsis/installerSidebar.bmp differdiff --git a/packages/desktop/electron-builder.yml b/packages/desktop/electron-builder.ymlindex d494e944..8bbdb89e 100644--- a/packages/desktop/electron-builder.yml+++ b/packages/desktop/electron-builder.yml@@ -148,6 +148,16 @@ win:nsis:oneClick: falseallowToChangeInstallationDirectory: true+ # The installer's own artwork, instead of what NSIS draws without it: the welcome and finish+ # pages would carry NSIS's stock `${NSISDIR}/Contrib/Graphics/Wizard/nsis3-metro.bmp`, and the+ # inner pages would have a blank header bar. Both sizes are NSIS's fixed ones — 164×314 for the+ # sidebar, 150×57 for the header, at 24 bits per pixel — and a bitmap of any other size is+ # ignored in silence, which is why scripts/render-installer-art.mjs draws at exactly these+ # pixels and test/installer-art.test.ts pins the two files to them. Rendered from the brand+ # mark, so they change only when it does. The uninstaller reuses the sidebar+ # (uninstallerSidebar defaults to installerSidebar).+ installerSidebar: build/nsis/installerSidebar.bmp+ installerHeader: build/nsis/installerHeader.bmplinux:# Pre-rendered freedesktop icon set (scripts/render-icon.mjs): a directory of NxN.pngdiff --git a/packages/desktop/scripts/render-installer-art.mjs b/packages/desktop/scripts/render-installer-art.mjsnew file mode 100644index 00000000..4f912e16--- /dev/null+++ b/packages/desktop/scripts/render-installer-art.mjs@@ -0,0 +1,204 @@+/**+ * Render the Windows installer's own artwork from the brand mark.+ *+ * NSIS's assisted installer draws two images, and without ours it draws neither of Adelie's:+ * `installerSidebar` falls back to `${NSISDIR}/Contrib/Graphics/Wizard/nsis3-metro.bmp` (NSIS's+ * own stock graphic) and `installerHeader` is not drawn at all, leaving the header bar blank.+ * That is the whole of what a person sees while installing Adelie on Windows, so both are+ * rendered here instead — from `packages/web/public/adelie-icon.svg`, the same immutable mark+ * `render-icon.mjs` uses, in the product's own typeface.+ *+ * Outputs (COMMITTED — regenerate only when the mark or the wordmark changes):+ * - build/nsis/installerSidebar.bmp 164×314. The welcome and finish pages' left column+ * (MUI_WELCOMEFINISHPAGE_BITMAP; the uninstaller reuses+ * it, electron-builder's own default). NSIS requires+ * these exact pixels: any other size and the bitmap is+ * ignored.+ * - build/nsis/installerHeader.bmp 150×57. The right-hand header image of every inner+ * page (MUI_HEADERIMAGE_BITMAP; electron-builder also+ * sets MUI_HEADERIMAGE_RIGHT, so it sits at the right+ * edge and the page title stays on the left).+ *+ * Both are 24-bit BMPs: NSIS's MUI loads them through Windows and 32-bit ones are not accepted.+ *+ * Regenerate: node packages/desktop/scripts/render-installer-art.mjs+ * Rasterizes via the Playwright chromium the Web App's tests already install (no new dependency+ * for this package), draws at the exact target size — no downscaling, which is what "the+ * installer looks blurry" usually is — and encodes the BMP in this script (no image library).+ */+import { mkdirSync, readFileSync, writeFileSync } from "node:fs";+import { createRequire } from "node:module";+import path from "node:path";+import { fileURLToPath } from "node:url";++const HERE = path.dirname(fileURLToPath(import.meta.url));+const PKG_DIR = path.resolve(HERE, "..");+const REPO_ROOT = path.resolve(PKG_DIR, "..", "..");+const SVG_PATH = path.join(REPO_ROOT, "packages", "web", "public", "adelie-icon.svg");+const FONT_DIR = path.join(REPO_ROOT, "packages", "ui", "src", "fonts", "misans");+const OUT_DIR = path.join(PKG_DIR, "build", "nsis");++// Resolve @playwright/test from a package that already carries it (the Web App's own test+// dependency — it is not a dependency of this package, and must not become one).+const requireHost = createRequire(path.join(REPO_ROOT, "packages", "web", "package.json"));+const { chromium } = requireHost("@playwright/test");++/**+ * The two images, and how each is laid out. `draw` runs in the page against a canvas of exactly+ * `width`×`height`; everything is drawn at native resolution.+ */+const TARGETS = [+ {+ file: "installerSidebar.bmp",+ width: 164,+ height: 314,+ art: {+ background: ["#0b1220", "#1b2b4d"],+ markSize: 84,+ markY: 88,+ wordSize: 24,+ wordY: 226,+ tagline: "local-first agents",+ taglineY: 250,+ ruleY: 194,+ },+ },+ {+ file: "installerHeader.bmp",+ width: 150,+ height: 57,+ art: {+ background: ["#ffffff", "#eef3fc"],+ markSize: 30,+ markX: 12,+ markY: 13,+ wordSize: 16,+ wordX: 50,+ wordY: 29,+ },+ },+];++const svgDataUrl = `data:image/svg+xml;base64,${Buffer.from(readFileSync(SVG_PATH, "utf8"), "utf8").toString("base64")}`;+const fontDataUrl = (name) =>+ `data:font/woff2;base64,${readFileSync(path.join(FONT_DIR, name)).toString("base64")}`;++const browser = await chromium.launch();+try {+ const page = await browser.newPage();+ await page.setContent(+ `<style>+ @font-face { font-family: "MiSans"; font-weight: 400; src: url("${fontDataUrl("misans-400-latin.woff2")}") format("woff2"); }+ @font-face { font-family: "MiSans"; font-weight: 500; src: url("${fontDataUrl("misans-500-latin.woff2")}") format("woff2"); }+ </style>`,+ );+ // Wait for both faces before drawing: a canvas renders whatever the font is at draw time.+ await page.evaluate(() => document.fonts.ready);++ mkdirSync(OUT_DIR, { recursive: true });+ for (const target of TARGETS) {+ const pixels = await page.evaluate(drawArt, { svg: svgDataUrl, target });+ const bmp = encodeBmp(Buffer.from(pixels, "base64"), target.width, target.height);+ const out = path.join(OUT_DIR, target.file);+ writeFileSync(out, bmp);+ console.log(`${target.file} ${target.width}×${target.height} ${bmp.length} bytes`);+ }+} finally {+ await browser.close();+}++/**+ * Draw one image and hand its RGBA pixels back as base64. Runs inside the page.+ */+function drawArt({ svg, target }) {+ const { width, height, art } = target;+ const canvas = document.createElement("canvas");+ canvas.width = width;+ canvas.height = height;+ const ctx = canvas.getContext("2d");++ const gradient = ctx.createLinearGradient(0, 0, width, height);+ gradient.addColorStop(0, art.background[0]);+ gradient.addColorStop(1, art.background[1]);+ ctx.fillStyle = gradient;+ ctx.fillRect(0, 0, width, height);++ return new Promise((resolve) => {+ const img = new Image();+ img.onload = () => {+ const light = art.background[0] === "#ffffff";+ const ink = light ? "#0e1c37" : "#ffffff";+ const muted = light ? "#5b6b86" : "#9fb3d4";++ if (art.markX === undefined) {+ ctx.drawImage(img, (width - art.markSize) / 2, art.markY, art.markSize, art.markSize);+ } else {+ ctx.drawImage(img, art.markX, art.markY, art.markSize, art.markSize);+ }++ ctx.fillStyle = ink;+ ctx.textBaseline = "alphabetic";+ if (art.wordX === undefined) {+ ctx.textAlign = "center";+ // The wordmark, in the product's own typeface, sized to sit comfortably in the column.+ ctx.font = `500 ${art.wordSize}px MiSans, "DejaVu Sans", sans-serif`;+ ctx.fillText("Adelie", width / 2, art.wordY);+ // A short rule in the brand blue, then the tagline under it.+ ctx.fillStyle = "#015dfc";+ ctx.fillRect(width / 2 - 18, art.ruleY, 36, 3);+ ctx.fillStyle = muted;+ ctx.font = `400 11px MiSans, "DejaVu Sans", sans-serif`;+ ctx.fillText(art.tagline, width / 2, art.taglineY);+ } else {+ ctx.textAlign = "left";+ ctx.font = `500 ${art.wordSize}px MiSans, "DejaVu Sans", sans-serif`;+ ctx.fillText("Adelie", art.wordX, art.wordY);+ }++ const rgba = ctx.getImageData(0, 0, width, height).data;+ let binary = "";+ const chunk = 0x8000;+ for (let i = 0; i < rgba.length; i += chunk) {+ binary += String.fromCharCode.apply(null, rgba.subarray(i, i + chunk));+ }+ resolve(btoa(binary));+ };+ img.src = svg;+ });+}++/**+ * Encode RGBA pixels as a 24-bit uncompressed BMP: BITMAPFILEHEADER + BITMAPINFOHEADER, rows+ * bottom-up, BGR triples, each row padded to a 4-byte boundary — what NSIS/MUI loads.+ */+function encodeBmp(rgba, width, height) {+ const rowSize = Math.ceil((width * 3) / 4) * 4;+ const pixelBytes = rowSize * height;+ const header = Buffer.alloc(54);+ header.write("BM", 0, "ascii");+ header.writeUInt32LE(54 + pixelBytes, 2); // file size+ header.writeUInt32LE(54, 10); // pixel data offset+ header.writeUInt32LE(40, 14); // BITMAPINFOHEADER+ header.writeInt32LE(width, 18);+ header.writeInt32LE(height, 22); // positive: rows are bottom-up+ header.writeUInt16LE(1, 26); // colour planes+ header.writeUInt16LE(24, 28); // bits per pixel+ header.writeUInt32LE(0, 30); // BI_RGB, no compression+ header.writeUInt32LE(pixelBytes, 34);+ header.writeInt32LE(2835, 38); // 72 DPI, both axes+ header.writeInt32LE(2835, 42);++ const pixels = Buffer.alloc(pixelBytes);+ for (let y = 0; y < height; y++) {+ const src = (height - 1 - y) * width * 4;+ const dst = y * rowSize;+ for (let x = 0; x < width; x++) {+ const s = src + x * 4;+ const d = dst + x * 3;+ pixels[d] = rgba[s + 2]; // B+ pixels[d + 1] = rgba[s + 1]; // G+ pixels[d + 2] = rgba[s]; // R+ }+ }+ return Buffer.concat([header, pixels]);+}diff --git a/packages/desktop/test/installer-art.test.ts b/packages/desktop/test/installer-art.test.tsnew file mode 100644index 00000000..9082e49d--- /dev/null+++ b/packages/desktop/test/installer-art.test.ts@@ -0,0 +1,74 @@+/**+ * The Windows installer's artwork, as `electron-builder.yml` points NSIS at it.+ *+ * NSIS's assisted installer draws two bitmaps, and both fail in silence when they are wrong:+ * a sidebar that is not exactly 164×314, or a header that is not exactly 150×57, is simply not+ * drawn (the page falls back to NSIS's stock graphic and a blank header bar), and a 32-bit BMP+ * is refused the same way. A person installing Adelie would then see none of Adelie's own+ * interface, with nothing in the build output saying so — hence this test: it reads the two+ * committed files, parses their headers, and checks them against the sizes the config names.+ *+ * The pixels come from scripts/render-installer-art.mjs, which the files' own headers describe;+ * regenerating is a manual step, so the files are committed rather than built.+ */+import fs from "node:fs";+import path from "node:path";+import { fileURLToPath } from "node:url";+import { describe, expect, it } from "vitest";++const pkgDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");++/** Width and height NSIS's MUI requires, per file, as `nsis:` in electron-builder.yml names them. */+const EXPECTED = [+ { file: "build/nsis/installerSidebar.bmp", width: 164, height: 314 },+ { file: "build/nsis/installerHeader.bmp", width: 150, height: 57 },+];++function readBmp(file: string): {+ width: number;+ height: number;+ bits: number;+ compression: number;+} {+ const buf = fs.readFileSync(path.join(pkgDir, file));+ expect(buf.subarray(0, 2).toString("ascii"), `${file} is not a BMP`).toBe("BM");+ expect(buf.readUInt32LE(14), `${file} is not a BITMAPINFOHEADER bitmap`).toBe(40);+ return {+ width: buf.readInt32LE(18),+ height: buf.readInt32LE(22),+ bits: buf.readUInt16LE(28),+ compression: buf.readUInt32LE(30),+ };+}++describe("NSIS installer artwork", () => {+ it.each(EXPECTED)(+ "$file is a 24-bit bitmap of exactly $width×$height",+ ({ file, width, height }) => {+ const bmp = readBmp(file);+ expect(bmp.width).toBe(width);+ // Positive height: rows are stored bottom-up, which is the only layout NSIS accepts.+ expect(bmp.height).toBe(height);+ expect(bmp.bits).toBe(24);+ expect(bmp.compression).toBe(0);+ // Rows padded to 4 bytes, plus the 54-byte header — the file is exactly as long as it says.+ const pixelBytes = Math.ceil((width * 3) / 4) * 4 * height;+ expect(fs.statSync(path.join(pkgDir, file)).size).toBe(54 + pixelBytes);+ },+ );++ it("is the artwork electron-builder.yml actually configures", () => {+ const config = fs.readFileSync(path.join(pkgDir, "electron-builder.yml"), "utf8");+ const configured = (key: string): string => {+ const value = new RegExp(`^\\s*${key}:\\s*(\\S+)\\s*$`, "m").exec(config)?.[1];+ expect(value, `electron-builder.yml does not set nsis.${key}`).toBeDefined();+ // electron-builder resolves a custom resource against the build resources dir first and+ // the package dir second; both are inside this package, so the second is the one to try.+ const resolved = path.resolve(pkgDir, value!);+ expect(fs.existsSync(resolved), `nsis.${key} points at a missing file: ${value}`).toBe(true);+ return path.relative(pkgDir, resolved);+ };+ expect(configured("installerSidebar")).toBe("build/nsis/installerSidebar.bmp");+ expect(configured("installerHeader")).toBe("build/nsis/installerHeader.bmp");+ });+});