Skip to content

fix(io): accept hardware button names case-insensitively - #479

Open
mobile-kevin wants to merge 1 commit into
mobile-next:mainfrom
mobile-kevin:fix-button-case-insensitive
Open

mobile-kevin wants to merge 1 commit into
mobile-next:mainfrom
mobile-kevin:fix-button-case-insensitive

Conversation

@mobile-kevin

@mobile-kevin mobile-kevin commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The help states "Button names are case-insensitive", but io button looked the name up in per-platform maps keyed by upper-case names (HOME, VOLUME_UP). So home, Home, volume_up all failed with "unsupported button" and only the exact upper-case form worked, on both Android and iOS.

Fix

Normalize the button name once in ButtonCommand (trim + upper-case) before dispatching to the device, so every platform accepts any case. The empty check and success message use the normalized name.

Tests

  • Unit: normalizeButtonName (case folding + trimming, empty/whitespace).
  • E2E (android): presses HOME as home/Home/hOmE and verifies the launcher returns each time.

Verified live: home/Home/HOME/volume_up all succeed on the emulator and simulator; a bogus name is still rejected.

Summary by CodeRabbit

  • Bug Fixes
    • Button names now ignore surrounding whitespace and capitalization, so inputs such as home, Home, and hOmE work consistently. Empty and whitespace-only names are rejected.
  • Tests
    • Added coverage for button-name normalization and Android HOME button behavior.

The help says "Button names are case-insensitive", but PressButton looked the
name up in per-platform maps keyed by upper-case names, so `home`, `Home` and
`volume_up` were rejected with "unsupported button" while only `HOME` worked.

Normalize the name once in ButtonCommand (trim + upper-case) before dispatching
to the device, so every platform accepts any case. Adds a unit test for the
normalization and an e2e test that presses HOME in several cases.
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: mobile-next/mobilecli/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 583500e2-bf19-434b-8762-057ddf6173f3

📥 Commits

Reviewing files that changed from the base of the PR and between 1e88c68 and 42c6a7f.

📒 Files selected for processing (3)
  • commands/input.go
  • commands/input_test.go
  • test/android.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.


📝 Walkthrough

Walkthrough

Button names are trimmed and converted to uppercase before validation, pressing, and reporting. Unit tests cover normalization, and an Android integration test checks HOME button names with different letter casing.

Changes

Button name normalization

Layer / File(s) Summary
Normalize button names and validate behavior
commands/input.go, commands/input_test.go, test/android.spec.ts
ButtonCommand trims and uppercases button names before validation, pressing, and reporting. Unit tests cover case and whitespace normalization. The Android test checks HOME presses with three letter-case variants.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: gmegidish

Merge Risk: ⚪ Minimal · up to 42c6a

Button names now accept mixed casing and surrounding whitespace while rejecting whitespace-only input. No actionable merge-blocking risk is identified; merge after normal checks pass.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: accepting hardware button names without case sensitivity.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🧪 Generate unit tests (beta)
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant