Skip to content

ADFA-7144: Sync current editor tab and displayed view - #2274

Open
dara-abijo-adfa wants to merge 5 commits into
stagefrom
ADFA-7144-editor-tab-false-close
Open

dara-abijo-adfa wants to merge 5 commits into
stagefrom
ADFA-7144-editor-tab-false-close

Conversation

@dara-abijo-adfa

Copy link
Copy Markdown
Contributor

Suppress onTabSelected during tab removal, clean up views, then explicitly re-sync selection when closing a tab.

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

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.

Tip: disable this comment in your organization's Code Review settings.

@atlassian

atlassian Bot commented Nov 16, 2026

Copy link
Copy Markdown

To enable Code Reviewer, link your GitHub account to your Atlassian account.

This is a one-time task that takes less than a minute. Once your account is linked, resubmit the pull request to trigger a code review.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Summary

  • Fixes tab-close synchronization in the editor (ADFA-7144). Closing a file tab or plugin tab now re-selects the tab that remains selected.
  • BaseEditorActivity adds protected var isRemovingTab. While it is true, onTabSelected returns early, so intermediate tab, view, and index updates do not trigger selection callbacks.
  • BaseEditorActivity adds protected abstract fun updateTabVisibility(). The file observer now calls this method for every activity variant. The previous inline visibility logic for non-EditorHandlerActivity instances is removed.
  • EditorHandlerActivity wraps file and plugin tab removal in a private removingTab { } block. The view is removed before the tab, and plugin index maps are updated inside the block.
  • EditorHandlerActivity adds syncSelectedTab(). It calls onTabSelected on the currently selected tab when tabs remain. When no tabs remain, it calls editorViewModel.setCurrentFile(-1, null) and then updateTabVisibility().
  • EditorHandlerActivity.updateTabVisibility() changes from fun to override fun.
  • Adds EditorCloseTabTest, a Robolectric suite with five tests. The tests cover closing the active file tab, closing a tab to the left, closeOthers(), closing the last tab, and closing an active plugin tab.
  • Changes assets/core.cgt (binary, 1626091 to 1546506 bytes). This change is not described in the PR objectives or the AI-generated summary.

Risks and best-practice concerns:

  • assets/core.cgt is a binary asset change with no explanation. Reviewers should confirm its origin and intent.
  • isRemovingTab is a mutable flag. removingTab resets it in finally, which is correct. Nested or re-entrant calls would clear the flag early, so callers must not nest removingTab blocks.
  • syncSelectedTab() calls onTabSelected directly. If onTabSelected has side effects, they run on every removal.
  • updateTabVisibility() is now abstract in BaseEditorActivity. Any other subclass must implement it, or the build fails.
  • The file observer now calls updateTabVisibility() for all activities. Behavior for non-EditorHandlerActivity subclasses changes if their implementation differs from the removed inline logic.
  • The test suite runs under Robolectric. CI results for this change are not available.

Tab removal now suppresses intermediate selection callbacks. After file or plugin tab removal, the activity synchronizes the selected tab or clears the current file when no tabs remain. Tests cover tab selection, current-file state, displayed content, and visibility.

Changes: Editor tab close synchronization

Layer / File(s) Summary
Tab selection and visibility contract
app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt, app/src/main/java/com/itsaky/androidide/activities/editor/EditorHandlerActivity.kt
BaseEditorActivity skips selection handling during tab removal and delegates tab visibility updates through an abstract method. EditorHandlerActivity implements that method.
Tab close synchronization
app/src/main/java/com/itsaky/androidide/activities/editor/EditorHandlerActivity.kt, app/src/test/java/com/itsaky/androidide/activities/editor/EditorCloseTabTest.kt
File and plugin tab removal runs under a guard, then synchronizes the selected tab or clears the current file when no tabs remain. Tests cover selected-tab, file-index, displayed-child, and visibility state.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant EditorHandlerActivity
  participant TabLayout
  participant BaseEditorActivity
  EditorHandlerActivity->>TabLayout: Remove tab while isRemovingTab is true
  TabLayout-->>BaseEditorActivity: Send selection callback
  BaseEditorActivity-->>TabLayout: Ignore callback during removal
  EditorHandlerActivity->>BaseEditorActivity: Synchronize selected tab after removal
Loading

Possibly related PRs

Merge Risk: Minimal · up to b755e

This change keeps the selected editor tab and displayed view in sync when a file or plugin tab is closed. No concrete merge-blocking problem was found, and tests cover the main close scenarios.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the ticket and the main change: tab-close synchronization between the current editor tab and the displayed view. The changeset adds suppression of onTabSelected during tab removal, a s…
Description check Passed The description states that onTabSelected is suppressed during tab removal, views are cleaned up, and selection is explicitly re-synced when closing a tab. These points match the changes in BaseEditor…
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.
Full details: Title check

Explanation

The title names the ticket and the main change: tab-close synchronization between the current editor tab and the displayed view. The changeset adds suppression of onTabSelected during tab removal, a syncSelectedTab step after closing tabs, and tests for those flows, so the title matches the primary change. The ticket prefix is a minor addition and does not affect the assessment.

Full details: Description check

Explanation

The description states that onTabSelected is suppressed during tab removal, views are cleaned up, and selection is explicitly re-synced when closing a tab. These points match the changes in BaseEditorActivity, EditorHandlerActivity, and the new EditorCloseTabTest suite.

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 taps a tab goodbye,
The next one takes its place nearby.
The file and view now stay in tune,
The last tab hides beneath the moon.
The tests hop through each closing case,
Then leave the editor in its place.

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: b5b9dc2e-36b2-4043-84e6-273bfb07312b
Commits

Reviewing files that changed from the base of the PR and between 0bcd618 and b755e10.

Files selected for processing: 4

  • app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt
  • app/src/main/java/com/itsaky/androidide/activities/editor/EditorHandlerActivity.kt
  • app/src/test/java/com/itsaky/androidide/activities/editor/EditorCloseTabTest.kt
  • assets/core.cgt

Included review availability: This review used your included allowance. 4 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.

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