⭐️⭐️⭐️ 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: decouple issue pickers and agent forms from resource permissions (#121)
Croffbddbea5d1cf6
diff --git a/apps/api/src/__tests__/helpers/members.ts b/apps/api/src/__tests__/helpers/members.tsnew file mode 100644index 00000000..712521e6--- /dev/null+++ b/apps/api/src/__tests__/helpers/members.ts@@ -0,0 +1,19 @@+import { authedApi, type Api } from './app';+import { signUpTestUser } from './auth';++// Signs up a user and puts them in the project through the invite flow, on the+// default member role unless a custom one is named. Returns a client acting as+// that member.+export async function addProjectMember(+ asOwner: Api,+ projectKey: string,+ roleId?: number,+): Promise<Api> {+ const user = await signUpTestUser();+ const invite = await asOwner+ .projects({ projectKey })+ .invites.post({ email: user.email, role: 'member', roleId });+ const api = authedApi(user.cookie);+ await api.invites({ token: invite.data!.token }).accept.post();+ return api;+}diff --git a/apps/api/src/ai-agents/store.ts b/apps/api/src/ai-agents/store.tsindex a69d1acb..be70286c 100644--- a/apps/api/src/ai-agents/store.ts+++ b/apps/api/src/ai-agents/store.ts@@ -12,7 +12,7 @@ import { and, eq, inArray, sql } from 'drizzle-orm';import { auth } from '@repo/auth';import { iso, HttpError, rethrowDuplicate } from '../shared/lib';import { getCredentialById } from '../integrations/store';-import { isLlmIntegration } from '../integrations/catalog';+import { integrationKind } from '../integrations/catalog';import { encryptSecret, decryptSecret } from '@repo/crypto';import { normalizeToolKeys, ALWAYS_ON_ACTIONS } from './runtime/tools/catalog';import { deleteThreadsWhere } from './runtime/memory';@@ -248,7 +248,7 @@ async function assertModelCredential(if (credentialId == null) return;const credential = await getCredentialById(credentialId, projectId);if (!credential) throw new HttpError(400, 'Credential not found');- if (!isLlmIntegration(credential.integrationKey)) {+ if (integrationKind(credential.integrationKey) !== 'llm') {throw new HttpError(400,`A model needs an LLM provider credential, not ${credential.integrationKey}.`,diff --git a/apps/api/src/cycles/__tests__/integration/cycles.test.ts b/apps/api/src/cycles/__tests__/integration/cycles.test.tsindex 2cf1dc1c..983f3c0d 100644--- a/apps/api/src/cycles/__tests__/integration/cycles.test.ts+++ b/apps/api/src/cycles/__tests__/integration/cycles.test.ts@@ -2,6 +2,7 @@ import { describe, it, expect, beforeEach } from 'bun:test';import { authedApi, type Api } from '../../../__tests__/helpers/app';import { signUpTestUser } from '../../../__tests__/helpers/auth';import { resetDb } from '../../../__tests__/helpers/db';+import { addProjectMember } from '../../../__tests__/helpers/members';// Cycles are time-boxed periods of work inside a project (sprints). Issues link to// one through issue.cycleId. The status (upcoming/active/completed) follows from the@@ -441,6 +442,40 @@ describe('cycles', () => {});});+ describe('options', () => {+ it('offers the cycles that have not finished', async () => {+ const { asOwner } = await setup();+ await createCycle(asOwner, { name: 'Current', startDate: day(0), endDate: day(6) });+ await createCycle(asOwner, { name: 'Past', startDate: day(-20), endDate: day(-14) });++ const res = await cycles(asOwner).options.get();+ expect(res.status).toBe(200);+ expect(res.data).toEqual([{ id: expect.any(Number), name: 'Current', status: 'active' }]);+ });++ it('reads under work items, so a role without cycle access can plan an issue', async () => {+ const { asOwner } = await setup();+ await createCycle(asOwner, { name: 'Current' });+ const role = await asOwner+ .projects({ projectKey: 'MKT' })+ .roles.post({ name: 'Issues only', permissions: { work_items: { read: true } } });+ const asMember = await addProjectMember(asOwner, 'MKT', role.data!.id);++ expect((await cycles(asMember).options.get()).status).toBe(200);+ // The cycles pages stay behind the cycles resource.+ expect((await cycles(asMember).get()).status).toBe(403);+ });++ it('denies a role without work item access', async () => {+ const { asOwner } = await setup();+ const role = await asOwner+ .projects({ projectKey: 'MKT' })+ .roles.post({ name: 'Nothing', permissions: {} });+ const asMember = await addProjectMember(asOwner, 'MKT', role.data!.id);+ expect((await cycles(asMember).options.get()).status).toBe(403);+ });+ });+describe('access', () => {it('returns 404 for an unknown project', async () => {const { asOwner } = await setup();diff --git a/apps/api/src/cycles/routes.ts b/apps/api/src/cycles/routes.tsindex 1f251bf9..62cb0673 100644--- a/apps/api/src/cycles/routes.ts+++ b/apps/api/src/cycles/routes.ts@@ -81,6 +81,31 @@ export const cycleRoutes = new Elysia({},)+ // Fills the cycle picker on an issue and the cycle lanes on the board. Read under+ // work items: planning an issue needs the names, not the cycle pages the `cycles`+ // resource gates.+ .get(+ '/projects/:projectKey/cycles/options',+ async ({ project }) => {+ const cycles = await listPlannedCycles(project.id);+ return cycles.map((c) => ({ id: c.id, name: c.name, status: c.status }));+ },+ {+ params: t.Object({ projectKey: t.String() }),+ permission: ['work_items', 'read'],+ response: {+ 200: t.Array(t.Object({ id: t.Number(), name: t.String(), status: t.String() })),+ 401: ErrorResponse,+ 403: ErrorResponse,+ 404: ErrorResponse,+ },+ detail: {+ summary: 'List cycle options',+ description: 'The cycles an issue can be planned into: id, name and status.',+ },+ },+ )+.get('/projects/:projectKey/cycles/completed',async ({ project, query }) => {diff --git a/apps/api/src/initiatives/__tests__/integration/initiatives.test.ts b/apps/api/src/initiatives/__tests__/integration/initiatives.test.tsindex 8553857c..4302a8b0 100644--- a/apps/api/src/initiatives/__tests__/integration/initiatives.test.ts+++ b/apps/api/src/initiatives/__tests__/integration/initiatives.test.ts@@ -2,6 +2,7 @@ import { describe, it, expect, beforeEach } from 'bun:test';import { authedApi, type Api } from '../../../__tests__/helpers/app';import { signUpTestUser } from '../../../__tests__/helpers/auth';import { resetDb } from '../../../__tests__/helpers/db';+import { addProjectMember } from '../../../__tests__/helpers/members';// Initiatives are a project-scoped grouping of issues. Issues link to one through// issue.initiativeId. status is a fixed lifecycle enum; progress and health are@@ -343,6 +344,69 @@ describe('initiatives', () => {});});+ describe('options', () => {+ it('lists the linkable initiatives, filtered by the search', async () => {+ const { asOwner } = await setup();+ await createInitiative(asOwner, { title: 'Q3 Launch' });+ await createInitiative(asOwner, { title: 'Billing rework' });+ await createInitiative(asOwner, { title: 'Old plan', status: 'completed' });++ const all = await initiatives(asOwner).options.get();+ expect(all.status).toBe(200);+ expect(all.data!.map((o) => o.title).sort()).toEqual(['Billing rework', 'Q3 Launch']);+ expect(all.data![0]).toMatchObject({ status: expect.any(String) });++ const search = await initiatives(asOwner).options.get({ query: { search: 'bill' } });+ expect(search.data!.map((o) => o.title)).toEqual(['Billing rework']);+ });++ it('keeps the initiative an issue already links to, closed or off the search', async () => {+ const { asOwner } = await setup();+ const closed = (await createInitiative(asOwner, { title: 'Old plan', status: 'completed' }))+ .data!;++ const res = await initiatives(asOwner).options.get({+ query: { search: 'nothing matches', include: closed.id },+ });+ expect(res.data!.map((o) => o.id)).toEqual([closed.id]);+ });++ it('puts the included initiative first, so the row cap cannot drop it', async () => {+ const { asOwner } = await setup();+ await createInitiative(asOwner, { title: 'Q3 Launch' });+ const closed = (await createInitiative(asOwner, { title: 'Old plan', status: 'completed' }))+ .data!;++ const res = await initiatives(asOwner).options.get({ query: { include: closed.id } });+ expect(res.data![0]!.id).toBe(closed.id);+ });++ it('reads under work items, so a role without initiative access can link an issue', async () => {+ const { asOwner } = await setup();+ await createInitiative(asOwner, { title: 'Q3 Launch' });+ const role = await asOwner+ .projects({ projectKey: 'MKT' })+ .roles.post({ name: 'Issues only', permissions: { work_items: { read: true } } });+ const asMember = await addProjectMember(asOwner, 'MKT', role.data!.id);++ const options = await initiatives(asMember).options.get();+ expect(options.status).toBe(200);+ expect(options.data).toHaveLength(1);++ // The initiative pages stay behind the initiatives resource.+ expect((await initiatives(asMember).get()).status).toBe(403);+ });++ it('denies a role without work item access', async () => {+ const { asOwner } = await setup();+ const role = await asOwner+ .projects({ projectKey: 'MKT' })+ .roles.post({ name: 'Nothing', permissions: {} });+ const asMember = await addProjectMember(asOwner, 'MKT', role.data!.id);+ expect((await initiatives(asMember).options.get()).status).toBe(403);+ });+ });+describe('access', () => {it('returns 404 for an unknown project', async () => {const { asOwner } = await setup();diff --git a/apps/api/src/initiatives/routes.ts b/apps/api/src/initiatives/routes.tsindex 1f322521..96159fb3 100644--- a/apps/api/src/initiatives/routes.ts+++ b/apps/api/src/initiatives/routes.ts@@ -8,6 +8,7 @@ import { HttpError } from '../shared/lib';import { ErrorResponse } from '../shared/responses';import {listInitiatives,+ listInitiativeOptions,initiativeStatusCounts,getInitiative,getInitiativeProjectId,@@ -164,6 +165,36 @@ export const initiativeRoutes = new Elysia({},)+ // Fills the initiative picker on an issue. Read under work items: linking an issue+ // needs the titles, not the initiative pages the `initiatives` resource gates.+ .get(+ '/projects/:projectKey/initiatives/options',+ async ({ project, query }) => listInitiativeOptions(project.id, query),+ {+ params: t.Object({ projectKey: t.String() }),+ query: t.Object({+ search: t.Optional(t.String({ description: 'Match by title.' })),+ include: t.Optional(+ t.Numeric({+ description: 'Keep this initiative in the list even when it is closed.',+ }),+ ),+ }),+ permission: ['work_items', 'read'],+ response: {+ 200: t.Array(t.Object({ id: t.Number(), title: t.String(), status: t.String() })),+ 400: ErrorResponse,+ 401: ErrorResponse,+ 403: ErrorResponse,+ 404: ErrorResponse,+ },+ detail: {+ summary: 'List initiative options',+ description: 'The initiatives an issue can be linked to: id, title and status.',+ },+ },+ )+.get('/projects/:projectKey/initiatives/counts',async ({ project }) => initiativeStatusCounts(project.id),diff --git a/apps/api/src/initiatives/store.ts b/apps/api/src/initiatives/store.tsindex 5eb8f692..e1c8712c 100644--- a/apps/api/src/initiatives/store.ts+++ b/apps/api/src/initiatives/store.ts@@ -1,5 +1,5 @@import { db, initiative, initiativeLabel, issue, label, projectColumn, user } from '@repo/db';-import { and, asc, desc, eq, ilike, inArray, sql } from 'drizzle-orm';+import { and, asc, desc, eq, ilike, inArray, or, sql } from 'drizzle-orm';import { labelNames } from '../issues/activity';import { getMembership } from '../members/store';import { HttpError, iso, num } from '../shared/lib';@@ -191,6 +191,44 @@ export async function listInitiatives(};}+export interface InitiativeOption {+ id: number;+ title: string;+ status: string;+}++// The statuses an issue can be linked to. A completed or canceled initiative is not+// offered, but stays listed through `include` when an issue already links to it.+const LINKABLE_STATUSES = ['proposed', 'planned', 'active'];++// The initiatives as picker options: title and status only, without the progress and+// health the list computes per row.+export async function listInitiativeOptions(+ projectId: number,+ { search, include }: { search?: string; include?: number },+): Promise<InitiativeOption[]> {+ const title = search?.trim();+ const linkable = and(+ inArray(initiative.status, LINKABLE_STATUSES),+ title ? ilike(initiative.title, `%${title}%`) : undefined,+ );+ // The included one is ordered first so the row cap can never drop it: it is what+ // labels the picker trigger.+ const order = [asc(initiative.position), desc(initiative.id)];+ if (include) order.unshift(desc(sql`${initiative.id} = ${include}`));+ return db+ .select({ id: initiative.id, title: initiative.title, status: initiative.status })+ .from(initiative)+ .where(+ and(+ eq(initiative.projectId, projectId),+ include ? or(linkable, eq(initiative.id, include)) : linkable,+ ),+ )+ .orderBy(...order)+ .limit(50);+}+export interface InitiativeStatusCounts {total: number;proposed: number;diff --git a/apps/api/src/integrations/__tests__/integration/integrations.test.ts b/apps/api/src/integrations/__tests__/integration/integrations.test.tsindex 9825f64e..4857c236 100644--- a/apps/api/src/integrations/__tests__/integration/integrations.test.ts+++ b/apps/api/src/integrations/__tests__/integration/integrations.test.ts@@ -2,6 +2,7 @@ import { describe, it, expect, beforeEach } from 'bun:test';import { authedApi, type Api } from '../../../__tests__/helpers/app';import { signUpTestUser } from '../../../__tests__/helpers/auth';import { resetDb } from '../../../__tests__/helpers/db';+import { addProjectMember } from '../../../__tests__/helpers/members';import { untaggedRoutes } from '../../../__tests__/helpers/mcp';// Integration credentials for a project: one store for LLM provider keys (kind 'llm')@@ -17,6 +18,7 @@ async function setup() {}const integrations = (api: Api) => api.projects({ projectKey: 'MKT' }).integrations;+const options = (api: Api) => integrations(api).options;describe('integrations', () => {beforeEach(async () => {@@ -124,15 +126,69 @@ describe('integrations', () => {// An agent's provider and model are picked over MCP, so the reads are tagged. The// writes are not: a credential body carries the provider's secret in plain text.+ // The options route is untagged too — it is what the UI pickers read, and the+ // credential list already covers the same ground for an agent.it('exposes the credential reads to MCP, not the writes', () => {const untagged = untaggedRoutes((route) => route.includes('integrations'));expect(untagged).toEqual([+ 'GET /projects/:projectKey/integrations/options','POST /projects/:projectKey/integrations','PATCH /projects/:projectKey/integrations/:credentialId','DELETE /projects/:projectKey/integrations/:credentialId',]);});+ describe('options', () => {+ it('lists the connected integrations without any credential fields', async () => {+ const { asOwner } = await setup();+ await integrations(asOwner).post({+ integrationKey: 'openai',+ label: 'Team',+ credential: { apiKey: 'sk-secret-1234' },+ });+ await integrations(asOwner).post({+ integrationKey: 'jina',+ credential: { apiKey: 'jina-secret-1234' },+ });++ const res = await options(asOwner).get();+ expect(res.status).toBe(200);+ expect(res.data).toEqual(+ expect.arrayContaining([+ expect.objectContaining({ integrationKey: 'openai', kind: 'llm', label: 'Team' }),+ expect.objectContaining({ integrationKey: 'jina', kind: 'tool', label: null }),+ ]),+ );+ expect(JSON.stringify(res.data)).not.toContain('••••');++ const llm = await options(asOwner).get({ query: { kind: 'llm' } });+ expect(llm.data!.map((o) => o.integrationKey)).toEqual(['openai']);+ });++ it('opens the options and the catalog to a member whose role has no integrations access', async () => {+ const { asOwner } = await setup();+ await integrations(asOwner).post({+ integrationKey: 'openai',+ credential: { apiKey: 'sk-secret-1234' },+ });+ const role = await asOwner+ .projects({ projectKey: 'MKT' })+ .roles.post({ name: 'Agents only', permissions: { ai_agents: { read: true } } });+ const asMember = await addProjectMember(asOwner, 'MKT', role.data!.id);++ expect((await options(asMember).get()).status).toBe(200);+ expect((await integrations(asMember).catalog.get()).status).toBe(200);+ // The credential list stays behind the integrations resource.+ expect((await integrations(asMember).get()).status).toBe(403);+ });++ it('denies a non-member', async () => {+ await setup();+ const asOutsider = authedApi((await signUpTestUser({ name: 'Outsider' })).cookie);+ expect((await options(asOutsider).get()).status).toBe(403);+ });+ });+it('denies a non-member', async () => {await setup();const outsider = await signUpTestUser({ name: 'Outsider' });diff --git a/apps/api/src/integrations/catalog.ts b/apps/api/src/integrations/catalog.tsindex 4142015a..2e791167 100644--- a/apps/api/src/integrations/catalog.ts+++ b/apps/api/src/integrations/catalog.ts@@ -69,8 +69,7 @@ export function credentialSchemaFor(key: string): ConfigField[] | undefined {return BY_KEY.get(key)?.credentialSchema;}-// Whether the integration is an LLM provider, i.e. its credential can back an agent's-// model.-export function isLlmIntegration(key: string): boolean {- return BY_KEY.get(key)?.kind === 'llm';+// The kind of an integration, or undefined for a key the catalog no longer carries.+export function integrationKind(key: string): IntegrationKind | undefined {+ return BY_KEY.get(key)?.kind;}diff --git a/apps/api/src/integrations/routes.ts b/apps/api/src/integrations/routes.tsindex 51b10f65..13323d7d 100644--- a/apps/api/src/integrations/routes.ts+++ b/apps/api/src/integrations/routes.ts@@ -5,7 +5,7 @@ import { authContext } from '../shared/auth-context';import { HttpError } from '../shared/lib';import { ErrorResponse } from '../shared/responses';import { mcpTool } from '../mcp/generate';-import { INTEGRATION_CATALOG } from './catalog';+import { INTEGRATION_CATALOG, integrationKind } from './catalog';import { listModelsForProvider } from './models';import { listCredentials, createCredential, updateCredential, deleteCredential } from './store';@@ -47,9 +47,20 @@ const IntegrationResponse = t.Object({const ProviderModelResponse = t.Object({ id: t.String(), name: t.String() });-// Gated under the integrations resource. The reads are exposed as MCP tools, so an-// internal agent's provider and model can be picked without the UI; the writes are-// not, because a credential body carries the provider's secret in plain text.+// A connected integration as a picker option: what it is and what it is called.+// Carries no credential fields, redacted or otherwise.+const IntegrationOptionResponse = t.Object({+ id: t.Number(),+ integrationKey: t.String(),+ kind: t.Union([t.Literal('llm'), t.Literal('tool')]),+ label: t.Nullable(t.String()),+});++// The credential store is gated under the integrations resource; the catalog, the+// provider models and the picker options carry no project secrets and are open to+// any member. The reads are exposed as MCP tools, so an internal agent's provider+// and model can be picked without the UI; the writes are not, because a credential+// body carries the provider's secret in plain text.export const integrationRoutes = new Elysia({name: 'integrations',detail: { tags: ['Integrations'] },@@ -57,9 +68,10 @@ export const integrationRoutes = new Elysia({.use(authContext).use(guards)- // The frontend builds the credential form from credentialSchema.+ // The frontend builds the credential form from credentialSchema. Open to any+ // project member: the catalog is a constant in this codebase, not project data..get('/projects/:projectKey/integrations/catalog', () => INTEGRATION_CATALOG, {- permission: ['integrations', 'read'],+ projectMember: true,response: {200: t.Array(IntegrationResponse),401: ErrorResponse,@@ -76,7 +88,8 @@ export const integrationRoutes = new Elysia({})// The models an LLM provider offers, from the models.dev registry. Backs the model- // select in the agent config UI.+ // select in the agent config UI. Open to any project member: the list comes from a+ // public registry and holds no project data..get('/projects/:projectKey/integrations/models/:provider',({ params }) => listModelsForProvider(params.provider),@@ -87,7 +100,7 @@ export const integrationRoutes = new Elysia({description: "LLM provider key from list_integrations, e.g. 'anthropic'.",}),}),- permission: ['integrations', 'read'],+ projectMember: true,response: {200: t.Array(ProviderModelResponse),401: ErrorResponse,@@ -105,6 +118,44 @@ export const integrationRoutes = new Elysia({},)+ // Fills the credential selects in the agent and tool forms. Open to any project+ // member, and deliberately separate from the credential list above: that one is+ // the integrations admin view and may grow fields this one must not carry.+ .get(+ '/projects/:projectKey/integrations/options',+ async ({ project, query }) => {+ const credentials = await listCredentials(project.id);+ return credentials.flatMap((c) => {+ const kind = integrationKind(c.integrationKey);+ if (!kind || (query.kind && kind !== query.kind)) return [];+ return [{ id: c.id, integrationKey: c.integrationKey, kind, label: c.label }];+ });+ },+ {+ params: t.Object({ projectKey: t.String() }),+ query: t.Object({+ kind: t.Optional(+ t.Union([t.Literal('llm'), t.Literal('tool')], {+ description: 'Only the integrations of this kind.',+ }),+ ),+ }),+ projectMember: true,+ response: {+ 200: t.Array(IntegrationOptionResponse),+ 400: ErrorResponse,+ 401: ErrorResponse,+ 403: ErrorResponse,+ 404: ErrorResponse,+ },+ detail: {+ summary: 'List integration options',+ description:+ "The project's connected integrations as picker options: id, key, kind and label.",+ },+ },+ )+.get('/projects/:projectKey/integrations', ({ project }) => listCredentials(project.id), {permission: ['integrations', 'read'],response: {diff --git a/apps/api/src/projects/__tests__/integration/projects.test.ts b/apps/api/src/projects/__tests__/integration/projects.test.tsindex 783484a8..67ffc99a 100644--- a/apps/api/src/projects/__tests__/integration/projects.test.ts+++ b/apps/api/src/projects/__tests__/integration/projects.test.ts@@ -2,6 +2,7 @@ import { describe, it, expect, beforeEach } from 'bun:test';import { authedApi, type Api } from '../../../__tests__/helpers/app';import { signUpTestUser } from '../../../__tests__/helpers/auth';import { resetDb } from '../../../__tests__/helpers/db';+import { addProjectMember } from '../../../__tests__/helpers/members';// Full integration flow: a real session against the real (test) database.// Requires the test DB to be up and migrated:@@ -23,18 +24,6 @@ async function signUpClient() {return { user, api: authedApi(user.cookie) };}-// Adds a member to project MKT through the invite flow, on the default member role-// unless a custom one is named. Returns a Treaty client acting as them.-async function addMember(owner: Api, roleId?: number) {- const user = await signUpTestUser();- const invite = await owner- .projects({ projectKey: 'MKT' })- .invites.post({ email: user.email, role: 'member', roleId });- const api = authedApi(user.cookie);- await api.invites({ token: invite.data!.token }).accept.post();- return api;-}-async function viewOf(client: Api, projectKey: string) {return client.projects({ projectKey }).get();}@@ -233,6 +222,21 @@ describe('projects', () => {const res = await viewOf(outsider.api, 'MKT');expect(res.status).toBe(403);});++ it('opens to a member whose role grants nothing, so any role can enter the project', async () => {+ const owner = await signUpClient();+ await owner.api.projects.post({ key: 'MKT', name: 'Marketing' });+ const role = await owner.api+ .projects({ projectKey: 'MKT' })+ .roles.post({ name: 'Notes only', permissions: { note_boards: { read: true } } });+ const member = await addProjectMember(owner.api, 'MKT', role.data!.id);++ const res = await viewOf(member, 'MKT');+ expect(res.status).toBe(200);+ expect(res.data!.permissions.work_items.read).toBe(false);+ // The issues themselves stay behind the work items resource.+ expect((await member.projects({ projectKey: 'MKT' }).issues.board.get()).status).toBe(403);+ });});describe('copy', () => {@@ -734,7 +738,7 @@ describe('projects', () => {it('holds the default member role out of the section', async () => {const owner = await signUpClient();await owner.api.projects.post({ key: 'MKT', name: 'Marketing' });- const member = await addMember(owner.api);+ const member = await addProjectMember(owner.api, 'MKT');expect((await autoArchive(member).get()).status).toBe(403);expect((await autoArchive(member).patch({ completedDays: 14, canceledDays: 3 })).status).toBe(@@ -748,7 +752,7 @@ describe('projects', () => {const role = await owner.api.projects({ projectKey: 'MKT' }).roles.post({ name: 'Reader', permissions: { workflow_config: { read: true } } });- const member = await addMember(owner.api, role.data!.id);+ const member = await addProjectMember(owner.api, 'MKT', role.data!.id);expect((await autoArchive(member).get()).status).toBe(200);expect((await autoArchive(member).patch({ completedDays: 14, canceledDays: 3 })).status).toBe(@@ -763,7 +767,7 @@ describe('projects', () => {name: 'Archivist',permissions: { workflow_config: { read: true, edit: true } },});- const member = await addMember(owner.api, role.data!.id);+ const member = await addProjectMember(owner.api, 'MKT', role.data!.id);const res = await autoArchive(member).patch({ completedDays: 14, canceledDays: 3 });expect(res.status).toBe(200);@@ -800,7 +804,7 @@ describe('projects', () => {it('holds the default member role out of the section', async () => {const owner = await signUpClient();await owner.api.projects.post({ key: 'MKT', name: 'Marketing' });- const member = await addMember(owner.api);+ const member = await addProjectMember(owner.api, 'MKT');expect((await subtasks(member).get()).status).toBe(403);expect(@@ -814,7 +818,7 @@ describe('projects', () => {const role = await owner.api.projects({ projectKey: 'MKT' }).roles.post({ name: 'Reader', permissions: { workflow_config: { read: true } } });- const member = await addMember(owner.api, role.data!.id);+ const member = await addProjectMember(owner.api, 'MKT', role.data!.id);expect((await subtasks(member).get()).status).toBe(200);expect(diff --git a/apps/api/src/projects/routes.ts b/apps/api/src/projects/routes.tsindex 403f38ba..27e50a8c 100644--- a/apps/api/src/projects/routes.ts+++ b/apps/api/src/projects/routes.ts@@ -320,6 +320,10 @@ export const projectRoutes = new Elysia({ name: 'projects', detail: { tags: ['Pr// items UI needs in one call. Assignee options come from the project's members// and AI agents, fetched separately. The web app gates its UI off `viewer`; the// API still enforces the same matrix on every request.+ //+ // Open to any project member: the payload is the project's own naming (columns,+ // types, labels, fields) plus the caller's own access, not the work items+ // themselves. A role without work item access still needs it to open any page..get('/projects/:projectKey',async ({ project, user }) => {@@ -349,7 +353,7 @@ export const projectRoutes = new Elysia({ name: 'projects', detail: { tags: ['Pr};},{- permission: ['work_items', 'read'],+ projectMember: true,response: {200: ProjectBoardResponse,401: ErrorResponse,diff --git a/apps/api/src/shared/__tests__/integration/access.test.ts b/apps/api/src/shared/__tests__/integration/access.test.tsindex 80466e10..f774a799 100644--- a/apps/api/src/shared/__tests__/integration/access.test.ts+++ b/apps/api/src/shared/__tests__/integration/access.test.ts@@ -57,9 +57,9 @@ describe('shared access', () => {.actions.post({ name: 'Auto-close' });expect(ownerCreate.status).toBe(201);- // Default member: granted work_items (the project view) ...- const view = await member.api.projects({ projectKey: 'MKT' }).get();- expect(view.status).toBe(200);+ // Default member: granted work_items, so the board issues load ...+ const board = await member.api.projects({ projectKey: 'MKT' }).issues.board.get();+ expect(board.status).toBe(200);// ... but denied on actions, which the default role does not grant.const list = await member.api.projects({ projectKey: 'MKT' }).actions.get();diff --git a/apps/web/src/features/issue/components/actions/IssueContextMenu.tsx b/apps/web/src/features/issue/components/actions/IssueContextMenu.tsxindex 3a1c4890..9ad6ceb9 100644--- a/apps/web/src/features/issue/components/actions/IssueContextMenu.tsx+++ b/apps/web/src/features/issue/components/actions/IssueContextMenu.tsx@@ -21,8 +21,8 @@ import type { ActionDef, ProjectDetail, Issue, IssuePatch } from '@/lib/api';import { actionIcon } from '@/utils/actionIcons';import { useActionsQuery } from '@/services/actions.service';import { useRestoreIssue, useUpdateIssue } from '@/services/issues.service';-import { useInitiativesQuery } from '@/services/initiatives.service';-import { LINKABLE_STATUSES, STATUS_META } from '@/utils/initiativeMeta';+import { useInitiativeOptionsQuery } from '@/services/initiatives.service';+import { STATUS_META } from '@/utils/initiativeMeta';import { CYCLE_STATUS_META } from '@/utils/cycleMeta';import { usePermissions } from '@/hooks/usePermissions';import { ShellCtx } from '@/context/shellContext';@@ -85,9 +85,8 @@ export default function IssueContextMenu({const [confirmingAction, setConfirmingAction] = useState<ActionDef | null>(null);// Initiatives are not in the board scaffold, so they are fetched here — only// while this menu is open, as every card on the board mounts one.- const initiativesQuery = useInitiativesQuery(+ const initiativesQuery = useInitiativeOptionsQuery(open && project.project.initiativesEnabled ? project.project.key : null,- { statuses: LINKABLE_STATUSES, pageSize: 50 },);// No Shell (public share): render the card as-is, without the right-click menu.@@ -117,7 +116,7 @@ export default function IssueContextMenu({PRIORITY_FIELDS.find((p) => p.value === (issue.priority ?? '')) ?? PRIORITY_FIELDS[0];const members = project.assignees.filter((a) => a.kind === 'member');const agents = project.assignees.filter((a) => a.kind === 'agent');- const initiatives = initiativesQuery.data?.items ?? [];+ const initiatives = initiativesQuery.data ?? [];return (<>diff --git a/apps/web/src/features/issue/components/create/NewIssueModal.tsx b/apps/web/src/features/issue/components/create/NewIssueModal.tsxindex 2aa28f03..eb857f5b 100644--- a/apps/web/src/features/issue/components/create/NewIssueModal.tsx+++ b/apps/web/src/features/issue/components/create/NewIssueModal.tsx@@ -1,12 +1,17 @@-import { useEffect, useRef, useState } from 'react';+import { useEffect, useMemo, useRef, useState } from 'react';import { type Editor } from '@tiptap/react';import { MoreHorizontal } from 'lucide-react';-import { type Issue, type IssueFieldValueInput, type ProjectDetail } from '@/lib/api';+import {+ type CycleRef,+ type Issue,+ type IssueFieldValueInput,+ type ProjectDetail,+} from '@/lib/api';import { type NewIssueDefaults } from '@/utils/project';import { cn } from '@/lib/utils';import { useSession } from '@/lib/auth-client';import { useCreateIssue, useSetFieldValue, useUpdateIssue } from '@/services/issues.service';-import { useCustomFieldsQuery } from '@/services/customFields.service';+import { fieldDefsForType } from '../../utils/fieldDefs';import { useFileDragZone } from '../../hooks/useFileDragZone';import { useFilePaste } from '../../hooks/useFilePaste';import { useNewIssueAttachments } from '../../hooks/useNewIssueAttachments';@@ -44,7 +49,7 @@ import {import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';import { Pill } from '@/components/common/fields/Pill';import InitiativeSelect from '../fields/InitiativeSelect';-import CycleSelect, { type CycleOption } from '../fields/CycleSelect';+import CycleSelect from '../fields/CycleSelect';export default function NewIssueModal({project,@@ -72,7 +77,7 @@ export default function NewIssueModal({const [initiativeId, setInitiativeId] = useState<number | null>(defaults.initiativeId ?? null);// A default cycle that is not among the planned ones has finished, and nothing new// is planned into it — the issue is created without a cycle instead.- const [cycle, setCycle] = useState<CycleOption | null>(+ const [cycle, setCycle] = useState<CycleRef | null>(() => project.plannedCycles.find((c) => c.id === defaults.cycleId) ?? null,);const { data: session } = useSession();@@ -97,11 +102,13 @@ export default function NewIssueModal({const [saving, setSaving] = useState(false);const [fullscreen, setFullscreen] = useState(false);- // Custom fields for the selected type (global + type-scoped). Fields flagged- // "show in main info" get their own body section; the rest are added on demand from- // the "…" menu.- const fieldsQuery = useCustomFieldsQuery(project.project.key, typeId ?? undefined);- const fieldDefs = fieldsQuery.data ?? [];+ // Custom fields for the selected type (project-wide + type-scoped), off the+ // scaffold every member already loads. Fields flagged "show in main info" get their+ // own body section; the rest are added on demand from the "…" menu.+ const fieldDefs = useMemo(+ () => fieldDefsForType(project.customFields, typeId),+ [project.customFields, typeId],+ );const [activeFieldIds, setActiveFieldIds] = useState<number[]>([]);const [fieldValues, setFieldValues] = useState<Record<number, IssueFieldValueInput>>({});const [justAddedId, setJustAddedId] = useState<number | null>(null);@@ -178,8 +185,7 @@ export default function NewIssueModal({useEffect(() => {const valid = new Set(fieldDefs.filter((d) => !d.showInBody).map((d) => d.id));setActiveFieldIds((prev) => prev.filter((id) => valid.has(id)));- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [fieldsQuery.data]);+ }, [fieldDefs]);const errorMessage = error ?? attachments.error;const bodyDefs = fieldDefs.filter((d) => d.showInBody);diff --git a/apps/web/src/features/issue/components/fields/CycleSelect.tsx b/apps/web/src/features/issue/components/fields/CycleSelect.tsxindex fd7fa632..f84b0d1b 100644--- a/apps/web/src/features/issue/components/fields/CycleSelect.tsx+++ b/apps/web/src/features/issue/components/fields/CycleSelect.tsx@@ -1,7 +1,7 @@import { useState } from 'react';import { Check, CircleDashed, RefreshCw } from 'lucide-react';-import type { Cycle } from '@/lib/api';-import { usePlannedCyclesQuery } from '@/services/cycles.service';+import type { CycleRef } from '@/lib/api';+import { useCycleOptionsQuery } from '@/services/cycles.service';import { colorDot } from '@/components/common/fields/colorDot';import { CYCLE_STATUS_META } from '@/utils/cycleMeta';import {@@ -15,8 +15,6 @@ import {import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';import { Pill } from '@/components/common/fields/Pill';-export type CycleOption = Pick<Cycle, 'id' | 'name'>;-// A Pill trigger opening the cycles an issue can be planned into: the ones that have// not finished. A completed cycle is not offered — it records what it delivered — but// the one the issue already sits on stays listed, so it can be read and unplanned.@@ -26,18 +24,18 @@ export default function CycleSelect({onChange,}: {projectKey: string;- value: CycleOption | null;- onChange: (cycle: CycleOption | null) => void;+ value: CycleRef | null;+ onChange: (cycle: CycleRef | null) => void;}) {const [open, setOpen] = useState(false);- const { data } = usePlannedCyclesQuery(projectKey);+ const { data } = useCycleOptionsQuery(projectKey);const planned = data ?? [];const cycles =value && !planned.some((c) => c.id === value.id)? [{ ...value, status: 'completed' as const }, ...planned]: planned;- const select = (cycle: CycleOption | null) => {+ const select = (cycle: CycleRef | null) => {onChange(cycle);setOpen(false);};diff --git a/apps/web/src/features/issue/components/fields/InitiativeSelect.tsx b/apps/web/src/features/issue/components/fields/InitiativeSelect.tsxindex 11ba9385..bb1201a2 100644--- a/apps/web/src/features/issue/components/fields/InitiativeSelect.tsx+++ b/apps/web/src/features/issue/components/fields/InitiativeSelect.tsx@@ -1,11 +1,8 @@import { useState } from 'react';import { Check, CircleDashed, Target } from 'lucide-react';-import { useQueryClient } from '@tanstack/react-query';-import { useInitiativeQuery, useInitiativesQuery } from '@/services/initiatives.service';-import type { Initiative } from '@/lib/api';-import { qk } from '@/services/queryKeys';+import { useInitiativeOptionsQuery } from '@/services/initiatives.service';import { colorDot } from '@/components/common/fields/colorDot';-import { LINKABLE_STATUSES, STATUS_META } from '@/utils/initiativeMeta';+import { STATUS_META } from '@/utils/initiativeMeta';import {Command,CommandEmpty,@@ -17,10 +14,6 @@ import {import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';import { Pill } from '@/components/common/fields/Pill';-// The dropdown shows at most this many initiatives at once; the rest are reached by-// typing, which the server matches by title.-const PAGE_SIZE = 15;-// A Pill trigger opening the project's initiatives, for linking an issue to one.// Lives in the shared layer so the issue detail can use it without depending on// the initiatives feature. Value is the initiative id or null.@@ -35,23 +28,18 @@ export default function InitiativeSelect({}) {const [open, setOpen] = useState(false);const [query, setQuery] = useState('');- const qc = useQueryClient();- // The linked initiative may fall outside the first page, so fetch it directly to- // label the trigger. The list query only runs while the dropdown is open.- const current = useInitiativeQuery(value).data;- const { data } = useInitiativesQuery(open ? projectKey : null, {- statuses: LINKABLE_STATUSES,+ // The linked initiative is asked for by id alongside the search, so it labels the+ // trigger and stays listed even once it is closed.+ const { data } = useInitiativeOptionsQuery(projectKey, {search: query.trim() || undefined,- pageSize: PAGE_SIZE,+ include: value ?? undefined,});- const options = data?.items ?? [];+ const options = data ?? [];+ const current = options.find((it) => it.id === value) ?? null;- // Seed the single-initiative cache on pick so the trigger labels immediately,- // without waiting for its own fetch.- const select = (initiative: Initiative | null) => {- if (initiative) qc.setQueryData(qk.initiative(initiative.id), initiative);- onChange(initiative?.id ?? null);+ const select = (id: number | null) => {+ onChange(id);setOpen(false);};@@ -83,7 +71,7 @@ export default function InitiativeSelect({</CommandItem>)}{options.map((it) => (- <CommandItem key={it.id} value={it.title} onSelect={() => select(it)}>+ <CommandItem key={it.id} value={it.title} onSelect={() => select(it.id)}>{colorDot(STATUS_META[it.status].color)}<span className="flex-1 truncate">{it.title}</span>{it.id === value && <Check className="ml-auto" />}diff --git a/apps/web/src/features/settings/SettingsAgentToolsPage.tsx b/apps/web/src/features/settings/SettingsAgentToolsPage.tsxindex 4c2b24e5..4b55e63d 100644--- a/apps/web/src/features/settings/SettingsAgentToolsPage.tsx+++ b/apps/web/src/features/settings/SettingsAgentToolsPage.tsx@@ -2,7 +2,10 @@import { useShell } from '@/context/shellContext';import { AGENT_TOOLS_SECTION } from '@/utils/settingsSections';-import { useIntegrationCatalogQuery, useCredentialsQuery } from '@/services/integrations.service';+import {+ useIntegrationCatalogQuery,+ useIntegrationOptionsQuery,+} from '@/services/integrations.service';import SectionPageView from '@/components/common/page/SectionPageView';import RequirePermission from '@/components/common/permissions/RequirePermission';import { SettingsResourceProvider } from './context/settingsPermission';@@ -18,7 +21,7 @@ export default function SettingsAgentToolsPage() {const { project } = useShell();const key = project?.project.key ?? null;const catalog = useIntegrationCatalogQuery(key).data ?? [];- const credentials = useCredentialsQuery(key).data ?? [];+ const credentials = useIntegrationOptionsQuery(key, 'tool').data ?? [];if (!project) return null;const projectKey = project.project.key;return (diff --git a/apps/web/src/features/settings/components/agent-tools/ToolConfigDialog.tsx b/apps/web/src/features/settings/components/agent-tools/ToolConfigDialog.tsxindex ed00cd2e..6e3a94d4 100644--- a/apps/web/src/features/settings/components/agent-tools/ToolConfigDialog.tsx+++ b/apps/web/src/features/settings/components/agent-tools/ToolConfigDialog.tsx@@ -1,5 +1,5 @@import { useMemo, useState } from 'react';-import type { IntegrationCredential, IntegrationMeta } from '@/lib/api';+import type { IntegrationMeta, IntegrationOption } from '@/lib/api';import Modal from '@/components/common/overlay/Modal';import { ToolPicker } from './ToolPicker';import { ToolCredentialStep } from './ToolCredentialStep';@@ -26,7 +26,7 @@ export function ToolConfigDialog({}: {projectKey: string;catalog: IntegrationMeta[];- credentials: IntegrationCredential[];+ credentials: IntegrationOption[];onClose: () => void;}) {const toolOptions = useMemo<ToolOption[]>(diff --git a/apps/web/src/features/settings/components/agent-tools/ToolCredentialStep.tsx b/apps/web/src/features/settings/components/agent-tools/ToolCredentialStep.tsxindex 6d732157..641dedd5 100644--- a/apps/web/src/features/settings/components/agent-tools/ToolCredentialStep.tsx+++ b/apps/web/src/features/settings/components/agent-tools/ToolCredentialStep.tsx@@ -1,6 +1,6 @@import { useState } from 'react';import { ChevronLeft } from 'lucide-react';-import type { IntegrationCredential } from '@/lib/api';+import type { IntegrationOption } from '@/lib/api';import { Button } from '@/components/ui/button';import { Label } from '@/components/ui/label';import {@@ -15,21 +15,9 @@ import { useCreateConfiguredTool } from '@/services/customTools.service';import { IntegrationIcon } from '../integrations/IntegrationIcon';import type { ToolOption } from './ToolConfigDialog';-// The masked secret fields of a credential joined into one line (e.g. "••••dmoT"), so-// several credentials of the same integration can be told apart.-const credMasked = (c: IntegrationCredential) =>- Object.values(c.redacted)- .map((v) => String(v))- .filter(Boolean)- .join(' · ');--// A credential's display text: its label if set, otherwise its masked secret, with the-// masked secret shown as a suffix when a label takes the primary slot.-function credLabel(c: IntegrationCredential): string {- const masked = credMasked(c);- const name = c.label ?? (masked || `Credential #${c.id}`);- return c.label && masked ? `${name} · ${masked}` : name;-}+// The id is the fallback so several unlabelled credentials of the same integration+// can still be told apart.+const credLabel = (c: IntegrationOption) => c.label ?? `Credential #${c.id}`;// Step two of adding a tool: pick the credential the tool runs on. The credential list// is narrowed to the tool's integration; if none exists yet, the user is pointed at the@@ -43,7 +31,7 @@ export function ToolCredentialStep({}: {projectKey: string;tool: ToolOption;- credentials: IntegrationCredential[];+ credentials: IntegrationOption[];onBack: () => void;onDone: () => void;}) {diff --git a/apps/web/src/features/settings/components/ai-agents/AgentModelSection.tsx b/apps/web/src/features/settings/components/ai-agents/AgentModelSection.tsxindex c12d6d80..987a5a19 100644--- a/apps/web/src/features/settings/components/ai-agents/AgentModelSection.tsx+++ b/apps/web/src/features/settings/components/ai-agents/AgentModelSection.tsx@@ -2,7 +2,7 @@import Link from 'next/link';import { ArrowUpRight, Cpu } from 'lucide-react';-import type { IntegrationCredential, IntegrationMeta, ProviderModel } from '@/lib/api';+import type { IntegrationMeta, IntegrationOption, ProviderModel } from '@/lib/api';import { integrationsPath } from '@/utils/paths';import {Select,@@ -35,12 +35,12 @@ export default function AgentModelSection({value: AgentFormValue;onChange: (patch: Partial<AgentFormValue>) => void;projectKey: string;- credentials: IntegrationCredential[];+ credentials: IntegrationOption[];catalog: IntegrationMeta[];models: ProviderModel[];modelsLoading: boolean;}) {- const credentialLabel = (c: IntegrationCredential) => {+ const credentialLabel = (c: IntegrationOption) => {const integration = integrationLabel(catalog, c.integrationKey);return c.label ? `${integration} · ${c.label}` : integration;};diff --git a/apps/web/src/features/settings/components/ai-agents/AgentSheetForm.tsx b/apps/web/src/features/settings/components/ai-agents/AgentSheetForm.tsxindex b4828640..83db4fb1 100644--- a/apps/web/src/features/settings/components/ai-agents/AgentSheetForm.tsx+++ b/apps/web/src/features/settings/components/ai-agents/AgentSheetForm.tsx@@ -6,9 +6,9 @@ import {useAgentToolsQuery,} from '@/services/aiAgents.service';import {- useCredentialsQuery,useIntegrationCatalogQuery,useIntegrationModelsQuery,+ useIntegrationOptionsQuery,} from '@/services/integrations.service';import { useRolesQuery } from '@/services/roles.service';import {@@ -75,14 +75,9 @@ export function AgentSheetForm({const toolsQuery = useAgentToolsQuery(projectKey);const catalogQuery = useIntegrationCatalogQuery(projectKey);const catalog = catalogQuery.data ?? [];- const credentialsQuery = useCredentialsQuery(projectKey);- const credentials = credentialsQuery.data ?? [];- // Only LLM-provider credentials can back a model.- const llmCredentials = credentials.filter(- (c) => catalog.find((i) => i.key === c.integrationKey)?.kind === 'llm',- );+ const llmCredentials = useIntegrationOptionsQuery(projectKey, 'llm').data ?? [];const selectedProvider =- credentials.find((c) => c.id === value.modelCredentialId)?.integrationKey ?? null;+ llmCredentials.find((c) => c.id === value.modelCredentialId)?.integrationKey ?? null;const providerModelsQuery = useIntegrationModelsQuery(projectKey,value.kind === 'internal' ? selectedProvider : null,diff --git a/apps/web/src/features/settings/components/ai-agents/SettingsAiAgentFields.tsx b/apps/web/src/features/settings/components/ai-agents/SettingsAiAgentFields.tsxindex 8ae104b9..8ac785b1 100644--- a/apps/web/src/features/settings/components/ai-agents/SettingsAiAgentFields.tsx+++ b/apps/web/src/features/settings/components/ai-agents/SettingsAiAgentFields.tsx@@ -9,13 +9,7 @@ import {Wrench,Zap,} from 'lucide-react';-import type {- AgentTool,- IntegrationCredential,- IntegrationMeta,- ProviderModel,- Role,-} from '@/lib/api';+import type { AgentTool, IntegrationMeta, IntegrationOption, ProviderModel, Role } from '@/lib/api';import { Input } from '@/components/ui/input';import { Checkbox } from '@/components/ui/checkbox';import { Switch } from '@/components/ui/switch';@@ -77,7 +71,7 @@ export default function SettingsAiAgentFields({toolsLoading: boolean;kindLocked: boolean;expanded?: boolean;- credentials: IntegrationCredential[];+ credentials: IntegrationOption[];catalog: IntegrationMeta[];models: ProviderModel[];modelsLoading: boolean;diff --git a/apps/web/src/features/settings/services/settings.service.ts b/apps/web/src/features/settings/services/settings.service.tsindex f3ca4127..5a745483 100644--- a/apps/web/src/features/settings/services/settings.service.ts+++ b/apps/web/src/features/settings/services/settings.service.ts@@ -25,7 +25,7 @@ function useProjectMutation<TArgs>(mutationFn: (args: TArgs) => Promise<unknown>,) {const invalidate = useInvalidateProject(projectKey);- return useMutation({ mutationFn, onSuccess: () => invalidate(true) });+ return useMutation({ mutationFn, onSuccess: () => invalidate() });}export function useCreateColumn(projectKey: string) {diff --git a/apps/web/src/features/work-items/components/kanban/BulkActionBar.tsx b/apps/web/src/features/work-items/components/kanban/BulkActionBar.tsxindex cd3363d3..4c354c2f 100644--- a/apps/web/src/features/work-items/components/kanban/BulkActionBar.tsx+++ b/apps/web/src/features/work-items/components/kanban/BulkActionBar.tsx@@ -4,8 +4,7 @@ import { useState } from 'react';import { Archive, Bot, CircleDashed, RefreshCw, Tag, Target, Trash2, User, X } from 'lucide-react';import { type ProjectDetail } from '@/lib/api';import { usePermissions } from '@/hooks/usePermissions';-import { useInitiativesQuery } from '@/services/initiatives.service';-import { LINKABLE_STATUSES } from '@/utils/initiativeMeta';+import { useInitiativeOptionsQuery } from '@/services/initiatives.service';import { CYCLE_STATUS_META } from '@/utils/cycleMeta';import { subtaskCount } from '@/utils/subtasks';import { cn } from '@/lib/utils';@@ -29,17 +28,13 @@ export function BulkActionBar({ project }: { project: ProjectDetail }) {const { can } = usePermissions();const bulk = useBulkActions(project);const [confirming, setConfirming] = useState<'delete' | 'archive' | null>(null);- // Initiatives are not in the board scaffold. The bulk picker fetches the first- // page of linkable (open) initiatives only while selection is active, and only- // while the project shows the Initiatives section (with none loaded the picker- // is left out).+ // Initiatives are not in the board scaffold. The bulk picker fetches the linkable+ // (open) ones only while selection is active, and only while the project shows the+ // Initiatives section (with none loaded the picker is left out).const initiativesKey =selection.isSelecting && project.project.initiativesEnabled ? project.project.key : null;- const { data } = useInitiativesQuery(initiativesKey, {- statuses: LINKABLE_STATUSES,- pageSize: 50,- });- const initiatives = data?.items ?? [];+ const { data } = useInitiativeOptionsQuery(initiativesKey);+ const initiatives = data ?? [];if (!selection.isSelecting) return null;diff --git a/apps/web/src/hooks/useShellProject.ts b/apps/web/src/hooks/useShellProject.tsindex 5a87d321..eec2c8f7 100644--- a/apps/web/src/hooks/useShellProject.ts+++ b/apps/web/src/hooks/useShellProject.ts@@ -6,7 +6,7 @@ import {useProjectsQuery,} from '@/services/projects.service';import { useViewsQuery } from '@/services/views.service';-import { usePlannedCyclesQuery } from '@/services/cycles.service';+import { useCycleOptionsQuery } from '@/services/cycles.service';import { ApiError } from '@/lib/api';import { applyFilters } from '@/utils/filters';import { withoutShownSubtasks } from '@/utils/subtasks';@@ -33,16 +33,11 @@ export function useShellProject(projectKey: string | null, activeViewId: numberconst projectQuery = useProjectQuery(projectKey);const boardIssuesQuery = useBoardIssuesQuery(projectKey);const scaffold = projectQuery.data ?? null;- // The planned cycles join the composite so grouping by cycle can lay out a lane+ // The cycle options join the composite so grouping by cycle can lay out a lane// per cycle a board plans into, not only per cycle an issue is already in. The// whole list is not loaded: it grows with every finished cycle, and a finished- // one only needs a lane while its issues name it. Fetched while the section is- // on and the viewer may read it.- const canReadCycles =- scaffold?.viewer.role === 'owner' || scaffold?.permissions.cycles?.read === true;- const cyclesQuery = usePlannedCyclesQuery(- scaffold?.project.cyclesEnabled && canReadCycles ? projectKey : null,- );+ // one only needs a lane while its issues name it.+ const cyclesQuery = useCycleOptionsQuery(scaffold?.project.cyclesEnabled ? projectKey : null);const project = useMemo(() =>scaffold@@ -92,8 +87,15 @@ export function useShellProject(projectKey: string | null, activeViewId: numberconst canCreateIssue =!!viewer && (viewer.role === 'owner' || project?.permissions.work_items?.create === true);+ // The scaffold is the membership check; the issues and the views carry their own+ // resource. A 403 on one of those is a role that does not grant it, not a project+ // out of reach, so it is dropped here and the pages the role does grant still open.+ const roleDenied = (e: unknown) => (e instanceof ApiError && e.status === 403 ? null : e);const error =- projectsQuery.error ?? projectQuery.error ?? boardIssuesQuery.error ?? viewsQuery.error;+ projectsQuery.error ??+ projectQuery.error ??+ roleDenied(boardIssuesQuery.error) ??+ roleDenied(viewsQuery.error);return {projects,@@ -105,9 +107,9 @@ export function useShellProject(projectKey: string | null, activeViewId: numbercustomFields,canCreateIssue,errorMsg: errorMessage(error),- // A 403 means the session is valid but the user is not a member of this- // project. Shown as an access message instead of the generic error banner+ // A 403 on the scaffold means the session is valid but the user is not a member+ // of this project. Shown as an access message instead of the generic error banner// (and never as a login bounce — the middleware owns the no-session case).- forbidden: error instanceof ApiError && error.status === 403,+ forbidden: projectQuery.error instanceof ApiError && projectQuery.error.status === 403,};}diff --git a/apps/web/src/lib/api.ts b/apps/web/src/lib/api.tsindex e8574a9d..d6568366 100644--- a/apps/web/src/lib/api.ts+++ b/apps/web/src/lib/api.ts@@ -300,13 +300,15 @@ export interface ConfigField {help?: string;}-// An integration the project can store a credential for (server-side catalog). `kind`// 'llm' is an AI provider (its models an agent runs on, no tools); 'tool' is a tool// integration whose `tools` are configured on a credential.+export type IntegrationKind = 'llm' | 'tool';++// An integration the project can store a credential for (server-side catalog).export interface IntegrationMeta {key: string;label: string;- kind: 'llm' | 'tool';+ kind: IntegrationKind;credentialSchema: ConfigField[];tools: { key: string; label: string; description: string; scopes?: string[] }[];}@@ -328,6 +330,15 @@ export interface IntegrationCredential {createdAt: string;}+// A connected integration as a picker option: what it is and what it is called,+// with none of the credential fields the admin list carries.+export interface IntegrationOption {+ id: number;+ integrationKey: string;+ kind: IntegrationKind;+ label: string | null;+}+export interface NewCredentialInput {integrationKey: string;label?: string | null;@@ -515,10 +526,10 @@ export interface Issue {typeId: number | null;// The initiative this issue is linked to, expanded to id + title for rendering,// or null. Set through updateIssue by initiativeId.- initiative: InitiativeOption | null;+ initiative: InitiativeRef | null;// The cycle this issue is planned into, expanded to id + name for rendering, or// null. Set through updateIssue by cycleId.- cycle: CycleOption | null;+ cycle: CycleRef | null;assigneeUserId: string | null;delegateUserId: string | null;columnId: number;@@ -1440,12 +1451,14 @@ export interface ProjectViewer {role: MemberRole;}-export interface InitiativeOption {+// How an issue carries the initiative and the cycle it belongs to: the id plus+// what to render. The picker lists are InitiativeOption / CycleOption.+export interface InitiativeRef {id: number;title: string;}-export interface CycleOption {+export interface CycleRef {id: number;name: string;}@@ -1484,10 +1497,9 @@ export interface BoardIssues {// The scaffold composed with its issues and the project's unfinished cycles, as// the Shell assembles it and passes it down. Downstream reads project.issues off-// this composite. `plannedCycles` is empty while the Cycles section is off, on a-// public share (whose bundle carries no cycle list), and for a viewer who may not-// read cycles.-export type ProjectDetail = ProjectScaffold & BoardIssues & { plannedCycles: Cycle[] };+// this composite. `plannedCycles` is empty while the Cycles section is off and on a+// public share (whose bundle carries no cycle list).+export type ProjectDetail = ProjectScaffold & BoardIssues & { plannedCycles: CycleOption[] };export interface IssueDetail extends Issue {fields: IssueFieldValue[];@@ -1692,10 +1704,24 @@ export interface Initiative {health: InitiativeHealth | null;}+// An initiative as a picker option, for linking an issue to one.+export interface InitiativeOption {+ id: number;+ title: string;+ status: InitiativeStatus;+}+// A time-boxed period of work (a sprint). status follows from the dates against// today and progress from the linked issues' states — neither is stored.export type CycleStatus = 'upcoming' | 'active' | 'completed';+// A cycle as a picker option, for planning an issue into one.+export interface CycleOption {+ id: number;+ name: string;+ status: CycleStatus;+}+export interface CycleProgress {completed: number;canceled: number;@@ -2128,10 +2154,6 @@ export const api = {deleteLabelGroup: (projectKey: string, groupId: number) =>request<void>(`/projects/${projectKey}/label-groups/${groupId}`, { method: 'DELETE' }),- listCustomFields: (projectKey: string, issueTypeId?: number) =>- request<CustomField[]>(- `/projects/${projectKey}/custom-fields${issueTypeId != null ? `?issueTypeId=${issueTypeId}` : ''}`,- ),createCustomField: (projectKey: string, input: NewCustomFieldInput) =>request<CustomField>(`/projects/${projectKey}/custom-fields`, {method: 'POST',@@ -2330,6 +2352,15 @@ export const api = {const qs = q.toString();return request<InitiativePage>(`/projects/${projectKey}/initiatives${qs ? `?${qs}` : ''}`);},+ listInitiativeOptions: (projectKey: string, params: { search?: string; include?: number }) => {+ const q = new URLSearchParams();+ if (params.search) q.set('search', params.search);+ if (params.include) q.set('include', String(params.include));+ const qs = q.toString();+ return request<InitiativeOption[]>(+ `/projects/${projectKey}/initiatives/options${qs ? `?${qs}` : ''}`,+ );+ },initiativeCounts: (projectKey: string) =>request<InitiativeCounts>(`/projects/${projectKey}/initiatives/counts`),getInitiative: (id: number) => request<Initiative>(`/initiatives/${id}`),@@ -2354,6 +2385,8 @@ export const api = {listCycles: (projectKey: string) => request<Cycle[]>(`/projects/${projectKey}/cycles`),listPlannedCycles: (projectKey: string) =>request<Cycle[]>(`/projects/${projectKey}/cycles?status=planned`),+ listCycleOptions: (projectKey: string) =>+ request<CycleOption[]>(`/projects/${projectKey}/cycles/options`),listCompletedCycles: (projectKey: string, params: { page: number; pageSize: number }) =>request<CyclePage>(`/projects/${projectKey}/cycles/completed?page=${params.page}&pageSize=${params.pageSize}`,@@ -2582,6 +2615,10 @@ export const api = {),listCredentials: (projectKey: string) =>request<IntegrationCredential[]>(`/projects/${projectKey}/integrations`),+ listIntegrationOptions: (projectKey: string, kind?: IntegrationKind) =>+ request<IntegrationOption[]>(+ `/projects/${projectKey}/integrations/options${kind ? `?kind=${kind}` : ''}`,+ ),createCredential: (projectKey: string, input: NewCredentialInput) =>request<IntegrationCredential>(`/projects/${projectKey}/integrations`, {method: 'POST',diff --git a/apps/web/src/services/customFields.service.ts b/apps/web/src/services/customFields.service.tsdeleted file mode 100644index d80a9541..00000000--- a/apps/web/src/services/customFields.service.ts+++ /dev/null@@ -1,11 +0,0 @@-import { useQuery } from '@tanstack/react-query';-import { api } from '@/lib/api';-import { qk } from '@/services/queryKeys';--export function useCustomFieldsQuery(projectKey: string | null, typeId?: number | null) {- return useQuery({- queryKey: qk.customFields(projectKey ?? '', typeId),- queryFn: () => api.listCustomFields(projectKey!, typeId ?? undefined),- enabled: projectKey != null,- });-}diff --git a/apps/web/src/services/cycles.service.ts b/apps/web/src/services/cycles.service.tsindex 3332a7a8..d11299dc 100644--- a/apps/web/src/services/cycles.service.ts+++ b/apps/web/src/services/cycles.service.ts@@ -39,6 +39,16 @@ export function usePlannedCyclesQuery(projectKey: string | null) {});}+// The cycles an issue can be planned into. Read under work items, so the picker and+// the board's cycle lanes work for a role without access to the cycles pages.+export function useCycleOptionsQuery(projectKey: string | null) {+ return useQuery({+ queryKey: qk.cycleOptions(projectKey ?? ''),+ queryFn: () => api.listCycleOptions(projectKey!),+ enabled: projectKey != null,+ });+}+// The finished cycles, newest first, a page at a time.export function useCompletedCyclesQuery(projectKey: string | null) {return useInfiniteQuery({diff --git a/apps/web/src/services/initiatives.service.ts b/apps/web/src/services/initiatives.service.tsindex 46fe9b5d..229d42fa 100644--- a/apps/web/src/services/initiatives.service.ts+++ b/apps/web/src/services/initiatives.service.ts@@ -26,6 +26,21 @@ export function useInitiativesQuery(projectKey: string | null, params: Initiativ});}+// The initiatives an issue can be linked to. Read under work items, so the picker+// works for a role without access to the initiatives pages. `include` keeps the+// linked initiative listed after it closes.+export function useInitiativeOptionsQuery(+ projectKey: string | null,+ params: { search?: string; include?: number } = {},+) {+ return useQuery({+ queryKey: qk.initiativeOptions(projectKey ?? '', params),+ queryFn: () => api.listInitiativeOptions(projectKey!, params),+ enabled: projectKey != null,+ placeholderData: keepPreviousData,+ });+}+// Per-status counts for the list's status tabs, independent of the current page.export function useInitiativeCountsQuery(projectKey: string | null) {return useQuery({diff --git a/apps/web/src/services/integrations.service.ts b/apps/web/src/services/integrations.service.tsindex 0efed17e..1e01439f 100644--- a/apps/web/src/services/integrations.service.ts+++ b/apps/web/src/services/integrations.service.ts@@ -1,5 +1,10 @@import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';-import { api, type NewCredentialInput, type CredentialPatch } from '@/lib/api';+import {+ api,+ type CredentialPatch,+ type IntegrationKind,+ type NewCredentialInput,+} from '@/lib/api';import { qk } from '@/services/queryKeys';export function useCredentialsQuery(projectKey: string | null) {@@ -10,6 +15,16 @@ export function useCredentialsQuery(projectKey: string | null) {});}+// The connected integrations as picker options, for the agent and tool forms. Open+// to any project member, unlike the credential list above.+export function useIntegrationOptionsQuery(projectKey: string | null, kind?: IntegrationKind) {+ return useQuery({+ queryKey: qk.integrationOptions(projectKey ?? '', kind),+ queryFn: () => api.listIntegrationOptions(projectKey!, kind),+ enabled: projectKey != null,+ });+}+// The integrations the instance offers. Changes only on deploy, so it is cached// for the session.export function useIntegrationCatalogQuery(projectKey: string | null) {diff --git a/apps/web/src/services/projects.service.ts b/apps/web/src/services/projects.service.tsindex 7094eac4..9d181538 100644--- a/apps/web/src/services/projects.service.ts+++ b/apps/web/src/services/projects.service.ts@@ -32,11 +32,9 @@ export function useBoardIssuesQuery(projectKey: string | null) {// Returns a callback that invalidates a project's detail query. Used by the// settings service mutations to refresh the project after a structural write.-// Passing `withCustomFields` also refreshes the custom-field lists (the Custom-// fields tab edits those).export function useInvalidateProject(projectKey: string | null) {const qc = useQueryClient();- return (withCustomFields = false) => {+ return () => {if (projectKey) {void qc.invalidateQueries({ queryKey: qk.project(projectKey) });// A structural change (deleted/renamed label, type, column, custom field) can@@ -48,7 +46,6 @@ export function useInvalidateProject(projectKey: string | null) {// from the issue query, not the project — so refresh any open issue too. Only// the active (open) issue actually refetches.void qc.invalidateQueries({ queryKey: qk.anyIssue });- if (withCustomFields) void qc.invalidateQueries({ queryKey: qk.anyCustomFields });};}diff --git a/apps/web/src/services/queryKeys.ts b/apps/web/src/services/queryKeys.tsindex 9e009275..c6f32960 100644--- a/apps/web/src/services/queryKeys.ts+++ b/apps/web/src/services/queryKeys.ts@@ -43,11 +43,6 @@ export const qk = {analytics: (projectKey: string, kind: string, params?: unknown) =>['analytics', projectKey, kind, params ?? {}] as const,analyticsForProject: (projectKey: string) => ['analytics', projectKey] as const,- // Custom fields are project-scoped; typeId narrows to one issue type's fields,- // 'all' is the project's full list.- customFields: (projectKey: string, typeId?: number | null) =>- ['customFields', projectKey, typeId ?? 'all'] as const,- anyCustomFields: ['customFields'] as const,// Project membership, invite links, and custom roles (the Members section). The// permission catalog is app-static, so it is not project-scoped.members: (projectKey: string) => ['members', projectKey] as const,@@ -79,6 +74,10 @@ export const qk = {integrationCatalog: (projectKey: string) => ['integrations', projectKey, 'catalog'] as const,integrationModels: (projectKey: string, provider: string) =>['integrations', projectKey, 'models', provider] as const,+ // The connected integrations as picker options, under the same prefix so a+ // credential mutation refreshes them too.+ integrationOptions: (projectKey: string, kind?: string) =>+ ['integrations', projectKey, 'options', kind ?? 'all'] as const,// The project skill library (the Skills page).agentSkills: (projectKey: string) => ['agentSkills', projectKey] as const,// Configured tools (the Tools page) and the tools enabled on one agent (the agent@@ -104,6 +103,9 @@ export const qk = {initiatives: (projectKey: string, params?: Record<string, unknown>) =>['initiatives', projectKey, params ?? {}] as const,initiativesForProject: (projectKey: string) => ['initiatives', projectKey] as const,+ // The linkable initiatives behind the issue picker, narrowed by the typed search.+ initiativeOptions: (projectKey: string, params: Record<string, unknown>) =>+ ['initiatives', projectKey, 'options', params] as const,initiativeCounts: (projectKey: string) => ['initiativeCounts', projectKey] as const,initiative: (id: number) => ['initiative', id] as const,initiativeFeed: (id: number) => ['initiativeFeed', id] as const,@@ -118,6 +120,7 @@ export const qk = {// under the same prefix, so one invalidation covers all three.cycles: (projectKey: string) => ['cycles', projectKey] as const,plannedCycles: (projectKey: string) => ['cycles', projectKey, 'planned'] as const,+ cycleOptions: (projectKey: string) => ['cycles', projectKey, 'options'] as const,completedCycles: (projectKey: string) => ['cycles', projectKey, 'completed'] as const,cycle: (id: number) => ['cycle', id] as const,anyCycles: ['cycles'] as const,diff --git a/apps/web/src/utils/initiativeMeta.ts b/apps/web/src/utils/initiativeMeta.tsindex 4b509d02..211dabfd 100644--- a/apps/web/src/utils/initiativeMeta.ts+++ b/apps/web/src/utils/initiativeMeta.ts@@ -20,10 +20,6 @@ export const STATUS_ORDER: InitiativeStatus[] = ['canceled',];-// The open statuses an issue can be linked to: the lifecycle without the terminal-// completed and canceled, which are not offered in the link pickers.-export const LINKABLE_STATUSES: InitiativeStatus[] = ['proposed', 'planned', 'active'];-// Health (computed server-side). null means there is nothing to judge yet.export const HEALTH_META: Record<InitiativeHealth, { label: string; color: string }> = {on_track: { label: 'On track', color: '#22c55e' },