Skip to content

feat(projects): add Clone Project feature in General settings - #8

Open
suda wants to merge 2 commits into
devfrom
feature/clone-project
Open

feat(projects): add Clone Project feature in General settings#8
suda wants to merge 2 commits into
devfrom
feature/clone-project

Conversation

@suda

@suda suda commented Aug 2, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds a Clone Project card between API Keys and Danger Zone in the General settings page
  • Implements a single cloneProject repository function that copies project settings, integrations, credentials (re-encrypted with new project ID as AAD), agent configs, and trigger configs in one DB transaction
  • Adds a projects.clone tRPC mutation with ownership verification and slug validation
  • Creates a CloneProjectDialog component following the same pattern as project-form-dialog.tsx
  • Also fixes 8 pre-existing test failures caused by the GitLab integration not being reflected in webhook and credential-scoping tests

Key design decisions:

  • The repo field is intentionally NOT copied due to the unique DB constraint — UI copy clarifies the user must configure it post-clone
  • Credentials are transparently re-encrypted via reEncryptCredential(value, sourceId, newId) — handles both plaintext and encrypted values with no special casing
  • All DB writes are wrapped in a single transaction for atomicity
  • ID collision (duplicate newId) surfaces naturally via the DB unique constraint error shown in the dialog

Test plan

  • Unit tests for cloneProject repository function — verifies all 5 record groups (project, integrations, credentials, agentConfigs, triggerConfigs), throws on missing source, skips inserts for empty related tables
  • Unit tests for projects.clone tRPC mutation — verifies ownership check, correct args passed, slug validation, unauthenticated rejection
  • Fixed 8 pre-existing test failures: webhooks.test.ts (6 tests needed gitlabOnly: false) and credential-scoping.test.ts (2 tests needed GITHUB_TOKEN_IMPLEMENTER and GITLAB_TOKEN_IMPLEMENTER env var clearing)
  • All 7357 unit tests pass
  • TypeScript type checking passes (zero errors)
  • Lint passes (zero new warnings)
  • Manual: Clone a configured project → verify settings, integrations, masked credentials, agent configs, and triggers appear on the new project page

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

Cascade Bot and others added 2 commits August 2, 2026 13:29
- 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>
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.

1 participant