Repository navigation
spec(AST-059): the layer runtime owns the viewport inset - #6916
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
Rubric pass (docs/contributing/spec-writing.md): the Intent names the behaviors rather than the changes that reached for them; no pull request remains as standing content; the open-pull-request and follow-up sections are gone (their durable facts are in the FRs; the rest is for the pull request description); rejected alternatives are one line each.
FR6 and DEC-4 rewrite on the owner's ruling: LayerProvider carries the inset, typed beside toast, with zero defaults; anchored layers and the toast viewport read one declaration (DEC-5). toast.inset stays as the per-edge toast override. Custom properties are the mechanism, not the API.
a714c7c to
19438d8
Compare
…ver exceeds the viewport FR8: a layer MUST NOT paint at a geometry it is about to correct; every geometry input resolves in the same frame as the render that produced it and the runtime measures nothing after paint. FR2/FR3: the layer box never exceeds the cap; content that cannot fit overflows inside. Verification rows name both viewports and the first-frame comparison.
|
/approve-spec 7cd9806 |
/approve-spec clears the merge gate; the record's own authority is written here: authority current, approved_by cixzhang, phase accepted, DEC-2 and DEC-5 as the owner's decisions.
PR Analysis ReportView Storybook for this PR · View Sandbox for this PR
Generated by PR Enrichment workflow | View current CI run |
There was a problem hiding this comment.
This PR proposes a new system record: the layer runtime would own the viewport inset for anchored layers — one gutter, a viewport (never span-beside-trigger) size cap, one flip-then-slide fallback order with a placement-axis span only as a last resort, and a single LayerProvider.inset declaration for an app floating a bar over a viewport edge.
Approval needs a maintainer to adopt this record as current for this exact revision through the spec-owner approval gate. Current records still assign viewport fitting to Popover, and that gate was still waiting for an engineering owner for this revision (the earlier /approve-spec comment named a predecessor), so I can't recommend approval yet. An owner question on adoption is already open for this revision. I'm not suggesting the proposal be removed or split for lacking spec authority; granting that authority is what this PR asks for.
Two smaller things to tidy alongside that decision:
- Please refresh the PR description and writing-rubric results, which still describe an earlier draft (FR1–FR7, draft authority) and don't yet mention FR8 or the new FR4 span last resort.
- One verification gap for that new FR4 clause is noted inline on the record.
For context, this is a record-only change with no runtime behavior today, and the knowledge validator passes on the new record.
[Automated review]
| | FR1, FR7 | One gutter module; a source scan for a second gutter or a `100%`-of-span cap among anchor-mode layers; story "the gutter" at both viewports | Default gutter at every edge; a wrapping layer beside a trigger flush with the edge | A second gutter constant among anchor-mode layers, or a layer inside the 16px gutter | | ||
| | FR2 | Stories "explicit size near an edge (352px)", "content-sized, fits beside the trigger", "content-sized, does not fit beside the trigger", "neither side fits" at both viewports; clamp strings in Popover and DropdownMenu suites | 352px end-aligned on a trigger 45px from the edge; a short content-sized layer; an unbreakable run wider than a phone; a 1000px layer on a phone, where the cap is 358px | A layer narrower than `min(asked, cap)`, a layer box wider than the cap at any viewport, or `100%` of the anchor span in a cap | | ||
| | FR3 | Story "taller than the viewport" at both viewports; the runtime's viewport-fit style on every anchor-mode layer | Content 2000px tall | The layer box's block size exceeds the viewport minus gutters | | ||
| | FR4 | Stories "content-sized, does not fit beside the trigger", "trigger near an edge flips", "neither side fits" at both viewports | A flip to end alignment at content size and at an explicit size; a 1000px layer slid inside the gutters where it fits | A layer squeezed into the span, a flipped edge off the trigger's edge, or a layer outside the gutters | |
There was a problem hiding this comment.
The FR4 verification row doesn't yet cover the clause just added to FR4: the last-resort span of the whole placement axis inside both gutters (which may cover the anchor), or a would-be placement being rejected only because it would end inside a gutter / under a declared bar. The representative states here cover flips and a slide where the layer fits, so an implementation could pass every named state while getting the span last resort wrong. Please add a representative state and failure expectation for that case (for example, content that fits on neither side of the placement axis, asserting the box stays inside both gutters and is not squeezed to one side's room).
There was a problem hiding this comment.
This PR proposes a new system record: the layer runtime would own the viewport inset for anchored layers — one gutter, a viewport (never span-beside-trigger) size cap, one flip-then-slide fallback order, and a single LayerProvider.inset declaration for an app floating a bar over a viewport edge.
Approval needs a maintainer to adopt this record as current for this exact revision through the spec-owner approval gate. Current records still assign viewport fitting to Popover, and that gate was still waiting for an engineering owner for this revision (the earlier /approve-spec comment named a predecessor), so I can't recommend approval yet. I've asked that maintainer question for this revision. I'm not suggesting the proposal be removed or split for lacking spec authority; granting that authority is what this PR asks for.
Two smaller things to tidy alongside that decision:
- Please refresh the PR description and writing-rubric results, which still describe an earlier draft (FR1–FR7, draft authority) and don't yet mention FR8 or the revised FR4 placement-axis language.
- Clarification and verification corrections for the revised FR4 text are noted inline on the record.
For context, this is a record-only change with no runtime behavior today, and the knowledge validator passes on the new record.
[Automated review]
| next option is tried. On the placement axis that positional bound is the | ||
| larger of the axis's two gutters, applied to both edges, so a bar declared on | ||
| one block edge keeps a layer the same distance from the opposite edge (the | ||
| size cap still subtracts each edge's own gutter). Content taller than either | ||
| side can hold is capped to the viewport and shifted into it, keeping its | ||
| anchor clearance from the edge it meets. The runtime authors this order; a component passes no |
There was a problem hiding this comment.
This revised placement-axis language leaves which distance a shifted taller layer keeps from the viewport edge unclear. The preceding sentence bounds position by the larger of the axis's two gutters on both edges, while the size cap subtracts each edge's own gutter, and this sentence instead says the shifted layer keeps "its anchor clearance from the edge it meets" — a term this record does not define (in the layer's own docs, clearance is the offset between a layer and its anchor, not the viewport gutter). An implementer therefore cannot tell whether the edge distance should be the larger gutter, that edge's gutter, or the anchor offset, nor how a layer at the size cap is meant to satisfy the symmetric positional bound when the two gutters differ. Please define or replace the term and state the intended edge distance for this case.
| | FR1, FR7 | One gutter module; a source scan for a second gutter or a `100%`-of-span cap among anchor-mode layers; story "the gutter" at both viewports | Default gutter at every edge; a wrapping layer beside a trigger flush with the edge | A second gutter constant among anchor-mode layers, or a layer inside the 16px gutter | | ||
| | FR2 | Stories "explicit size near an edge (352px)", "content-sized, fits beside the trigger", "content-sized, does not fit beside the trigger", "neither side fits" at both viewports; clamp strings in Popover and DropdownMenu suites | 352px end-aligned on a trigger 45px from the edge; a short content-sized layer; an unbreakable run wider than a phone; a 1000px layer on a phone, where the cap is 358px | A layer narrower than `min(asked, cap)`, a layer box wider than the cap at any viewport, or `100%` of the anchor span in a cap | | ||
| | FR3 | Story "taller than the viewport" at both viewports; the runtime's viewport-fit style on every anchor-mode layer | Content 2000px tall | The layer box's block size exceeds the viewport minus gutters | | ||
| | FR4 | Stories "content-sized, does not fit beside the trigger", "trigger near an edge flips", "neither side fits" at both viewports | A flip to end alignment at content size and at an explicit size; a 1000px layer slid inside the gutters where it fits | A layer squeezed into the span, a flipped edge off the trigger's edge, or a layer outside the gutters | |
There was a problem hiding this comment.
The FR4 verification row does not yet cover the revised FR4 clauses: a placement-axis positional bound that applies the larger of the two gutters to both edges (for example, a bar declared on one block edge only, asserting the distance kept from the opposite edge alongside the per-edge size cap), or content taller than either side of its trigger can hold that is capped and shifted into the viewport. The representative states here cover flips and a slide where the layer fits, and the FR3 row covers only a taller layer's size cap — neither asserts the symmetric positional bound's opposite-edge distance nor a shifted taller layer's final edge distance, so an implementation could pass every named state while getting those two cases wrong. Please add representative states and failure expectations for them.
There was a problem hiding this comment.
This PR proposes a new system record: the layer runtime would own the viewport inset for anchored layers — one gutter, a viewport (never span-beside-trigger) size cap, one flip-then-slide fallback order, and a single LayerProvider.inset declaration for an app floating a bar over a viewport edge, now including a nested-provider rule for a subtree's layers.
Approval needs a maintainer to adopt this record as current for this exact revision through the spec-owner approval gate. Current records still assign viewport fitting to Popover, and that gate was still waiting for an engineering owner for this revision (the earlier /approve-spec comment named a predecessor), so I can't recommend approval yet. I've asked that maintainer question for this revision. I'm not suggesting the proposal be removed or split for lacking spec authority; granting that authority is what this PR asks for.
Two smaller things to tidy alongside that decision:
- Please refresh the PR description and writing-rubric results, which still describe an earlier draft (FR1–FR7, draft authority) and don't yet mention FR8, the revised FR4 language, the nested-provider rule, or VG1.
- Clarification and verification corrections — including what nested-provider "narrows" means per edge and what VG1 requires an implementation to do on return after a slide — are noted inline on the record.
For context, this is a record-only change with no runtime behavior today, and the knowledge validator passes on the new record.
[Automated review]
| next option is tried. On the placement axis that positional bound is the | ||
| larger of the axis's two gutters, applied to both edges, so a bar declared on | ||
| one block edge keeps a layer the same distance from the opposite edge (the | ||
| size cap still subtracts each edge's own gutter). Content taller than either | ||
| side can hold is capped to the viewport and shifted into it, keeping its | ||
| anchor clearance from the edge it meets. The runtime authors this order; a component passes no |
There was a problem hiding this comment.
This placement-axis language leaves which distance a shifted taller layer keeps from the viewport edge unclear. The preceding sentence bounds position by the larger of the axis's two gutters on both edges, while the size cap subtracts each edge's own gutter, and this sentence instead says the shifted layer keeps "its anchor clearance from the edge it meets" — a term this record does not define. In the layer's own vocabulary, clearance is the gap between a layer and its anchor (kept across a flip), not a distance from the viewport edge, so a reader cannot tell whether the shifted layer keeps the larger gutter, that edge's own gutter, or its anchor clearance. Please name the one distance intended, in the gutter terms this record already defines.
| | FR1, FR7 | One gutter module; a source scan for a second gutter or a `100%`-of-span cap among anchor-mode layers; story "the gutter" at both viewports | Default gutter at every edge; a wrapping layer beside a trigger flush with the edge | A second gutter constant among anchor-mode layers, or a layer inside the 16px gutter | | ||
| | FR2 | Stories "explicit size near an edge (352px)", "content-sized, fits beside the trigger", "content-sized, does not fit beside the trigger", "neither side fits" at both viewports; clamp strings in Popover and DropdownMenu suites | 352px end-aligned on a trigger 45px from the edge; a short content-sized layer; an unbreakable run wider than a phone; a 1000px layer on a phone, where the cap is 358px | A layer narrower than `min(asked, cap)`, a layer box wider than the cap at any viewport, or `100%` of the anchor span in a cap | | ||
| | FR3 | Story "taller than the viewport" at both viewports; the runtime's viewport-fit style on every anchor-mode layer | Content 2000px tall | The layer box's block size exceeds the viewport minus gutters | | ||
| | FR4 | Stories "content-sized, does not fit beside the trigger", "trigger near an edge flips", "neither side fits" at both viewports | A flip to end alignment at content size and at an explicit size; a 1000px layer slid inside the gutters where it fits | A layer squeezed into the span, a flipped edge off the trigger's edge, or a layer outside the gutters | |
There was a problem hiding this comment.
The FR4 verification row does not yet cover the revised FR4 clauses: a placement-axis positional bound that applies the larger of the two gutters to both edges (for example, a bar declared on one block edge only, asserting the distance kept from the opposite edge alongside the per-edge size cap), or content taller than either side of its trigger can hold that is capped and shifted into the viewport. The representative states here cover flips and a slide where the layer fits, and the FR3 row covers only a taller layer's size cap — neither asserts the symmetric positional bound's opposite-edge distance nor a shifted taller layer's final edge distance, so an implementation could pass every named state while getting those two cases wrong. Please add representative states and failure expectations for them.
| one hosted in place. A provider nested under another is otherwise inert, but | ||
| one that declares an inset narrows it for the anchored layers in its | ||
| subtree; the toast viewport is the root provider's and reads the root's | ||
| declaration. The inset is app state, not a theme value (DEC-4). |
There was a problem hiding this comment.
This new nested-provider sentence does not define what "narrows it" does per edge. Today nested providers are complete no-ops, so implementers need the operation: does a nested declaration replace the root's value edge by edge, add to it, or only ever increase it (narrow the usable viewport)? It also needs the unset case: if a nested provider declares one edge, or declares zero, do the other edges inherit the root's declaration or fall back to zero — that is, can a nested provider ever widen a subtree back out from under the root's bar? As written, the earlier sentence "moves the toast viewport by the same amount" also reads as applying to a nested declaration, which this sentence then contradicts for toasts. Please state the per-edge composition rule, qualify the toast sentence to the root provider, and add a nested-provider state to the FR6 verification row (root bar plus a nested declaration over layers in and outside the subtree, with a toast staying at the root's position).
| **Verification gap — VG1.** A layer that had to slide (it fit on neither | ||
| side of its trigger) and whose anchor leaves and returns can come back | ||
| start-aligned to its anchor and off-screen until its next layout: Chromium | ||
| does not re-run the slide when the off-screen pin is withdrawn. The "anchor | ||
| leaves the viewport" story asserts the return only where the layer fit beside | ||
| its trigger. FR5's hold is verified; the return after a slide is not. |
There was a problem hiding this comment.
VG1 honestly names the gap, but it leaves the normative status of the slide-then-return case unsettled. FR4 requires a layer that fits on neither side to slide inside the gutters while its anchor is in view, FR5's verification row fails a layer that "does not return with its anchor," and this paragraph says such a layer can come back off-screen until its next layout because the slide is not re-run. Please state what conformance requires here: must an implementation re-run the slide (or force the layout that does) so the returning layer is never painted off-screen, or is off-screen-until-next-layout an explicitly accepted limitation — and if it is accepted, bound it (for example, no painted frame off-screen) so the FR5 row and VG1 do not contradict each other. As written an implementer cannot tell whether shipping the Chromium behavior described here passes or fails this record.
|
/approve-spec d127aa1 |
Exact decision needed
Who owns an anchored layer's viewport inset — the gutter from the viewport edge and the device safe area, the size cap, the fallback order (flip, then slide), and the place an app declares a persistent bar floating over a viewport edge. Today four components each define their own, the copies have drifted, and one of them caps an aligned layer's inline size to the span of viewport beside its trigger, so an explicit width shrinks near an edge.
Existing authority searched
architecture:layer-runtime(current): INV3 already says anchor mode owns placement and fallbacks, and its Positioning section records that Popover adds viewport sizing above the geometry — true of shipped code. The record describes shippedmainand incorporates accepted change only as it ships (spec:AST-003is its precedent), so it cannot carry this decision until the consolidation lands.component:Popover(current): FR3, ORD2, ORD3 claim viewport and safe-area capping for Popover. Same authority rule.Popover.tsx(POPOVER_VIEWPORT_GUTTER),DropdownMenu.tsx/DropdownMenuSubMenu.tsx(MENU_VIEWPORT_GUTTER, plus amin(300px, …)cap the popover lacks),BaseTypeahead.tsx(TYPEAHEAD_*, span cap only, unclamped match-trigger minimum),ComplexSelector.tsx(a fifth copy without the safe-area term).useLayerhas no viewport-inset code;getPositionTryFallbacksreturns span fallbacks for centered alignments only.span-allfallbacks from Popover into the layer) and feat(layer): per-edge viewport inset custom properties for a persistent bar floating over the viewport #6686 (four per-edge inset custom properties read by three components). Neither is touched by this PR.Decision
spec:AST-059(authority: draft): the layer runtime owns the viewport inset; Popover is an application of the layer that adds styling on top.max(--spacing-4, env(safe-area-inset-<edge>))plus that edge's app-declared inset; one definition in the runtime.insetonLayerProvider(blockStart/blockEnd/inlineStart/inlineEnd, zero by default); anchored layers and the toast viewport both read it;toast.insetstays as the toast-only per-edge override that replaces, never adds (DEC-5). App configuration, not a theme value; nolayertheme target (DEC-4, owner ruling).useLayeranchor-mode andusePopoverconsumer inherits FR1–FR5 with no record change; a consumer minimum is clamped by the runtime's cap.Popover keeps its props, its visual treatment, conditional scrolling, and the one fact the layer cannot know: whether this instance was given an explicit size (explicit width wins over trigger matching).
Rejected alternatives
popovertheme target or a newlayertarget (DEC-4): one component's theme governing three others; a theme cannot know an app's shell layout. Hand-written custom properties as the public surface: untyped, undiscoverable besidetoast, no default.toast.insetto the provider inset: clears the same bar twice.Claim scope and non-goals
Owns the gutter, the caps, the fallback order, the app-declared inset, consumer inheritance, and the Layer stories. Does not settle sizing a layer to the roomier side on the placement axis, Toast or fullscreen Dialog, the reduced no-anchor-positioning docs (
spec:AST-003), or any component's scrolling, focus, dismissal, or theming.Writing rubric results
Pass against
docs/contributing/spec-writing.mdat heada714c7c(FR6/DEC-4/DEC-5 rewrite included):Relationship to open work (description only — not record content)
span-allfallbacks are FR4 at the layer, and the off-screen behavior the owner found is FR5. Its 352px end-aligned case is aCore/Layerstory in feat(layer): the layer runtime owns the viewport inset (spec:AST-059) #6919. Closing fix(popover): an explicit width is capped by the viewport, not the span beside the trigger #6688 is the owner's call; it is untouched.Evidence and implementation relationship
Evidence is Astryx's own source, read on
mainatd8370a1: the five gutter copies, thecalc(100% - gutter)span cap,resolveMenuWidthwrapping a length asmin(<length>, span),getPositionTryFallbacksreturning flips only for aligned layers, and #6688's own Chromium measurement (352px asked, 274px rendered). The record lists the exact deltas toarchitecture:layer-runtimeandcomponent:Popoverto apply when the consolidation ships, what the other consumers inherit, the disposition of #6688 (superseded in substance) and #6686 (rebases onto the consolidation), and the ordered follow-up list.Stories and the consolidation are #6919, stacked on this branch; the record is valid without them. Opened as a draft so the spec gate does not auto-merge a draft-only record before the owner has read it.
Scope
Validation
pnpm check:knowledge— Knowledge templates and records are aligned.git diff --check— clean.