Skip to content

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

Merged
dara-abijo-adfa merged 13 commits into
stagefrom
ADFA-7144-editor-tab-false-close
Nov 20, 2026
Merged

dara-abijo-adfa merged 13 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 →

Important

Review skipped

We couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting @coderabbitai full review.

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

  • 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 · previous review 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.

Comment thread assets/core.cgt Resolved
Commit 51c169c mistakenly staged and committed a modified binary
core.cgt. This restores core.cgt back to the origin/stage baseline.
@dara-abijo-adfa
dara-abijo-adfa merged commit 71ce5ad into stage Nov 20, 2026
5 checks passed
@dara-abijo-adfa
dara-abijo-adfa deleted the ADFA-7144-editor-tab-false-close branch November 20, 2026 14:47
davidschachterADFA added a commit that referenced this pull request Nov 20, 2026
Conflict in EditorHandlerActivity.closeFile with ADFA-7144 (#2274):
kept stage's removingTab, its view-plugin-tab removal order and
syncSelectedTab, with the removal passed to removeFile so the indexes
shift only after the tab and view are gone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Vh2DAZWMkFWJh7CY7P4kCH
davidschachterADFA added a commit that referenced this pull request Nov 20, 2026
Reverts 6669fb6 and ee8fd0f. Since ADFA-7144 (#2274), closeFile
re-selects the selected tab after each close, which sets the current
and shown indexes from the tab strip once the closed tab's view is
gone. removeFile's own shift, and the removeViews callback that ordered
it after the view removal, did the same job a second way. closeFile and
removeFile now match stage, apart from removeFile's reset to -1 when
the last file closes.

Keeps CloseOthersTest.closingAnEarlierTabRemovesItsViewBeforeTheShownIndexMoves,
which now pins stage's order: removeViewAt(0) before setDisplayedChild(1).
Drops the four EditorViewModelDisplayedFileTest cases that called
removeFile on its own, since it no longer shifts the indexes;
EditorCloseTabTest covers that at the activity level.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Vh2DAZWMkFWJh7CY7P4kCH
davidschachterADFA added a commit that referenced this pull request Nov 20, 2026
…a79020 (ADFA-7115 scoped project model, ADFA-7144, ADFA-7142, ADFA-6574 and five more)

Brings in from stage, since 5f3d76a: #2241 (ADFA-7083 sqlite-js docs),
#2245 (ADFA-7100), #2171 (ADFA-4605), #2284 (ADFA-7226), #2266-#2270
(ADFA-7115), #2274 (ADFA-7144), #2255 (ADFA-7142) and #2247 (ADFA-6574).

No conflicts: stage and this PR change no file in common.

Semantic checks: :subprojects:sqlite-debugger depends on no in-repo
module, and stage changed neither settings.gradle.kts,
gradle/libs.versions.toml, composite-builds/build-logic, CLAUDE.md,
ARCHITECTURE.md nor the SQLite debugger README. Stage's workflow edits
(the CI perf write removed from debug.yml and analyze.yml) and hook
shebang changes do not touch test-sqlite-debugger.yml.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA added a commit that referenced this pull request Nov 20, 2026
…137: stage at ea79020 via #2259

Brings in #2259's merge of stage (632bc27): #2241, #2245, #2171,
#2284, #2266-#2270 (ADFA-7115), #2274 (ADFA-7144), #2255 (ADFA-7142)
and #2247 (ADFA-6574). #2259's own code is unchanged.

No conflicts: stage and this PR change no file in common.

Semantic checks: stage adds no Room database, entity or migration, and
RecentProjectRoomDatabase is still at version 5 on stage, so this PR's
version 6 with debugger_endpoint_table and migration5To6 stays the next
step. Stage changes no Koin module (di/AppModule.kt untouched), no
AndroidManifest entry, and none of LaunchAppAction, ProjectHandlerActivity,
ApkInstaller, InstallationResultReceiver or the SQLite debugger README.
Stage drops assets/core.cgt from the index (#2274); .gitignore already
covers it and app/build.gradle.kts fetches it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA added a commit that referenced this pull request Nov 20, 2026
…139: stage at ea79020 via #2259 and #2260

Brings in #2260's merge of #2259 (54ce393), which carries stage at
ea79020: #2241, #2245, #2171, #2284, #2266-#2270 (ADFA-7115), #2274
(ADFA-7144), #2255 (ADFA-7142) and #2247 (ADFA-6574). The code of #2259
and #2260 is unchanged.

No conflicts: stage and this PR change no file in common.

Semantic checks: stage changes nothing in plugin-api (sources or
api/plugin-api.api), plugin-manager, di/AppModule.kt,
CredentialProtectedApplicationLoader, docs/plugin-api.md,
docs/PLUGIN_AUTHORING.md or the SQLite debugger README.
docs/PLUGIN_API_CHANGELOG.md is unchanged on stage since #2243, which the
old base already had; stage's newest heading is still 26.43, so this
PR's entry stays under 26.48.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA added a commit that referenced this pull request Nov 20, 2026
…138: stage at ea79020 via #2259

Brings in #2259's merge of stage (632bc27): #2241, #2245, #2171,
#2284, #2266-#2270 (ADFA-7115), #2274 (ADFA-7144), #2255 (ADFA-7142)
and #2247 (ADFA-6574). #2259's own code is unchanged.

No conflicts. Two files changed on both sides merged cleanly, in
separate hunks:
- .github/workflows/debug.yml: stage drops the CI perf write (#2284);
  this PR's sqliteReleaseApkTest step is untouched.
- EditorHandlerActivity.kt: stage's #2247 makes a tap on the greyed
  Quick Build button flash QuickBuildAction.disabledReason and gives
  its content description the reason; #2274 syncs the tab after a
  close. This PR's runQuickBuildAction (dropdown row and status-line
  tap) is a separate hunk.

Semantic checks: stage's QuickBuildAction calls
QuickBuildProjectSupport.unsupportedProjectTypeMessage,
nonDebuggableVariantMessage and
GradleQuickBuildProvisioner.selectedVariantName, which this PR leaves
as they are; it only adds isSqliteDebuggerEnabled and the Refused
result. The project-model calls this PR adds (getAndroidAppModules,
projectDirPath, workspace) are unchanged by ADFA-7115. Stage changes
nothing in gradle-plugin, gradle-plugin-config, common, quickbuild,
resources, app/build.gradle.kts, gradle/libs.versions.toml,
settings.gradle.kts or composite-builds.

Not resolved here, as it needs a decision: after #2247 a tap on the
greyed button flashes why, while runQuickBuildAction still does
nothing when the button is greyed. The dropdown row is disabled then,
but the "tap for details" status line is not (for example after a
switch to a release variant), so its KDoc's "as the button does" no
longer holds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
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