Skip to content

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

Open
jomen-adfa wants to merge 2 commits intostagefrom
fix/ADFA-3720-packagename
Open

fix/ADFA-3720 make set text() async#1278
jomen-adfa wants to merge 2 commits intostagefrom
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: 12853226-ea86-49b3-ade9-9fbec2508b4f

📥 Commits

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

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

📝 Walkthrough

Release Notes - Fix ADFA-3720: Make setText() Async During IME Decomposition

Changes

  • Modified TemplateWidgetViewProviderImpl.createTextField to asynchronously defer text updates during IME input
  • Text field updates are now posted to the main thread's message queue via input.post() instead of executing immediately
  • Specifically addresses synchronization desync issues with TextField on Android 12 devices during IME decomposition

⚠️ Risks & Best Practice Violations

  • Deferred async pattern may mask underlying architecture issue: Using post() to defer setText() is a workaround rather than addressing the root cause of IME synchronization problems. Consider investigating whether this issue exists in the IME observer callback itself.

  • Potential for timing-dependent bugs: Asynchronously deferring text updates can introduce race conditions if multiple text updates occur in rapid succession or if the app is backgrounded before the post executes.

  • Possible user-visible text input lag: The deferred update may introduce a noticeable delay between user input and text display, particularly on slower devices or under high main thread load.

  • Limited test coverage scope: Change is narrowly targeted to IME decomposition; similar desync issues may exist elsewhere in text field handling paths (programmatic updates, paste operations, etc.).

  • No explicit synchronization mechanism: The solution relies on main thread ordering guarantees without explicit locks or synchronization primitives, which may be fragile across different Android 12 variants.

Recommended Testing

  • Verify text responsiveness with multiple IME types on Android 12+ devices
  • Test rapid input, paste operations, and edge cases with empty/large text
  • Monitor for observable delays in text updates

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 title 'fix/ADFA-3720 make set text() async' clearly summarizes the main change: making setText() asynchronous, which aligns with the changeset that wraps setText() in input.post().
Description check ✅ Passed The description 'make settext() async during IME decomposition to address android 12 desync bug' is directly related to the changeset, explaining the purpose of wrapping setText() in input.post() to fix an Android 12 synchronization issue.
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

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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
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.

2 participants