Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .agents/skills/verify-huebo/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ These are the stable handles. Use them, not CSS classes or the order of elements
| The picked square | `td[aria-selected="true"]`, whose `button` carries the name |
| Format | `find role radio click --name "RGB"` (or `HSB`, `Hex`) |
| Copy | `find role button click --name "Copy Hex"`. The name follows the format |
| Copy confirmation | the dialog `Copied Hex #4998BF` inside the region `Notifications` |
| Copy confirmation | the text `Copied Hex #4998BF` inside the region `Selected colour`, and the same words in the page's polite live region |
| Help | `find role button click --name "Help"`, which opens the dialog `Picking a colour` |

Read state through what a person or the browser sees: `agent-browser get url`, `agent-browser get attr '[role="slider"]' aria-valuenow`, `agent-browser eval "history.length"`, `agent-browser eval "document.title"`, and `agent-browser snapshot -c`.
Expand Down
5 changes: 3 additions & 2 deletions .agents/skills/verify-huebo/features/card.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ Preconditions:

- **Values.** Run `agent-browser get text '[aria-label="Selected colour"]'`. It includes `#4998BF`, `HSB 200,62,75`, `RGB 73,152,191`, `White text 3.2:1, AA large` and `Black text 6.5:1, AA`.
- **Copy (`card-copy`).** Run `agent-browser find role button click --name "Copy Hex"` and `agent-browser wait --text "Copied Hex #4998BF"`. Then `.agents/skills/verify-huebo/input.mjs read-clipboard` prints `#4998BF`.
- **Dedupe (`card-copy-dedupe`).** Click `Copy Hex` three times in a row. `agent-browser snapshot -s '[aria-label="Notifications"]'` lists exactly one dialog, `Copied Hex #4998BF`.
- **Dedupe (`card-copy-dedupe`).** Click `Copy Hex` three times in a row. `agent-browser eval "[...document.querySelector('[aria-label=\"Selected colour\"]').querySelectorAll(':popover-open')].map(e => e.textContent)"` lists exactly one confirmation, `Copied Hex #4998BF`.
- **Format (`card-format`).** Run `agent-browser find role radio click --name "RGB"`. The copy button's name becomes `Copy RGB`. Then `agent-browser reload`, and the `RGB` radio is still checked (`snapshot -c` shows `checked=true`).
- **Empty (`card-empty`).** Open `"$URL/200"`. The card reads `Pick a colour`.
- **Proof.** Run `snapshot -c > $EVIDENCE/card/<step>.aria.txt` and `screenshot $EVIDENCE/card/<step>.png`. Put the clipboard output in `steps.txt`.

## Gotchas

- `agent-browser clipboard read` is denied in this browser. Use `input.mjs read-clipboard`, which grants the permission for this tab's origin and reads.
- The toast closes on its own after a few seconds. Snapshot it right after the click.
- The toast closes on its own after 1.8 seconds. Snapshot it right after the click.
- The toast is hidden from screen readers, which hear it through the page's live region instead, so `snapshot -c` doesn't list it. Read it with `get text` or the `:popover-open` query above.
- A failed write shows `Couldn't copy <format>` and no tick. agent-browser can't make the clipboard fail on demand, so that path is `not driven`. `src/picker/color-card/__tests__/ColorCard.test.tsx` covers it.
- The format persists in `localStorage`, so clear it before a recipe that expects Hex.
2 changes: 1 addition & 1 deletion .agents/skills/verify-huebo/features/page-and-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ Preconditions:

- Change the viewport before `open`, or `reload` after, so the layout query is evaluated fresh.
- The `html` background has a 500 ms transition. Without `input.mjs front`, the tab is hidden, the transition never runs, and the background reads `rgba(0, 0, 0, 0)`. Wait about 600 ms after a change before reading it.
- Help that's still in the snapshot after Escape means the tab is hidden. Base UI waits for the close transition, which only runs in a visible tab. Run `input.mjs front`.
- An Escape that the page doesn't swallow hides agent-browser's tab, and closing Help with Escape is one. Run `input.mjs front` after every Escape, or later transitions freeze at their first frame and Help reads as invisible while open.
- The status-bar and toolbar strip only shows on a real phone browser. Here, `page-tint` checks the root background and `theme-color`, which are what that strip uses.
6 changes: 4 additions & 2 deletions CODING_STANDARDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ How code in Huebo is written. The terms come from `GLOSSARY.md`, and the decisio
- The React Compiler is on. Don't write `useMemo`, `useCallback` or `memo`.
- Use `useEffectEvent` for callbacks that an effect calls but shouldn't re-run on.
- An effect only connects to something outside React, such as a DOM listener, history or the motion store. If it sets state from other state, derive the value instead.
- Build related parts as compound components (`HueDial.Root`, `HueDial.Ring`, …), sharing through context, not with boolean props. Use Base UI for popovers, toasts and radios.
- Base UI popups that portal need a container inside the themed tree, as in `Header.tsx`, or they lose the hue theme's variables.
- Build related parts as compound components (`HueDial.Root`, `HueDial.Ring`, …), sharing through context, not with boolean props.
- Build popups and form controls from the platform: the `popover` attribute, CSS anchor positioning, and native inputs. Help in `Header.tsx`, Copy's confirmation in `ColorCardRoot.tsx`, and the radios in `Format.tsx` are the pattern. Don't add a component library for them (ADR-0007).
- A popover stays in the themed tree, so it keeps the hue theme's variables. Don't portal it.

## Styling

Expand All @@ -43,6 +44,7 @@ How code in Huebo is written. The terms come from `GLOSSARY.md`, and the decisio
- Tests live in a `__tests__` folder beside the module they test, with any helpers and fixtures they need: `src/picker/hue-dial/__tests__/motion.test.ts` tests `src/picker/hue-dial/motion.ts`. The app-wide helpers and the browser setup are in `src/__tests__/`.
- Unit tests (`*.test.ts`) run in Node, for pure modules. Exhaustive checks (`*.verify.ts`) run in Node through `pnpm verify`. Browser tests (`*.test.tsx`) run in Chromium through the real router, using `openAt` in `src/__tests__/app.tsx`. Don't mock modules (lint bans it).
- A new test must fail on the code before the change. If it would pass anyway, it proves nothing.
- Tautological tests are considered harmful. A test that restates the code, such as computing the expected value the same way the module does or asserting that a constant equals itself, can't fail for a real reason. Expect a value worked out by hand, or a behaviour a person would see.
- Assert on what a person can observe: the URL, `history.length`, roles and names, and element identity when the claim is "the same one, not a new one".

## Proof
Expand Down
20 changes: 20 additions & 0 deletions docs/adr/0007-popups-from-the-platform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Popups and radios come from the platform, not a component library

Help, Copy's confirmation and the format radios were built on Base UI. Together they cost 135 KB of a 492 KB script, more than a quarter of it, for three small parts. They are now built on the platform instead:

- **Help** is a `<dialog popover>` opened by `popovertarget`. The browser gives the toggle, Escape, light dismiss, the top layer and `aria-expanded`. CSS anchor positioning hangs it below Help and flips or shifts it to stay on screen. `@starting-style` and `transition-behavior: allow-discrete` animate it in and out. Huebo adds two things Base UI did: focus moves to the link on open, and back to Help after a click outside or a Tab out.
- **Copy's confirmation** is a `popover="manual"` anchored to Copy, shown and hidden by a timer store (`confirmation.ts`) read through `useSyncExternalStore`. Screen readers hear it through the app's `Announcer`.
- **The format radios** are `<input type="radio">`, so arrow keys, wrapping and Tab already behave as they should.

The animations, timings and positions match Base UI's frame for frame, and the Help and card tests pass against both.

## Considered options

- **Keep Base UI.** It costs nothing to maintain, but a quarter of the script ships for three parts, and it stays in the bundle however few parts are used, because its popover pulls in hover, safe-polygon and focus-trap code that Huebo never runs.
- **Lazy-load Help.** That would shrink the first load, not the total, and the toast and radios would still need Base UI.

## Consequences

- Copy's confirmation is no longer a focusable dialog in a `Notifications` landmark. It loses Base UI's swipe to dismiss, its pause on hover, and F6. It lasts 1.8 s and repeats nothing a person needs to act on.
- In browsers without CSS anchor positioning, Help and the confirmation fall back to the centre of the screen. In browsers without `overlay` transitions, they leave the top layer as soon as they start to close.
- Base UI used to fix edge cases for us. Now we fix them.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"vitest-browser-react": "^2.3.0"
},
"dependencies": {
"@base-ui/react": "^1.9.0",
"@fontsource-variable/bricolage-grotesque": "^5.3.0",
"@stylexjs/stylex": "^0.19.1",
"@tanstack/react-router": "^1.170.46",
Expand Down
93 changes: 2 additions & 91 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@ button {
-webkit-user-select: none;
user-select: none;
}

:where([target='_blank'])::after {
content: '\2197' / ' Link to external site';
display: inline-block;
margin-inline-start: 0.3em;
}
Loading
Loading