Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(sidebar): a Cloud's sidebar is plain, with no night sky or stars (#3880)

Milind Soni9eb690ed943e
diff --git a/scripts/check-skin-contrast.mjs b/scripts/check-skin-contrast.mjs
index ba844e4499..969be58965 100644
--- a/scripts/check-skin-contrast.mjs
+++ b/scripts/check-skin-contrast.mjs
@@ -271,39 +271,4 @@ if (!night) {
}
}
-// A Cloud's sidebar lays a wash of one night colour over its panel (src/styles.css [data-cloud-sky]::before): every ink
-// must read on the panel with that wash at its strongest.
-const washOf = (rule) => ({ token: /var\((--cloud-night-[\w-]+)\)\)/.exec(rule ?? "")?.[1], strength: Number(/opacity: ([\d.]+);/.exec(rule ?? "")?.[1]) });
-const washLight = washOf(/\n\[data-cloud-sky\]::before \{([^}]*)\}/.exec(css)?.[1]);
-const washDark = washOf(/@container style\(--code-color-scheme: dark\) \{\s*\[data-cloud-sky\]::before \{([^}]*)\}/.exec(css)?.[1]);
-if (!night || !washLight.token || !washDark.token || !(washLight.strength > 0) || !(washDark.strength > 0)) {
- failed = true;
- console.log("✗ Cloud sidebar — cannot read the wash's strength or the night tokens");
-} else {
- const hex = ({ r, g, b }) => `#${[r, g, b].map((v) => Math.round(v).toString(16).padStart(2, "0")).join("")}`;
- let washFailed = false;
- for (const [id, tokens] of skins) {
- const dark = tokens["--code-color-scheme"] === "dark";
- const pick = (token) => /^light-dark\(\s*([^,]+?)\s*,\s*([^)]+?)\s*\)$/.exec(night[token] ?? "")?.[dark ? 2 : 1];
- const panel = parseHex(tokens["--color-panel"] ?? "");
- const problems = [];
- const wash = dark ? washDark : washLight;
- const tint = parseHex(pick(wash.token) ?? "");
- if (!panel || !tint) problems.push(`cannot measure ${wash.token} over --color-panel`);
- else {
- const washed = hex(flatten({ ...tint, a: wash.strength }, panel));
- for (const fg of ["--color-ink", "--color-ink-secondary", "--color-ink-tertiary"]) {
- const ratio = contrast(tokens[fg] ?? "", washed);
- if (ratio === null || ratio < 4.5) problems.push(`${fg} on the panel under ${wash.token}: ${ratio?.toFixed(2) ?? "unmeasurable"}:1 (needs 4.5:1)`);
- }
- }
- if (problems.length) {
- failed = true;
- washFailed = true;
- for (const problem of problems) console.log(`✗ ${id} Cloud sidebar — ${problem}`);
- }
- }
- if (!washFailed) console.log(`✓ Cloud sidebar — every skin's inks read under the night wash (${washLight.token} at ${washLight.strength} light, ${washDark.token} at ${washDark.strength} dark)`);
-}
-
process.exit(failed ? 1 : 0);
diff --git a/src/components/Sidebar.simple-layout.test.ts b/src/components/Sidebar.simple-layout.test.ts
index 9a37b308f3..e7904a35bb 100644
--- a/src/components/Sidebar.simple-layout.test.ts
+++ b/src/components/Sidebar.simple-layout.test.ts
@@ -314,22 +314,6 @@ describe("Simple-mode sidebar layout", () => {
expect(render().tree.some((node) => node.type === SimpleRailFooter)).toBe(false);
});
- it("marks a Cloud's own sidebar for its night sky, Simple, Advanced or as a rail, and never a local one", () => {
- const sky = () => render().root.props["data-cloud-sky"];
- expect(sky(), "a local workspace").toBeUndefined();
- fixture.state = { ...fixture.state, config: { ...fixture.state.config, cloudHome: false } as AppState["config"] };
- expect(sky(), "a server that is no Cloud").toBeUndefined();
- fixture.state = { ...fixture.state, config: { ...fixture.state.config, cloudHome: true } as AppState["config"] };
- expect(sky()).toBe("simple");
- fixture.advanced = true;
- expect(sky()).toBe("advanced");
- setSidebarDensity("icons");
- expect(sky(), "Advanced collapsed to avatars").toBe("rail");
- fixture.advanced = false;
- expect(sky(), "Simple's rail").toBe("rail");
- expect(render(true).root.props["data-cloud-sky"], "held collapsed by a side panel").toBe("rail");
- });
-
it("New Bot makes a bot at once in both modes, Chief of Staff or not; Advanced keeps Create department and Templates", () => {
fixture.state = { ...fixture.state, bots: [bot("atlas", { chiefOfStaff: true }), bot("bea")] };
const openMenu = () => {
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index a34ffb590f..40486fd5d4 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -1375,7 +1375,7 @@ export function Sidebar({ open, onClose, collapseToIcons = false }: {
tabIndex={-1}
aria-label={t("sidebar.aria")}
data-native-view-overlay
- data-sidebar data-cloud-sky={state.config?.cloudHome === true ? density === "icons" ? "rail" : advanced ? "advanced" : "simple" : undefined}
+ data-sidebar
onClick={(event) => {
// The phone's list covers the whole screen: choosing the bot that is already open has to dismiss it too.
if (phone && open && event.target instanceof Element && !(event.target instanceof HTMLInputElement) && event.target.closest("[data-sidebar-bot-row], [data-sidebar-hero]")) onClose();
diff --git a/src/lib/cloud-sky.test.ts b/src/lib/cloud-sky.test.ts
deleted file mode 100644
index c1903c8e77..0000000000
--- a/src/lib/cloud-sky.test.ts
+++ /dev/null
@@ -1,63 +0,0 @@
-import { readFileSync } from "node:fs";
-import { dirname, join } from "node:path";
-import { fileURLToPath } from "node:url";
-import { describe, expect, it } from "vitest";
-
-const css = readFileSync(join(dirname(fileURLToPath(import.meta.url)), "../styles.css"), "utf8").replace(/\r\n/g, "\n");
-/** The rule whose whole selector is `selector`, not one it ends a selector list of. */
-const body = (selector: string) => {
- let start = css.indexOf(`\n${selector} {`);
- while (start > 0 && css[start - 1] === ",") start = css.indexOf(`\n${selector} {`, start + 1);
- expect(start, selector).toBeGreaterThanOrEqual(0);
- return css.slice(css.indexOf("{", start) + 1, css.indexOf("}", start));
-};
-const list = (rule: string, property: string) => (new RegExp(`${property}: ([^;]+);`).exec(rule)?.[1] ?? "").split(/,(?![^(]*\))/).map((part) => part.trim());
-
-describe("a Cloud's own sidebar sky", () => {
- it("draws 5 to 7 small stars over the sidebar and fewer on the rail, each with its own place, one of them twinkling", () => {
- for (const [variant, least, most] of [["simple", 5, 7], ["advanced", 5, 7], ["rail", 3, 5]] as const) {
- const rule = body(`[data-cloud-sky="${variant}"]::after`);
- const stars = list(rule, "background-image"), places = list(rule, "background-position");
- expect(stars.length, variant).toBeGreaterThanOrEqual(least);
- expect(stars.length, variant).toBeLessThanOrEqual(most);
- expect(places, variant).toHaveLength(stars.length);
- expect(new Set(places).size, `${variant}: no two stars in one place`).toBe(places.length);
- expect(stars.filter((star) => star === "var(--twinkle)"), variant).toHaveLength(1);
- }
- });
-
- it("keeps every star tiny and faint", () => {
- const after = body("[data-cloud-sky]::after");
- for (const name of ["star", "faint", "bright", "twinkle"]) {
- const star = new RegExp(`--${name}: radial-gradient\\(circle ([\\d.]+)px, color-mix\\(in srgb, var\\(--cloud-sky-star\\) ([^,]+), transparent\\)`).exec(after);
- expect(star, name).not.toBeNull();
- expect(Number(star![1]), `${name} radius`).toBeLessThanOrEqual(1.5);
- if (name !== "twinkle") {
- expect(Number.parseFloat(star![2]!), `${name} strength`).toBeGreaterThanOrEqual(25);
- expect(Number.parseFloat(star![2]!), `${name} strength`).toBeLessThanOrEqual(45);
- }
- }
- });
-
- it("twinkles one star rarely and softly, and never under reduced motion, the system's or the app's", () => {
- const [, seconds] = /animation: cloud-sky-twinkle ([\d.]+)s/.exec(body("[data-cloud-sky]::after")) ?? [];
- expect(Number(seconds)).toBeGreaterThanOrEqual(20);
- expect(Number(seconds)).toBeLessThanOrEqual(40);
- expect(css).toMatch(/@media \(prefers-reduced-motion: reduce\) \{\s*\[data-cloud-sky\]::after \{ animation: none; \}/);
- expect(css).toContain(':root[data-reduced-motion="true"] [data-cloud-sky]::after { animation: none; }');
- });
-
- it("takes no pointer and holds no focus or words: both layers are empty pseudo-elements", () => {
- const layers = body("[data-cloud-sky]::before,\n[data-cloud-sky]::after");
- expect(layers).toContain('content: "";');
- expect(layers).toContain("pointer-events: none;");
- });
-
- it("is gone before the first bot: at most 120px tall, its wash fading to nothing", () => {
- for (const selector of ["[data-cloud-sky]::before,\n[data-cloud-sky]::after", '[data-cloud-sky="rail"]::before,\n[data-cloud-sky="rail"]::after']) {
- const [, height] = /height: (\d+)px;/.exec(body(selector)) ?? [];
- expect(Number(height), selector).toBeLessThanOrEqual(120);
- }
- expect(body("[data-cloud-sky]::before")).toMatch(/mask-image: linear-gradient\(to bottom, [^;]*transparent \d+%\);/);
- });
-});
diff --git a/src/styles.css b/src/styles.css
index fd8d8b105d..a576d2a7eb 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -3021,72 +3021,6 @@ button:disabled.bg-danger {
100% { opacity: 0; transform: translate(120px, 36px); }
}
-/* A Cloud's own sidebar: a faint wash of the night card's sky behind the window controls, gone before the first bot,
- and a few small stars in the gaps between the controls (5 to 7, never under a label or a button). One twinkles,
- briefly, once every half a minute. Both layers are pseudo-elements, so they hold no focus and take no pointer;
- light-dark() reads the color-scheme each layer sets for itself, never the sidebar's own. */
-@property --cloud-sky-twinkle {
- syntax: "<percentage>";
- inherits: false;
- initial-value: 32%;
-}
-[data-cloud-sky] {
- --cloud-sky-star: light-dark(#8e9cc6, var(--cloud-night-star));
- --cloud-sky-dot: radial-gradient(circle 1.2px, var(--cloud-sky-star), transparent);
-}
-[data-cloud-sky]::before,
-[data-cloud-sky]::after {
- content: "";
- position: absolute;
- inset: 0 0 auto;
- height: 112px;
- pointer-events: none;
- color-scheme: var(--code-color-scheme);
-}
-[data-cloud-sky]::before {
- background: linear-gradient(100deg, color-mix(in srgb, var(--cloud-night-to) 70%, transparent), var(--cloud-night-to));
- opacity: 0.08;
- -webkit-mask-image: linear-gradient(to bottom, #000 0%, rgb(0 0 0 / 0.5) 30%, rgb(0 0 0 / 0.12) 48%, transparent 58%);
- mask-image: linear-gradient(to bottom, #000 0%, rgb(0 0 0 / 0.5) 30%, rgb(0 0 0 / 0.12) 48%, transparent 58%);
-}
-@container style(--code-color-scheme: dark) {
- [data-cloud-sky]::before {
- background: linear-gradient(100deg, color-mix(in srgb, var(--cloud-night-glow) 70%, transparent), var(--cloud-night-glow));
- opacity: 0.13;
- }
-}
-[data-cloud-sky]::after {
- --star: radial-gradient(circle 1.1px, color-mix(in srgb, var(--cloud-sky-star) 38%, transparent), transparent);
- --faint: radial-gradient(circle 0.9px, color-mix(in srgb, var(--cloud-sky-star) 26%, transparent), transparent);
- --bright: radial-gradient(circle 1.3px, color-mix(in srgb, var(--cloud-sky-star) 45%, transparent), transparent);
- --twinkle: radial-gradient(circle 1.3px, color-mix(in srgb, var(--cloud-sky-star) var(--cloud-sky-twinkle), transparent), transparent);
- background-repeat: no-repeat;
- animation: cloud-sky-twinkle 31s ease-in-out infinite;
-}
-[data-cloud-sky="simple"]::after {
- background-image: var(--star), var(--bright), var(--faint), var(--star), var(--faint), var(--twinkle);
- background-position: 88px 9px, 134px 14px, 10px 52px, calc(100% - 54px) 6px, calc(100% - 20px) 58px, 118px 36px;
-}
-[data-cloud-sky="advanced"]::after {
- background-image: var(--star), var(--faint), var(--faint), var(--faint), var(--bright), var(--twinkle);
- background-position: 96px 4px, 168px 3px, calc(100% - 64px) 3px, 10px 39px, 136px 38px, 62px 38px;
-}
-[data-cloud-sky="rail"]::before,
-[data-cloud-sky="rail"]::after { height: 88px; }
-[data-cloud-sky="rail"]::after {
- background-image: var(--star), var(--faint), var(--faint), var(--twinkle);
- background-position: calc(100% - 14px) 14px, 8px 58px, calc(100% - 10px) 90px, calc(100% - 12px) 40px;
-}
-[data-cloud-sky]::after { background-size: 4px 4px; }
-@keyframes cloud-sky-twinkle {
- 0%, 86%, 100% { --cloud-sky-twinkle: 32%; }
- 92% { --cloud-sky-twinkle: 72%; }
-}
-@media (prefers-reduced-motion: reduce) {
- [data-cloud-sky]::after { animation: none; }
-}
-:root[data-reduced-motion="true"] [data-cloud-sky]::after { animation: none; }
-
/* Trace waterfall: AI steps lavender, tools pale teal, errors red, each mixed into the skin's card so every skin keeps its contrast. */
.trace-bar { border: 1px solid transparent; }
.trace-bar-step {