Skip to content

Fix atomic IME text replacement - #149

Merged
RasulOs merged 9 commits into
mainfrom
fix/atomic-text-input
Jul 21, 2026
Merged

Fix atomic IME text replacement#149
RasulOs merged 9 commits into
mainfrom
fix/atomic-text-input

Conversation

@RasulOs

@RasulOs RasulOs commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • replace the complete field atomically with one selection plus commitText for clear=true
  • reject partial, nonzero-offset, or end-unverified extracted windows before full-field replacement
  • finish active composition before reading the final pre-commit snapshot, then select and replace the field
  • verify append operations against the exact result predicted from the original text and selection
  • never recommit or accessibility-replay any operation after commitText accepts it
  • distinguish thrown commitText outcomes from observed acceptance and skip replay when delivery is unknown
  • contain readback exceptions inside the editor and report accepted-but-unverifiable only after observed acceptance
  • preserve one-shot appends when extracted text or composition preparation is unsupported
  • preserve accepted and input-session-changed clear outcomes so keyboardClear cannot replay them through accessibility
  • keep verification, pre-commit retries, and fallback bound to the original input session
  • advance the session generation for every onStartInput, including editor restarts
  • ignore app-added U+200B/U+FEFF sentinels for ordinary input, while requiring explicitly requested zero-width characters to survive
  • route clearText() through the same verified replacement path

Reproduction matrix

Path Before After
Accepted append with stale or throwing readback The append could be committed twice or replayed through accessibility Returns accepted-but-unverifiable after exactly one commit
Thrown commitText An exception was treated as accepted even though delivery was unknown Returns commit-outcome-unknown; the API reports an error and skips replay
Accepted clear with stale readback A retry could select the old length and corrupt a longer replacement Never recommits; returns accepted-but-unverifiable unless the first readback verifies
Accepted clear with unreadable readback Boolean collapse could trigger accessibility on a newly focused field Preserves accepted-but-unverifiable and skips fallback
Active composing region commitText could replace only the composing range Finishes composition before reading, selecting, and replacing the complete field
Unsupported append preparation Text could be dropped even though commitText was supported Performs one direct commit at the current selection and skips fallback when accepted
Snapshot-less append Input was rejected before commitText Commits once at the editor's current selection and skips fallback
Focus changes during input Retry or fallback could modify a newly focused field Returns an input-session-changed error without retry or fallback
Editor restartInput A replacement connection retained the previous generation Every start callback invalidates in-flight work, including restarts
Partial or truncated extracted text clear=true could replace only the extracted slice Rejects before committing unless the snapshot starts at zero, is a full report, and its represented suffix reaches the field end
Requested zero-width text A dropped requested character could be normalized into false success Requested U+200B/U+FEFF must be present exactly to verify
Android 16 Settings search Legacy input could report success without atomic verification Shared patched editor produced exactly MRTEST7319; the dedicated clear endpoint then emptied the field

No search result was selected. Test text was cleared afterward, and the public Mobilerun IME/accessibility configuration was restored.

Tests

  • PASS: focused ApiHandlerTest and InputConnectionTextEditorTest
  • PASS: ./gradlew assembleDebug --no-daemon
  • Full suite: 480/481 passed. The only failure is the unchanged pre-existing SwitchTintResourceTest.trackTintSeparatesCheckedAndUncheckedStates assertion.
  • PASS on Android 16 emulator-5554 through the mirrored internal debug package at the latest commit: composition-aware atomic replacement and the dedicated clear endpoint were verified from fresh UI hierarchies.
  • The public debug APK was not installed over the existing public build because Android rejected its lower version code.

Companion PR

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test Build Ready

APK for PR #149 is available for testing.

Download APK from workflow run

Artifacts expire after 30 days.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b29ba4565c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/src/main/java/com/mobilerun/portal/input/InputConnectionTextEditor.kt Outdated
Comment thread app/src/main/java/com/mobilerun/portal/input/MobilerunKeyboardIME.kt Outdated
Comment thread app/src/main/java/com/mobilerun/portal/input/InputConnectionTextEditor.kt Outdated
@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test Build Ready

APK for PR #149 is available for testing.

Download APK from workflow run

Artifacts expire after 30 days.

RasulOs commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c8d1d3d10c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/src/main/java/com/mobilerun/portal/input/InputConnectionTextEditor.kt Outdated
@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test Build Ready

APK for PR #149 is available for testing.

Download APK from workflow run

Artifacts expire after 30 days.

RasulOs commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a9e4442c18

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/src/main/java/com/mobilerun/portal/input/MobilerunKeyboardIME.kt Outdated
@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test Build Ready

APK for PR #149 is available for testing.

Download APK from workflow run

Artifacts expire after 30 days.

RasulOs commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eb3ebd1aba

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test Build Ready

APK for PR #149 is available for testing.

Download APK from workflow run

Artifacts expire after 30 days.

RasulOs commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b29890c4a7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/src/main/java/com/mobilerun/portal/input/InputConnectionTextEditor.kt Outdated
@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test Build Ready

APK for PR #149 is available for testing.

Download APK from workflow run

Artifacts expire after 30 days.

RasulOs commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: ad8f63509d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test Build Ready

APK for PR #149 is available for testing.

Download APK from workflow run

Artifacts expire after 30 days.

RasulOs commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 86a719116a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/src/main/java/com/mobilerun/portal/input/MobilerunKeyboardIME.kt Outdated
@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test Build Ready

APK for PR #149 is available for testing.

Download APK from workflow run

Artifacts expire after 30 days.

RasulOs commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4f8266f26b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/src/main/java/com/mobilerun/portal/input/InputConnectionTextEditor.kt Outdated

RasulOs commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test Build Ready

APK for PR #149 is available for testing.

Download APK from workflow run

Artifacts expire after 30 days.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b1bd641fb0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

RasulOs commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

Physical Android 16 validation completed against head b1bd641fb0fec6cd4af1a9eb30526b040e9f11f5.

Device: Samsung SM-S918B, Android 16/API 36
WhatsApp: com.whatsapp 2.26.27.85
Debug APK SHA-256: a79fd1dcbb86d4004c49b251be00a39abef78b5e8490813645a15ab783e53a12

Scenario Result
Settings atomic replacement PASS: OLD7319 -> exactly MRTEST7319; response: input done via IME (clear=true)
Settings append PASS: MRTEST + 7319 -> exactly MRTEST7319; response: input done via IME (clear=false)
Settings clear PASS: field returned to hint-only Search; response: Text cleared via IME
IME restart/reacquisition PASS: switched Portal -> Samsung -> Portal, then replaced with exactly MRRESTART7319
WhatsApp global search PASS: 3 consecutive replacements with 9911656022; each response reported IME success; raw text was U+200B + requested digits and normalized exactly
WhatsApp contact search PASS: 2 consecutive replacements with exactly 9911656022; each response reported IME success
WhatsApp Message yourself composer PASS: exactly MRTEST7319, then cleared via IME; no message sent

No accessibility fallback, false success, false negative, stale suffix, or duplicate append was observed. All test text was cleared. The phone was restored to Samsung Keyboard with accessibility disabled; both debug Portal apps remain installed but inactive.

RasulOs commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

Android 16 emulator edge-case validation completed against source head b1bd641fb0fec6cd4af1a9eb30526b040e9f11f5 on emulator-5554 (API 36).

Result: 140/140 runtime cases passed.

Covered:

  • shorter, longer, and empty atomic replacements;
  • empty and normal appends;
  • cursor insertion (ABCDE -> ABCXDE);
  • selected-range replacement (ABCDE, select CD, insert XY -> ABXYE);
  • spaces, punctuation, emoji, combining characters, Arabic, requested U+200B/U+FEFF, multiline text, and an exact 4096-character value;
  • 50 alternating replacements, 50 sequential appends, and 20 repeated clears;
  • no-focused-editor rejection;
  • inactive-IME accessibility fallback reporting;
  • numeric Google Messages recipient input and unsent multiline composer input;
  • focus-change race: 1 induced session change, 0 wrong-field writes;
  • IME-restart sweep at 0–90 ms: 8 session-change errors with fallback skipped, 2 completed successes, exact BASEX in all 10 outcomes, and 0 duplicate appends.

Repository checks:

  • Focused input/API unit tests and assembleDebug pass.
  • The complete testDebugUnitTest run still has only the pre-existing unrelated SwitchTintResourceTest.trackTintSeparatesCheckedAndUncheckedStates tint-resource failure.

No public Portal defect was found and no code change was needed. Test text was cleared, no message was sent, and no draft remains.

@RasulOs
RasulOs merged commit a511a6b into main Jul 21, 2026
11 of 12 checks passed
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