Skip to content

refactor(Layer): one presentation hold keeps a layer's chosen presentation until its close settles - #8587

Merged
cixzhang merged 4 commits into
mainfrom
feat/presentation-hold
Nov 8, 2026
Merged

cixzhang merged 4 commits into
mainfrom
feat/presentation-hold

Conversation

@cixzhang

@cixzhang cixzhang commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Retargeted to main: both bases (#8187, Popover's touch presentation; #8342, the input hold) are merged. A maintainer replayed this pull request's two commits onto current main (authorship kept) and resolved them against Popover's newer code.

What it does

One internal module with one job, the layer runtime's presentation hold (architecture:layer-runtime INV14): keep a layer's chosen presentation from the open until its close settles. packages/core/src/Layer/presentationHold.ts:

  • usePresentationHold({isOpen, presentation}) → {presentation, isHeld, release}. The render in which isOpen turns on holds presentation as it is then. It stays held, whatever presentation becomes, until the component calls release() when its close has settled.
  • createPresentationHold(): the same hold for code that chooses at an open event (take, current, isHeld, release).

It decides nothing about timing; the component says when its close has settled. It isn't the input hold (inputHold.ts, which drops input while a presentation animates). It isn't exported from the package or the Layer barrel (presentationHold.test.tsx locks that). It contains no component names.

Record

architecture:layer-runtime's current-gaps paragraph no longer says no shared presentation hold exists or that Popover builds its own; Owning code and verified_by name Layer/presentationHold.ts. INV14 itself is unchanged.

Writing rubric results

R1 narration: none; the current-gaps sentence and the Owning code entry state what the runtime owns now, in the present tense.
R2 research: none in the record.
R3 evidence: no evidence, basis or verification cell changed; verified_by names a test file.
R4 rejected alternatives: none added.
R5 change references: none.
R6 open questions: none touched.

Second pass, after the Popover, PowerSearch and Tokenizer records were edited (one gap sentence each):
R1 narration: none; each sentence states the current gap in the present tense.
R2 research: none. R3 evidence: no evidence cell changed. R4 rejected alternatives: none. R5 change references: none. R6 open questions: none.

First adopter: Popover

All three of Popover's latches move onto it:

Other components adopt it one pull request each: MobileNav (#8590) and Selector/MultiSelector (#8591) are open; Dialog, Lightbox and ToastViewport follow their touch-presentation pull requests, and BottomSheet its sheet stack. Known exception: Drawer follows side while open; adopting the shared hold would freeze it at open, a public behavior change for a later decision, so Drawer keeps its own exit latch.

No behavior change

Popover's existing tests are the oracle and pass unchanged: Popover.test.tsx, PopoverPresentation.test.tsx (the sheet latch, rotation and reopen cases) and the Layer suite, 370 tests in all, plus the module's own tests. The real-browser check is Popover's touch-presentation specs, which this PR's CI runs because the change touches the Popover folder.

Size (gzip KB, minified)

Method: a fresh packages/core dist at the base and at this head; an entry re-exporting the component; esbuild bundle, minify, splitting, ESM, packages external. Desktop is the static-import closure; phone is all chunks.

Component Desktop Phone
Popover 49.27 → 49.43 (+0.16) 68.85 → 69.01 (+0.16)
Drawer 25.14 → 25.15 (+0.01) 38.65 → 38.65 (+0.00)
DateRangeInput 56.12 → 56.12 (+0.00) 71.95 → 71.95 (+0.00)
Table 71.03 → 71.03 (+0.00) 90.73 → 90.73 (+0.00)
PowerSearch 136.42 → 136.43 (+0.01) 140.22 → 140.22 (+0.00)

Popover gains 0.16 KB for the shared module; later adopters reuse it.

Testing

  • pnpm vitest run --project ui packages/core/src/Layer packages/core/src/Popover: 370 pass.
  • tsc and eslint clean.
  • [chore] changeset (internal, no behavior change).

Co-authored with vjeux (the latches move from his Popover code).

Maintainer update (replayed onto main)

  • Both commits replayed onto main; their authorship is kept.
  • usePopoverSurfaceMotion: main's version (the shared isCoarsePointer resolver, release() for a fine pointer) with its touch latch moved onto createPresentationHold; closeStart reads the hold and lets it go.
  • layer-runtime current-gaps paragraph: keeps main's newer BottomSheet and INV17 text, and states that the runtime owns the shared presentation hold, which Popover uses; the other components still build their own.
  • Popover FR9's gap closes (its latch uses the shared hold); PowerSearch FR10 and Tokenizer FR16 keep their own holds, and their INV14 gap now says the runtime provides one that they have yet to adopt.
  • presentationHold.ts header no longer cites the record (the comment-provenance rule); the record links the file through Owning code and verified_by.
  • Testing: vitest for packages/core/src/Popover and packages/core/src/Layer: 30 files, 708 tests pass. tsc --noEmit: exit 0. check:knowledge: pass (also after the record edits). Strict lint on the changed files: clean.

@vercel

vercel Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 7, 2026 4:31pm UTC

Request Review

@github-actions github-actions Bot added needs:spec-owner-review Current knowledge records await owner approval needs:design-review Affects visuals — Design should review labels Oct 26, 2026
@astracat-bot

astracat-bot Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 7, 2026, 4:44 PM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 26, 2026
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · e75ef3d

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
LayerProvider 4.2 kB (0) · 20 B CSS (0) — ✓ · ✓ · ✗
lab/Comments 322.8 kB (+180 B) · 2.5 kB CSS (0) — — · — · —
Popover · Storybook 87.4 kB (+178 B) · 13.9 kB CSS (0) 1,509 (+2) ✓ · ✓ · ✓
7 more components
Component Size LoC Visual · A11y · RTL
lab/ChatReactionBar 103.0 kB (+172 B) · 1.1 kB CSS (0) — — · — · —
lab/CommentComposer 143.8 kB (+159 B) · 1.9 kB CSS (0) — — · — · —
lab/TourStep 93.7 kB (+152 B) · 590 B CSS (0) — — · — · —
lab/ChatEmojiPicker 101.8 kB (+144 B) · 773 B CSS (0) — — · — · —
lab/CommentThread 317.8 kB (+135 B) · 2.4 kB CSS (0) — — · — · —
layer — — — · ✓ · —
Layer — — ✓ · ✓ · —

Package size: @astryxdesign/core 6.90 MB packed (+3.0 kB); no new dependencies.

API changes: none in this pull request

Committed API report behind this build: cli 21 rows, core 25 rows; run pnpm api:report.

Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This can't be approved yet: it needs an engineering owner's decision on a spec addition, and three changes. Through the stacked exit-copy work, the diff against main adds INV13 ("One exit copy per closing layer") to the current architecture:layer-runtime record. An engineering owner records approval or rejection by commenting /approve-spec followed by the full head commit SHA on this pull request, and the author may do so if they are an engineering owner.

  • Land the parent pull requests (#8187, #8342 and the stack beneath them) and rebase, or retarget the base, so the diff carries only the 295-line presentation-hold commit instead of 38,390 authored lines.
  • Add touchHold to the useCallback dependency list at packages/core/src/Popover/usePopoverSurfaceMotion.ts:134, which currently fails the Lint check.
  • Update the Current gaps paragraph and Owning code in docs/architecture/layer-runtime.md, which still say no shared presentation hold exists and that Popover builds its own.

[Automated review]

Comment thread docs/architecture/layer-runtime.md Resolved
@cixzhang
cixzhang changed the base branch from main to stack/8587-base October 26, 2026 20:42
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 99b0ba8

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One small change is needed before approval: this pull request edits docs/architecture/layer-runtime.md, so please add a ## Writing rubric results section to the description with one line for each of R1–R6 from docs/contributing/spec-writing.md. The code needs no changes: Popover's three latches move onto the internal presentation hold with no behavior change, the Layer and Popover tests pass, Chromium renders the sheet and touch states exactly as before, and the record change is approved at this head. The failed Review signal job refused a stale 208-file count, so re-running it should publish review-required for this head.

[Automated review]

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks ready to approve: Popover's three presentation latches move onto the layer runtime's internal presentation hold with no behavior change, the unchanged Layer and Popover tests pass, Chromium renders the sheet and touch states exactly as before, and the record change is approved at this head with the writing rubric results now in the description. One housekeeping step remains: the Review signal check failed on a stale 208-file count when the base changed, so re-running it should publish review-required for this head.

[Automated review]

vjeux added a commit to vjeux/astryx that referenced this pull request Oct 27, 2026
# Conflicts:
#	docs/architecture/layer-runtime.md
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 27, 2026
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 30, 2026
Takes meta#8223's head, which carries meta#8187, meta#8342 and meta#8587 on main, and
meta#8329's, which carries meta#8909, meta#8340 and meta#8497 on meta#8360. They merge with no
conflict, and nothing in this pull request's own files needed resolving.
@github-actions github-actions Bot removed the needs:design-review Affects visuals — Design should review label Oct 31, 2026
vjeux added a commit to vjeux/astryx that referenced this pull request Nov 3, 2026
# Conflicts:
#	docs/architecture/layer-runtime.md
vjeux added a commit to vjeux/astryx that referenced this pull request Nov 3, 2026
vjeux added a commit to vjeux/astryx that referenced this pull request Nov 3, 2026
Takes meta#8223's head, which carries meta#8187, meta#8342 and meta#8587 on main, and
meta#8329's, which carries meta#8909, meta#8340 and meta#8497 on meta#8360. They merge with no
conflict, and nothing in this pull request's own files needed resolving.
…ation until its close settles

architecture:layer-runtime INV14 gives the layer runtime the presentation
hold: keeping a layer's chosen presentation from the open until the close
settles. Layer/presentationHold.ts (internal) is that one job:
createPresentationHold for code that chooses at an open event, and
usePresentationHold for a choice taken during render; the component releases
it when its close settles.

Popover adopts it for its three latches, with no behavior change: the
controlled surface (taken as isOpen turns on, let go as it turns off), the
sheet kept mounted until its dialog has closed, and the touch-or-pointer
presentation its close plays in (usePopoverSurfaceMotion). Not the input
hold (inputHold.ts). Not exported; a test locks that.

Co-authored-by: Christopher Chedeau <[email protected]>

# Conflicts:
#	packages/core/src/Popover/Popover.tsx
#	packages/core/src/Popover/usePopoverSurfaceMotion.ts
…the record names the shared hold

usePopoverSurfaceMotion's returned callback reads touchHold, so it is in its
dependency list (lint). architecture:layer-runtime's current-gaps paragraph
no longer says no shared presentation hold exists or that Popover builds
its own: the runtime owns it (Layer/presentationHold.ts) and Popover uses
it; Owning code and verified_by name it.

# Conflicts:
#	docs/architecture/layer-runtime.md
#	packages/core/src/Popover/usePopoverSurfaceMotion.ts
…iting the record

The record links the file through its Owning code and verified_by, so the header drops the record and claim citation the comment-provenance rule refuses.
@cixzhang
cixzhang changed the base branch from stack/8587-base to main November 7, 2026 15:53
@cixzhang
cixzhang force-pushed the feat/presentation-hold branch from 99b0ba8 to cf409fc Compare November 7, 2026 15:54
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 7, 2026
@cixzhang

cixzhang commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec cf409fc

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 7, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes requested: the refactor itself is sound, but three spec records still describe the shared presentation hold as missing.

  • Regression: docs/specs/components/Popover/Popover.spec.md line 196 (FR9's state), docs/specs/components/PowerSearch/PowerSearch.spec.md line 262 (FR10) and docs/specs/components/Tokenizer/Tokenizer.spec.md line 244 (FR16) still say the layer runtime has no shared presentation hold, which contradicts the updated architecture:layer-runtime record, so please set FR9's state to "Implemented" and say in the other two that the runtime's hold is Layer/presentationHold.ts and the field keeps its own until it adopts it.

Popover's existing tests pass unchanged and catch a broken hold, and the new module stays internal. The inline suggestions on the new comments are optional. A new commit needs a fresh /approve-spec <full head SHA> from an engineering owner, which the author may record as one.

[Automated review]

Comment thread docs/architecture/layer-runtime.md Resolved
Comment on lines +5 to +29
/**
* @file presentationHold.ts
* @input Whether a layer is open, and the presentation an opening would
* choose now
* @output createPresentationHold (an imperative hold, for code that decides
* at an open event) and usePresentationHold (the same hold taken during
* render): the presentation the opening chose, held until the component
* releases it
* @position The layer runtime's presentation hold: it keeps a layer's chosen
* presentation from the open until its close settles. Internal to core: not
* exported from the package or any barrel (presentationHold.test.tsx locks
* that). Not the input hold (inputHold.ts), which drops input while a
* presentation animates.
*
* A layer that can present more than one way (a popover that is a sheet on a
* phone, a touch grow or a pointer entrance) chooses as it opens, and its
* close has to play out in the same presentation even when what it would
* choose has changed meanwhile (a phone rotated past the compact width, a
* pointer that changed). One job: take the choice at the opening, hold it,
* and let it go when the component says its close has settled (its
* `<dialog>`'s `close` event, its exit animation's end). The component
* decides when that is; the hold decides nothing about timing.
*
* SYNC: When modified, update presentationHold.test.tsx.
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Optional (INV29): this header runs 25 lines, about twice the limit, and @output repeats the hook's JSDoc. A shorter header can keep only the reason:

/**
 * @file presentationHold.ts
 * @input Whether a layer is open, and the presentation it would choose now
 * @output createPresentationHold and usePresentationHold
 * @position The layer runtime's presentation hold. Internal to core. It is
 *   not the input hold (inputHold.ts).
 *
 * A close plays in the presentation that its open chose. The component
 * releases the hold when its close settles.
 *
 * SYNC: When modified, update presentationHold.test.tsx.
 */

Comment on lines +612 to +614
// The layer runtime's presentation hold (Layer/presentationHold), taken
// during render as the controlled `isOpen` turns on, so the open surface is
// known in the same render that opens it, and let go as it turns off.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Optional (INV29): this is one 37-word sentence that names the module and covers both the take and the release. Suggested:

// The hold is taken during render. The render that opens the popover then
// knows its surface.

Comment on lines +636 to +637
// The sheet's presentation hold: from the render that opens it until its
// dialog has closed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Optional (INV29): this restates usePresentationHold({isOpen: isSheetOpen, …}) and the comment above, which already says the sheet stays until its dialog has closed. It can go.

Comment on lines +63 to +64
// Whether the presentation in progress is the touch one, held from the
// open until its close begins (Layer/presentationHold).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Optional (INV29): "(Layer/presentationHold)" restates the import. Suggested:

// True while the presentation in progress is the touch one, until its close
// begins.

…ime's presentation hold

Popover FR9's open-to-close latch uses the shared hold, so its gap closes. PowerSearch FR10 and Tokenizer FR16 keep their own holds; their INV14 gap now says the runtime provides one and the field has yet to adopt it.
@cixzhang

cixzhang commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec e75ef3d

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved pending CI: the required test, build and docsite-test checks were stopped on this head because CI was full, so they have not run yet; re-run all jobs before this merges.

The Popover, PowerSearch and Tokenizer records now name the layer runtime's presentation hold, which resolves the earlier change request. Popover's existing tests pass unchanged, its sheet, touch and mouse presentations render the same before and after, and the hold stays internal. The earlier inline suggestions on the new comments remain optional.

[Automated review]

@cixzhang cixzhang closed this Nov 8, 2026
@cixzhang cixzhang reopened this Nov 8, 2026
@cixzhang
cixzhang merged commit 6422a1d into main Nov 8, 2026
171 of 177 checks passed
@github-actions
github-actions Bot deleted the feat/presentation-hold branch November 8, 2026 06:04
cixzhang added a commit that referenced this pull request Nov 9, 2026
#8587 (the layer runtime's presentation hold) merged as a squash, so
this takes main for everything outside MobileNav and keeps only
MobileNav's adoption: main's MobileNav, including the shared scroll
lock, with its close hold moved onto usePresentationHold.
cixzhang added a commit that referenced this pull request Nov 9, 2026
The presentation hold (#8587) merged into main, so this branch now targets
main. The Selector adoption's own diff is unchanged.

This branch was successfully deployed

1 active deployment
Preview — e75ef3d3 Deployed Nov 7, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant