Skip to content

fix(cases): only refuse the cases folder and its direct children for a custom-folder case - #567

Merged
Ark0N merged 1 commit into
Ark0N:masterfrom
opticon454:fix/case-path-nested-in-cases-dir
Oct 18, 2026
Merged

Ark0N merged 1 commit into
Ark0N:masterfrom
opticon454:fix/case-path-nested-in-cases-dir

Conversation

@opticon454

Copy link
Copy Markdown
Contributor

Problem

Add Case → Create New → custom folder refuses any folder below the cases directory with "That folder is inside the cases folder; create a case there with plain Create New". The stated reason is that such a folder is already listed as a local case, but GET /api/cases lists only the direct children of the cases directory. A deeper folder is not listed, so linking it cannot register it twice.

It matters when CODEMAN_CASES_PATH is a broad root. With /mnt/user/Scripts, a new case at /mnt/user/Scripts/GitHub/me/new-project was refused, although existing linked cases already live at that depth.

Change

blockedReason() (src/web/case-path.ts) now refuses the cases directory itself and its direct children only. The message names the cases directory. The resolved-path (symlink) check is unchanged, because it goes through the same function.

Tests

test/case-path.test.ts: direct children and the cases directory itself are still refused (message names the folder); a folder two or more levels down, under a broad cases root, is allowed. tsc --noEmit clean. test/routes/case-custom-path-routes.test.ts only uses direct children, so it is unaffected (it refuses to run outside npm test).

@opticon454
opticon454 force-pushed the fix/case-path-nested-in-cases-dir branch from 7499f73 to 4796ca6 Compare October 9, 2026 10:42
…a custom-folder case

blockedReason() refused every path below a cases directory, with the reason that it is
"already listed as a local case". GET /api/cases lists only the direct children of the cases
directory, so only those can be registered twice. With CODEMAN_CASES_PATH set to a broad root
such as /mnt/user/Scripts, the rule blocked almost the whole tree, including folders that are
already linked cases. Refuse the cases directory itself and its direct children only, and name
the cases directory in the message.
@Ark0N

Ark0N commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Thanks @opticon454, and sorry this one sat for so long without a word. It is a clean fix: Create New with a custom folder now refuses only the cases folder itself and its direct children, so a broad CODEMAN_CASES_PATH such as /mnt/user/Scripts no longer blocks the whole tree below it. The reasoning holds: GET /api/cases reads one level, so only those folders can show up twice. I also ran it against a real filesystem: a nested folder is accepted, while a direct child, the cases folder itself, a CODEMAN_CASES_PATH with a trailing slash and a symlink pointing into the cases folder are all still refused through the resolved-path pass. Your new tests fail on master and pass here, which is exactly what I want to see.

A few small things, mostly docs:

  1. docs/api-reference.md:779 still documents the old rule ("must not be, or be inside, the cases directory"). It should say the cases directory itself and its direct children are refused, and a folder further down is allowed.
  2. src/web/case-path.ts:15: the @fileoverview bullet still says "must not be, or be inside, a cases directory", which now contradicts the comment you added below. Same update there.
  3. src/web/case-path.ts:107 (wording): for the cases folder itself the message reads "That folder is in the cases folder (...), where it is already listed as a case", and for a direct child that does not exist yet "already listed" is not true either. A separate message for absPath === dir, and "is listed" instead of "is already listed" for a direct child, would read better.
  4. test/routes/case-custom-path-routes.test.ts: a route test next to the existing refusal test, where POST /api/cases with a path two levels under the cases directory returns 200 and lands in the linked-cases registry, would pin the user-facing fix end to end.

These are small, so I will apply them on top at merge time; no need to push again unless you would like to do them yourself. Thanks again for the clear write-up, here and in #637.

@Ark0N
Ark0N merged commit 2f8e037 into Ark0N:master Oct 18, 2026
2 checks passed
Ark0N pushed a commit that referenced this pull request Oct 18, 2026
…t children

docs/api-reference.md and the case-path.ts @fileoverview still said a custom
folder must not be, or be inside, the cases directory. After #567 only the
cases directory itself and its direct children are refused (those are what
GET /api/cases lists as local cases); a folder further down is allowed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Ark0N pushed a commit that referenced this pull request Oct 18, 2026
…t 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) <noreply@anthropic.com>
Ark0N pushed a commit that referenced this pull request Oct 18, 2026
…directory

Pins the user-facing fix end to end: POST /api/cases with a path two levels
down returns 200, lands in the linked-cases registry and is scaffolded.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Ark0N pushed a commit that referenced this pull request Oct 18, 2026
… its direct children for a custom-folder case

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Ark0N

Ark0N commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Merged and shipped in 1.43.0. Thanks @opticon454, and sorry again for the long wait on this one.

As promised, the merge-time commits on top: docs/api-reference.md and the case-path.ts @fileoverview now state the new rule, the refusal message is split (the cases folder itself vs a direct child), and a route test creates a case two levels under the cases directory end to end. #637 is closed with it.

@opticon454
opticon454 deleted the fix/case-path-nested-in-cases-dir branch October 18, 2026 08:31
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.

2 participants