Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
fix(spaces-web): stop the first run and Settings jumping between steps and tabs (CUA-3554) (#6585)
Francesco Bonacci8ba03b6cda7f
diff --git a/apps/cua-spaces-web/e2e/layout-anchors.spec.ts b/apps/cua-spaces-web/e2e/layout-anchors.spec.tsnew file mode 100644index 0000000000..2bb4fd6ef1--- /dev/null+++ b/apps/cua-spaces-web/e2e/layout-anchors.spec.ts@@ -0,0 +1,150 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++/**+ * Nothing jumps when you move between first-run steps or Settings tabs, at the window sizes people use.+ *+ * First run (the new setup, Labs): the logo, the headline's top edge, the step dots and the primary button stay put+ * on every step. Steps differ in height; they used to be centred, so the headline and the button moved up and down,+ * and the header and the dots' row changed height with Skip for now and the dots.+ *+ * Settings: the heading, the tab bar and the content keep their left edge on every tab. The app styles its+ * scrollbars, and WebKit (the Mac app's web view) reserves no `scrollbar-gutter` for a styled scrollbar, so a tab+ * that scrolls was 10 px narrower than one that doesn't. Chromium does reserve it; the test turns the gutter off to+ * see the page as WebKit does.+ */++import type { Page } from "@playwright/test";++import { expect, test } from "./host";++const SIZES = [+ [1000, 640],+ [1180, 820],+ [1440, 900],+] as const;++/** 1 px: subpixel rounding, never a layout change. */+const TOLERANCE = 1;++type Box = { x: number; y: number; w: number; h: number };++const box = (page: Page, selector: string) =>+ page.evaluate((sel) => {+ const el = document.querySelector(sel);+ if (!el) return null;+ const r = el.getBoundingClientRect();+ return { x: r.left, y: r.top, w: r.width, h: r.height };+ }, selector);++/** Each anchor's edges on every step agree with the first step that has it, within the tolerance. */+function expectSteady(rows: Record<string, Record<string, Box | null>>, edges: Record<string, (b: Box) => number>, where: string) {+ const steps = Object.keys(rows);+ for (const [anchor, edge] of Object.entries(edges)) {+ const [name, side] = anchor.split(".") as [string, string];+ const seen = steps.flatMap((s) => (rows[s]![name] ? [[s, edge(rows[s]![name]!)] as const] : []));+ expect(seen.length, `${where}: ${name} on no step`).toBeGreaterThan(0);+ const [firstStep, first] = seen[0]!;+ for (const [step, v] of seen) {+ expect(Math.abs(v - first), `${where}: ${name} ${side} on ${step} is ${v.toFixed(1)}, on ${firstStep} ${first.toFixed(1)}`).toBeLessThanOrEqual(TOLERANCE);+ }+ }+}++test.use({+ // Headless Chromium hides scrollbars; a Mac with a mouse (or "always show scrollbars") shows them, and they take width.+ launchOptions: { ignoreDefaultArgs: ["--hide-scrollbars"] },+});++for (const [width, height] of SIZES) {+ test.describe(`${width}x${height}`, () => {+ test("first run: the logo, headline, step dots and primary button stay put on every step", async ({ page }) => {+ await page.setViewportSize({ width, height });+ await page.addInitScript(() => {+ localStorage.setItem("cua.flag.spaces_new_onboarding", "1");+ localStorage.setItem("cua.flag.spaces_ask_first_home", "1");+ });+ // signin-wait: the browser never confirms, so the sign-in step stays to be measured.+ await page.goto("/onboarding?bridge=demo&demo=fresh,signin-wait&parity");+ const root = page.locator("[data-new-first-run]");+ const primary = page.locator("[data-onboarding-primary]");++ const rows: Record<string, Record<string, Box | null>> = {};+ const measure = async (step: string, button = "[data-onboarding-primary]") => {+ await expect(root).toHaveAttribute("data-step", step, { timeout: 30_000 });+ // Off the buttons: a hovered button grows (hover:scale) and would read as a move.+ await page.mouse.move(width - 2, height - 2);+ await page.waitForTimeout(300);+ rows[step] = {+ logo: await box(page, "[data-new-run-logo]"),+ title: await box(page, "[data-onboarding-heading]"),+ dots: await box(page, "[data-new-run-dots-row]"),+ primary: await box(page, button),+ };+ };++ await measure("welcome");+ await primary.click();+ await measure("signin", "[data-new-run-try-again]");+ await page.locator("[data-onboarding-later]").click();+ await measure("where");+ await primary.click();+ await page.locator("[data-new-run='agent']:not([data-state='looking'])").waitFor({ timeout: 30_000 });+ if (await primary.isDisabled()) await page.locator("[data-new-run-agent][role=checkbox]").first().click();+ await measure("agent");+ await primary.click();+ await measure("ready");+ await primary.click();+ await measure("next");++ expectSteady(+ rows,+ {+ "logo.left": (b) => b.x,+ "logo.top": (b) => b.y,+ "title.left": (b) => b.x,+ "title.top": (b) => b.y,+ "dots.top": (b) => b.y,+ "dots.height": (b) => b.h,+ "primary.left": (b) => b.x,+ "primary.top": (b) => b.y,+ },+ `${width}x${height}`,+ );+ });++ test("Settings: the heading, tab bar and content keep their place on every tab", async ({ page }) => {+ await page.setViewportSize({ width, height });+ await page.goto("/settings?bridge=demo&parity");+ // WebKit reserves no gutter for the app's styled scrollbars: see the page as it does.+ await page.addStyleTag({ content: "* { scrollbar-gutter: auto !important; }" });+ const nav = page.getByRole("tablist", { name: "Settings" });+ await nav.waitFor();++ const rows: Record<string, Record<string, Box | null>> = {};+ for (const tab of ["Account", "General", "Connections", "Advanced", "About"]) {+ await nav.getByRole("tab", { name: tab, exact: true }).click();+ await expect(nav.getByRole("tab", { name: tab, exact: true })).toHaveAttribute("aria-selected", "true");+ await page.waitForTimeout(300);+ rows[tab] = {+ heading: await box(page, "h1"),+ nav: await box(page, 'nav[aria-label="Settings"]'),+ content: await box(page, 'nav[aria-label="Settings"] + *'),+ };+ }++ expectSteady(+ rows,+ {+ "heading.left": (b) => b.x,+ "heading.top": (b) => b.y,+ "nav.left": (b) => b.x,+ "nav.width": (b) => b.w,+ "content.left": (b) => b.x,+ "content.width": (b) => b.w,+ },+ `${width}x${height}`,+ );+ });+ });+}diff --git a/apps/cua-spaces-web/e2e/settings-tab-layout.spec.ts b/apps/cua-spaces-web/e2e/settings-tab-layout.spec.tsindex 794ecc6a69..2fcf06923c 100644--- a/apps/cua-spaces-web/e2e/settings-tab-layout.spec.ts+++ b/apps/cua-spaces-web/e2e/settings-tab-layout.spec.ts@@ -41,7 +41,7 @@ test("Settings: the heading, tab bar and content keep their left edge across tabawait page.waitForTimeout(150);edges[label] = await page.evaluate(() => {const nav = document.querySelector('nav[aria-label="Settings"]')!;- const scroller = nav.closest(".overflow-y-auto")!;+ const scroller = nav.closest(".scroll-y-stable")!;const first = nav.nextElementSibling;return {heading: document.querySelector("h1")!.getBoundingClientRect().left,diff --git a/apps/cua-spaces-web/src/components/ask-first/home.tsx b/apps/cua-spaces-web/src/components/ask-first/home.tsxindex cc4d11bc9f..3d7ae91916 100644--- a/apps/cua-spaces-web/src/components/ask-first/home.tsx+++ b/apps/cua-spaces-web/src/components/ask-first/home.tsx@@ -135,7 +135,7 @@ export function AskFirstHome() {const first = prep.state?.wanted ? tasks.length === 0 && listed.counted.every((c) => prepared(c.id)) : !chats?.length && listed.counted.length === 0;return (- <div className="h-full overflow-y-auto [scrollbar-gutter:stable]" data-ask-first-home="">+ <div className="h-full scroll-y-stable" data-ask-first-home=""><div className={cn("mx-auto flex w-full flex-col gap-8 px-8 pb-16", first ? "max-w-[880px] pt-24" : "max-w-[1040px] pt-10")}>{first ? <h1 className="font-heading text-[40px] font-semibold tracking-tight">What do you want to do?</h1> : null}<AskBoxdiff --git a/apps/cua-spaces-web/src/components/first-run-new/first-run-new.tsx b/apps/cua-spaces-web/src/components/first-run-new/first-run-new.tsxindex 87cd0b3eb1..0be148ad4d 100644--- a/apps/cua-spaces-web/src/components/first-run-new/first-run-new.tsx+++ b/apps/cua-spaces-web/src/components/first-run-new/first-run-new.tsx@@ -135,47 +135,79 @@ function Row({ icon, name, sub, picked, disabled, onClick, extra, check = true,const Divider = () => <div className="mx-3 my-1.5 h-px bg-white/[0.14]" />;const Label = ({ children }: { children: ReactNode }) => <div className={cn("px-3 pt-3 pb-1 text-[12.5px] font-semibold tracking-[0.02em]", GREY)}>{children}</div>;-/** How far above the footer the list fades out. */+/** How far above the footer the content fades out. */const FADE_PX = 28;/**- * Fades `content` out just above `footer` while the window is too short for both, so the list never runs- * under Continue. A mask on the content, never a background on the footer: nothing covers the stars or keys.+ * A screen's action row. It sits at the bottom of the content area on every screen and every window size, so the+ * primary button never moves between steps: short content leaves space above it (`mt-auto` in the page's full-height+ * column), long content scrolls under it (`sticky`). It has no background of its own, so the stars and keys show+ * through; the content fades out just above it instead (`useFadeUnder`).*/-function useFadeUnder(content: RefObject<HTMLElement | null>, footer: RefObject<HTMLElement | null>) {+function Actions({ children, className }: { children: ReactNode; className?: string }) {+ return (+ <div className={cn("sticky bottom-0 z-10 mt-auto pt-[min(20px,2.2vh)] pb-3", className)} data-new-run-footer="">+ {children}+ </div>+ );+}++/**+ * Fades the screen's content out just above its action row (`Actions`) while the window is too short for both, so+ * nothing runs under the buttons. A mask on each block above the row, never a background on the row: nothing covers+ * the stars or keys. One for the whole page (`scroller` is its `main`), so every screen gets it; `screen` re-reads+ * the row when the screen changes.+ */+function useFadeUnder(scroller: RefObject<HTMLElement | null>, screen: string) {useLayoutEffect(() => {- const c = content.current;- const f = footer.current;- if (!c || !f) return;- const scroller = c.closest("main") ?? c.parentElement;+ const main = scroller.current;+ if (!main) return;let frame = 0;+ const masked = new Set<HTMLElement>();+ const clear = (el: HTMLElement) => {+ el.style.removeProperty("mask-image");+ el.style.removeProperty("-webkit-mask-image");+ delete el.dataset.faded;+ masked.delete(el);+ };const update = () => {frame = 0;- const box = c.getBoundingClientRect();- const cut = f.getBoundingClientRect().top - box.top;- const under = box.height > 0 && cut < box.height - 1;- const mask = under ? `linear-gradient(to bottom, #000 ${Math.max(0, cut - FADE_PX)}px, transparent ${Math.max(0, cut)}px)` : "";- c.style.setProperty("mask-image", mask);- c.style.setProperty("-webkit-mask-image", mask);- if (under) c.dataset.faded = "";- else delete c.dataset.faded;+ const footer = main.querySelector<HTMLElement>("[data-new-run-footer]");+ const above = footer ? [...(footer.parentElement?.children ?? [])].filter((el): el is HTMLElement => el instanceof HTMLElement && el !== footer && Boolean(el.compareDocumentPosition(footer) & Node.DOCUMENT_POSITION_FOLLOWING)) : [];+ for (const el of [...masked]) if (!above.includes(el)) clear(el);+ if (!footer) return;+ const top = footer.getBoundingClientRect().top;+ for (const el of above) {+ const box = el.getBoundingClientRect();+ const cut = top - box.top;+ if (!(box.height > 0 && cut < box.height - 1)) {+ if (masked.has(el)) clear(el);+ continue;+ }+ const mask = `linear-gradient(to bottom, #000 ${Math.max(0, cut - FADE_PX)}px, transparent ${Math.max(0, cut)}px)`;+ el.style.setProperty("mask-image", mask);+ el.style.setProperty("-webkit-mask-image", mask);+ el.dataset.faded = "";+ masked.add(el);+ }};const schedule = () => {if (!frame) frame = requestAnimationFrame(update);};update();- scroller?.addEventListener("scroll", schedule, { passive: true });+ main.addEventListener("scroll", schedule, { passive: true });window.addEventListener("resize", schedule);const ro = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(schedule);- ro?.observe(c);- if (scroller) ro?.observe(scroller);+ ro?.observe(main);+ if (main.firstElementChild) ro?.observe(main.firstElementChild);return () => {if (frame) cancelAnimationFrame(frame);- scroller?.removeEventListener("scroll", schedule);+ main.removeEventListener("scroll", schedule);window.removeEventListener("resize", schedule);ro?.disconnect();+ for (const el of [...masked]) clear(el);};- }, [content, footer]);+ }, [scroller, screen]);}/**@@ -225,11 +257,11 @@ export function WelcomeScreen({ onAdd }: { onAdd: () => void }) {<div data-new-run="welcome"><Title>{WELCOME.title}</Title><Line>{WELCOME.line}</Line>- <div className="mt-9">+ <Actions><button type="button" className={WHITE_BUTTON} onClick={onAdd} data-onboarding-primary="">{WELCOME.primary}</button>- </div>+ </Actions></div>);}@@ -255,7 +287,7 @@ export function SignInScreen({ view, onTryAgain, onUseCode, onOpen }: { view: Si{view.waiting}</div>) : null}- <div className="mt-6 flex flex-wrap items-center gap-3">+ <Actions className="flex flex-wrap items-center gap-3"><button type="button" className={view.tryAgainPrimary ? WHITE_BUTTON : GLASS_BUTTON} onClick={onTryAgain} data-new-run-try-again="">{view.tryAgain}</button>@@ -264,7 +296,7 @@ export function SignInScreen({ view, onTryAgain, onUseCode, onOpen }: { view: Si{view.useCode}</button>) : null}- </div>+ </Actions></div>);}@@ -290,13 +322,10 @@ export function WhereScreen({const sep = view.separate;const fold = view.offlineFold;const [showOffline, setShowOffline] = useState(false);- const content = useRef<HTMLDivElement>(null);- const footer = useRef<HTMLDivElement>(null);- useFadeUnder(content, footer);const other = (o: ComputerRow) => <Row key={o.id} icon={<Mark os={o.os} />} name={o.name} sub={o.sub} picked={o.picked} disabled={o.disabled} onClick={() => onToggle(o.id)} data-new-run-computer={o.id} data-offline={o.disabled ? "" : undefined} />;return (<div data-new-run="where">- <div ref={content} data-new-run-content="">+ <div data-new-run-content=""><Title>{view.title}</Title><Line>{view.line}</Line><div className={cn(CARD, "mt-[min(28px,3vh)]")} data-new-run-computers="">@@ -415,13 +444,11 @@ export function WhereScreen({) : null}</div></div>- {/* Stays in view at the bottom of the window however long the list is. It has no background of its own, so the- stars and keys show through; the list fades out just above it instead (`useFadeUnder`). */}- <div ref={footer} className="sticky bottom-0 z-10 mt-2 pt-[min(20px,2.2vh)] pb-3" data-new-run-footer="">+ <Actions><button type="button" className={WHITE_BUTTON} disabled={!view.continueEnabled} onClick={onContinue} data-onboarding-primary="">Continue</button>- </div>+ </Actions></div>);}@@ -457,23 +484,24 @@ export function AgentScreen({ view, onPick, onContinue, onInstall, busy }: { vie) : null}{view.install ? (<>- <div className="mt-9 flex flex-wrap items-center gap-6">+ <p className={cn("mt-[min(28px,3vh)] max-w-[480px] text-[13.5px] font-medium", GREY)}>{view.install.note}</p>+ <Actions className="flex flex-wrap items-center gap-6"><button type="button" className={WHITE_BUTTON} onClick={() => onInstall("claude-code")} data-new-run-install="claude-code">{view.install.primary}</button><button type="button" className={cn(LINK, "text-[15px]")} onClick={() => onInstall("codex")} data-new-run-install="codex">{view.install.secondary}</button>- </div>- <p className={cn("mt-4 max-w-[480px] text-[13.5px] font-medium", GREY)}>{view.install.note}</p>+ </Actions></>- ) : view.state !== "looking" ? (- <div className="mt-[min(28px,3vh)]">+ ) : (+ // Shown (greyed) while the agents are still being looked for, so it doesn't pop in once they're found.+ <Actions><button type="button" className={WHITE_BUTTON} disabled={!view.continueEnabled || busy} onClick={onContinue} data-onboarding-primary="">{busy ? "Setting up…" : "Continue"}</button>- </div>- ) : null}+ </Actions>+ )}</div>);}@@ -542,11 +570,11 @@ export function ReadyScreen({ view, agent, onDone, onContinueChat, place }: { vi</div>{/* The person's own recent chats on this computer (CUA-3319), hidden when there are none. */}{onContinueChat ? <PickUpWhereYouLeftOff className="mt-[min(28px,3vh)]" place={place} onContinue={onContinueChat} /> : null}- <div className="mt-6">+ <Actions><button type="button" className={WHITE_BUTTON} onClick={onDone} data-onboarding-primary="">{view.done}</button>- </div>+ </Actions></div>);}@@ -578,11 +606,11 @@ export function NextScreen({ view, onRow, onDone, apps }: { view: NextView; onRo);})}</div>- <div className="mt-[min(28px,3vh)]">+ <Actions><button type="button" className={WHITE_BUTTON} onClick={onDone} data-onboarding-primary="">{view.done}</button>- </div>+ </Actions></div>);}@@ -655,6 +683,8 @@ export function NewFirstRun() {const [explain, setExplain] = useState(false);const [addOpen, setAddOpen] = useState(false);const [appsOpen, setAppsOpen] = useState(false);+ const mainRef = useRef<HTMLElement>(null);+ useFadeUnder(mainRef, s.screen);const [host, setHost] = useState<HostStatus | null>(null);// A new screen: focus moves to its title, so a screen reader reads it. Moved with the arrow keys on the@@ -982,8 +1012,9 @@ export function NewFirstRun() {return (<div className="dark relative flex h-full flex-col overflow-hidden bg-[#050607] text-white" data-window-surface="#050607" data-new-first-run="" data-step={s.screen}><FloatKeys copyRight={544} />- <header className="relative z-30 flex shrink-0 items-center justify-between pt-[calc(var(--titlebar-height,0px)+12px)] pr-16 pb-2 pl-16">- <span className="flex items-center gap-1.5">+ {/* A fixed height, with or without Skip for now, so the content under it never moves between steps. */}+ <header className="relative z-30 box-content flex h-9 shrink-0 items-center justify-between pt-[calc(var(--titlebar-height,0px)+12px)] pr-16 pb-2 pl-16">+ <span className="flex items-center gap-1.5" data-new-run-logo=""><CuaLogo className="size-5" /><span className="font-display text-[19px] font-medium tracking-[-0.01em] text-white">Cua</span></span>@@ -993,16 +1024,16 @@ export function NewFirstRun() {</button>) : null}</header>- <main className="relative z-20 flex min-h-0 flex-1 flex-col overflow-y-auto px-16">- <div aria-hidden className="min-h-0 shrink-0 grow basis-0" />- <div className="flex w-full max-w-[600px] shrink-0 flex-col py-2">{body}</div>- <div aria-hidden className="min-h-2 shrink-0 grow-[1.4] basis-0" />+ {/* Every screen starts at the same height under the header (never centred: screens differ in height, and a+ centred one moved the title and the button between steps). The screen fills the area, so its action row+ (`Actions`) sits at the bottom of it; content longer than the window scrolls above that row. */}+ <main ref={mainRef} className="relative z-20 flex min-h-0 flex-1 flex-col overflow-y-auto px-16" data-new-run-main="">+ <div className="flex w-full max-w-[600px] shrink-0 grow flex-col pt-[clamp(16px,8vh,96px)] *:flex *:grow *:flex-col">{body}</div></main>- {dots ? (- <StepDots dots={dots} onGo={goDot} />- ) : (- <div className="h-8 shrink-0" />- )}+ {/* The dots' row keeps its height on the screens without dots, so the area above it keeps its height too. */}+ <div className="relative z-20 flex h-[38px] shrink-0 flex-col justify-end" data-new-run-dots-row="">+ {dots ? <StepDots dots={dots} onGo={goDot} /> : null}+ </div><AddComputerSheet open={addOpen} onOpenChange={setAddOpen} /></div>);diff --git a/apps/cua-spaces-web/src/components/page.tsx b/apps/cua-spaces-web/src/components/page.tsxindex 82e18a512f..4dabe95879 100644--- a/apps/cua-spaces-web/src/components/page.tsx+++ b/apps/cua-spaces-web/src/components/page.tsx@@ -18,11 +18,11 @@ export function Page({ children, className, contained }: { children: ReactNode;</div>);}- // The gutter is always reserved: otherwise a page that scrolls (Settings >- // General) is narrower than one that doesn't, and the centred column jumps- // sideways between them.+ // The scrollbar's room is always reserved (`scroll-y-stable`, index.css):+ // otherwise a page that scrolls (Settings > General) is narrower than one+ // that doesn't, and the centred column jumps sideways between them.return (- <div className="h-full overflow-y-auto [scrollbar-gutter:stable]">+ <div className="h-full scroll-y-stable"><div className={cn("mx-auto w-full max-w-5xl px-8 pt-6 pb-16", className)}>{children}</div></div>);diff --git a/apps/cua-spaces-web/src/index.css b/apps/cua-spaces-web/src/index.cssindex 47ed666eb4..47b3c1940b 100644--- a/apps/cua-spaces-web/src/index.css+++ b/apps/cua-spaces-web/src/index.css@@ -247,6 +247,19 @@}}+/*+ * A vertical scroller whose content keeps its place whether or not it scrolls (Settings' tabs, Home, All agents).+ * `scrollbar-gutter: stable` alone is not enough: the app styles its scrollbars (`::-webkit-scrollbar` above), and+ * WebKit (the Mac app's web view) reserves no gutter for a styled scrollbar, so the bar took 10 px from the column+ * only on the pages that scroll and the centred column moved 5 px sideways between them. `overflow-y: scroll`+ * keeps the bar's room on every page in every engine; its track is transparent, so a page that doesn't scroll+ * shows nothing there.+ */+@utility scroll-y-stable {+ overflow-y: scroll;+ scrollbar-gutter: stable;+}+@utility glass {background: color-mix(in oklch, var(--popover) 90%, transparent);backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));diff --git a/apps/cua-spaces-web/src/routes/agents/all.tsx b/apps/cua-spaces-web/src/routes/agents/all.tsxindex 0342cf7659..1baa6ab728 100644--- a/apps/cua-spaces-web/src/routes/agents/all.tsx+++ b/apps/cua-spaces-web/src/routes/agents/all.tsx@@ -94,7 +94,7 @@ function AgentsPage() {const detail = opened && (selected.ref || selected.agent);return (- <div className="h-full overflow-y-auto [scrollbar-gutter:stable]">+ <div className="h-full scroll-y-stable"><div className="mx-auto flex min-h-full w-full max-w-5xl flex-col px-8 pt-8 pb-16">{detail ? (<div className="flex min-h-0 flex-1 flex-col" data-agent-view>