From af52de4d05de8c4ca326fe83b392e2038e7584ba Mon Sep 17 00:00:00 2001 From: Codeman maintainer Date: Sun, 18 Oct 2026 08:05:39 +0200 Subject: [PATCH] fix(#567): separate refusal messages for the cases folder and a direct child The one message read "That folder is in the cases folder (...), where it is already listed as a case" for the cases folder itself too, which is not in itself and is never listed, and "already listed" is not true for a direct child that does not exist yet. Two messages now, both still pointing at plain Create New. Co-Authored-By: Claude Opus 5.5 (1M context) --- src/web/case-path.ts | 7 +++++-- test/case-path.test.ts | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/web/case-path.ts b/src/web/case-path.ts index df950396..369464d9 100644 --- a/src/web/case-path.ts +++ b/src/web/case-path.ts @@ -105,8 +105,11 @@ export function blockedReason( // perfectly good linked case: with CODEMAN_CASES_PATH pointing at a broad root such as /mnt/user/Scripts, // refusing everything below it blocked most of the tree. for (const dir of ctx.casesDirs ?? []) { - if (absPath === dir || dirname(absPath) === dir) { - return `That folder is in the cases folder (${dir}), where it is already listed as a case; create it there with plain Create New (no custom folder)`; + if (absPath === dir) { + return `That is the cases folder itself (${dir}); create a case inside it with plain Create New (no custom folder)`; + } + if (dirname(absPath) === dir) { + return `That folder is directly in the cases folder (${dir}), where it is listed as a local case; create it there with plain Create New (no custom folder)`; } } return null; diff --git a/test/case-path.test.ts b/test/case-path.test.ts index 7b267dcd..bd1d8be5 100644 --- a/test/case-path.test.ts +++ b/test/case-path.test.ts @@ -59,6 +59,11 @@ describe('blockedReason', () => { expect(blockedReason('/home/u/codeman-cases', withCases)).toMatch(/plain Create New/); expect(blockedReason('/home/u/codeman-cases/foo', withCases)).toMatch(/plain Create New/); expect(blockedReason('/home/u/codeman-cases/foo', withCases)).toContain('/home/u/codeman-cases'); + // Two messages: the cases folder is not "in" itself, and a child that does not exist yet is not + // "already" listed. + expect(blockedReason('/home/u/codeman-cases', withCases)).toMatch(/cases folder itself/); + expect(blockedReason('/home/u/codeman-cases/foo', withCases)).toMatch(/directly in the cases folder/); + expect(blockedReason('/home/u/codeman-cases/foo', withCases)).not.toMatch(/already/); expect(blockedReason('/home/u/codeman-cases-old/foo', withCases)).toBeNull(); expect(blockedReason('/home/u/codeman-cases/foo', c)).toBeNull(); });