feat(cases): create a new case in a custom folder - #535
Open
opticon454 wants to merge 2 commits into
Open
opticon454 wants to merge 2 commits into
opticon454 wants to merge 2 commits into
Conversation
POST /api/cases takes an optional path; Add Case > Create New gets a 'Create in a custom folder' option with Browse. The folder is created (or an empty one filled), scaffolded like a normal case and registered as a linked case. System, home, credential and Codeman folders are refused; a folder with files is Link Existing's job; a failure after the first write undoes what this call created. Admin only in multi-user mode, like Link Existing. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JrzFKEdBLwVfu6ev2ZscJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Create a new case in a folder of your choice. Add Case → Create New gets a 📁 Create in a custom folder option with a Browse… button: pick the parent folder, and the case folder is created inside it (preview line:
Will create: <parent>/<name>), scaffolded like any other case (CLAUDE.md,src/,.claude/settings.local.json), and listed alongside the rest. Until now a new case always lived under~/codeman-cases, and putting one elsewhere meant creating the folder by hand and using Link Existing.POST /api/casestakes an optionalpathfor the same thing (absolute, or starting with~).How it behaves
linked-cases.json), so it lists, resolves and deletes like one: deleting unlinks and never removes files.src/web/case-path.ts, pure policy + fs checks, no side effects):.., none of the shell metacharacters a session working directory is rejected for (isValidWorkingDir), so a case this accepts is one a session can start in;/etc,/usr,/proc, ...), the home folder itself, Codeman's own data folder (any~/.codeman*), credential/config trees (~/.ssh,~/.aws,~/.claude, ...), judged on the path as typed and its symlink-resolved form, so a link into/etcis no way around it;409, and the message says so), so this can never scaffold into someone's project; a symlink or plain file at the target is refused.POST /api/cases/link: it writes outside the cases directory and into the shared, ownerless registry). The option is hidden for a non-admin there.path= exactly the old behaviour.Tests
test/case-path.test.ts(39): the path policy on a real temp filesystem: expansion, every refusal above (including symlink-into-blocked, file-as-parent, non-empty folder, symlink target), names that merely contain a blocked word (/etcetera,~/etc/app) are allowed, nothing is ever created.test/routes/case-custom-path-routes.test.ts(17): real fs: scaffold + registry + listing at the custom path,~and empty-folder fill, nothing undercodeman-cases, the 400/404/409 cases, duplicate name and already-a-case, name validation, rollback for both a new folder and a picked empty folder, no-pathunchanged, multi-user 403 with nothing created / admin allowed.test/case-custom-path.browser.test.ts(7, real Chromium + real server + real folders): field hidden until ticked, live preview, Docker exclusivity both ways, Browse opens the picker for directories only and fills the field, empty-field error, a real create (folder + scaffold + listed at that path + modal closes), the server's "Link Existing" reason shown with the folder untouched, state resets on reopen.Merge order
Rebased onto 1.34.0 (the earlier
config/test-suites.tsoverlap with the merged PRs is resolved). Independent of my other open PRs apart from adjacent insertions inconfig/test-suites.tsanddocs/api-reference.md, which will need a trivial rebase for whichever lands second. I will do that as they merge.🤖 Generated with Claude Code
https://claude.ai/code/session_01JrzFKEdBLwVfu6ev2ZscJS