S3.1: pixel design language: palette with day-part and season rotation, Fusion Pixel font on whole screen pixels, dither ground, 9-slice dialogs, pixel buttons, menu arrow

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-09 12:07:31 -04:00
1 parent d422b2ce69
commit 86dbb4efa1
24 files changed
+777 -145

No files matched your search

+72
View File
@@ -0,0 +1,72 @@
import { _electron as electron, expect, test } from "@playwright/test";
import { mkdirSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { randomUUID } from "node:crypto";
import { seedBuiltinSkillsFixture } from "./builtin-skills-fixture";
import { closeApp, onboard } from "./onboard";
test("text uses the bundled pixel font, and the palette follows the day part, season and clock theme", async () => {
const profileDir = join(tmpdir(), `agentcompany-new-e2e-pixel-${randomUUID()}`);
mkdirSync(profileDir, { recursive: true });
const builtinDir = seedBuiltinSkillsFixture(join(tmpdir(), `agentcompany-new-e2e-pixel-builtin-${randomUUID()}`));
const app = await electron.launch({
args: [resolve("out/main/index.js")],
env: { ...process.env, AGENTCOMPANY_NEW_PROFILE_DIR: profileDir, AGENTCOMPANY_NEW_AUTORUN: "0", AGENTCOMPANY_NEW_BUILTIN_SKILLS_DIR: builtinDir },
});
try {
const page = await app.firstWindow();
await onboard(page, "Pixel Co");
// The font file itself loaded, not a fallback.
expect(await page.evaluate(async () => {
await document.fonts.load('12px "Fusion Pixel"', "像素 Pixel");
return [...document.fonts].some((face) => face.family.replace(/"/g, "") === "Fusion Pixel" && face.status === "loaded");
})).toBe(true);
expect(await page.evaluate(() => getComputedStyle(document.body).fontFamily)).toMatch(/^"?Fusion Pixel/);
const expected = await page.evaluate(() => {
const now = new Date();
const hour = now.getHours();
const month = now.getMonth();
const part = hour >= 5 && hour < 8 ? "dawn" : hour >= 8 && hour < 17 ? "day" : hour >= 17 && hour < 20 ? "dusk" : "night";
const season = month >= 2 && month <= 4 ? "spring" : month >= 5 && month <= 7 ? "summer" : month >= 8 && month <= 10 ? "autumn" : "winter";
return { part, season };
});
const root = page.locator("html");
await expect(root).toHaveAttribute("data-daypart", expected.part);
await expect(root).toHaveAttribute("data-season", expected.season);
// The ground carries the dither; the chosen nav row blinks the pixel menu arrow, other rows show none; dialogs sit in the 9-slice frame.
expect(await page.evaluate(() => getComputedStyle(document.querySelector(".main")!).backgroundImage)).toContain("data:image/svg+xml");
expect(await page.evaluate(() => {
const rows = [...document.querySelectorAll(".nav > .nav-item")];
const active = rows.find((row) => row.matches(".active, [aria-current]"))!;
const idle = rows.find((row) => !row.matches(".active, [aria-current]"))!;
return [getComputedStyle(active, "::before").animationName, getComputedStyle(idle, "::before").animationName, getComputedStyle(idle, "::before").visibility];
})).toEqual(["px-blink", "none", "hidden"]);
await page.getByRole("button", { name: "New task" }).click();
const dialog = page.getByRole("dialog", { name: "New task" });
await expect(dialog).toBeVisible();
expect(await dialog.evaluate((node) => {
const style = getComputedStyle(node.closest(".modal") ?? node.querySelector(".modal")!);
return [style.borderImageSource.startsWith('url("data:image/svg+xml'), style.borderImageSlice, style.borderTopWidth];
})).toEqual([true, "3 fill", "6px"]);
await page.keyboard.press("Escape");
await expect(dialog).toHaveCount(0);
await page.getByRole("button", { name: "Settings" }).click();
await page.getByRole("combobox", { name: "Theme" }).selectOption("dark");
await expect(root).toHaveAttribute("data-theme", "dark");
await page.getByRole("combobox", { name: "Theme" }).selectOption({ label: "Follow the clock" });
await expect(root).toHaveAttribute("data-theme", expected.part === "night" ? "dark" : "light");
// Each font pixel covers a whole number of screen pixels at this display's scale.
expect(await page.evaluate(() => {
const fontPx = parseFloat(getComputedStyle(document.body).fontSize) * window.devicePixelRatio;
return Math.abs(fontPx - Math.round(fontPx)) < 1e-6 && Math.round(fontPx) % 12 === 0;
})).toBe(true);
} finally {
await closeApp(app);
}
});
+33
View File
@@ -0,0 +1,33 @@
import { expect, test } from "vitest";
import { dayPart, resolveTheme, season } from "../../src/renderer/src/shared/palette-clock";
const at = (month: number, hour: number, minute = 0) => new Date(2026, month - 1, 15, hour, minute);
test("the day turns dawn, day, dusk and night at fixed local hours", () => {
expect(dayPart(at(6, 4, 59))).toBe("night");
expect(dayPart(at(6, 5))).toBe("dawn");
expect(dayPart(at(6, 7, 59))).toBe("dawn");
expect(dayPart(at(6, 8))).toBe("day");
expect(dayPart(at(6, 16, 59))).toBe("day");
expect(dayPart(at(6, 17))).toBe("dusk");
expect(dayPart(at(6, 19, 59))).toBe("dusk");
expect(dayPart(at(6, 20))).toBe("night");
expect(dayPart(at(6, 0))).toBe("night");
});
test("seasons follow the months", () => {
expect([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].map((month) => season(at(month, 12)))).toEqual([
"winter", "winter", "spring", "spring", "spring", "summer", "summer", "summer", "autumn", "autumn", "autumn", "winter",
]);
});
test("light and dark are kept as chosen; system follows the OS; the clock goes dark only at night", () => {
expect(resolveTheme("light", true, at(1, 23))).toBe("light");
expect(resolveTheme("dark", false, at(1, 12))).toBe("dark");
expect(resolveTheme("system", true, at(1, 12))).toBe("dark");
expect(resolveTheme("system", false, at(1, 23))).toBe("light");
expect(resolveTheme("clock", true, at(1, 12))).toBe("light");
expect(resolveTheme("clock", false, at(1, 18))).toBe("light");
expect(resolveTheme("clock", false, at(1, 21))).toBe("dark");
expect(resolveTheme("clock", true, at(1, 4))).toBe("dark");
});
+16
View File
@@ -0,0 +1,16 @@
import { expect, test } from "vitest";
import { pixelScale } from "../../src/renderer/src/shared/pixel-scale";
test("one font pixel always covers a whole number of screen pixels, never fewer than one", () => {
expect(pixelScale(1)).toBe(1);
expect(pixelScale(2)).toBe(1);
expect(pixelScale(1.5)).toBeCloseTo(4 / 3);
expect(pixelScale(1.25)).toBeCloseTo(0.8);
expect(pixelScale(1.75)).toBeCloseTo(8 / 7);
expect(pixelScale(0.9)).toBeCloseTo(1 / 0.9);
for (const ratio of [1, 1.25, 1.5, 1.75, 2, 2.5, 3]) {
const device = 12 * pixelScale(ratio) * ratio;
expect(Math.abs(device - Math.round(device))).toBeLessThan(1e-9);
expect(Math.round(device) % 12).toBe(0);
}
});