Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/daemon/__tests__/selector-capture-runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ test('selector capture cache is keyed by scoped presentation options', async ()
const runtime = createSelectorCaptureRuntime({
ref: sessionStore.lookup(sessionName),
device: session.device,
session,
sessionStore,
sessionName,
capture: boundCapture,
Expand Down Expand Up @@ -228,7 +227,6 @@ function proofRuntime(params: {
const runtime = createSelectorCaptureRuntime({
ref: sessionStore.lookup(params.sessionName),
device: session.device,
session,
sessionStore,
sessionName: params.sessionName,
consumedSnapshot,
Expand Down Expand Up @@ -322,7 +320,6 @@ function makeCaptureRuntime(sessionName: string) {
const runtime = createSelectorCaptureRuntime({
ref: sessionStore.lookup(sessionName),
device: session.device,
session,
sessionStore,
sessionName,
capture: boundCapture,
Expand Down Expand Up @@ -356,7 +353,6 @@ test('a held selector capture updates the matching rebuilt record without restor
const runtime = createSelectorCaptureRuntime({
ref,
device: ref.session.device,
session: ref.session,
sessionStore,
sessionName: address,
capture: boundCapture,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,59 @@ function selectorResult(readiness?: { polls: number; waitedMs: number }): PressC

const WAITED_SELECTOR_RESULT = selectorResult({ polls: 3, waitedMs: 400 });

test.each([false, true])('selector-touch observation after retirement=%s', async (retired) => {
const sessionStore = makeSessionStore();
const address = 'cwd:selector-touch-response:default';
const session = makeSession('default');
session.snapshot = {
nodes: attachRefs([{ index: 0, type: 'Button', label: 'Continue' }]),
createdAt: Date.now(),
backend: 'xctest',
};
session.snapshotGeneration = 3;
const ref = sessionStore.publish(address, session);
const result: PressCommandResult = {
...selectorResult(),
settle: {
settled: true,
waitedMs: 25,
captures: 2,
quietMs: 25,
timeoutMs: 2000,
diff: {
summary: { additions: 1, removals: 0, unchanged: 0 },
lines: [{ kind: 'added', text: 'Continue', ref: 'e1' }],
},
},
};
let successor;
if (retired) {
sessionStore.retire(ref);
successor = sessionStore.publish(address, makeSession('default'));
}
const payloads = await buildTargetedTouchResponsePayloads({
params: {
req: { token: 't', command: 'press', positionals: ['@e1'], session: 'default' },
sessionName: address,
sessionRef: ref,
sessionStore,
contextFromFlags,
captureSnapshotForSession: vi.fn(),
},
result,
staleRefsWarning: undefined,
extra: {},
});
if (retired) {
expect(payloads.responseData.settle).toBeUndefined();
expect(payloads.result.settle).toBeUndefined();
expect(sessionStore.lookup(address)).toEqual(successor);
expect(successor?.session.snapshot).toBeUndefined();
} else {
expect(payloads.responseData.settle).toMatchObject({ refsGeneration: 3, settled: true });
}
});

test.each([false, true])(
'point-touch publication after a held frame probe, retired=%s',
async (retired) => {
Expand Down Expand Up @@ -157,7 +210,6 @@ test.each([false, true])(
return sessionStore.requireCurrent(ref).snapshot!;
},
},
session,
result,
staleRefsWarning: undefined,
extra: {},
Expand Down
4 changes: 1 addition & 3 deletions src/daemon/interaction/internal/find-target-capture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export function createFindTargetCapture(
params: Readonly<{
ref: SessionRef;
device: SessionState['device'];
session: SessionState;
req: DaemonRequest;
logPath: string;
locator: FindLocator;
Expand All @@ -36,11 +35,10 @@ export function createFindTargetCapture(
captureProof: RequestCaptureProof;
}>,
): () => Promise<FindTargetTree> {
const { device, session, req, logPath, locator, query, sessionStore, sessionName } = params;
const { device, req, logPath, locator, query, sessionStore, sessionName } = params;
const captureRuntime = createSelectorCaptureRuntime({
ref: params.ref,
device,
session,
sessionStore,
sessionName,
req,
Expand Down
1 change: 0 additions & 1 deletion src/daemon/interaction/internal/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ export async function handleFindCommands(params: FindRouteInput): Promise<Daemon
const readTargetTree = createFindTargetCapture({
ref: sessionRef,
device,
session,
req,
logPath,
locator,
Expand Down
1 change: 0 additions & 1 deletion src/daemon/interaction/internal/interaction-touch-press.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ function buildTargetedRuntimeOptions(
const resultDurationMs = readLongPressResultDuration(result);
return await buildTargetedTouchResponsePayloads({
params,
session,
result,
staleRefsWarning,
publicData: transformTouchResponseData({
Expand Down
19 changes: 9 additions & 10 deletions src/daemon/interaction/internal/interaction-touch-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
} from '../../../core/interaction-response-data-transform.ts';
import { issueSettleRefs } from '../../session-snapshot.ts';
import type { RecordedTargetCapture } from '@agent-device/selectors/target-evidence';
import type { SessionState } from '../../session-state.ts';
import type { CaptureSnapshotForSession, InteractionRouteInput } from './types.ts';
import { resolveDirectTouchReferenceFrameSafely } from './interaction-touch-reference-frame.ts';
import { readSnapshotNodesReferenceFrame } from '@agent-device/capture-kit/touch-reference-frame';
Expand Down Expand Up @@ -288,14 +287,13 @@ export async function buildTargetedTouchResponsePayloads(params: {
params: InteractionRouteInput & {
captureSnapshotForSession: CaptureSnapshotForSession;
};
session: SessionState;
result: TargetedTouchResult;
staleRefsWarning: string | undefined;
publicData?: Record<string, unknown>;
extra: Record<string, unknown>;
}): Promise<InteractionResponsePayloads> {
const { params: handlerParams, result, publicData, extra } = params;
const referenceFrame =
const probedFrame =
Comment thread
thymikee marked this conversation as resolved.
result.kind === 'point'
? await resolveDirectTouchReferenceFrameSafely({
ref: handlerParams.sessionRef!,
Expand All @@ -305,13 +303,14 @@ export async function buildTargetedTouchResponsePayloads(params: {
captureSnapshotForSession: handlerParams.captureSnapshotForSession,
observation: handlerParams.androidObservation,
})
: readSnapshotNodesReferenceFrame(
handlerParams.sessionStore.requireCurrent(handlerParams.sessionRef!).snapshot?.nodes ??
[],
);
const currentResult = handlerParams.sessionStore.resolveCurrent(handlerParams.sessionRef!)
? result
: { ...result, settle: undefined };
: undefined;
const current = handlerParams.sessionStore.resolveCurrent(handlerParams.sessionRef!);
const referenceFrame = current
? result.kind === 'point'
? probedFrame
: readSnapshotNodesReferenceFrame(current.snapshot?.nodes ?? [])
: undefined;
const currentResult = current ? result : { ...result, settle: undefined };
return buildInteractionResponseData({
source: { kind: 'runtime', result: currentResult, publicData },
referenceFrame,
Expand Down
1 change: 0 additions & 1 deletion src/daemon/selector-capture-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const SELECTOR_CAPTURE_CACHE_TTL_MS = 750;
export type SelectorCaptureRuntimeParams = {
ref: SessionRef | undefined;
device: SessionState['device'];
session: SessionState | undefined;
sessionStore: SessionStore;
sessionName: string;
req: DaemonRequest;
Expand Down
1 change: 0 additions & 1 deletion src/daemon/selector-runtime-backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ function createSelectorBackend(params: SelectorRuntimeDeviceParams): AgentDevice
: createSelectorCaptureRuntime({
ref: params.ref,
device,
session,
sessionStore,
sessionName,
req,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ test('fresh open does not publish when its artifact directory cannot be created'
fs.writeFileSync(path.dirname(store.resolveSessionDir('cwd:held-open:default')), 'blocked');
await expect(
invokeHeldOpen(store, { runtime: { metroHost: 'new-host', metroPort: 9000 } }),
).rejects.toThrow();
).rejects.toMatchObject({ code: 'ENOTDIR' });
expect(mockDispatch).toHaveBeenCalled();
expect(store.get('cwd:held-open:default')).toBeUndefined();
expect(store.getRuntimeHints('cwd:held-open:default')).toBeUndefined();
Expand Down
Loading