Skip to content

Commit d440262

Browse files
committed
fix(nuxi): show hover styles in coder captures
Headless Chromium reports no mouse, so `(hover: hover)` does not match and a site built with Tailwind v4 never applies its `hover:` styles. A clip of a hover showed the pointer on the link and no change. The sandbox template now writes agent-browser's user config with the Blink settings that make Chromium report a mouse. agent-browser reads that file at every launch, so the `browser__*` tools and the capture tools get the same browser. Amp-Thread-ID: https://ampcode.com/threads/T-01a1f322-7f89-7504-81af-fa4ded7c86d5
1 parent 14e45fa commit d440262

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎layers/nuxi/agent/lib/media/capture.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ import { z } from 'zod'
55
/** One browser per sandbox: the `browser__*` tools and the capture tools drive the same page. */
66
export const BROWSER_SESSION = 'nuxi'
77

8+
/**
9+
* Launch flags of the sandbox's Chromium, which `subagents/coder/sandbox.ts` writes to agent-browser's
10+
* user config. Headless Chromium reports no mouse, so `(hover: hover)` doesn't match and a site built
11+
* with Tailwind v4 never shows its `hover:` styles in a capture. These Blink settings make it report
12+
* one. The setting is per browser, so the `tablet` and `mobile` viewports report a mouse too.
13+
*/
14+
export const BROWSER_LAUNCH_ARGS = '--blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4'
15+
816
/** Where captures land in the sandbox, as `<name>.<ext>`. */
917
export const CAPTURES_DIR = '/workspace/captures'
1018

‎layers/nuxi/agent/subagents/coder/sandbox.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { installAgentBrowser } from '@agent-browser/eve/sandbox'
1+
import { installAgentBrowser, quoteShellArg } from '@agent-browser/eve/sandbox'
22
import { DefaultSandbox, defineSandbox } from 'eve/sandbox'
3-
import { PRIVATE_SUBNETS } from '../../lib/media/capture.js'
3+
import { BROWSER_LAUNCH_ARGS, PRIVATE_SUBNETS } from '../../lib/media/capture.js'
44

55
type PrepareSandbox = NonNullable<NonNullable<Parameters<typeof DefaultSandbox.environment>[0]>['prepare']>
66

@@ -27,6 +27,12 @@ const prepare: PrepareSandbox = async (sandbox) => {
2727
{ installBrowser, installSystemDependencies: true }
2828
)
2929

30+
// agent-browser reads its user config at every launch, so the `browser__*` tools and the capture
31+
// tools start the same Chromium whichever runs first. `args` is one string: it refuses an array.
32+
const config = quoteShellArg(JSON.stringify({ args: BROWSER_LAUNCH_ARGS }))
33+
const configured = await sandbox.run({ command: `mkdir -p "$HOME/.agent-browser" && printf '%s' ${config} > "$HOME/.agent-browser/config.json"` })
34+
if (configured.exitCode !== 0) throw new Error(`Could not write the agent-browser config: ${configured.stderr || configured.stdout}`)
35+
3036
const ffmpeg = await sandbox.run({ command: 'sudo apt-get install -y --no-install-recommends ffmpeg' })
3137
if (ffmpeg.exitCode !== 0) throw new Error(`Could not install ffmpeg: ${ffmpeg.stderr || ffmpeg.stdout}`)
3238
}

0 commit comments

Comments
 (0)