Skip to content

ADFA-2460: add a dedicated 'Edit' button to variable items in debugger variable tree#1053

Merged
itsaky-adfa merged 4 commits intostagefrom
fix/ADFA-2460
Mar 10, 2026
Merged

ADFA-2460: add a dedicated 'Edit' button to variable items in debugger variable tree#1053
itsaky-adfa merged 4 commits intostagefrom
fix/ADFA-2460

Conversation

@itsaky-adfa
Copy link
Contributor

@itsaky-adfa itsaky-adfa commented Mar 9, 2026

See ADFA-2460 for more details.

Signed-off-by: Akash Yadav <akashyadav@appdevforall.org>
Signed-off-by: Akash Yadav <akashyadav@appdevforall.org>
@itsaky-adfa itsaky-adfa requested a review from a team March 9, 2026 14:10
@itsaky-adfa itsaky-adfa self-assigned this Mar 9, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

📝 Walkthrough

Release Notes: Debugger Variable Edit Button

Features

  • Added a dedicated "Edit" button to variable items in the debugger variable tree, allowing users to edit variable values directly from a dedicated UI control
  • New edit button is positioned to the right of variable labels with proper spacing
  • Edit button includes validation to prevent editing of immutable variables or unavailable/error values

UI/Layout Changes

  • Added new edit ImageView button (@+id/edit) to debugger variable item layout
  • Introduced spacing view (label_edit_space) to separate variable label from edit button
  • Updated label constraints to accommodate the new edit button
  • Disabled horizontal scrolling on the variable tree view (supportHorizontalScroll = false)

Code Changes

  • Refactored VariableListBinder with internal restructuring of binding logic and click handlers
  • Moved set-value dialog trigger from root view to dedicated edit button
  • Maintained async binding and coroutine-based text loading for dialog initialization

⚠️ Risks & Best Practice Violations

Critical Accessibility Issue:

  • The new edit button ImageView is missing the required android:contentDescription attribute. Interactive buttons must provide content descriptions for screen readers to support users with visual impairments. This violates WCAG accessibility guidelines and Android Material Design best practices.

Other Concerns:

  • Disabled horizontal scrolling on the tree view may cause usability issues for users with very long variable names that exceed available screen space
  • String comparison validation logic (debugger_value_unavailable, debugger_value_error, etc.) is fragile as it depends on exact localized string matches rather than enumerated states

Walkthrough

The changes refactor and reformat the debug variable list UI components, introducing a ViewHolderState data class in the binder, disabling horizontal scrolling on the tree view, and adjusting layout constraints for the variable item including label height and click target positioning.

Changes

Cohort / File(s) Summary
Kotlin Debug Classes
app/src/main/java/com/itsaky/androidide/fragments/debug/VariableListBinder.kt, app/src/main/java/com/itsaky/androidide/fragments/debug/VariableListFragment.kt
Reformatted constructor parameters with trailing commas; reintroduced ViewHolderState data class for per-view state management; changed variable item click handling from itemBinding.root to itemBinding.edit for dialog triggering; disabled tree view horizontal scrolling; restructured dialog setup and async binding logic with preserved coroutine semantics.
Layout Resource
app/src/main/res/layout/debugger_variable_item.xml
Updated constraint chain from icon-label-space to parent to icon-label-space to edit; changed label height from 0dp to wrap_content; introduced label_edit_space spacer view; adjusted label end constraint to anchor to edit button instead of parent.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 Constraints realigned, click targets refined,
State holders bound, scrolling unwound,
Layout chains dance, UI takes stance,
Debug vars glow, cleanly they flow!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding a dedicated 'Edit' button to variable items in the debugger variable tree, which aligns with the layout and implementation changes shown in the changeset.
Description check ✅ Passed The description references the related Jira issue (ADFA-2460) which provides context for the changes, demonstrating a connection to the changeset, though minimal detail is provided in the PR body itself.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/ADFA-2460

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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
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: 2

🧹 Nitpick comments (2)
app/src/main/java/com/itsaky/androidide/fragments/debug/VariableListFragment.kt (1)

79-82: Touch listener is set redundantly on every tree update.

The setOnTouchListener is called inside the observeLatestVariablesTree callback, so it gets reset every time the tree updates. Consider moving it outside the observer to set it only once.

♻️ Suggested refactor
 		viewLifecycleOwner.lifecycleScope.launch {
 			viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
+				treeView?.setOnTouchListener { _, event ->
+					gestureDetector?.onTouchEvent(event)
+					false
+				}
+
 				viewModel.observeLatestVariablesTree(
 					scope = this,
 					notifyOn = Dispatchers.Main,
 				) { tree ->
 					treeView?.tree = tree
 					treeView?.refresh()
-
-					treeView?.setOnTouchListener { _, event ->
-						gestureDetector?.onTouchEvent(event)
-						false
-					}
 				}
 			}
 		}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@app/src/main/java/com/itsaky/androidide/fragments/debug/VariableListFragment.kt`
around lines 79 - 82, The touch listener is being reattached on every update
because setOnTouchListener is called inside observeLatestVariablesTree; move the
treeView?.setOnTouchListener { _, event -> gestureDetector?.onTouchEvent(event);
false } out of the observer and set it once (e.g., in onViewCreated or
initialization code) so that gestureDetector is attached a single time; keep
observeLatestVariablesTree only for updating the tree data, not for UI listener
wiring.
app/src/main/java/com/itsaky/androidide/fragments/debug/VariableListBinder.kt (1)

319-334: Consider narrowing the exception type caught.

The catch block catches generic Exception, but based on project learnings, Kotlin code should prefer catching specific exception types (e.g., IllegalArgumentException) to maintain fail-fast behavior during development.

PrecomputedTextCompat.create() typically throws IllegalArgumentException for invalid parameters.

♻️ Suggested fix
-			} catch (e: Exception) {
+			} catch (e: IllegalArgumentException) {
 				logger.error("Failed to precompute text", e)

Based on learnings: "prefer narrow exception handling that catches only the specific exception type reported in crashes... instead of a broad catch-all."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@app/src/main/java/com/itsaky/androidide/fragments/debug/VariableListBinder.kt`
around lines 319 - 334, The catch block currently catches a broad Exception
around PrecomputedTextCompat.create() in VariableListBinder.kt; narrow it to
catch IllegalArgumentException (the documented/observed failure type) so only
expected text-precompute errors are handled, keep the logger.error(...) and the
withContext UI update (dialogBinding.input.setText(...) and
finalizeDialogUI(...)), and either remove any generic catch or add a separate
catch for Throwable that rethrows so unexpected errors still fail fast.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/src/main/res/layout/debugger_variable_item.xml`:
- Around line 69-78: The ImageView with id "edit" is missing accessibility
attributes; update the "edit" ImageView to include
android:contentDescription="@string/debugger_edit_variable" and add
android:importantForAccessibility="yes" (to match the "chevron" behavior), and
then add the string resource debugger_edit_variable (e.g., "Edit variable
value") to your strings.xml; ensure the contentDescription accurately describes
the action for screen readers.
- Around line 50-67: The label_edit_space spacer is being squashed because the
MaterialTextView with id "label" is constrained to end_toStartOf "@id/edit",
leaving no room for the spacer; change the constraints so "label" ends at the
start of the spacer and the spacer sits between "label" and "edit": set label's
app:layout_constraintEnd_toStartOf to "@id/label_edit_space" (instead of
"@id/edit"), keep label_edit_space
app:layout_constraintStart_toEndOf="@id/label" and
app:layout_constraintEnd_toStartOf="@id/edit", and ensure "label" and
"label_edit_space" maintain 0dp/defined widths as intended so the spacer can
occupy the padding space.

---

Nitpick comments:
In
`@app/src/main/java/com/itsaky/androidide/fragments/debug/VariableListBinder.kt`:
- Around line 319-334: The catch block currently catches a broad Exception
around PrecomputedTextCompat.create() in VariableListBinder.kt; narrow it to
catch IllegalArgumentException (the documented/observed failure type) so only
expected text-precompute errors are handled, keep the logger.error(...) and the
withContext UI update (dialogBinding.input.setText(...) and
finalizeDialogUI(...)), and either remove any generic catch or add a separate
catch for Throwable that rethrows so unexpected errors still fail fast.

In
`@app/src/main/java/com/itsaky/androidide/fragments/debug/VariableListFragment.kt`:
- Around line 79-82: The touch listener is being reattached on every update
because setOnTouchListener is called inside observeLatestVariablesTree; move the
treeView?.setOnTouchListener { _, event -> gestureDetector?.onTouchEvent(event);
false } out of the observer and set it once (e.g., in onViewCreated or
initialization code) so that gestureDetector is attached a single time; keep
observeLatestVariablesTree only for updating the tree data, not for UI listener
wiring.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7bff64a9-a8d9-4248-ae67-83980d0dc361

📥 Commits

Reviewing files that changed from the base of the PR and between a9cc45d and 9161797.

📒 Files selected for processing (3)
  • app/src/main/java/com/itsaky/androidide/fragments/debug/VariableListBinder.kt
  • app/src/main/java/com/itsaky/androidide/fragments/debug/VariableListFragment.kt
  • app/src/main/res/layout/debugger_variable_item.xml

@itsaky-adfa itsaky-adfa merged commit 831d4d6 into stage Mar 10, 2026
2 checks passed
@itsaky-adfa itsaky-adfa deleted the fix/ADFA-2460 branch March 10, 2026 10:35
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