You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ADFA-7258: Wait for the editor's async layout in IDEEditorAccessibilityTest - #2301
Fixes IDEEditorAccessibilityTest's "accessibility click requests soft keyboard when editable", which has failed since it was added in d0bdfa8 (ADFA-4605, PR #2171). The test was wrong; the editor is right. Test-only change, one file, (+36 / -1), in two commits; the second answers the independent review.
Why it failed
IDEEditor's accessibility click calls sora's CodeEditor.showSoftInput(). That reaches InputMethodManager.showSoftInput() only when isEditable() is true.
isEditable() is editable && !layoutBusy && !isFormatting. After setText(), sora measures the text in a task on a background executor (AbstractLayout.executor). The task sets layoutBusy when it starts (LineBreakLayout, WordwrapLayout) and clears it in a callback it posts to the main looper.
Robolectric runs that callback only when the test idles the main looper. setUp() idled once, right after setText(), usually before the background layout finished. So the click hit a busy editor, and the IMM was never called.
A temporary print at click time showed layoutBusy true, and the IMM's showSoftInput never ran. A temporary 100-run stress test failed 99/100 before this change and 0/100 after it. The test also fails at d0bdfa8 itself, so no later commit broke it.
The change
setUp() calls a new awaitEditorLayout() in place of the single idle(). It polls until sora's layout executor has no queued or running task andeditor.isEditable is true, twice in a row, idling the main looper each time. Checking only isEditable isn't enough: it can read true before the layout task starts and sets layoutBusy. The second poll makes it unlikely, though not impossible, to miss a task that has left the queue but not yet started. After 10 s it fails with a message giving the executor's queue size and active count, isEditable and isFormatting.
The keyboard test asserts editor.isEditable before the click, with a message, so a future failure points at the precondition rather than at the IMM.
awaitEditorLayout() reads sora's private static AbstractLayout.executor by reflection, because sora exposes no "layout finished" signal. If a sora upgrade renames that field, setUp() fails at once with NoSuchFieldException in all 5 tests, rather than becoming flaky; a type change fails fast too. The one quiet case is sora keeping the field but no longer using it: the helper then rests on isEditable alone.
Not in this PR
The same race can happen on a phone, though I've only found it by reading the code. A TalkBack double-tap (or an ordinary tap) that lands while the editor is re-laying out its text, such as when a file opens, the text size or word wrap changes, or the phone rotates, brings up no keyboard. A second tap works. Changing the editor to wait for the layout is a separate change, tracked in ADFA-7270.
Sibling tests checked. The only other unit test that builds a real sora editor is StaleWordwrapRowsTest (ADFA-6543). It has the same single idle() after setText(), and in the review's probe its layout was still running after that idle in 50/50 runs. Its pending word-wrap callback may then rebuild rowTable during the test's last idle, so its final assertion might pass even without the fix's relayout step (rebuildLayout()). That isn't proven, and it's left alone here: ADFA-7271 tracks checking and fixing it. EditorCloseTabTest mocks its editors, and the instrumented IDEEditorTest runs on a real looper.
No CI check gates on :editor unit tests (ADFA-5328): PR CI doesn't run them, and the nightly Analyze run, which does, ignores their failures. So the run above is the check. The stress test isn't committed.
The independent review reran the class (5/5), reproduced the stage failure (4/5, at the IMM assertion), and probed 300 rounds: 0 failures with this helper, 291 with the old single idle().
Code Reviewer: Code Reviewer couldn't review this pull request
The pull request author does not have access to AI for the associated Atlassian organization.
…tyTest
"accessibility click requests soft keyboard when editable" failed since it
was added in d0bdfa8. The editor is right; the test raced a background
thread.
IDEEditor's a11y click calls sora's CodeEditor.showSoftInput(), which only
reaches InputMethodManager.showSoftInput() when isEditable() is true.
isEditable() is false while layoutBusy: sora measures text on a background
executor and clears the flag in a callback it posts to the main looper.
Robolectric runs that callback only when the test idles the looper, and
setUp() idled once, right after setText(), before the layout finished. The
click then hit a busy editor and the IMM was never called.
setUp() now waits until sora's layout executor is idle and the editor is
editable, and the keyboard test asserts that precondition. A temporary
100-iteration stress test failed 99/100 with the old setUp and 0/100 with
the new one. The wait reads sora's private static AbstractLayout.executor by
reflection; if sora renames it, setUp fails loudly rather than flakily.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
From the independent review of #2301:
- The KDoc said isEditable() stays false until the layout callback runs.
In fact sora's layout task sets layoutBusy itself when it starts, so
isEditable() can read true before then. That is why the helper also
waits for the executor to be idle. The second settled poll makes a
missed task unlikely, not impossible.
- The timeout message now gives the executor's queue size and active
count, isEditable and isFormatting, and names the limit once.
- The isEditable assertion before the click now says what failed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
The reason will be displayed to describe this comment to others. Learn more.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Review was skipped as selected files did not have any reviewable changes.
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Essentials
Run ID: a72e2a0c-3fbe-4737-b8d8-6843b8bee1c7
Commits
Reviewing files that changed from the base of the PR and between 965184c and 6763a8d.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Summary
Release notes:
Fixes a race in the IDEEditorAccessibilityTest setup. Setup now waits for editor layout through the new awaitEditorLayout helper.
The helper checks sora's layout executor and editor.isEditable. It requires two consecutive settled polls and fails after 10 seconds.
Adds an editability assertion before the soft-keyboard accessibility click.
Test-only change. No editor runtime behavior changes.
Risks and best-practice violations:
The helper uses reflection on sora's private AbstractLayout.executor. A renamed or retyped field fails the test. If the field stays but is unused, the helper relies only on isEditable().
Two settled polls make a missed layout task unlikely, not impossible. Some flakiness may remain.
The real-device keyboard race is not fixed (ADFA-7270). The StaleWordwrapRowsTest race is unproven (ADFA-7271).
PR CI does not run editor unit tests. The nightly Analyze run ignores their failures. Verification depends on the reported local test run.
The accessibility test setup now waits for editor layout work to settle. A new helper checks executor and editor state, and the soft-keyboard accessibility-click test verifies that the editor is editable before clicking.
Changes: Editor accessibility test
Layer / File(s)
Summary
Wait for editor layout and verify editability editor/src/test/java/com/itsaky/androidide/editor/ui/IDEEditorAccessibilityTest.kt
Setup waits for two consecutive settled layout polls, with a 10-second timeout and state details on failure. The soft-keyboard accessibility-click test asserts that the editor is editable before clicking.
appdevforall/CodeOnTheGo#2298: Reports a failure in the soft-keyboard accessibility-click test that this change also targets.
Suggested reviewers:dara-abijo-adfa, itsaky-adfa
Merge Risk: Minimal · previous review 96518
This change makes an editor accessibility unit test wait for layout work to settle before it runs. It does not touch production behavior. A small residual chance of test flakiness remains, but it does not block merging.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: the test now waits for the editor's async layout in IDEEditorAccessibilityTest. It is specific, short, and matches the raw summary, which describes the new awaitEditor…
Description check
The description explains the failing test, the root cause in sora's asynchronous layout, the test-only fix (awaitEditorLayout and an editability assertion), the reflection risk, related follow-up tick…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: the test now waits for the editor's async layout in IDEEditorAccessibilityTest. It is specific, short, and matches the raw summary, which describes the new awaitEditorLayout helper replacing the single idle in setUp.
Full details: Description check
Explanation
The description explains the failing test, the root cause in sora's asynchronous layout, the test-only fix (awaitEditorLayout and an editability assertion), the reflection risk, related follow-up tickets, and the validation run. It matches the changeset.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
A rabbit waits while layouts run, Then checks the editor before the click. Two quiet polls, and work is done, The keyboard test can proceed. No busy state slips past the gate.
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Essentials
Run ID: cf2089ae-c4d3-41de-a8f3-cb6f60890305
Commits
Reviewing files that changed from the base of the PR and between 5a49afd and 965184c.
Included review availability: This review used your included allowance. Your plan provides up to 5 included reviews per hour; 2 remain after this review.
Brings in ADFA-7258 (#2301), which waits for the editor's async layout in
IDEEditorAccessibilityTest. stage requires a PR to be up to date before
it merges. No conflicts; the only file stage changed is that test.
This PR's own diff is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ADFA-7258
Fixes
IDEEditorAccessibilityTest's "accessibility click requests soft keyboard when editable", which has failed since it was added in d0bdfa8 (ADFA-4605, PR #2171). The test was wrong; the editor is right. Test-only change, one file, (+36 / -1), in two commits; the second answers the independent review.Why it failed
IDEEditor's accessibility click calls sora'sCodeEditor.showSoftInput(). That reachesInputMethodManager.showSoftInput()only whenisEditable()is true.isEditable()iseditable && !layoutBusy && !isFormatting. AftersetText(), sora measures the text in a task on a background executor (AbstractLayout.executor). The task setslayoutBusywhen it starts (LineBreakLayout,WordwrapLayout) and clears it in a callback it posts to the main looper.setUp()idled once, right aftersetText(), usually before the background layout finished. So the click hit a busy editor, and the IMM was never called.A temporary print at click time showed
layoutBusytrue, and the IMM'sshowSoftInputnever ran. A temporary 100-run stress test failed 99/100 before this change and 0/100 after it. The test also fails at d0bdfa8 itself, so no later commit broke it.The change
setUp()calls a newawaitEditorLayout()in place of the singleidle(). It polls until sora's layout executor has no queued or running task andeditor.isEditableis true, twice in a row, idling the main looper each time. Checking onlyisEditableisn't enough: it can read true before the layout task starts and setslayoutBusy. The second poll makes it unlikely, though not impossible, to miss a task that has left the queue but not yet started. After 10 s it fails with a message giving the executor's queue size and active count,isEditableandisFormatting.editor.isEditablebefore the click, with a message, so a future failure points at the precondition rather than at the IMM.awaitEditorLayout()reads sora's private staticAbstractLayout.executorby reflection, because sora exposes no "layout finished" signal. If a sora upgrade renames that field,setUp()fails at once withNoSuchFieldExceptionin all 5 tests, rather than becoming flaky; a type change fails fast too. The one quiet case is sora keeping the field but no longer using it: the helper then rests onisEditablealone.Not in this PR
The same race can happen on a phone, though I've only found it by reading the code. A TalkBack double-tap (or an ordinary tap) that lands while the editor is re-laying out its text, such as when a file opens, the text size or word wrap changes, or the phone rotates, brings up no keyboard. A second tap works. Changing the editor to wait for the layout is a separate change, tracked in ADFA-7270.
Sibling tests checked. The only other unit test that builds a real sora editor is
StaleWordwrapRowsTest(ADFA-6543). It has the same singleidle()aftersetText(), and in the review's probe its layout was still running after that idle in 50/50 runs. Its pending word-wrap callback may then rebuildrowTableduring the test's last idle, so its final assertion might pass even without the fix's relayout step (rebuildLayout()). That isn't proven, and it's left alone here: ADFA-7271 tracks checking and fixing it.EditorCloseTabTestmocks its editors, and the instrumentedIDEEditorTestruns on a real looper.Testing
./gradlew :editor:testV8DebugUnitTest --tests '*IDEEditorAccessibilityTest*': 5/5 pass (4/5 before)../gradlew spotlessCheck: passes.:editorunit tests (ADFA-5328): PR CI doesn't run them, and the nightly Analyze run, which does, ignores their failures. So the run above is the check. The stress test isn't committed.idle().🤖 Generated with Claude Code
https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
Code Reviewer: Code Reviewer couldn't review this pull request
The pull request author does not have access to AI for the associated Atlassian organization.