Skip to content

fix(desktop): keep desktop-workspace pointer in sync across all navigation paths#3436

Merged
esengine merged 2 commits into
esengine:main-v2from
drafish:fix/remove-workspace-cleanup-active-pointer
Jun 8, 2026
Merged

fix(desktop): keep desktop-workspace pointer in sync across all navigation paths#3436
esengine merged 2 commits into
esengine:main-v2from
drafish:fix/remove-workspace-cleanup-active-pointer

Conversation

@drafish

@drafish drafish commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Problem

The desktop-workspace file records which project is currently active. Two bugs cause it to become stale:

Bug 1: RemoveWorkspace leaves a stale pointer

RemoveWorkspace() cleans up desktop-workspaces.json and desktop-projects.json but never clears desktop-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: OpenProjectTab never updates the pointer

SwitchWorkspace correctly calls saveWorkspace(dir), but clicking an existing project in the sidebar goes through handleOpenTopicOpenProjectTab, which never calls saveWorkspace. This means that after switching projects via the sidebar, desktop-workspace still 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-workspace still contains the path to the deleted project A. Images pasted into the session save to the wrong .reasonix/attachments/ directory.

Reproduction

  1. Add two projects (project-a and project-b)
  2. Start Reasonix — project-a becomes active → desktop-workspace = project-a
  3. Delete project-a from the project list
  4. Click project-b in the sidebar to open it
  5. desktop-workspace still contains project-a (stale)
  6. Paste a screenshot → it saves to project-a/.reasonix/attachments/ instead of project-b

Fix

desktop/app.goRemoveWorkspace

After deleting the project, check whether the removed dir matches the active pointer. If so:

  • Fall back to the first remaining project (if any)
  • Or clear the pointer entirely when no projects remain

desktop/tabs.goOpenProjectTab

Add saveWorkspace(workspaceRoot) so the pointer updates when opening any project tab, matching what SwitchWorkspace already does.

desktop/workspace.go — new clearWorkspace()

Removes the desktop-workspace file so no stale reference persists.

Tests

  • TestRemoveWorkspaceClearsActivePointerWhenRemovingCurrentWorkspace
  • TestRemoveWorkspaceFallsBackToRemainingProject
  • TestClearWorkspace
  • TestOpenProjectTabUpdatesActiveWorkspacePointer

…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
@github-actions github-actions Bot added desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development labels Jun 7, 2026
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.
@drafish drafish changed the title fix(desktop): clear active workspace pointer when removing current project fix(desktop): keep desktop-workspace pointer in sync across all navigation paths Jun 7, 2026
@drafish drafish changed the title fix(desktop): keep desktop-workspace pointer in sync across all navigation paths fix(desktop): keep desktop-workspace pointer in sync across all navigation and startup paths Jun 7, 2026
@drafish drafish force-pushed the fix/remove-workspace-cleanup-active-pointer branch from fc61062 to 306a1fc Compare June 7, 2026 11:36
@drafish drafish changed the title fix(desktop): keep desktop-workspace pointer in sync across all navigation and startup paths fix(desktop): keep desktop-workspace pointer in sync across all navigation paths Jun 7, 2026

@esengine esengine left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修掉两个真 bug:删除活动项目残留的 desktop-workspace 指针、侧栏切项目漏更新指针。fix 正确,tool/指针清理逻辑到位。

@esengine esengine merged commit f8bd98c into esengine:main-v2 Jun 8, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants