Skip to content

fix(project-group): keep a group editable after its folder is renamed externally - #1882

Merged
vastsa merged 4 commits into
vastsa:mainfrom
SeanLiu326:fix/project-group-external-rename
Oct 26, 2026
Merged

vastsa merged 4 commits into
vastsa:mainfrom
SeanLiu326:fix/project-group-external-rename

Conversation

@SeanLiu326

Copy link
Copy Markdown
Contributor

Fixes #1869.

Root cause

A project group whose folder was renamed (or its drive unmounted) outside the app could no longer be healed from the edit dialog, through two stacked locks:

  1. Desktop update pre-check (apps/desktop/electron/main/ipc/workspace-ipc.ts): projectGroupUpdate rejected any submission that still contained the stale root with project group folders must be directories — including submissions where the user kept the stale row while adding the renamed folder (the reporter's screenshot 1).
  2. Host is_dir check (crates/host-core/src/db/project_groups.rs, update_project_group): the same per-folder directory check, so dropping the desktop pre-check alone would not help.

Because every natural edit path was blocked, the reporter next created a project on the renamed folder. The create-side dedupe (project-slice.ts) compares stored root spellings only, so it missed the renamed spelling and created a shadow group owning the new path. From then on the host's ownership guard rejected every heal of the original group with folder already belongs to a project group (the reporter's screenshot 2) — the group kept a folder that no longer existed and could never be edited again.

Fix

  • update_project_group exempts roots the edited group already owns from the on-disk directory check: a root renamed/unmounted externally can be kept, reordered, or dropped by the edit that is supposed to fix it. Folders that are new to the group must still exist on disk, exactly as before.
  • The desktop projectGroupUpdate handler no longer pre-rejects missing folders, so the host rule is the single gate (and its error names the offending path). projectGroupCreate keeps its pre-check because every submitted folder is new there.

After the fix the reporter's flow lands: keep the stale root while adding and promoting its replacement (now allowed), then drop the stale root in a follow-up edit — it detaches and the sidebar stops showing the dead folder.

Tests

  • crates/host-core/src/db/tests.rs — project_group_update_allows_a_root_renamed_away_externally: keep-stale-plus-add-replacement succeeds, follow-up drop heals and detaches the stale root, and a folder that is new to the group is still refused when missing on disk. (Runs in CI; no cargo locally.)
  • apps/desktop/test/project-edit.test.mjs — pins the new contract: only creation pre-checks folder existence in the desktop layer; 8/8 pass locally, workspace-roots.test.mjs 7/7.

The shadow-group ownership conflict itself is a separate product decision (transfer vs refuse) and is intentionally left as-is; this PR removes the path that leads users into it.

SeanLiu326 and others added 4 commits October 26, 2026 01:21
… externally

A project group whose folder was renamed (or its drive unmounted) outside
the app could no longer be healed from the edit dialog (vastsa#1869): both the
desktop update handler and the host rejected any submission that still
contained the stale root ('project group folders must be directories' /
'project group root is not a directory'), so the only way out was to drop
the stale root — and once the user had created a shadow group on the
renamed folder, even that died with 'folder already belongs to a project
group'.

The host now exempts roots the edited group already owns from the on-disk
directory check (folders new to the group must still exist), and the
desktop update handler no longer pre-rejects missing folders so the host
rule is the single gate. Keeping the stale root while adding and
promoting its replacement, then dropping the stale root in a follow-up
edit, both land; creation keeps validating every folder.
@vastsa
vastsa merged commit 68e848e into vastsa:main Oct 26, 2026
5 checks passed

vastsa commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Merged as 68e848ef2, preserving the contributor commits and merging current main into the PR branch without rewriting history. Independently reproduced the renamed-root regression on old main, then verified 8 project-group Host/DB/RPC tests, 15 Desktop project-edit/workspace-root tests, cargo fmt --check, and the isolated real-React/Electron project-edit journey. The tested integration tree equals the updated PR head/landed tree. New roots must still exist, and cross-group ownership remains enforced. This fixes the editor's stale-root validation path; it does not transfer a folder already owned by a separate group. CI status was ignored as requested.

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.

[Bug] 项目所属工作区的文件夹名在外部重命名后,使用项目编辑无法切换工作区到重命名后的文件夹

2 participants