Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .axe-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.7.0
1.7.1
18 changes: 17 additions & 1 deletion src/mcp/tools/ui-automation/__tests__/key_sequence.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ import {
simulatorId,
} from './ui-action-test-helpers.ts';

function createImmediatePostActionTiming() {
let nowMs = 0;

return {
now: () => nowMs,
sleep: async (durationMs: number) => {
nowMs += durationMs;
},
};
}

describe('Key Sequence Tool', () => {
beforeEach(() => {
sessionStore.clear();
Expand Down Expand Up @@ -194,7 +205,12 @@ describe('Key Sequence Tool', () => {
describe('Handler Behavior (Complete Literal Returns)', () => {
it('captures a fresh runtime snapshot after a successful key sequence', async () => {
const { calls, executor } = createTrackingExecutor();
const executeKeySequence = createKeySequenceExecutor(executor, createMockAxeHelpers());
const executeKeySequence = createKeySequenceExecutor(
executor,
createMockAxeHelpers(),
undefined,
createImmediatePostActionTiming(),
);

const result = await executeKeySequence({ simulatorId, keyCodes: [40, 42, 44] });

Expand Down
25 changes: 25 additions & 0 deletions src/mcp/tools/ui-automation/__tests__/runtime-snapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,31 @@ describe('runtime snapshot normalization', () => {
expect(snapshot.payload.elements[0]?.actions).not.toContain('tap');
});

it('classifies tab radio buttons from AXe as tabs', () => {
const snapshot = createRuntimeSnapshotRecord({
simulatorId,
uiHierarchy: [
createNode({
type: 'RadioButton',
role: 'AXRadioButton',
role_description: 'tab',
AXLabel: 'Reports',
AXValue: '0',
}),
],
nowMs: 1_000,
});

expect(snapshot.payload.elements[0]).toEqual(
expect.objectContaining({
role: 'tab',
label: 'Reports',
value: '0',
actions: expect.arrayContaining(['tap', 'longPress', 'touch']),
}),
);
});

it('derives deterministic screen hashes from normalized UI content', () => {
const uiHierarchy = [createNode({ AXLabel: 'Continue' }), createNode({ AXLabel: 'Cancel' })];

Expand Down
7 changes: 6 additions & 1 deletion src/mcp/tools/ui-automation/key_sequence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ import {
clearRuntimeSnapshot,
withSimulatorUiAutomationTransaction,
} from './shared/snapshot-ui-state.ts';
import { captureRuntimeSnapshotAfterActionSafely } from './shared/post-action-snapshot.ts';
import {
captureRuntimeSnapshotAfterActionSafely,
type PostActionSnapshotTiming,
} from './shared/post-action-snapshot.ts';
import type { AxeHelpers } from './shared/axe-command.ts';
import type { NonStreamingExecutor } from '../../../types/tool-execution.ts';
import type { UiActionResultDomainResult } from '../../../types/domain-results.ts';
Expand Down Expand Up @@ -57,6 +60,7 @@ export function createKeySequenceExecutor(
executor: CommandExecutor,
axeHelpers: AxeHelpers = defaultAxeHelpers,
debuggerManager: DebuggerManager = getDefaultDebuggerManager(),
postActionSnapshotTiming?: PostActionSnapshotTiming,
): NonStreamingExecutor<KeySequenceParams, KeySequenceResult> {
return async (params) =>
withSimulatorUiAutomationTransaction(params.simulatorId, async () => {
Expand Down Expand Up @@ -91,6 +95,7 @@ export function createKeySequenceExecutor(
simulatorId,
executor,
axeHelpers,
timing: postActionSnapshotTiming,
});
return createUiActionSuccessResult(
action,
Expand Down
3 changes: 3 additions & 0 deletions src/mcp/tools/ui-automation/shared/runtime-snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ function deriveRole(
node: AccessibilityNode,
identifier: string | undefined,
): RuntimeElementRoleV1 | undefined {
const roleDescription = normalizeText(node.role_description)?.toLowerCase();
if (roleDescription === 'tab') return 'tab';

const roleText = [node.role, node.type, node.subrole, node.role_description]
.map((value) => normalizeText(value)?.toLowerCase())
.filter((value): value is string => value !== undefined)
Expand Down
Loading