Skip to content

feat: detect HarmonyOS NEXT - #429

Merged
matthewhudson merged 1 commit into
mainfrom
claude/harmonyos-next
Sep 28, 2026
Merged

matthewhudson merged 1 commit into
mainfrom
claude/harmonyos-next

Conversation

@matthewhudson

Copy link
Copy Markdown
Owner

Summary

Fixes B1 from the project audit (搂3.3, the remaining Medium detection bug): Huawei's Android-free HarmonyOS NEXT (OpenHarmony 5 and later, ArkWeb engine) was not recognised. Its user agents have no Android and no HarmonyOS token, only OpenHarmony and a device-type token:

User agent Before After
(Phone; OpenHarmony 5.0) ... ArkWeb/4.1.6.1 Mobile unknown / mobile, class mobile harmonyos / mobile, classes harmonyos mobile
(Tablet; OpenHarmony 5.0) ... ArkWeb/4.1.6.1 unknown / desktop, class desktop harmonyos / tablet, classes harmonyos tablet
(PC; OpenHarmony 5.0; HarmonyOS 5.0) ... harmonyos / desktop, classes harmonyos mobile harmonyos / desktop, classes harmonyos desktop

Changes

  • device.harmonyos() also matches openharmony.
  • Two private checks read the HarmonyOS NEXT form factor from the (Phone/Mobile and (Tablet tokens and feed device.mobile() / device.tablet(). The Android-based HarmonyOS 2 to 4 keep going through androidPhone()/androidTablet(); device.android() stays false for HarmonyOS NEXT.
  • The harmonyos class branch now follows device.type (tablet, mobile, else the new harmonyos desktop), which also fixes the PC case above, where the classes disagreed with the type.
  • Feature-phone fallback excludes HarmonyOS.
  • README: class table, method table, device support and the Limitations bullet that said HarmonyOS NEXT was undetected.
  • Minor changeset (a newly detected platform).

Fixtures

Three new fixtures. The PC one is verbatim from the Matomo fixtures. The phone and tablet strings are Huawei's documented default user agent format (linked as source); the Huawei developer site could not be reached from this environment to re-verify the page, so the fixture comment says they are the documented format rather than a capture. The openharmony token and the (Phone/(Tablet/(PC device-type tokens are the stable part of that format; the Chrome and ArkWeb versions vary.

Test plan

  • pnpm run typecheck, pnpm run test (641 passed, 1 expected failure), pnpm run build, pnpm run test:dist (99 passed, 1 expected failure)
  • pnpm run corpus: no change outside the OpenHarmony entries (89.1% type accuracy, Android groups unchanged)
  • If you have access to a HarmonyOS NEXT device, navigator.userAgent from it would confirm the phone/tablet strings

馃 Generated with Claude Code

https://claude.ai/code/session_01VR63CHdvbRNYKvpNqMWVdm


Generated by Claude Code

Huawei's Android-free HarmonyOS (OpenHarmony 5+, ArkWeb) sends
"(Phone; OpenHarmony 5.0) ... Mobile", "(Tablet; OpenHarmony 5.0)" or
"(PC; OpenHarmony 5.0; HarmonyOS 5.0)". Phones were mobile with os
unknown; tablets and PCs were desktop with no OS. All three now report
os 'harmonyos' with the right type, and the harmonyos class branch
follows device.type (new `harmonyos desktop` classes for PCs).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VR63CHdvbRNYKvpNqMWVdm
@matthewhudson
matthewhudson merged commit ae3eb78 into main Sep 28, 2026
3 checks passed
@matthewhudson
matthewhudson deleted the claude/harmonyos-next branch September 28, 2026 21:13
@github-actions github-actions Bot mentioned this pull request Sep 28, 2026
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