Repository navigation
fix: handle duplicate workspace source folders and fs roots - #4513
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…t land yet Both need multi-root workspace registration (MoonshotAI#4336): the REST create and update schemas carry only `root` and `name`, so there is no `additional_dirs` field to pass through or to de-duplicate. MoonshotAI#4511's fs half is already in place — resolveWorkspaceFs forwards ws.additionalDirs — so it stays in_progress with that note rather than being closed or signed off.
Port of upstream MoonshotAI/kimi-code 67045e5 (MoonshotAI#4513), on top of the source-folder surface added in 0390f64. A repeated `additional_dirs` entry, or one naming the root itself, used to be dropped silently, so a caller could not tell a typo from an accepted folder. Both the create and the update route now answer `40006` with `Duplicate source folder: <path>` and `details: [{ path: "additional_dirs.N", directory }]`. `PATCH /workspaces/{id}` also accepts `additional_dirs` now, so the folder list can be replaced without re-registering the workspace. Verified: kap-server typecheck clean, the workspaces suite is 25 pass / 1 fail where that failure (legacy split-bucket session counts) fails identically before this work, the locale and hardcoded-prose gates pass, and check:no-comments is green.
…MoonshotAI#4513 MoonshotAI#4336 is in_progress: d07cc07 adds managed creation with retry-safe ids and 0390f64 puts source folders on the REST and wire surfaces. MoonshotAI#4513 lands on top of that in 718a3ae and is closed against a route probe. MoonshotAI#4511 keeps its fs-side forwarding, but its route-level cross-folder search test is still missing, so it stays in_progress with a manual probe rather than borrowing the workspace-creation case as evidence.
Requirement or Bug
Multi-root workspaces can reject duplicate source folders with an opaque validation error, and workspace file operations can drop additional source directories.
Bug Reproduction Steps
40001error withadditional_dirs.N: duplicate pathinstead of a useful error code and the actual directory.Root Cause
Duplicate directory validation reused the generic validation envelope, which exposed only a field index and an English diagnostic string. The workspace FS resolver also built its temporary scope from
ws.rootalone, discardingadditionalDirsand making it impossible for clients to address a registered multi-root workspace safely by ID.This is a fundamental fix: duplicate directories now have a dedicated error code and resolved path, and workspace FS resolution preserves the complete registered directory set.
Code Changes
WORKSPACE_DUPLICATE_DIR = 40006for additional directories that duplicate the primary directory or another additional directory.Duplicate source folder: <resolved absolute path>inmsg, with structureddetails: [{ path, directory }]. Other validation errors keep their existing40001contract.ws.additionalDirswhen acquiring workspace FS scopes for list, search, suggest, and workspace-form searches.Behavior Changes and Affected Users
40001withadditional_dirs.N: duplicate path40006with a resolved absolute path and structured{ path, directory }detailscreateOrTouch4000140006and itsmsg/detailscontract are documented in English and ChineseChecklist
gen-changesetsskill; no changeset was requested for this PR.CI Note
test (3)was retried once and hit the same 5-second timeout inpackages/session-import/test/images.test.ts:267(concurrent processes wait for another writer to finish publishing a complete file). This is unrelated to the changed code and passes locally withpnpm --filter @moonshot-ai/session-import exec vitest run test/images.test.ts -t "concurrent processes wait". All other core checks passed, and no unrelated test changes were made.