Skip to content

Commit 36f5a22

Browse files
committed
fix(contracts): keep tap/longPress/fill required in touch facts
Making every touch cell optional dropped the compile-time guard on the three operations every owner implements, with nothing replacing it: an owner could silently drop `tap` and nothing would fail. Only the truly per-owner cells (tapRef, hover, hoverRef, fillRef, tapElementSelector) need `unsupported` as their default. Restoring the required fields caught a real regression this refactor introduced: platform-web's touch facts had silently lost their explicit `longPress: readinessUnavailable` cell, so longPress reported the family's `unsupported` fallback instead of the owner's own readiness reason. Restored it, and fixed the other now-required-field call sites (the fully-unavailable owner fixtures, and the screenshot-runtime-fixture test double, which had also silently lost its longPress/fill distinction). Refs #2412
1 parent 0eca306 commit 36f5a22

7 files changed

Lines changed: 47 additions & 18 deletions

File tree

‎packages/contracts/src/platform-runtime-unavailable.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,12 @@ export function createUnavailablePlatformRuntimeFacts(
235235
}),
236236
...scrollRuntimeOperationFacts({ scroll: frozen.scroll }),
237237
...typeTextRuntimeOperationFacts({ type: frozen.typeText }),
238-
...touchRuntimeOperationFacts({ unsupported: frozen.touch }),
238+
...touchRuntimeOperationFacts({
239+
unsupported: frozen.touch,
240+
tap: frozen.touch,
241+
longPress: frozen.touch,
242+
fill: frozen.touch,
243+
}),
239244
...elementTextRuntimeOperationFacts({ readTextAtPoint: frozen.elementText }),
240245
...backRuntimeOperationFacts({ back: frozen.back }),
241246
...homeRuntimeOperationFacts({ home: frozen.home }),

‎packages/contracts/src/touch-runtime.test.ts‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,20 @@ test("an operation the owner never names reports the owner's own denial verbatim
4444
hint: 'focus is supported on Android emulators and physical devices.',
4545
} as const;
4646

47-
expect(touchRuntimeOperationFacts({ unsupported: denial, tap: available })).toEqual({
47+
expect(
48+
touchRuntimeOperationFacts({
49+
unsupported: denial,
50+
tap: available,
51+
longPress: available,
52+
fill: available,
53+
}),
54+
).toEqual({
4855
tapPoint: available,
4956
tapRef: denial,
50-
longPressPoint: denial,
57+
longPressPoint: available,
5158
hoverPoint: denial,
5259
hoverRef: denial,
53-
fillPoint: denial,
60+
fillPoint: available,
5461
fillRef: denial,
5562
tapElementSelector: denial,
5663
});

‎packages/contracts/src/touch-runtime.ts‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,24 @@ export const HOVER_UNAVAILABLE_HINT =
7575
'hover raises pointer hover state and is available on web targets only. On touch platforms use longpress for hold gestures.';
7676

7777
/**
78-
* What an owner declares about the touch family. Every operation is optional and `unsupported` is
79-
* not: an owner names the operations it implements and states, once, the denial every operation it
80-
* left out reports. Adding a touch operation therefore costs an edit only in the owner that gained
81-
* it — an owner that does not implement it already classified it, by the same `unsupported` cell,
82-
* with the same reason and hint it would have written out by hand.
78+
* What an owner declares about the touch family. `tap`, `longPress` and `fill` are universally
79+
* implemented, so they stay required cells — a compile-time guard against an owner silently
80+
* dropping one. Every other operation is optional, and `unsupported` names the denial an omitted
81+
* cell reports: an owner that does not implement one of those already classified it, by the same
82+
* `unsupported` cell, with the same reason and hint it would have written out by hand. Adding a new
83+
* touch operation therefore costs an edit only in the owner that gained it.
8384
*
8485
* Omission is a classified denial, never an unclassified cell and never an implied success: the
8586
* type refuses a call that does not carry `unsupported`, so no owner can leave the family blank.
8687
*/
8788
export type TouchRuntimeOperationFactsInput = Readonly<{
8889
unsupported: RuntimeOperationUnavailability;
89-
tap?: RuntimeOperationFact;
90+
tap: RuntimeOperationFact;
9091
tapRef?: RuntimeOperationFact;
91-
longPress?: RuntimeOperationFact;
92+
longPress: RuntimeOperationFact;
9293
hover?: RuntimeOperationFact;
9394
hoverRef?: RuntimeOperationFact;
94-
fill?: RuntimeOperationFact;
95+
fill: RuntimeOperationFact;
9596
fillRef?: RuntimeOperationFact;
9697
tapElementSelector?: RuntimeOperationFact;
9798
}>;
@@ -102,12 +103,12 @@ export function touchRuntimeOperationFacts(
102103
const declared = (fact: RuntimeOperationFact | undefined): RuntimeOperationFact =>
103104
fact ?? input.unsupported;
104105
return Object.freeze({
105-
tapPoint: declared(input.tap),
106+
tapPoint: input.tap,
106107
tapRef: declared(input.tapRef),
107-
longPressPoint: declared(input.longPress),
108+
longPressPoint: input.longPress,
108109
hoverPoint: withHoverRefusalHint(declared(input.hover)),
109110
hoverRef: withHoverRefusalHint(declared(input.hoverRef)),
110-
fillPoint: declared(input.fill),
111+
fillPoint: input.fill,
111112
fillRef: declared(input.fillRef),
112113
tapElementSelector: declared(input.tapElementSelector),
113114
});

‎packages/platform-web/src/runtime.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ function webRuntimeFacts(
388388
unsupported: readinessUnavailable,
389389
tap: browserDevice,
390390
tapRef: webOptionalOperationFact(interactor?.tapRef, browserDevice),
391+
longPress: readinessUnavailable,
391392
hover: webOptionalOperationFact(interactor?.hover, browserDevice),
392393
hoverRef: webOptionalOperationFact(interactor?.hoverRef, browserDevice),
393394
fill: browserDevice,

‎src/__tests__/test-utils/runtime-operation-facts.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ export const unavailableDeploymentSnapshotAndShutdownOperationFacts = Object.fre
4646
setViewport: unavailable,
4747
focusPoint: unavailable,
4848
typeText: unavailable,
49-
...touchRuntimeOperationFacts({ unsupported: unavailable }),
49+
...touchRuntimeOperationFacts({
50+
unsupported: unavailable,
51+
tap: unavailable,
52+
longPress: unavailable,
53+
fill: unavailable,
54+
}),
5055
...gestureRuntimeOperationFacts({
5156
plan: unavailable,
5257
directionalFling: unavailable,

‎src/daemon/__tests__/screenshot-runtime-fixture.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,12 @@ export function screenshotRuntimeFixture(
101101
customActions: options.snapshot ?? available,
102102
withoutActiveApp: options.snapshot ?? available,
103103
}),
104-
...touchRuntimeOperationFacts({ unsupported: unavailable, tap: available }),
104+
...touchRuntimeOperationFacts({
105+
unsupported: unavailable,
106+
tap: available,
107+
longPress: unavailable,
108+
fill: unavailable,
109+
}),
105110
},
106111
};
107112
};

‎src/daemon/handlers/__tests__/install-source.test.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,12 @@ function sourceRuntimeFacts(
363363
setViewport: unavailable,
364364
focusPoint: unavailable,
365365
typeText: unavailable,
366-
...touchRuntimeOperationFacts({ unsupported: unavailable }),
366+
...touchRuntimeOperationFacts({
367+
unsupported: unavailable,
368+
tap: unavailable,
369+
longPress: unavailable,
370+
fill: unavailable,
371+
}),
367372
...gestureRuntimeOperationFacts({
368373
plan: unavailable,
369374
directionalFling: unavailable,

0 commit comments

Comments
 (0)