Skip to content

fix(builder): include iframe padding in the frame's content origin - #700

Merged
mobeenabdullah merged 4 commits into
mainfrom
fix/frame-content-origin-padding
Aug 12, 2026
Merged

mobeenabdullah merged 4 commits into
mainfrom
fix/frame-content-origin-padding

Conversation

@mobeenabdullah

@mobeenabdullah mobeenabdullah commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Two follow-ups raised against #683 after it merged.

The iframe's content origin excluded padding

An iframe's nested viewport begins at the content box, so padding displaces it exactly as a border does. Callers built the inset from clientLeft/clientTop, which report the border alone, so every frame-local point mapped toward the border by the scaled padding width.

Measured in Chromium rather than reasoned about — an 8px border with 12px padding:

border box x 8
clientLeft 8
padding-left 12
border-only content origin 16
where the inner element actually is 28

The 12px gap is the padding exactly.

FrameInset is now documented as the COMPLETE border-to-content offset, and both DOM readers measure clientLeft + paddingLeft. The geometry module itself is unchanged — it was always correct about the numbers it was given, and the fault was in what it was given.

The acceptance case could not have caught this: it set a border and no padding, so it passed whether or not padding was accounted for. It now sets both and asserts both applied, because a case whose inline style loses to the canvas stylesheet degrades to the at-rest case and passes while testing nothing.

The discovery control sat inside the glob it verifies

module-extensions.test.mts proves the runner follows .mts by executing. But if TEST_GLOBS loses that extension, the control stops being collected — so the evidence disappears along with the behaviour it was evidence for, and the run simply reports fewer tests passing.

The first attempt at this was wrong, and measurably so. It anchored the assertion in layering.test.ts on the reasoning that a .ts file is collected by any glob set that collects anything. But the globs are derived from one extension list, so narrowing that list un-collects the anchor too. Dropping ts from MODULE_EXTENSIONS reports:

Test Files  1 passed (1)
     Tests  2 passed (2)

Green, with every layering and geometry guard silently absent.

A check cannot survive a mutation it depends on, so it moved out of the suite entirely. vitest.global-setup.ts runs before any file is collected, where no glob decides whether it executes, and both outcomes are loud: with files collected it throws, and with none collected vitest raises FilesNotFoundError on its own.

It reads neither BUNDLED_MODULE nor MODULE_EXTENSIONS — both narrow with the mutation, and the check would agree with itself and pass. It walks every file, spells out what a test is named like as a literal, and compares that against the globs the runner was actually handed. An empty walk throws rather than reporting success.

Verified against three injected mutations:

mutation before after
ts dropped from MODULE_EXTENSIONS 1 passed (1), green throws, names all 3 uncollected files
mts dropped control silently absent throws, names module-extensions.test.mts
walk pointed at a directory with no tests n/a throws rather than passing on nothing

layering.test.ts keeps its glob/extension consistency check, which is a real internal-consistency property, with a comment that no longer claims it survives narrowing.

Verification

Builder: 60 tests, check-types and lint clean. e2e typechecks and lints clean. The browser suite is CI's to run; I have not re-run it locally against this commit and am not implying otherwise.

An iframe's nested viewport begins at the CONTENT box, so padding displaces it
exactly as a border does. Callers built the inset from clientLeft/clientTop,
which report the border alone, so every frame-local point mapped toward the
border by the scaled padding.

Measured in Chromium: an 8px border with 12px padding puts the border box at
x=8 and the inner element at host x=28, while border-only arithmetic computes
16. The 12px gap is the padding exactly.

The bordered acceptance case could not expose it because it set only a border;
it now sets padding too and asserts both applied, since a case that silently
loses its inline style degrades to the at-rest case and passes.

Also anchors the discovery check outside the derived glob. The .mts control
proves the runner follows that extension by executing, but a glob set that
loses .mts stops collecting the control, so the evidence vanishes with the
behaviour and the run just reports fewer tests. The assertion now lives in a
.ts file, which any glob set that collects anything will collect.
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@mobeenabdullah, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 50 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a8a2e76f-6ad6-4d57-9f48-54a24861e15c

📥 Commits

Reviewing files that changed from the base of the PR and between 5bfac2f and 7ddeb23.

⛔ Files ignored due to path filters (1)
  • .changeset/frame-content-origin-padding.md is excluded by !.changeset/**
📒 Files selected for processing (11)
  • e2e/tests/canvas/coordinate-mapping.spec.ts
  • e2e/tests/canvas/coordinate-mapping.ts
  • e2e/tests/canvas/poc-driver.ts
  • packages/builder/README.md
  • packages/builder/src/geometry-dom.ts
  • packages/builder/src/geometry.ts
  • packages/builder/src/index.ts
  • packages/builder/src/layering.test.ts
  • packages/builder/src/source-modules.ts
  • packages/builder/vitest.config.ts
  • packages/builder/vitest.global-setup.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Aug 12, 2026

Copy link
Copy Markdown

Open in StackBlitz

@nextlyhq/adapter-drizzle

npm i https://pkg.pr.new/@nextlyhq/adapter-drizzle@7ddeb23

@nextlyhq/adapter-mysql

npm i https://pkg.pr.new/@nextlyhq/adapter-mysql@7ddeb23

@nextlyhq/adapter-postgres

npm i https://pkg.pr.new/@nextlyhq/adapter-postgres@7ddeb23

@nextlyhq/adapter-sqlite

npm i https://pkg.pr.new/@nextlyhq/adapter-sqlite@7ddeb23

@nextlyhq/admin

npm i https://pkg.pr.new/@nextlyhq/admin@7ddeb23

@nextlyhq/admin-css

npm i https://pkg.pr.new/@nextlyhq/admin-css@7ddeb23

@nextlyhq/blocks-engine

npm i https://pkg.pr.new/@nextlyhq/blocks-engine@7ddeb23

@nextlyhq/blocks-react

npm i https://pkg.pr.new/@nextlyhq/blocks-react@7ddeb23

@nextlyhq/builder

npm i https://pkg.pr.new/@nextlyhq/builder@7ddeb23

create-nextly-app

npm i https://pkg.pr.new/create-nextly-app@7ddeb23

nextly

npm i https://pkg.pr.new/nextly@7ddeb23

@nextlyhq/plugin-form-builder

npm i https://pkg.pr.new/@nextlyhq/plugin-form-builder@7ddeb23

@nextlyhq/plugin-page-builder

npm i https://pkg.pr.new/@nextlyhq/plugin-page-builder@7ddeb23

@nextlyhq/plugin-sdk

npm i https://pkg.pr.new/@nextlyhq/plugin-sdk@7ddeb23

@nextlyhq/plugin-seo

npm i https://pkg.pr.new/@nextlyhq/plugin-seo@7ddeb23

@nextlyhq/storage-s3

npm i https://pkg.pr.new/@nextlyhq/storage-s3@7ddeb23

@nextlyhq/storage-uploadthing

npm i https://pkg.pr.new/@nextlyhq/storage-uploadthing@7ddeb23

@nextlyhq/storage-vercel-blob

npm i https://pkg.pr.new/@nextlyhq/storage-vercel-blob@7ddeb23

@nextlyhq/ui

npm i https://pkg.pr.new/@nextlyhq/ui@7ddeb23

commit: 7ddeb23

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ffe53b784c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread e2e/tests/canvas/coordinate-mapping.spec.ts Outdated
Comment thread packages/builder/src/geometry.ts
… recipe

The padding fix duplicated the very thing it was fixing: clientLeft + padding
was written independently in the acceptance mapping and in the driver, so a
future correction to one would recreate the silent drift.

frameInsetOf is now the single reader, exported from the package. It is passed
INTO the page rather than called on the Node side — Playwright serializes the
function, which works only because it closes over nothing — so one definition
serves the editor and the harness alike.

Both public recipes corrected too. The README and the FrameGeometry JSDoc still
defined the inset as clientLeft/clientTop, so a consumer following either
instruction reproduced the offset this branch fixes. They now name the function
instead of restating a recipe, because the recipe was documented and three call
sites still got it wrong.
@mobeenabdullah

Copy link
Copy Markdown
Collaborator Author

@codex please review this PR

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 36e57110bd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/builder/src/index.ts
Comment thread packages/builder/src/layering.test.ts Outdated
Comment thread packages/builder/src/geometry-dom.ts
Deriving the vitest globs, the layering guard's idea of a test and the file
walk from one extension list means a single edit narrows all of them at once.
Dropping "ts" from MODULE_EXTENSIONS leaves one .mts control collected and the
run reports 1 passed (1) in green, with every layering and geometry guard
silently absent.

The previous anchor sat in layering.test.ts, reasoning that any glob set
collecting anything would collect that file. The narrowing un-collects it too,
which is how the mutation went green; its comment now says what it actually
covers.

The check moves to globalSetup, which runs before any file is collected, so no
glob decides whether it executes. Both outcomes are loud: with files collected
it throws, and with none collected vitest raises FilesNotFoundError itself.

It reads neither BUNDLED_MODULE nor MODULE_EXTENSIONS, because both narrow with
the mutation and the check would agree with itself and pass. It walks every
file, spells out what a test is named like, and compares that against the globs
the runner was handed. An empty walk throws rather than reporting success.
The branch changes runtime behaviour in a published package and adds a public
export, so it needs a release record of its own to schedule the train.
@mobeenabdullah

Copy link
Copy Markdown
Collaborator Author

@codex please review this PR

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 7ddeb239b7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@mobeenabdullah
mobeenabdullah merged commit cf04a67 into main Aug 12, 2026
20 checks passed
@github-actions github-actions Bot added the type: docs Documentation only label Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: docs Documentation only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant