feat(driver): native DoubleTap RPC for a tight inter-tap gap

Composing two Tap round trips from the Go client spread the taps by
hundreds of milliseconds on iOS, wide enough for the app to navigate
between them, so double-submission races could never reproduce. The
sidecar now lands both taps back-to-back next to the device transport.
This commit is contained in:
pj committed 2026-06-05 19:05:27 +05:30
1 parent d6188df667
commit 4f579d2a0b
8 files changed
+151 -38

No files matched your search

+46
View File
@@ -22,6 +22,7 @@ const (
Driver_Launch_FullMethodName = "/sanderling.driver.v1.Driver/Launch"
Driver_Terminate_FullMethodName = "/sanderling.driver.v1.Driver/Terminate"
Driver_Tap_FullMethodName = "/sanderling.driver.v1.Driver/Tap"
Driver_DoubleTap_FullMethodName = "/sanderling.driver.v1.Driver/DoubleTap"
Driver_TapSelector_FullMethodName = "/sanderling.driver.v1.Driver/TapSelector"
Driver_InputText_FullMethodName = "/sanderling.driver.v1.Driver/InputText"
Driver_EraseText_FullMethodName = "/sanderling.driver.v1.Driver/EraseText"
@@ -44,6 +45,11 @@ type DriverClient interface {
Launch(ctx context.Context, in *LaunchRequest, opts ...grpc.CallOption) (*Empty, error)
Terminate(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error)
Tap(ctx context.Context, in *Point, opts ...grpc.CallOption) (*Empty, error)
// DoubleTap lands two taps as close together as the platform allows.
// Composing two Tap calls from the client spreads them by hundreds of
// milliseconds on iOS, wide enough for navigation to interleave, which
// defeats double-submission testing.
DoubleTap(ctx context.Context, in *Point, opts ...grpc.CallOption) (*Empty, error)
TapSelector(ctx context.Context, in *Selector, opts ...grpc.CallOption) (*Empty, error)
InputText(ctx context.Context, in *Text, opts ...grpc.CallOption) (*Empty, error)
// EraseText deletes characters from the focused field so InputText can
@@ -102,6 +108,16 @@ func (c *driverClient) Tap(ctx context.Context, in *Point, opts ...grpc.CallOpti
return out, nil
}
func (c *driverClient) DoubleTap(ctx context.Context, in *Point, opts ...grpc.CallOption) (*Empty, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(Empty)
err := c.cc.Invoke(ctx, Driver_DoubleTap_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *driverClient) TapSelector(ctx context.Context, in *Selector, opts ...grpc.CallOption) (*Empty, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(Empty)
@@ -239,6 +255,11 @@ type DriverServer interface {
Launch(context.Context, *LaunchRequest) (*Empty, error)
Terminate(context.Context, *Empty) (*Empty, error)
Tap(context.Context, *Point) (*Empty, error)
// DoubleTap lands two taps as close together as the platform allows.
// Composing two Tap calls from the client spreads them by hundreds of
// milliseconds on iOS, wide enough for navigation to interleave, which
// defeats double-submission testing.
DoubleTap(context.Context, *Point) (*Empty, error)
TapSelector(context.Context, *Selector) (*Empty, error)
InputText(context.Context, *Text) (*Empty, error)
// EraseText deletes characters from the focused field so InputText can
@@ -276,6 +297,9 @@ func (UnimplementedDriverServer) Terminate(context.Context, *Empty) (*Empty, err
func (UnimplementedDriverServer) Tap(context.Context, *Point) (*Empty, error) {
return nil, status.Error(codes.Unimplemented, "method Tap not implemented")
}
func (UnimplementedDriverServer) DoubleTap(context.Context, *Point) (*Empty, error) {
return nil, status.Error(codes.Unimplemented, "method DoubleTap not implemented")
}
func (UnimplementedDriverServer) TapSelector(context.Context, *Selector) (*Empty, error) {
return nil, status.Error(codes.Unimplemented, "method TapSelector not implemented")
}
@@ -390,6 +414,24 @@ func _Driver_Tap_Handler(srv interface{}, ctx context.Context, dec func(interfac
return interceptor(ctx, in, info, handler)
}
func _Driver_DoubleTap_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Point)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DriverServer).DoubleTap(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Driver_DoubleTap_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DriverServer).DoubleTap(ctx, req.(*Point))
}
return interceptor(ctx, in, info, handler)
}
func _Driver_TapSelector_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Selector)
if err := dec(in); err != nil {
@@ -643,6 +685,10 @@ var Driver_ServiceDesc = grpc.ServiceDesc{
MethodName: "Tap",
Handler: _Driver_Tap_Handler,
},
{
MethodName: "DoubleTap",
Handler: _Driver_DoubleTap_Handler,
},
{
MethodName: "TapSelector",
Handler: _Driver_TapSelector_Handler,