Skip to content

Commit 7a6e0db

Browse files
thymikeecursoragent
andcommitted
refactor: unify iOS interactor, remove dead input stubs
Since runnerContext is always passed and the capability matrix ensures iOS only runs on simulators in v1, the two iOS interactor code paths collapse into one: shared methods (open, close, screenshot) plus runner overrides spread on top. No branch needed. This deletes 7 dead iOS input stubs from ios/index.ts (pressIos, longPressIos, focusIos, typeIos, fillIos, scrollIos, scrollIntoViewIos) that only ever threw UNSUPPORTED_OPERATION errors. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent b115bbe commit 7a6e0db

2 files changed

Lines changed: 6 additions & 87 deletions

File tree

src/platforms/ios/index.ts

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -83,68 +83,6 @@ export async function closeIosApp(device: DeviceInfo, app: string): Promise<void
8383
]);
8484
}
8585

86-
export async function pressIos(device: DeviceInfo, _x: number, _y: number): Promise<void> {
87-
ensureSimulator(device, 'press');
88-
throw new AppError(
89-
'UNSUPPORTED_OPERATION',
90-
'simctl io tap is not available; use the XCTest runner for input',
91-
);
92-
}
93-
94-
export async function longPressIos(
95-
device: DeviceInfo,
96-
_x: number,
97-
_y: number,
98-
_durationMs = 800,
99-
): Promise<void> {
100-
ensureSimulator(device, 'long-press');
101-
throw new AppError(
102-
'UNSUPPORTED_OPERATION',
103-
'long-press is not supported on iOS simulators without XCTest runner support',
104-
);
105-
}
106-
107-
export async function focusIos(device: DeviceInfo, x: number, y: number): Promise<void> {
108-
await pressIos(device, x, y);
109-
}
110-
111-
export async function typeIos(device: DeviceInfo, _text: string): Promise<void> {
112-
ensureSimulator(device, 'type');
113-
throw new AppError(
114-
'UNSUPPORTED_OPERATION',
115-
'simctl io keyboard is not available; use the XCTest runner for input',
116-
);
117-
}
118-
119-
export async function fillIos(
120-
device: DeviceInfo,
121-
x: number,
122-
y: number,
123-
text: string,
124-
): Promise<void> {
125-
await focusIos(device, x, y);
126-
await typeIos(device, text);
127-
}
128-
129-
export async function scrollIos(
130-
device: DeviceInfo,
131-
_direction: string,
132-
_amount = 0.6,
133-
): Promise<void> {
134-
ensureSimulator(device, 'scroll');
135-
throw new AppError(
136-
'UNSUPPORTED_OPERATION',
137-
'simctl io swipe is not available; use the XCTest runner for input',
138-
);
139-
}
140-
141-
export async function scrollIntoViewIos(text: string): Promise<void> {
142-
throw new AppError(
143-
'UNSUPPORTED_OPERATION',
144-
`scrollintoview is not supported on iOS without UI automation (${text})`,
145-
);
146-
}
147-
14886
export async function screenshotIos(device: DeviceInfo, outPath: string): Promise<void> {
14987
if (device.kind === 'simulator') {
15088
await ensureBootedSimulator(device);

src/utils/interactors.ts

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,9 @@ import {
1515
} from '../platforms/android/index.ts';
1616
import {
1717
closeIosApp,
18-
fillIos,
19-
focusIos,
20-
longPressIos,
2118
openIosApp,
2219
openIosDevice,
23-
pressIos,
24-
scrollIos,
25-
scrollIntoViewIos,
2620
screenshotIos,
27-
typeIos,
2821
} from '../platforms/ios/index.ts';
2922
import { runIosRunnerCommand } from '../platforms/ios/runner-client.ts';
3023

@@ -49,7 +42,7 @@ export type Interactor = {
4942
screenshot(outPath: string): Promise<void>;
5043
};
5144

52-
export function getInteractor(device: DeviceInfo, runnerContext?: RunnerContext): Interactor {
45+
export function getInteractor(device: DeviceInfo, runnerContext: RunnerContext): Interactor {
5346
switch (device.platform) {
5447
case 'android':
5548
return {
@@ -65,36 +58,25 @@ export function getInteractor(device: DeviceInfo, runnerContext?: RunnerContext)
6558
scrollIntoView: (text) => scrollIntoViewAndroid(device, text),
6659
screenshot: (outPath) => screenshotAndroid(device, outPath),
6760
};
68-
case 'ios': {
69-
if (device.kind === 'simulator' && runnerContext) {
70-
return createIosSimulatorInteractor(device, runnerContext);
71-
}
61+
case 'ios':
7262
return {
7363
open: (app) => openIosApp(device, app),
7464
openDevice: () => openIosDevice(device),
7565
close: (app) => closeIosApp(device, app),
76-
tap: (x, y) => pressIos(device, x, y),
77-
longPress: (x, y, durationMs) => longPressIos(device, x, y, durationMs),
78-
focus: (x, y) => focusIos(device, x, y),
79-
type: (text) => typeIos(device, text),
80-
fill: (x, y, text) => fillIos(device, x, y, text),
81-
scroll: (direction, amount) => scrollIos(device, direction, amount),
82-
scrollIntoView: (text) => scrollIntoViewIos(text),
66+
...iosRunnerOverrides(device, runnerContext),
8367
screenshot: (outPath) => screenshotIos(device, outPath),
8468
};
85-
}
8669
default:
8770
throw new AppError('UNSUPPORTED_PLATFORM', `Unsupported platform: ${device.platform}`);
8871
}
8972
}
9073

91-
function createIosSimulatorInteractor(device: DeviceInfo, ctx: RunnerContext): Interactor {
74+
type IoRunnerOverrides = Pick<Interactor, 'tap' | 'longPress' | 'focus' | 'type' | 'fill' | 'scroll' | 'scrollIntoView'>;
75+
76+
function iosRunnerOverrides(device: DeviceInfo, ctx: RunnerContext): IoRunnerOverrides {
9277
const runnerOpts = { verbose: ctx.verbose, logPath: ctx.logPath, traceLogPath: ctx.traceLogPath };
9378

9479
return {
95-
open: (app) => openIosApp(device, app),
96-
openDevice: () => openIosDevice(device),
97-
close: (app) => closeIosApp(device, app),
9880
tap: async (x, y) => {
9981
await runIosRunnerCommand(
10082
device,
@@ -164,7 +146,6 @@ function createIosSimulatorInteractor(device: DeviceInfo, ctx: RunnerContext): I
164146
}
165147
throw new AppError('COMMAND_FAILED', `scrollintoview could not find text: ${text}`);
166148
},
167-
screenshot: (outPath) => screenshotIos(device, outPath),
168149
};
169150
}
170151

0 commit comments

Comments
 (0)