Skip to content

fix(nsgotest): move native selections on phone targets - #1968

Merged
houko merged 1 commit into
nsgo-dev:mainfrom
houko:fix/native-select-1353
Nov 22, 2026
Merged

houko merged 1 commit into
nsgo-dev:mainfrom
houko:fix/native-select-1353

Conversation

@houko

@houko houko commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

app.Select now moves the native focused field on iOS, Android and HarmonyOS target tests. Previously these targets changed only the test model; adding OnSelectionChange skipped the test, and typing still acted on the native field's old caret.

The optional testhost.TextSelectionSurface uses UIKit UITextInput, Android InputConnection, and HarmonyOS's existing TextInputController path. It returns the actual native range so fields without an application callback also keep the model correct. UTF-16 ranges are clipped and ordered before reaching the host. HarmonyOS waits for its real selection callback, and its test typing replaces that reported range and places the native caret afterward. Desktop/web editing-key selection remains in place.

Refs #1353. The issue stays open: HarmonyOS device validation and its test host's existing lack of native clipboard editing keys are retained in the roadmap. This PR does not add that separate clipboard implementation.

Targets

  • Shared code (core, base, ui, tsx, the nsgo tool)
  • iOS
  • Android
  • HarmonyOS
  • macOS
  • tvOS
  • watchOS
  • Windows
  • Linux
  • Web
  • Mini programs
  • Docs or website only

Screenshots

None. These are native test-driver actions, covered by text/range/callback assertions.

Verification

  • go tool nsgo check (host and dev client).
  • go tool nsgo test ./nsgotest: 169 passed, 1 existing skip; go tool nsgo test ./internal/testhost: 3 passed.
  • Native selection regressions on iOS 18.4 simulator and Android API 35 arm64 emulator: selection callbacks plus replacement typing, single-line and multiline supplementary/combining text in UTF-16, reversed/clipped ranges, collapsed carets, and native copy/paste replacement. Four cases passed on each. The first Android run had a screen/keyguard probe timeout before the multiline test; a complete rerun passed all four.
  • go tool nsgo check -target ios_simulator,android,harmonyos,web -jobs 2.
  • HarmonyOS JS/Wasm tests with nsgotest: delayed native bridge callback/readback and replacement typing, input configuration and press routing, 3 passed. The bridge regression waits for a delayed callback instead of manufacturing a test-model selection.
  • Layering, app-author skill and changelog-fragment checks: 3 passed.

No HarmonyOS target or SDK is available locally, so no HarmonyOS native device/emulator validation was performed. Physical iPhone/Android devices were not used. The Android runtime was rebuilt locally to run the new test-agent operation; only Java source is committed, with DEX/JAR updates left to the repository's runtime workflow. This task's isolated iOS simulator and Android emulator/AVD were removed afterward.

Checklist

  • Conventional Commit title.
  • Architecture, public English/Chinese docs, app-author skill, roadmap and changelog fragment updated.
  • No new third-party code, assets or dependencies.

@github-actions github-actions Bot added bug Something isn't working size/M documentation Improvements or additions to documentation iOS Android labels Nov 22, 2026
@github-actions github-actions Bot added the conflict Conflicts with the base branch; resolve it first label Nov 22, 2026
@houko

houko commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator Author

Reviewed. iOS (UITextInput), Android (InputConnection.setSelection) and HarmonyOS (controller plus onTextSelectionChange) test hosts now move the real native selection in UTF-16 units and the model takes the range the host reads back; the shared keys fixture covers emoji/combining-mark ranges, clamping and copy/paste, and targets without a native path now skip instead of moving only the model. Rebased onto main (docs and roadmap conflicts only). HarmonyOS remains device-unverified as the docs say.

@houko
houko force-pushed the fix/native-select-1353 branch from 8b8beb7 to 2f19efb Compare November 22, 2026 14:37
@houko
houko enabled auto-merge November 22, 2026 14:37
@houko
houko force-pushed the fix/native-select-1353 branch from 2f19efb to 0cbbe71 Compare November 22, 2026 14:47
@houko
houko merged commit 99f1954 into nsgo-dev:main Nov 22, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Android bug Something isn't working conflict Conflicts with the base branch; resolve it first documentation Improvements or additions to documentation iOS size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant