Skip to content

refactor(apple-runner): extract the keyboard return control lookup - #4589

Merged
thymikee merged 1 commit into
mainfrom
refactor/apple-runner-return-key-lookup
Nov 16, 2026
Merged

thymikee merged 1 commit into
mainfrom
refactor/apple-runner-return-key-lookup

Conversation

@thymikee

@thymikee thymikee commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Summary

Extracts the keyboard return-control lookup from the keyboard enter press path into one reusable function, so a later PR can report the return key in keyboard status (approved design, Feature C). No behavior change.

Layer 1 of 2: kind(of:) and its cases are read by #4602. Per review on 1a6fc6c, the mapping and its tests stay with the lookup they name.

  • findKeyboardReturnControl(app:) owns the ordered label probe (RunnerKeyboardReturnKey.probeLabels, same labels, same order); tapKeyboardReturnControl taps what it returns.
  • New pure rule RunnerKeyboardReturnKey.kind(of:) maps a return key's label/identifier to go|search|send|next|done|join|route|continue|enter|unknown. Exact case-insensitive matches only; Apple's branded Google/Yahoo keys, Emergency Call, and localized or ambiguous labels stay unknown on purpose.

Touched files: 3. No TypeScript changes, no public API change.

Validation

Tested at cc7940a31646865a7f452fbb9f81eabd60d188c5.

  • pnpm check:affected --run --head cc7940a: passed, exactCommit: true (native-dupes, xctest-selection, packaged-runner-swift). swift-runner-* and replay-* are GitHub-authoritative lanes (CI obligations). At head 1a6fc6c all 20 CI checks passed, including both swift-runner lanes.
  • iOS XCUITest build with AGENT_DEVICE_XCUITEST_INCLUDE_UNIT_TESTS=1: succeeded. Method-selected simulator run: 7 executed, 0 failures, including the 5 new mapping tests and the existing keyboard-return tests. At 1a6fc6c the busy-keyboard tap path also passed locally.
  • macOS host lane: builds locally; its XCTest run cannot start on this machine (automation-mode timeout), so host-lane execution of the new tests is CI evidence.
  • pnpm format, pnpm check:quick: clean.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.32 MB 6.32 MB +523 B
Package (unpacked) 6.32 MB 6.32 MB +523 B
Package (download) 1.92 MB 1.92 MB +164 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 43.3 ms 37.6 ms -5.6 ms
CLI --help 86.6 ms 72.1 ms -14.5 ms

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files

You’re at about 96% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

@apex-sentinel-staging

apex-sentinel-staging Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve

Since the last review: 0 new · 0 still open · 0 no longer raised

No open findings.

1 finding below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (cfe08502f0f6).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

Earlier reviews

Review of 1a6fc6cc · 16.11.2026 14:10 UTC

Apex Sentinel · ✅ Approve

No open findings.

1 finding below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (36dbd2616fc6).

@thymikee

Copy link
Copy Markdown
Member Author

The extraction in 1a6fc6c looks behavior-preserving, and I found nothing that blocks it. All 20 checks pass, including the swift-runner iOS and macOS lanes that compile and run the touched runner files. There are no conflicts.

Not blocking, and you can take or leave it: RunnerKeyboardReturnKey's cases and kind(of:) have no production reader at this head (RunnerKeyboardReturnKey.swift#L34). Only probeLabels is read, at RunnerTests+Keyboard.swift:501, and the new unit tests are the only callers of the rest. Those tests also pin a wire value for a keyboard status field that does not exist yet. Could this PR keep to the lookup extraction and move kind(of:), its cases and its tests into the PR whose keyboard status reads them? If you prefer to keep them here, please say in the PR body that this is layer 1 and link the follow-up.

The three open inline threads still apply: the macOS/tvOS nil meaning, the findKeyboardReturnControl(in:) name, and the "each Apple return-key type" claim. All three are doc-comment fixes. On the last one, whether Google should stay unknown depends on how iOS labels the Google and Yahoo return keys today.

Before merge, please resolve those three threads and decide whether kind(of:) ships here or with its first reader.

Pulls the keyboard's return-key lookup out of the enter press into
findKeyboardReturnControl(in:) and one pure rule, RunnerKeyboardReturnKey,
that maps a return key's label or identifier to a normalized kind. The press
probes the same labels in the same order and taps what it found, so the
behavior is unchanged. The kind is what a later keyboard status operation
reports as returnKey.

Checks the mapping in the in-bundle unit tests, which run on the macOS host
lane on every PR and the iOS nightly lane.
@thymikee
thymikee force-pushed the refactor/apple-runner-return-key-lookup branch from 1a6fc6c to cc7940a Compare November 16, 2026 15:43
@thymikee

Copy link
Copy Markdown
Member Author

Addressed in cc7940a.

Keeping kind(of:) here: the stacked keyboard status PR reads it and its cases, and the mapping is the vocabulary the extracted lookup itself names, so splitting it would leave this PR's own doc comments referring at cases defined elsewhere. The PR body now states this is layer 1 of 2 and points at the follow-up.

All three inline threads are fixed and resolved: the doc comment distinguishes the iOS nil (nothing hittable) from the non-iOS nil (nothing queried, not to be read as an absent return control); both references now name findKeyboardReturnControl(app:); and the test comment names only the mapped Apple types, with Google, Yahoo and Emergency Call documented as intentionally unmapped and pinned .unknown by a new explicit test rather than sitting in the localized/custom negatives.

Validated at cc7940a: pnpm check:affected --run --head cc7940a passed with exactCommit: true; the iOS runner unit-test build (AGENT_DEVICE_XCUITEST_INCLUDE_UNIT_TESTS=1) runs the five mapping tests plus the existing keyboard-return tests green on the simulator (7 executed, 0 failures).

@thymikee

Copy link
Copy Markdown
Member Author

I found no problems in cc7940a, and the three earlier findings from #4589 (comment) are fixed. The nil-return comment, the findKeyboardReturnControl(app:) name and the return-key test comment and new test (Google, Yahoo and Emergency Call map to .unknown) all match the code now.

The three review threads on those points are fixed at this head, so you can resolve them: #4589 (comment), #4589 (comment) and #4589 (comment).

CI shows 20 checks with none failing. The swift-runner iOS and macOS lanes passed at the earlier head 1a6fc6c, and the changes since then are comments, one test split and one added test, with no production logic change. How iOS labels the Google and Yahoo return keys is unverified, but the code is correct either way. Nothing else from this review needs to happen before merge as long as CI stays green at cc7940a.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 16, 2026
@thymikee
thymikee added this pull request to stack #4606 November 16, 2026 17:21
@thymikee
thymikee merged commit cb33595 into main Nov 16, 2026
20 checks passed
@thymikee
thymikee deleted the refactor/apple-runner-return-key-lookup branch November 16, 2026 17:22
thymikee added a commit that referenced this pull request Nov 16, 2026
#4589 moved the return-control lookup into findKeyboardReturnControl and left
tapKeyboardReturnControl calling XCUIElement.tap() on every platform. tap() is
unavailable on tvOS, so the tvOS runner build in the release job failed. Restore
the iOS guard the original function had.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant