⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.
TypeScript agenticagileai-agentsbug-reportingbug-trackerganttissue-trackerjirajira-alternativekanbanlinearlinear-alternativeopen-sourceproduct-managementproject-managementroadmapself-hostedsprint-planningteam-collaborationtrello-alternative
fix(api): apply the instance mcp default when a project is copied (#291)
Ahmad Othman Ammar Adia010cb23b0cf
diff --git a/apps/api/src/modules/projects/__tests__/integration/projects.test.ts b/apps/api/src/modules/projects/__tests__/integration/projects.test.tsindex 914ba1ba..acff5a19 100644--- a/apps/api/src/modules/projects/__tests__/integration/projects.test.ts+++ b/apps/api/src/modules/projects/__tests__/integration/projects.test.ts@@ -328,6 +328,30 @@ describe('projects', () => {});});+ it('takes mcpEnabled from the instance default, not from the source project', async () => {+ const { api } = await signUpClient();+ await api.projects.post({ key: 'SRC', name: 'Source' });+ await api.projects({ projectKey: 'SRC' }).settings.patch({ mcpEnabled: false });++ await api.projects({ projectKey: 'SRC' }).copy.post({ key: 'DST', name: 'Destination' });++ const settings = await api.projects({ projectKey: 'DST' }).settings.get();+ expect(settings.data?.mcpEnabled).toBe(true);+ });++ // The other direction, so the copy is shown to read the default rather than to+ // carry a fixed value. The first account of a fresh database holds the god role.+ it('copies a project with MCP off once the instance default is turned off', async () => {+ const { api } = await signUpClient();+ await api.projects.post({ key: 'SRC', name: 'Source' });+ await api.god['project-defaults'].put({ mcpEnabled: false });++ await api.projects({ projectKey: 'SRC' }).copy.post({ key: 'DST', name: 'Destination' });++ const settings = await api.projects({ projectKey: 'DST' }).settings.get();+ expect(settings.data?.mcpEnabled).toBe(false);+ });+it('copies the estimate kinds and time logging the source project carries', async () => {const { api } = await signUpClient();await api.projects.post({ key: 'SRC', name: 'Source' });diff --git a/apps/api/src/modules/projects/copy.ts b/apps/api/src/modules/projects/copy.tsindex 5b6ce79a..4afa1f18 100644--- a/apps/api/src/modules/projects/copy.ts+++ b/apps/api/src/modules/projects/copy.ts@@ -22,6 +22,7 @@ import { eq, inArray } from 'drizzle-orm';import { iso } from '#shared/lib';import { defaultMemberPermissions } from '#shared/permissions';import { DEFAULT_COLUMNS, type ProjectRow } from './service';+import { getProjectDefaults } from '#modules/settings/service';import { GIT_SETTING_KEY } from '#modules/git/service';import { listAgents, createAgent, type NewAgentInput } from '#modules/agents/core/service';import {@@ -278,10 +279,15 @@ export async function copyProject(const skillMap = new Map<number, number>();const agentMap = new Map<number, number>();+ // What a new project starts with, set instance-wide in god mode. Read before the+ // transaction opens so the settings lookup is not part of it.+ const defaults = await getProjectDefaults();+const newProject = await db.transaction(async (tx) => {// The optional sections the source project shows and the estimate kinds it// carries are part of its configuration, so the copy starts with the same ones.- // mcpEnabled is not carried: a copy opts into MCP on its own.+ // mcpEnabled comes from the instance default instead, the same as it does for a+ // project created from scratch.const [sourceFeatures] = await tx.select({initiativesEnabled: project.initiativesEnabled,@@ -304,6 +310,7 @@ export async function copyProject(key: input.key,name: input.name,description: input.description ?? '',+ mcpEnabled: defaults.mcpEnabled,...sourceFeatures,}).returning();