fix(desktop): keep desktop-workspace pointer in sync across all navigation paths#3436
Merged
esengine merged 2 commits intoJun 8, 2026
Conversation
…oject RemoveWorkspace() was cleaning up desktop-workspaces.json and desktop-projects.json but never cleared the desktop-workspace pointer file. When the removed project was the active workspace, this left a stale reference that caused subsequent sessions to use the wrong workspace root — attachments and memory would land in a deleted project's directory. Now RemoveWorkspace checks whether the removed dir matches the active pointer and either falls back to the first remaining project or clears the pointer entirely when no projects remain. Fixes esengine#1623
SwitchWorkspace correctly saves the active pointer, but clicking an existing project in the sidebar goes through OpenProjectTab instead, which never called saveWorkspace. This meant that after switching projects via the sidebar, desktop-workspace still pointed to whichever project was active at app startup — causing attachments and memory to land in the wrong project directory. Now OpenProjectTab also calls saveWorkspace so the pointer stays in sync regardless of how the user navigates between projects. Also adds a test verifying OpenProjectTab updates the pointer.
fc61062 to
306a1fc
Compare
esengine
approved these changes
Jun 8, 2026
esengine
left a comment
Owner
There was a problem hiding this comment.
修掉两个真 bug:删除活动项目残留的 desktop-workspace 指针、侧栏切项目漏更新指针。fix 正确,tool/指针清理逻辑到位。
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
The
desktop-workspacefile records which project is currently active. Two bugs cause it to become stale:Bug 1:
RemoveWorkspaceleaves a stale pointerRemoveWorkspace()cleans updesktop-workspaces.jsonanddesktop-projects.jsonbut never clearsdesktop-workspace. When the removed project was the active one, a stale reference remains — subsequent sessions attach to a deleted project's directory, causing attachments and memory to land in the wrong place.Bug 2:
OpenProjectTabnever updates the pointerSwitchWorkspacecorrectly callssaveWorkspace(dir), but clicking an existing project in the sidebar goes throughhandleOpenTopic→OpenProjectTab, which never callssaveWorkspace. This means that after switching projects via the sidebar,desktop-workspacestill points to whichever project was active at app startup.Combined effect: If the user deletes project A (the startup-active one) and then switches to project B,
desktop-workspacestill contains the path to the deleted project A. Images pasted into the session save to the wrong.reasonix/attachments/directory.Reproduction
project-aandproject-b)project-abecomes active →desktop-workspace=project-aproject-afrom the project listproject-bin the sidebar to open itdesktop-workspacestill containsproject-a(stale)project-a/.reasonix/attachments/instead ofproject-bFix
desktop/app.go—RemoveWorkspaceAfter deleting the project, check whether the removed dir matches the active pointer. If so:
desktop/tabs.go—OpenProjectTabAdd
saveWorkspace(workspaceRoot)so the pointer updates when opening any project tab, matching whatSwitchWorkspacealready does.desktop/workspace.go— newclearWorkspace()Removes the
desktop-workspacefile so no stale reference persists.Tests
TestRemoveWorkspaceClearsActivePointerWhenRemovingCurrentWorkspaceTestRemoveWorkspaceFallsBackToRemainingProjectTestClearWorkspaceTestOpenProjectTabUpdatesActiveWorkspacePointer