Skip to content

feat(core): one shared context request from a long press, a right click and Shift+F10 - #8670

Merged
cixzhang merged 4 commits into
meta:mainfrom
vjeux:uikit/f2-context-request
Nov 12, 2026
Merged

cixzhang merged 4 commits into
meta:mainfrom
vjeux:uikit/f2-context-request

Conversation

@vjeux

@vjeux vjeux commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

User need

A context menu should open the same way from a held finger or pen, a right click, and Shift+F10 or the context-menu key. Each component wired its own handlers, so the rules differed: a held finger on Android could open the browser's own menu beside Astryx's.

Problem and solution fit

One internal attachContextRequest(element, {onRequest}) decides for every component. It reports one request per gesture, naming its input (hold, pointer or keyboard), its pointer and its point. So a keyboard-opened menu can focus its first row.

Current specification

spec:AST-094 FR43: one shared context request from a long press, a context click, or Shift+F10 and the context-menu key; FR24 for listening only while enabled. This change names gestures/contextRequest.ts in FR43 and lists it in the record's paths.

Public delta and caller burden

None: the module is internal and not exported. A component passes its element, an onRequest callback, and optionally isEnabled and onHold.

Design and alternatives

  • The hold is UIKit's long press, 500 ms and 10 pt. As an arena participant, it loses to a claim another recognizer made first, such as a reorder handle's.
  • A mouse held still makes no request: it selects text and drags.
  • A control that keeps its press for a hold-repeat owns only its hold; its right click and Shift+F10 still reach the request.
  • The browser's own menu is refused once. A finger's is refused while it is down inside the element, and a pen's during and right after any hold of it there.
  • Inside nested requests, a right click or a key reaches only the innermost.
  • It listens on its own element only, and only while enabled.
  • Rejected: per-component handlers, whose rules drift, and a public request; the headless context menu is the public layer.

Evidence

  • Unit cases cover each rule above: a kept press, a mouse hold and the browser menu. They also cover a pen's menu after another participant's hold, nested requests, and a finger elsewhere during a right click.
  • In Chromium and WebKit, a held finger, a right click and Shift+F10 on one row each make exactly one request, naming their input.

Scope

  • One capability is added.
  • Unrelated fixes, cleanup, and policy changes were removed or split.
  • Consumer docs, focused tests, and migration evidence ship with the feature.
  • Public text and artifacts contain no internal Meta context.

Leaves draft on its own; #8693, its first user, builds on it. Feel check: not applicable; nothing visible changes until a component adopts it.

Testing

Local gates at 3b24c79, three commits on main f890983. The first merges main. Its one conflict is in GestureHost.ts, where main's per-window clock made eventTime's clock argument required. The merge keeps this change's pen-hold note and passes this.timing in its three eventTime calls. No other line of this change differs. The second commit is records-only. The third keeps the set of answered menu events under a registered key, so nested requests in two copies of Core answer once (spec:AST-110 FR3).

  • tsc --project packages/core/tsconfig.json --noEmit, strict ESLint, Prettier on the changed files, pnpm check:knowledge and pnpm review:pre (no findings): clean.
  • Core's unit files (packages/core in the ui project), at 226b3a1: 838 files, 22,392 tests passed. At this head, the gesture, ContextMenu and utility units: 108 files, 2,218 tests passed.
  • scripts/shared-identity.test.mjs: 7 passed at this head; at 226b3a1 it listed the module-local set. The new two-copies case fails with that set: the outer copy also requests.
  • The whole node project at this head, on a shared 40-CPU box: 1,066 files passed and 9 skipped. Five CLI files failed in that run: four on timeouts, and one render case with ERR_RENDER_FAILED for ERR_RENDER_COMPILE. Alone, those five files pass: 798 tests. Main f890983, run the same way, fails six files, four of them the same.
  • The gesture browser proofs: Chromium 78 passed and 4 skipped. In WebKit at CI's profile (4 CPUs, CI=1, LP_NUM_THREADS=4, one worker), three runs: 210 passed and 36 skipped, none failed.
  • ContextMenu's long-press accessibility proof in Chromium: 2 passed.
  • At the earlier replay 6fdf902, WebKit ran the gesture proofs ten times: 690 passed and 120 skipped, none failed.

Writing rubric results

  • R1 narration: none; the FR43 sentences state what the module does.
  • R2 research: none.
  • R3 evidence: no verification cell changes.
  • R4 rejected alternatives: none added.
  • R5 change references: none.
  • R6 open questions: none.
  • R7 project status: none added. No headless context menu ships today. component:ContextMenu FR10 records that gap, and FR43 cites FR10 rather than repeating it.

@vercel

vercel Bot commented Oct 27, 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 12, 2026 10:51am UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 12, 2026, 11:02 AM UTC

@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Oct 27, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 27, 2026
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 27, 2026
… selection off document-wide) into the meta#8228 helper
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 27, 2026
… for a recognizer inside a shadow root) into the meta#8228 helper

@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.

The context request needs an engineering owner's decision before it can be approved: attachContextRequest rests on spec:AST-094 FR43 and DEC-21, which exist only in open #8646, and its hold attaches a recognizer with a blocking touchmove under a fine pointer, which FR19, FR24 and architecture:react-component-runtime INV13 on main still rule out. An engineering owner records that #8646's text governs here by commenting /approve-spec <full head SHA> on this pull request (the author may do so as an engineering owner), or the change waits for #8646 to land; that decision should also settle whether a hold-repeat control keeps the row's right click and Shift+F10, which no record states yet. Independently of it:

  • Land #8665 and its ancestors first, or retarget, so this diff is the context request's 676 lines rather than 29,372.
  • Refuse a pen's own contextmenu after its hold and keep a pen barrel press from starting a press, since a pen now gets two requests for one gesture.
  • Schedule hold.requestMs on the arena's clock and report its deadline, as FR16 requires, with a test.

[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.

Recommending approval. attachContextRequest follows spec:AST-094 FR43 and its neighbouring claims (FR41, FR12, FR15, FR24), and the engineering owner's rulings on the hold-repeat control and the cut hold options. Two optional follow-ups, fine to leave for the context menu that adopts it:

  • A held Shift+F10 makes one request per auto-repeat (onKeyDown in contextRequest.ts); ignoring key.repeat after cancelling it keeps the README's one request per gesture.
  • onHold reports committed for a request disabled during the hold, while its JSDoc says committed comes as the hold requests; read isEnabled first or reword the JSDoc.

[Automated review]

vjeux added a commit to vjeux/astryx that referenced this pull request Nov 3, 2026
useLongPress takes her createLongPressDetector with stages, the structure
kept whole, and my side's two changes on it: the defaults come from the one
long-press source (motion/uikit/longPress.ts) and a long press's drift is a
distance, as UIKit measures allowableMovement ((7, 7) keeps the press,
(7.2, 7.2) ends it). Her measured context-menu tolerance is per axis ((11,
11) still opens the menu, M-CM3), so the detector gains isPerAxis and
contextMenuPress passes it. Her FR24 case 'leaves no timer of the lift
behind when it unmounts while the lift is still growing' found the click
guard's 400 ms window (utils/clickGuard.ts, from my side) still armed at
unmount: that timer is the page's, not the lift's, so the case disarms the
guard before it counts. The two READMEs take both sides' rows and sections.
vjeux added a commit to vjeux/astryx that referenced this pull request Nov 3, 2026
… selection off document-wide) into the meta#8228 helper
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
… for a recognizer inside a shadow root) into the meta#8228 helper
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
… when asked, cancels on a drift, and times its request on the gesture clock) into the meta#8228 helper
vjeux added a commit to vjeux/astryx that referenced this pull request Nov 3, 2026
…s menu trigger tolerance at the press, meta#8358's useLongPress on each axis, meta#8336's flat-tree scroll checks) into the meta#8228 helper

# Conflicts:
#	packages/core/src/hooks/useLongPress.ts
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
…t after the commit requests) into the headless context menu
vjeux added a commit to vjeux/astryx that referenced this pull request Nov 3, 2026
…into the headless context menu

packages/core/src/utils/pressFeedback.ts: meta#8670's text, with this
stack's own press-paint subscription (c338e93: subscribePressPaint,
which ContextMenu's press feedback follows) re-applied on it; meta#8670's
fold kept only its own line's edits to this file.
vjeux added a commit to vjeux/astryx that referenced this pull request Nov 3, 2026
…, with no stages (spec:AST-094 FR43)

Red: meta#8670 cuts the context request's two-stage hold (commitMs,
requestMs, requestOnLift) and its per-axis allowance, as asked there:
the hold is UIKit's long press and requests as it begins. ContextMenu
and the factory's menu still open a held finger at 735 ms, open at a
lift after 400 ms, and allow 11.5 pt on each axis. They should open at
500 ms under any primary pointer, open nothing for a lift before it, and
open nothing for a drift past 10 pt.
vjeux added a commit to vjeux/astryx that referenced this pull request Nov 3, 2026
meta#8665 now carries meta#8360's new head and the maintainer's host review: a
blur ends an armed press, a kept press's touchmove follows the press,
hover reaches every pointer, and a pen's barrel button starts no press.
The one conflict, utils/pressFeedback.ts, takes meta#8665's text: both merges
of main resolved it the same way, and this pull request does not change
that file.
vjeux added a commit to vjeux/astryx that referenced this pull request Nov 3, 2026
…peat control owns only its hold

- A pen held still requests through the hold, and the browser then fires
  the pen's own context menu event, during the hold or at its lift: a
  second request for one gesture. One request only, the hold's.
- The engineering owner's ruling on meta#8670: a hold-repeat control inside a
  row owns only its hold; its right click and Shift+F10 still reach the
  row's context request. Today both are refused there.
Both fail until the context request refuses the pen's echo and leaves a
kept press only its hold.
vjeux added a commit to vjeux/astryx that referenced this pull request Nov 3, 2026
… with no options a record does not need

The engineering owner's ruling on meta#8670: cut the two-stage commitMs,
requestMs and requestOnLift, and the allowableMovement and isPerAxis
tolerance, until a record calls for them. The hold is UIKit's long press,
500 ms and 10 px as a distance, and requests as it begins; onHold reports
it committed, then ended or cancelled. LongPressGestureRecognizer loses
isPerAxis and geometry its axisTravel, with their tests.
vjeux added a commit to vjeux/astryx that referenced this pull request Nov 3, 2026
…press, with no options) into the headless context menu

packages/core/src/utils/pressFeedback.ts and its test: meta#8670's text,
with this stack's press-paint subscription (subscribePressPaint, which
ContextMenu's press feedback follows) kept beside it.
packages/core/src/hooks/useLongPress.ts, its test, its page and
useMenuPress.ts: meta#8670's text. This stack's useLongPress `stages` and
press start times served ContextMenu's two-stage hold, which no longer
exists (the context request opens ContextMenu, and its hold has no
stages), so they go, with their changeset and the hooks entry's
LongPressStage type.
vjeux added a commit to vjeux/astryx that referenced this pull request Nov 3, 2026
… with none of the hold options meta#8670 cut (spec:AST-094 FR43)

meta#8670 cuts the context request's two-stage hold (commitMs, requestMs,
requestOnLift), allowableMovement and isPerAxis, as asked there: the hold
is UIKit's long press and requests as it begins. ContextMenu and the
factory passed them for UIContextMenuInteraction's 400 ms commit, 735 ms
menu, open at a lift and 11.5 pt on each axis. They pass none now: under
any primary pointer a held finger gets the menu at 500 ms, a lift before
it is a tap, and a drift past 10 pt (a distance) opens nothing. Under the
touch model the commit, now the long press, plays the haptic and the
press feedback plays UIKit's press curve until the menu shows.

The UIKit table's per-axis drift guess has no reader left and goes. The
tests, the interaction specs, the docs, the story and the changesets
that described the two-stage hold describe the long press; the tests of
a lift after the commit and of a drag between the commit and the menu
go with that window.

@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: CI has not run on this head yet. attachContextRequest follows spec:AST-094 FR43 and its neighbouring claims (FR41, FR12, FR15, FR24), and the engineering owner's rulings on the hold-repeat control and the cut hold options; nothing blocks.

Next: mark the pull request ready for review, and a maintainer adds the ci:run label so CI runs on this fork branch.

Two optional follow-ups, fine to leave for the context menu that adopts it:

  • A held Shift+F10 makes one request per auto-repeat (onKeyDown in contextRequest.ts); ignoring key.repeat after cancelling it keeps the README's one request per gesture.
  • onHold reports committed for a request disabled during the hold, while its JSDoc says committed comes as the hold requests; read isEnabled first or reword the JSDoc.

[Automated review]

A context menu should open the same way from a held finger or pen,
a right click, and Shift+F10 or the context-menu key. Each component
wired its own handlers, so the rules differed: a held finger on
Android could open the browser's own menu beside Astryx's.

attachContextRequest(element, {onRequest}) is the one internal request
a context menu answers. Each gesture makes one request, naming its
input (a hold, a pointer or the keyboard), so a keyboard-opened menu
can focus its first row. A held key's repeats make no request. The
hold is UIKit's long press and an arena participant, so it loses
to a claim another recognizer made first. A hold disabled before
it requests reports nothing. A mouse held still makes no request. A
control that keeps its press for a hold-repeat owns only its hold,
while its right click and Shift+F10 still reach the request. The
browser's own menu is refused once, for a finger while it is down
inside the element and for a pen during and right after any hold of it
there. Inside nested requests, a right click or a key reaches only the
innermost. It listens on its own element only, and only while enabled.

@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: CI has not run on this head yet, because the pull request is still a draft from a fork. To run it, mark the pull request ready for review, and a maintainer adds the ci:run label.

attachContextRequest follows spec:AST-094 FR43 and its neighbouring current claims (FR12, FR15, FR24, FR41) and the engineering owner's rulings on hold-repeat controls and the hold options; the unit cases and the Chromium browser case cover each rule, and the earlier notes on a held key's repeats and onHold's committed are fixed.

Non-blocking:

  • The module-scope answered set (contextRequest.ts:62) would split under a swizzled copy of the module, so a package request nested in a copied one could answer the same right click twice; keeping it in a realm store, as the gesture host registry does, keeps one set.

[Automated review]

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 8cb9f21

FR43 says one shared context request answers a long press, a right
click and Shift+F10. The requirement now names that module,
gestures/contextRequest.ts, and what it does: one request per gesture,
the input that made it, the browser's own menu kept closed, and a hold
that loses to an earlier claim. The headless context menu makes its
request through it, and ContextMenu through that menu, so every menu
opens by the same rules. The record's path list links the module.
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 226b3a1

@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: CI has not run on this head yet because the pull request is still a draft; marking it ready for review starts CI, since it already carries ci:run.

attachContextRequest follows spec:AST-094 FR43 as rewritten here, which an engineering owner approved for this head, and its neighbouring claims (FR12, FR15, FR24, FR41); the unit cases and the FR43 browser case cover each rule, and the earlier inline findings are fixed apart from the first note below.

Non-blocking:

  • The module-scope answered set (contextRequest.ts:62) would split under a swizzled copy of the module, so a package request nested in a copied one could answer one right click twice; keeping it in a realm store, as the gesture host registry does, keeps one set.
  • Newly live check: the README's "only while enabled" (gestures/README.md:577) holds for the state read at attach; a request that turns disabled later keeps its element listeners until its caller detaches it, so the README could say that such a menu attaches again.
Claims and files checked
  • Changeset, one shared request from a long press, a right click, Shift+F10 and the context-menu key: verified (contextRequest.ts:89-197; tests at contextRequest.test.ts:149, :164, :233).
  • Changeset, the request reports which input made it, one per gesture: verified (tests at :149-:180, :505).
  • Changeset, a held finger's hold loses to a claim made first: verified (test at :414).
  • Changeset, a hold-repeat control owns only its hold and its right click and Shift+F10 reach the request: verified (contextRequest.ts:97; test at :439).
  • Changeset, a held pen's own menu event is refused like a finger's: verified (contextRequest.ts:151-156; tests at :280, :463).
  • Changeset, the hold is UIKit's long press and requests as it begins: verified (contextRequest.ts:89-126; test at :233).
  • Changeset, not exported from the package entry point: verified (Core's exports map and src/index.ts).
  • Description, menus wire their own handlers today: verified for ContextMenu (ContextMenu.tsx:647-700); the Android sentence is motivation, not something this change claims to fix.
  • Description, one request per gesture naming its input, pointer and point: verified (contextRequest.ts:19-34).
  • Description, the record names the module in FR43 and lists it in its paths: verified (spec.md lines 37 and 874-880).
  • Description, no public delta, and the options are the element, onRequest, isEnabled and onHold: verified (contextRequest.ts:36-50).
  • Description, a 500 ms / 10 pt hold that loses to a claim made first, and no request from a mouse held still: verified (tests at :403, :414, :253).
  • Description, the browser's menu is refused, a finger's while it is down inside and a pen's during and right after a hold: verified (contextRequest.ts:140-158; tests at :233, :280, :463, :523).
  • Description, nested requests answer once, at the innermost: verified (test at :505).
  • Description, the request listens on its own element only and only while enabled: verified for the state read at attach (test at :581); see the second note.
  • Description, unit and browser cases cover each rule: verified by reading (contextRequest.test.ts; gestures.interaction.browser.spec.ts:1197); not re-run in this review.
  • Description, the merge changed only the three clock arguments and the last commit only the record: verified (GestureHost.ts:3907-3912, :3957-3959, :4082-4084).
  • Files: the changeset, spec.md, GestureHost.ts, bareFixture.ts, gestures.interaction.browser.spec.ts and contextRequest.test.ts clear; gestures/README.md and contextRequest.ts one note each.

Automated review (maintainer link)

refused, never requested again; and a mouse held still makes no request. A
control that keeps its press for a hold-repeat owns only its hold: its right
click and Shift+F10 still reach the request. A right click or a ctrl-click on macOS starts no press.
The request listens on its own element only, and only while enabled.

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.

Non-blocking (newly live check): this holds for the state read at attach (contextRequest.ts:80-83). A request that turns disabled after attaching keeps contextmenu, keydown, pointerdown and the hold's blocking touchmove on the element until its caller detaches it, so FR24's "while a touch presentation is disabled none is active" rests on the adopter. Saying here that a menu that turns disabled attaches again, as the option's JSDoc implies, would close it.

A right click or a key inside nested context requests reaches only
the innermost: the first request adds the event to a set, and the
others skip it. The set was module state, so a request in a swizzled
copy of Core kept its own set and answered the same event again. It
is now a shared weak set under a registered key, as the
shared-identity check asks for module state an export uses.
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 3b24c79

@cixzhang

Copy link
Copy Markdown
Contributor

Decision: D-20261112-316

@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: CI has not run on this head yet because the pull request is still a draft; marking it ready for review starts CI.

attachContextRequest turns a held finger or pen, a context click, and Shift+F10 or the context-menu key into one request that names its input, as the touch-presentations record's shared context request asks, and the record's new wording carries an engineering owner's approval for this head. Sharing the answered-event set across copies of Core closes the earlier note about swizzled copies.

  • Non-blocking: the gestures README says the request listens only while enabled, but contextRequest.ts decides what to register once, at attach; saying that a menu whose enabled state changes detaches and attaches again would make it exact.
Claims and files checked
  • One request from a long press, a right click, Shift+F10 or the context-menu key: verified (contextRequest.ts lines 92-196; unit cases at lines 150, 165, 234).
  • Each request names its input, once per gesture: verified (a held key's repeats and nested requests make one; unit cases at lines 181, 506, 524).
  • A hold loses to a claim another gesture made first: verified (unit case at line 415).
  • A hold-repeat control keeps only its hold, and its right click and Shift+F10 reach the request: verified (GestureHost.ts lines 3038-3056; unit case at line 440).
  • A held pen's own menu event is refused like a finger's: verified (contextRequest.ts lines 154-159; unit cases at lines 281, 464).
  • The hold is UIKit's 500 ms / 10 pt long press and requests as it begins: verified (contextRequest.ts lines 92-125).
  • A mouse held still makes no request: verified (unit case at line 254).
  • Not exported from the package: verified (package entry point and exports map).
  • Listens on its own element only, and only while enabled: true for the state read at attach (contextRequest.ts lines 83-86); see the note above.
  • The record names the module and lists it in its paths: verified.
  • The merge passes the host's clock in its three new time reads, the second commit changes only the record, and the third shares the answered set across copies: verified.
  • Local test, lint and browser runs: the author's statement, not independently re-run.
  • Files: all eight visited; the changeset, the record, GestureHost.ts, contextRequest.ts, the unit tests, the browser test and its fixture are clear, and the README carries the note above.

Automated review (maintainer link)

@vjeux vjeux mentioned this pull request Nov 12, 2026
4 tasks done

This branch was successfully deployed

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

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) 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.

2 participants