fix(desktop): close tabs when removing workspace to prevent ghost reappear#5121
Open
HUQIANTAO wants to merge 2 commits into
Open
fix(desktop): close tabs when removing workspace to prevent ghost reappear#5121HUQIANTAO wants to merge 2 commits into
HUQIANTAO wants to merge 2 commits into
Conversation
…ppear When a user removes a workspace from the sidebar, RemoveWorkspace only cleared desktop-projects.json and desktop-workspaces.json but left open tabs referencing that workspace in desktop-tabs.json. On shutdown the tab state was persisted; on the next startup restoreOrBuildTabs recreated those tabs and ensureTopicIndexed unconditionally re-added the project to desktop-projects.json, causing the removed workspace to reappear. Close all tabs belonging to the workspace before removing it from the project index, following the same pattern as TrashTopic. If all tabs are removed, create a fallback global tab so the app is not left headless. Fixes esengine#5079
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Removed workspaces reappear in the sidebar every time the application restarts.
Reproduction (Issue #5079):
Root Cause
Three persistence layers are involved:
desktop-projects.jsondesktop-workspaces.jsondesktop-tabs.jsonworkspaceRootandtopicIdRemoveWorkspace(desktop/app.go:1121) only cleaned up the first two:On shutdown,
saveTabsLocked()persisted the still-open tabs (with theirWorkspaceRootpointing to the removed workspace) back todesktop-tabs.json. On the next startup:restoreOrBuildTabsreadsdesktop-tabs.jsonand creates tabs for the removed workspacebuildTabControllercallsensureTopicIndexed(desktop/tabs.go:1364)ensureTopicIndexedunconditionally re-adds the project todesktop-projects.jsonif not presentFix
Close all tabs belonging to the workspace before removing it from the project index. This follows the same pattern used by
TrashTopic(desktop/tabs.go:1937):WorkspaceRoot == dira.tabsanda.tabOrdersaveTabsLocked()to persist the cleaned stateThen proceed with the existing
forgetWorkspace+removeProjectcleanup.Changes in
desktop/app.go:Testing