Repository navigation
fix(mobile): report the declared spec gesture in every useSpecGesture fallback - #9788
Conversation
… fallback `useSpecGesture` builds each `onGesture` fallback payload by spreading the recognizer's runtime context next to a declared `type`. That context carries a `type` of its own — `GestureContext.type`, the direction-fused recognizer vocabulary — so the three arms that wrote `type` BEFORE the spread (`pinch`, `pan`/`drag`, `rotate`) had the declared value overwritten by the recognizer's. `type` now goes last at all three, which is what the `swipe` arm already did. Only `drag` moves observably: it is the one arm where the two vocabularies disagree, and it reported `pan`. `pinch`, `rotate` and a declared `pan` name their recognizer identically, so those overwrote a value with itself — repaired because the agreement is a coincidence of two vocabularies, not a property of the code. The rule moves from the `swipe` arm's local comment onto the `fallback` declaration every arm calls, and the public `onGesture` docblock now states the contract the implementation was pulled back onto. `spec-gesture-fallback-type-order.test.tsx` pins it three ways: the runtime fact the defect rests on, each arm driven with a recognizer context whose `type` has drifted off the declared name, and the writing order read off the hook's source so a fourth arm cannot grow the same shape. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018HrVaotisyhgmot9o2MLRq
✅ Console Performance Budget
The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it. 📦 Bundle Size Report
Size Limits
|
Contract reviewServed-tier: ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS Generated by Claude Code |
Contract-review gate CLEARED — provenance
⛔ This seat did not self-review. Served tier measured this fire = ⭐ The review corrected the dispatching seat, not the delivery. Both grounds this seat published for treating the card as execution-not-decision were measured false (the docblock sentence is ADDED by this PR, ⛔ not pre-existing; objectui#9689's changeset never declared this break and itself said
Generated by Claude Code |
Fixes #9691
Clause-②: yes
useSpecGesturebuilds eachonGesturefallback payload by spreading the recognizer's runtime context next to a declaredtype. That context carries atypeof its own —GestureContext.type, the direction-fused recognizer vocabulary — so an arm that writestypeBEFORE the spread has its declared value overwritten by the recognizer's. Three arms carried that order;typenow goes last at all three, which is the spelling theswipearm already uses.Executed as one change per the triage ruling on the card (comment
5714886682): 「三处是同一个书写顺序缺陷,⛔ 一起改;并顺手加一条断言把「展开在前、type在后」钉住,否则第四处会以同样方式长出来。」The card's table, re-derived on this branch's base
The table on the card was measured on PR #9689's head. Re-derived on
origin/mainat57c07f002— every row holds, and the line numbers happen not to have moved:typesurvives?swipe{ ...ctx, type: 'swipe' }long_press{ type: 'long_press' }ctxspreadpinch{ type: 'pinch', ...ctx }double_tap{ type: 'double_tap' }ctxspreadpan/drag{ type: declared, ...ctx }rotate{ type: 'rotate', ...ctx }One arm moves observably; the rest were latent
dragis the only configuration whose payload changes. It is the one arm where the two vocabularies disagree —dragdeclared,panrecognized — so it reportedpan.pinch,rotateand a declaredpanname their recognizer identically, so the overwrite replaced each value with itself. The changeset says exactly this rather than claiming three behaviour changes.The load-bearing runtime fact, pinned instead of probed
The card supported "
ctxreally carries atypekey at runtime" with a throwaway probe that was then deleted. That fact is now a standing assertion —useGesture's emitted context is asserted to carry the recognizer's own name. It passes on both sides of the repair by design and is not a witness; it is there so that removingGestureContext.typesome day reds the file that depends on it, and the test says so in its own name and message.The ordering pin
packages/mobile/src/__tests__/spec-gesture-fallback-type-order.test.tsx, three kinds of pin, because no one kind covers the defect:typehas been moved off the declared name ('tap', a real recognizer name that is no spec gesture's declared name). That drift is precisely the condition the card says a rename on either vocabulary creates, so it is how the quiet arms are made to speak. Without it,pinchandrotatepass identically on defect and fix;fallback(...)payload is brace-matched out ofuseSpecGesture.tsand the spread is required to precedetype. This is the part that answers the triage's 「否则第四处会以同样方式长出来」: a behavioural pin only guards arms somebody thought to list, this one guards the shape. It carries its own non-vacuity checks — the brace matcher must account for everyfallback(call it finds, and at least one payload must actually spread — so a scanner that silently stops matching reds instead of going quietly green.The behavioural rows are also a completeness pin: the row set is compared against
SPEC_GESTURE_TYPES, so a new spec gesture cannot be added with a switch arm and no row.Shown RED before the repair
The pin was run against the unrepaired hook, then again after the fix was committed, with the mutation and the restore both proved by
git hash-objectagainst recorded blob hashes rather than by an exit code.useSpecGesture.tsblob489483d9dbb37431c3fc04bb4b7e2ea439f292d0(theorigin/mainblob)3dde33fc1cc89ed17dc7e60dce9dafa8575ebfd2(this branch's HEAD blob)The six that go red are the whole defect and nothing else — the live instance, the four drifted-context arms, and the shape pin:
with the two discriminating readings:
swipe,long_pressanddouble_tappass on both sides and are kept anyway: the first is the arm PR #9689 already repaired and the other two spread nothing, so none of the three can tell the two implementations apart. Said here rather than left for a reader to discover.The suite imports the hook by a RELATIVE source path from inside its own package, so the mutated file is unambiguously the one under test — no
distand no vitest alias sits between them.The fourth file, and why it is there
packages/mobile/tsconfig.test.jsongains"types": ["node"]. The shape pin reads the hook's own source, and this package's test project named notypes, sonode:fsdid not resolve (TS2591). Twenty-five sibling packages already declare it the same way,packages/typesfor the same reason (its re-export guard'sreadFileSync). Namingtypesswitches off automatic@types/*inclusion, so the list is deliberately complete: these suites import no ambient matcher package.tsc -p packages/mobile/tsconfig.test.json --listFilesconfirms the new test really is a program input rather than silently excluded.Adjacent, deliberately untouched
SPEC_GESTURE_TYPE_MAP.swipeis still'swipe-left'as a declared placeholder. Changing an exported map's VALUE is a published-surface change no card has ruled on, and this branch does not touch those lines.Verification
Run at
f38da33.pnpm exec vitest run packages/mobile/pnpm --filter @object-ui/mobile type-checktsc --noEmit+tsc -p tsconfig.test.json)pnpm --filter '@object-ui/mobile^...' buildnode scripts/check-changeset-presence.mjsnode scripts/check-changeset-no-major.mjs/-overwrite.mjs/-claims.mjsnode scripts/check-pending-changeset-literals.mjsnode scripts/check-vi-mock-specifiers.mjs/-inherit.mjs/-override-shape.mjsnode scripts/check-test-path-roots.mjsnode scripts/check-control-bytes.mjsnode scripts/check-new-cross-file-line-citations.mjsnode scripts/check-doc-example-types.mjs/-snippet-types.mjs/check-readme-exports.mjsnode scripts/check-type-check-coverage.mjs·check-published-tsconfig-tooling-exclude.mjs·check-phantom-dependencies.mjs·check-unreferenced-sources.mjs·check-doc-fence-languages.mjsnode scripts/check-governed-queue-guard.mjs --test(4 paths)Every exit code was redirected to a file and read from there, never through a pipe.
ESLint is a declared narrowing, not a skip.
pnpm exec eslint packages/mobile --format jsonatf38da33: 21 files judged, 0 errors, 18 warnings, none of them in either file this branch writes. The narrowing is safe to make because this repo's flat config extendstseslint.configs.recommendedwith noparserOptions.projectand noprojectService— type-aware linting is off, so a file's verdict is a function of its own bytes and the shared config alone, and this branch adds no config, no shared file ESLint reads and no disable directive. It therefore cannot move the verdict of any file it does not touch. The repo-widepnpm lintand the full sharded suite remain CI's.Heavy runs were serialized through the shared verify lock.
Generated by Claude Code