fix: address the release-prep review of #680

Claude history merges, never overwriting, into a project directory a deleted case of the new name left behind, instead of staying orphaned under the old key.
The free-target pre-check also refuses a dangling symlink (lstat), so stopSessions no longer ends sessions before a 409 EXISTS.
The rename dialog says stopped sessions are closed (their tabs go away) and, after a failed rename, how many were already closed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Codeman maintainer committed 2026-10-24 14:43:13 +02:00
1 parent ac6d4aa2db
commit d1e0e0aea6
10 files changed
+185 -39

No files matched your search

+2 -2
View File
@@ -1346,8 +1346,8 @@
[/^Case renamed to "(.+)"$/, (_m, name) => `案例已重命名为“${name}”`],
[/^New name for "(.+)"$/, (_m, name) => `“${name}”的新名称`],
[
/^These sessions have the folder open: (.+)\. They will be stopped \(nothing is restarted\) before the folder is renamed\.$/,
(_m, list) => `这些会话正在使用该文件夹:${list}。重命名前将停止它们(不会重新启动)。`,
/^These sessions have the folder open: (.+)\. They will be closed \(their tabs go away and nothing is restarted\) before the folder is renamed\.$/,
(_m, list) => `这些会话正在使用该文件夹:${list}。重命名前将关闭它们(其标签页会消失,不会重新启动)。`,
],
[/^Failed to (.+)$/, (_m, action) => `操作失败:${action}`],
[/^Will create: (.+)$/, (_m, path) => `将创建:${path}`],
+7 -2
View File
@@ -5067,12 +5067,17 @@ Object.assign(CodemanApp.prototype, {
if (data.requiresStop) {
const list = (data.sessions || []).map((s) => `${s.name}`).join(', ');
state.stop = true;
this._renameCaseNotice(`These sessions have the folder open: ${list}. They will be stopped (nothing is restarted) before the folder is renamed.`);
this._renameCaseNotice(`These sessions have the folder open: ${list}. They will be closed (their tabs go away and nothing is restarted) before the folder is renamed.`);
if (submit) submit.textContent = 'Stop sessions and rename';
return;
}
if (!data.success) {
this._renameCaseNotice(data.error || 'Failed to rename the case.');
// A rename that failed after closing sessions says so: their tabs are gone either way.
const closed = Number(data.stoppedSessions) || 0;
const message = data.error || 'Failed to rename the case.';
this._renameCaseNotice(
closed > 0 ? `${message} (${closed} session${closed === 1 ? ' was' : 's were'} already closed.)` : message
);
return;
}
this.closeRenameCase();
+14 -2
View File
@@ -1819,8 +1819,20 @@ export function registerCaseRoutes(
const moveFolder = !isLinked || body.renameFolder === true;
const newPath = isLinked ? (moveFolder ? siblingPath(oldPath, newName) : oldPath) : join(casesBase, newName);
if (moveFolder && newPath !== oldPath && (await probePath(newPath, { pastCap: true })) !== 'absent') {
return fail(409, ApiErrorCode.ALREADY_EXISTS, `A folder named ${newPath} already exists`);
if (moveFolder && newPath !== oldPath) {
// probePath follows symlinks, so a dangling one reads as absent; moveCaseFolder would still refuse it
// (it checks with lstat), but only after the sessions below were stopped. The probe answered for this
// very path, so the lstat after it is not a first touch of an unreachable mount.
const target = await probePath(newPath, { pastCap: true });
const danglingLink =
target === 'absent' &&
(await fs.lstat(newPath).then(
() => true,
() => false
));
if (target !== 'absent' || danglingLink) {
return fail(409, ApiErrorCode.ALREADY_EXISTS, `A folder named ${newPath} already exists`);
}
}
// Sessions with the folder open. Only a move disturbs them; an alias-only rename leaves them running.