Skip to content

fix/ADFA-3720 make set text() async#1278

Merged
jomen-adfa merged 2 commits into
stagefrom
fix/ADFA-3720-packagename
May 8, 2026
Merged

fix/ADFA-3720 make set text() async#1278
jomen-adfa merged 2 commits into
stagefrom
fix/ADFA-3720-packagename

Conversation

@jomen-adfa
Copy link
Copy Markdown
Contributor

make settext() async during IME decomposition to address android 12 desync bug

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1b2307f4-0b5d-4c9f-9bd5-e98215b844ce

📥 Commits

Reviewing files that changed from the base of the PR and between 7277dfd and 58937dd.

📒 Files selected for processing (1)
  • templates-impl/src/main/java/com/itsaky/androidide/templates/impl/TemplateWidgetViewProviderImpl.kt

📝 Walkthrough
  • Change: In TemplateWidgetViewProviderImpl.createTextField the DefaultObserver.onChanged handler now defers updates via input.post { disableAndRun { input.setText(param.value) } } instead of calling disableAndRun { input.setText(param.value) } directly.
  • Purpose: Workaround to address TextField desynchronization during IME composition on Android 12 by deferring setText() to the main thread message queue.

Risks & best-practice notes:

  • Workaround, not root-cause fix — deferring with input.post() may mask the underlying IME/observer timing issue.
  • Timing-dependent race conditions — posted runnables can reorder or be skipped by lifecycle changes (background/foreground) or rapid successive updates.
  • Potential input lag — users on slow devices or under heavy main-thread load may perceive delayed text updates.
  • Limited coverage — other text-update paths (programmatic updates, paste, undo/redo) may still suffer similar desyncs.
  • No explicit synchronization — relying on main-thread posting assumes stable ordering across device/IME variants and may be fragile.

Recommended testing:

  • Validate composition behavior across multiple IMEs and Android versions, with emphasis on Android 12.
  • Test rapid typing, paste, undo/redo, and programmatic updates to detect lost or out-of-order updates.
  • Exercise lifecycle transitions (background/foreground) during active composition to ensure posted updates apply.
  • Measure perceived input latency on low-end devices and under heavy main-thread load.

Walkthrough

The createTextField observer now defers parameter value updates to the view message queue with input.post { disableAndRun { input.setText(param.value) } } instead of applying them immediately; other widget wiring and logic are unchanged.

Changes

Text Field Update Deferral

Layer / File(s) Summary
Threading Update
templates-impl/src/main/java/com/itsaky/androidide/templates/impl/TemplateWidgetViewProviderImpl.kt
Text field value changes from the parameter observer are now posted to the view's message queue via input.post { disableAndRun { input.setText(param.value) } } instead of executing immediately.

Sequence Diagram(s)

sequenceDiagram
  participant Observer
  participant UIThread
  participant TextInputLayout
  Observer->>UIThread: input.post(runnable)
  UIThread->>TextInputLayout: runnable -> disableAndRun { setText(value) }
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 I hop where threads and views align,
Posting gently, one small line,
disableAndRun keeps changes neat,
setText waits until it's safe to meet,
Hooray — the UI sleeps and wakes on cue!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title directly relates to the main change: making setText() async by wrapping it in input.post() to address an Android 12 desync bug.
Description check ✅ Passed The description is related to the changeset, explaining the purpose of making setText() async during IME decomposition to fix an Android 12 desync bug.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ADFA-3720-packagename

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@templates-impl/src/main/java/com/itsaky/androidide/templates/impl/TemplateWidgetViewProviderImpl.kt`:
- Around line 144-152: The observer's onChanged currently calls disableAndRun {
input.post { input.setText(param.value) } } which re-enables the observer before
setText runs; move the disableAndRun inside the posted Runnable so the
reentrancy guard covers the actual setText call. Locate the observer object
(DefaultObserver<String>) and its onChanged implementation and change the order
so you call input.post { disableAndRun { input.setText(param.value) } },
ensuring programmatic updates don't trigger the TextWatcher to call
param.setValue/resetStartAndEndIcons/constraint checks.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: feac20e2-868c-4ad8-b21b-26259bbf811b

📥 Commits

Reviewing files that changed from the base of the PR and between 69e03bf and 0f413e9.

📒 Files selected for processing (1)
  • templates-impl/src/main/java/com/itsaky/androidide/templates/impl/TemplateWidgetViewProviderImpl.kt

@jomen-adfa jomen-adfa force-pushed the fix/ADFA-3720-packagename branch from 990e09b to aea8274 Compare May 7, 2026 06:00
@jomen-adfa jomen-adfa requested review from Daniel-ADFA and itsaky-adfa and removed request for davidschachterADFA May 7, 2026 06:10
@jomen-adfa jomen-adfa force-pushed the fix/ADFA-3720-packagename branch from aea8274 to 7277dfd Compare May 7, 2026 21:03
@jomen-adfa jomen-adfa force-pushed the fix/ADFA-3720-packagename branch from 7277dfd to 58937dd Compare May 8, 2026 16:52
@jomen-adfa jomen-adfa merged commit 13b45ee into stage May 8, 2026
2 checks passed
@jomen-adfa jomen-adfa deleted the fix/ADFA-3720-packagename branch May 8, 2026 16:59
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.

3 participants