Skip to content

fix(patchy): look preview --compare shows both whole looks in one screenshot - #696

Merged
allisonmahmood merged 1 commit into
mainfrom
fix/595-compare-frames
Oct 15, 2026
Merged

allisonmahmood merged 1 commit into
mainfrom
fix/595-compare-frames

Conversation

@allisonmahmood

Copy link
Copy Markdown
Owner

patchy look preview <dir> --compare puts each look in its own frame, and each frame was 100vh and scrolled on its own. A full-page screenshot, which is what an agent takes, came out one screen tall: each look's masthead and headings, and none of its cards, table, form, states or swatches. The global skill worked around it by telling agents to screenshot each look alone.

The compare page now sizes each frame to its specimen, so the page scrolls as one and one screenshot holds both whole looks:

  • A small inline script on the two-pane page only, allowed by a script-src 'sha256-…' entry computed from its exact text. After load it reads each frame's .specimen (srcdoc frames are same-origin), resets its min-height/height so a look's own main { min-height: 100vh } or main { height: 100vh } can't tie it to the frame, and sets the frame's height from a ResizeObserver on it. That covers the first fit, late fonts and window resizes, and frames shrink as well as grow.
  • It measures the specimen's border box, not the frame's document, which is never shorter than the frame. The frame's height is the specimen's offset in its document, its height, and the bottom padding, border and margin a look puts on the body and root, plus the 1px divider between panes.
  • Without JavaScript the frames stay 100vh, as before. The single-look page, including the --compare fallback, stays script-free and passes tier 0 validateHtml. Each specimen keeps its own CSP, and the frames still keep each look's styles and fonts to itself. The CLI's flags, --json shape and exit codes don't change.

#677 had landed a check in the same compare test: a specimen's #vendors link scrolls instead of loading the page into the frame. That still holds. With the frame fitted, Chromium scrolls the page around it instead, and the test's comment now says so.

It works

Run by hand through a pnpm dev up team environment's CLI, with the company look set to the Duolingo fixture and the Linear fixture as the candidate. patchy look preview linear --compare opened offline in Playwright at 1280×720 with every request refused. The full-page screenshot is 1280×3903 and shows both whole specimens, swatches included. The Linear frame is 2651px and the Duolingo frame 3903px. Each frame's document scrollHeight equals its frame height, so neither scrolls on its own, and no requests were made.

  • The Chromium compare case in test/browser-tier1/look-preview.spec.ts now gives one look main { min-height: 100vh }, and the other main { height: 100vh } plus body { position: relative; margin: 32px; padding-bottom: 64px }. At 1280px it polls until each frame is at least as tall as its specimen's bottom and the frame document's scrollHeight fits the frame. Then it checks they grow at 375px and return to the exact same heights at 1280px. It fails on the old code (no frame ever fits). It also fails with the specimen height reset removed: the height look clips, and the min-height look sticks at 3600px instead of 2651px. It fails again if the top is measured with offsetTop, which a positioned body makes 0, or if the space below is assumed to mirror the space above. The existing checks stay: each frame shows its own look, there's no horizontal overflow, and no request is made.
  • The CLI test for the no-current-look --compare fallback also asserts validateHtml(page) is ok.
  • look-preview.spec.ts passes 6/6 after a fresh build on the rebased branch. cliLook, lookPreview and skillLock vitest pass 13/13. Lint, prettier and both typechecks are clean.
  • pnpm verify is queued behind the machine's shared lock (10+ runs deep), so CI is the gate here.
  • GPT 6.1 Sol review at xhigh, three rounds. Round 1 found a medium issue: offsetTop reads 0 under a positioned body, so the frame clipped. It also found a low one: the observer watched the content box, not the border box. Both are fixed and the first is now in the test. Round 2 found a low issue: assuming the space below mirrors the space above left uneven trailing spacing a little inner scroll. It's fixed by measuring that spacing, and it's in the test too. Round 3 found nothing.

Surfaces

  • CLI README, look preview: the compare frames fit their looks, so one full-page screenshot shows both.
  • Global patchy skill, "Changing the look": the "screenshot each look alone" workaround is replaced by "a full-page screenshot shows both looks whole". skills-lock.json hash refreshed.
  • ADR-0004, docs/product.md, glossaries: no change. The CLI contract and the product's shape are unchanged.

Closes #595

Made by Claude Opus 5.5 in Claude Code, running in T3 Code.

@github-actions github-actions Bot added area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:docs Touches the docs area size:m 100-500 changed lines labels Oct 15, 2026
…eenshot

Each compare frame was 100vh and scrolled on its own, so a full-page
screenshot showed only the top of each look. A small hashed script now
sizes each frame to its specimen; the single-look page stays script-free.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood
allisonmahmood merged commit aa98240 into main Oct 15, 2026
13 checks passed
@allisonmahmood
allisonmahmood deleted the fix/595-compare-frames branch October 15, 2026 21:04
allisonmahmood added a commit that referenced this pull request Oct 15, 2026
… none (#697)

Stacked on #696

With no company look, `patchy look preview` (no folder) refused with
exit 1, and `--compare` showed the candidate alone. Yet `GET /api/look`
already returns `patchyLook`, the look the company's tools actually
render while it has none. So an admin couldn't compare a first look
against what people see today, and the skill's advice to preview the
company's look failed in a company without one.

Preview now reads `patchyLook` when `current` is null:

- With a company look, nothing changes: the pane is "Revision N, the
company's look".
- With none, the company-side pane is the Patchy look's files, labelled
"The Patchy look" with the note "The company has no look yet. New tools
start from this one." It gets no logo, as `patchyLook` carries none, so
the masthead falls back to the brief's heading as a wordmark.
- `patchy look preview` with no folder renders that single pane, exit 0,
and the file passes `patchy validate`. `--compare` frames the candidate
beside it, and the candidate pane no longer carries a "no look yet"
note.
- Unchanged: the `--json` shape `{ ok, path, failures, warnings? }`,
`failures` listing only the candidate's publish failures, a candidate
alone previewing offline with no request, and `--compare` without a
folder failing locally before any request. A response with neither
`current` nor `patchyLook`, which the server never sends, still gets the
local refusal.

No API, server, generation or renderer change. `Pane` and `previewPage`
are reused as they are.

## It works

Run by hand against a `pnpm dev up team` environment (Acme Co, no
company look), through its CLI, with each file opened offline in
Playwright at 1280×720:

- `patchy look preview --json` exited 0 with
`{"ok":true,…,"failures":[]}`. The page is labelled "The Patchy look"
with the note, its wordmark is "Patchy's look", it has no logo `<img>`,
and its full-page screenshot is 1280×2961. `patchy validate` on it
returned `{"ok":true,"warnings":[]}`.
- `patchy look preview linear --compare --json` exited 0 with `failures:
[]`, and wrote two frames titled "Candidate" and "The Patchy look", the
second with the note. The full-page screenshot is 1280×3611 with both
whole looks (frames 2651px and 3611px). No requests.
- After `patchy look publish duolingo`, the same `--compare` shows
"Candidate" beside "Revision 1, the company's look", as before.

Tests, in `packages/patchy/src/cliLook.test.ts`:

- With no company look, `look preview --json` exits 0 with `{ ok: true,
failures: [] }`. The file shows "The Patchy look" and the note, has no
`data:image/svg+xml`, and passes `validateHtml`.
- With no company look, `look preview <dir> --compare` writes frames
"Candidate" and "The Patchy look".
- A response with neither look still exits 1, and `--compare` without a
folder still exits 1 with no request. The existing company-look and
offline-candidate cases are unchanged.
- Both new cases fail against the old `commands.ts`. `cliLook`,
`lookPreview` and `skillLock` vitest pass 13/13, `look-preview.spec.ts`
passes 6/6 after a fresh build, and lint, prettier and the typechecks
are clean. `pnpm verify` is queued behind the machine's shared lock; CI
is the gate.
- GPT 6.1 Sol review at xhigh found nothing at any level.

## Surfaces

- The command's help strings: the `dir` argument, `--compare` and the
command description name the Patchy-look fallback. These are the only
`commands.ts` edits, all inside `look preview`.
- CLI README's look section: the command table row, the `--compare`
paragraph (the Patchy look stands in, labelled, no logo), the `failures`
sentence, the exit-1 paragraph (only `--compare` without a folder), and
the `--compare` flag line.
- ADR-0004's look preview contract: the table row and paragraph. The
`--json` shape and exit codes are unchanged; only the no-look behaviour
moved.
- `docs/product.md`'s specimen paragraph, and the comment on the
browser-tier compare spec (comparing needs an instance, not "a current
look").
- Global `patchy` skill, "Changing the look": `--compare` shows the
candidate beside the company's look, or the Patchy look when there is
none. `skills-lock.json` hash refreshed.

Closes #593

Made by Claude Opus 5.5 in Claude Code, running in T3 Code.
allisonmahmood added a commit that referenced this pull request Oct 16, 2026
…u when they fail (#720)

Release 13's What's new entry, written from `c9b8fc4`, ahead of
deploying it. `patchy` and `CURRENT_RELEASE` move to `0.13.0`, so CLIs
and patch repos installed before this deploy are told to upgrade.

| Change | PRs |
| --- | --- |
| New: Home puts the patches you use first | #713, #716, #719 |
| New: Every patch in one list | #715 |
| Improved: Each patch's page leads with Open | #717 |
| New: See when your tools are failing | #718 |
| Fixed: Everyone has a name | #687 |
| Improved: Your company's look is easier to get right | #697, #696,
#703, #688 |
| Improved: Forms follow your look's error states | #691, #692 |
| Improved: Clearer answers when a publish goes wrong | #686, #685, #689
|
| Fixed: Your agent's Patchy commands are steadier | #695, #704, #680,
#681 |
| Behind the scenes: stricter checks on static pages and tools' database
requests; malformed requests are logged | #682, #693, #683 |
| Behind the scenes: usage numbers count every publish, sharing change
and restore | #698, #699, #700, #690 |
| Test and tooling only, no line | #705, #702, #701, #694, #684, #607 |

Made by Claude Opus 5.5 in Claude Code, running in T3 Code.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:docs Touches the docs area size:m 100-500 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(patchy): a look preview --compare screenshot shows only the top of each look

1 participant