Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Match the iPhone browser bar to the active skin.
Shreerama9290bf407d6e7
diff --git a/index.html b/index.htmlindex 36e4d3ac13..aac0df4145 100644--- a/index.html+++ b/index.html@@ -3,7 +3,7 @@<head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />- <meta name="theme-color" content="#070707" />+ <meta name="theme-color" content="#121212" /><meta name="mobile-web-app-capable" content="yes" /><meta name="apple-mobile-web-app-capable" content="yes" /><meta name="apple-mobile-web-app-title" content="OpenMausBot" />diff --git a/public/manifest.webmanifest b/public/manifest.webmanifestindex 9443c72cac..d658e97639 100644--- a/public/manifest.webmanifest+++ b/public/manifest.webmanifest@@ -5,8 +5,8 @@"start_url": "/","scope": "/","display": "standalone",- "background_color": "#070707",- "theme_color": "#070707",+ "background_color": "#121212",+ "theme_color": "#121212","icons": [{ "src": "/app-icon-192.png", "sizes": "192x192", "type": "image/png", "purpose": "any" },{ "src": "/app-icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "any" }diff --git a/src/lib/browser-chrome.test.ts b/src/lib/browser-chrome.test.tsnew file mode 100644index 0000000000..09a17fb31f--- /dev/null+++ b/src/lib/browser-chrome.test.ts@@ -0,0 +1,50 @@+import { describe, expect, it } from "vitest";+import { applyThemeColor, type ThemeColorDocument } from "./browser-chrome";++function meta() {+ const attrs = new Map<string, string>();+ return {+ attrs,+ getAttribute: (name: string) => attrs.get(name) ?? null,+ setAttribute: (name: string, value: string) => { attrs.set(name, value); },+ };+}++function doc(existing?: ReturnType<typeof meta>): ThemeColorDocument & { created: ReturnType<typeof meta>[] } {+ const created: ReturnType<typeof meta>[] = [];+ return {+ created,+ head: {+ querySelector: () => existing ?? null,+ appendChild: (node) => { created.push(node as ReturnType<typeof meta>); },+ },+ createElement: () => meta(),+ };+}++describe("theme-color follows the skin ground", () => {+ it("creates the meta with a dark app ground", () => {+ const page = doc();+ expect(applyThemeColor("#121212", page)).toBe(true);+ expect(page.created).toHaveLength(1);+ expect(page.created[0].getAttribute("name")).toBe("theme-color");+ expect(page.created[0].getAttribute("content")).toBe("#121212");+ });++ it("replaces an existing light bar color when the skin is dark", () => {+ const bar = meta();+ bar.setAttribute("name", "theme-color");+ bar.setAttribute("content", "#fcfcfc");+ const page = doc(bar);+ expect(applyThemeColor(" #0b0c0b ", page)).toBe(true);+ expect(page.created).toHaveLength(0);+ expect(bar.getAttribute("content")).toBe("#0b0c0b");+ });++ it("leaves the bar alone when the surface is not a hex color", () => {+ const page = doc();+ expect(applyThemeColor("var(--color-app)", page)).toBe(false);+ expect(applyThemeColor("", page)).toBe(false);+ expect(page.created).toHaveLength(0);+ });+});diff --git a/src/lib/browser-chrome.ts b/src/lib/browser-chrome.tsnew file mode 100644index 0000000000..761c67e280--- /dev/null+++ b/src/lib/browser-chrome.ts@@ -0,0 +1,46 @@+/** Safari on iPhone paints its bottom bar from the root scheme and from+ * theme-color. The skin lives in --color-app; the bar has to be told. */++const SURFACE = /^#[0-9a-fA-F]{3}(?:[0-9a-fA-F]{3}){1,2}$/;++type ThemeColorMeta = {+ getAttribute(name: string): string | null;+ setAttribute(name: string, value: string): void;+};++export type ThemeColorDocument = {+ head: {+ querySelector(selector: string): ThemeColorMeta | null;+ appendChild(node: ThemeColorMeta): void;+ } | null;+ createElement(tag: string): ThemeColorMeta;+};++/** Writes a skin surface onto the theme-color meta. Refuses anything that is+ * not a hex color, so a custom property or an empty read cannot reach Safari. */+export function applyThemeColor(color: string, doc: ThemeColorDocument): boolean {+ const surface = color.trim();+ if (!SURFACE.test(surface) || !doc.head) return false;+ const found = doc.head.querySelector('meta[name="theme-color"]');+ const meta = found ?? doc.createElement("meta");+ if (!found) {+ meta.setAttribute("name", "theme-color");+ doc.head.appendChild(meta);+ }+ meta.setAttribute("content", surface);+ return true;+}++/** Reads the worn skin's app ground and copies it to theme-color. No-ops+ * where there is no computed style, which is the case for the stub document+ * the skin tests install. */+export function syncBrowserChrome(doc: Document = document): void {+ if (typeof getComputedStyle !== "function") return;+ let surface = "";+ try {+ surface = getComputedStyle(doc.documentElement).getPropertyValue("--color-app");+ } catch {+ return;+ }+ applyThemeColor(surface, doc);+}diff --git a/src/lib/skins.test.ts b/src/lib/skins.test.tsindex c227baaaae..d703296950 100644--- a/src/lib/skins.test.ts+++ b/src/lib/skins.test.ts@@ -58,6 +58,7 @@ describe("skins", () => {expect(body).toContain(`--code-color-scheme: ${scheme};`);}expect(css).toMatch(/\.chat-md \.shiki\s*\{\s*color-scheme:\s*var\(--code-color-scheme\);\s*\}/);+ expect(css).toMatch(/html\s*\{\s*background-color:\s*var\(--color-app\);\s*color-scheme:\s*var\(--code-color-scheme\);\s*\}/);});it("adds Meadow without moving or replacing the original eight", () => {diff --git a/src/lib/skins.ts b/src/lib/skins.tsindex 579e3df062..4f656d4d7e 100644--- a/src/lib/skins.ts+++ b/src/lib/skins.ts@@ -1,5 +1,6 @@import { SKIN_IDS } from "../../shared/app-settings";import { paintAuroraField } from "./aurora-field";+import { syncBrowserChrome } from "./browser-chrome";import { hasPriorRun } from "./prior-run";import { windowPrefChanged } from "./window-pref-changes";@@ -96,6 +97,7 @@ export function subscribeSkin(listener: () => void): () => void {function paintSkin(id: SkinId): void {document.documentElement.dataset.skin = id;if (id === "aurora") paintAuroraField();+ syncBrowserChrome();for (const listener of listeners) listener();// On Windows the caption buttons sit in a native overlay the main process paints, out of CSS's reach.try {@@ -124,6 +126,7 @@ function followSystem(follow: boolean): void {export function wearSkin(value: unknown): void {if (!isSkinId(value)) return;document.documentElement.dataset.skin = value;+ syncBrowserChrome();for (const listener of listeners) listener();}diff --git a/src/styles.css b/src/styles.cssindex 98f742eae4..9c66cf192c 100644--- a/src/styles.css+++ b/src/styles.css@@ -1370,6 +1370,15 @@ body,height: 100%;}+/* iOS Safari keeps its bottom bar in light mode unless the root names a+ scheme. The bar's color is theme-color, copied from --color-app when the+ skin changes. The root itself has to paint the same ground, or the home+ indicator inset stays the canvas white. */+html {+ background-color: var(--color-app);+ color-scheme: var(--code-color-scheme);+}+/* Standalone phone windows can reach behind the notch and home indicator.Keep the app's existing h-full layout inside the usable area. Desktopbrowsers and Electron report zero insets. */