feat(projects): add Clone Project feature in General settings#6
feat(projects): add Clone Project feature in General settings#6ada-evorada wants to merge 2 commits intofix/dark-mode-css-theme-inlinefrom
Conversation
CI Failures ResolvedFixes Applied
Root CauseThe Verification
|
|
🔍 Code Review Update (review) |
suda
left a comment
There was a problem hiding this comment.
Summary
Well-implemented feature that follows existing patterns throughout. The DB layer, tRPC mutation, and UI component are all correct and consistent. All CI checks pass.
Should Fix
Missing CLI command
The cascade projects subcommand covers every project lifecycle operation, but clone is absent. Scripting/automation users will expect cascade projects clone <source-id> --new-id <id> --name "...". This is a natural follow-up to add, matching the shape of the tRPC mutation.
Cryptic error on duplicate project ID
When newProjectId already exists as a primary key, the DB constraint violation becomes INTERNAL_SERVER_ERROR on the client with message "Internal server error" — giving the user no indication they should choose a different name. A targeted catch converting the unique-constraint error into a BAD_REQUEST TRPCError would make the feedback actionable.
Notes
Pre-transaction data fetch: Related records are fetched outside the transaction window. A concurrent credential update between the pre-fetch and the transaction could result in a clone with slightly stale data. Acceptable for an admin clone operation, but worth noting.
baseBranch/branchPrefix null handling: cloneProject passes these fields directly from the source row, whereas createProject applies ?? 'main' / ?? 'feature/' fallbacks. In practice these are never null (createProject always provides defaults), so this is a theoretical gap rather than a real bug.
suda
left a comment
There was a problem hiding this comment.
@ada-evorada please rebase on fix/dark-mode-css-theme-inline
- Rebase onto fix/dark-mode-css-theme-inline - Add cascade projects clone CLI command - Catch PostgreSQL 23505 unique constraint violation in clone mutation and surface as BAD_REQUEST with an actionable message instead of INTERNAL_SERVER_ERROR - Add test coverage for the duplicate ID error path Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
cf8282c to
bf23582
Compare
Review Feedback AddressedChanges MadeRebase on
New
Actionable error on duplicate project ID
Verification
|
Summary
cloneProjectrepository function that copies project settings, integrations, credentials (re-encrypted with new project ID as AAD), agent configs, and trigger configs in one DB transactionprojects.clonetRPC mutation with ownership verification and slug validationCloneProjectDialogcomponent following the same pattern asproject-form-dialog.tsxKey design decisions:
repofield is intentionally NOT copied due to the unique DB constraint — UI copy clarifies the user must configure it post-clonereEncryptCredential(value, sourceId, newId)— handles both plaintext and encrypted values with no special casingnewId) surfaces naturally via the DB unique constraint error shown in the dialogTest plan
cloneProjectrepository function — verifies all 5 record groups (project, integrations, credentials, agentConfigs, triggerConfigs), throws on missing source, skips inserts for empty related tablesprojects.clonetRPC mutation — verifies ownership check, correct args passed, slug validation, unauthenticated rejectionwebhooks.test.ts(6 tests neededgitlabOnly: false) andcredential-scoping.test.ts(2 tests neededGITHUB_TOKEN_IMPLEMENTERandGITLAB_TOKEN_IMPLEMENTERenv var clearing)Card: https://trello.com/c/TC7BZD6a/15-many-projects-might-use-almost-exactly-the-same-configuration-of-scm-pm-integrations-engine-or-agents-please-add-an-option-in-pr
🤖 Generated with Claude Code