The open-source app everyone uses to manage agents at work
TypeScript acpxagent-orchestrationagent-skillsagentic-aiai-agentsai-engineeringai-governanceai-toolsautonomous-agentsclaudeclaude-codeclaude-skillscodexhermesllmmcpmulti-agentopenclawproject-managementworkflow-automation
Exclude archived projects from the default project list route (#10146)
Nicky Leach564870020b38
diff --git a/server/src/__tests__/projects-list-archived-routes.test.ts b/server/src/__tests__/projects-list-archived-routes.test.tsnew file mode 100644index 0000000000..b8201552f7--- /dev/null+++ b/server/src/__tests__/projects-list-archived-routes.test.ts@@ -0,0 +1,110 @@+import { randomUUID } from "node:crypto";+import express from "express";+import request from "supertest";+import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest";+import { companies, createDb, projects } from "@paperclipai/db";+import {+ getEmbeddedPostgresTestSupport,+ startEmbeddedPostgresTestDatabase,+} from "./helpers/embedded-postgres.js";+import { errorHandler } from "../middleware/index.js";+import { projectRoutes } from "../routes/projects.js";++const embeddedPostgresSupport = await getEmbeddedPostgresTestSupport();+const describeEmbeddedPostgres = embeddedPostgresSupport.supported ? describe : describe.skip;++if (!embeddedPostgresSupport.supported) {+ console.warn(+ `Skipping embedded Postgres project list archived tests on this host: ${+ embeddedPostgresSupport.reason ?? "unsupported environment"+ }`,+ );+}++function boardActor(companyId: string): Express.Request["actor"] {+ return {+ type: "board",+ userId: "user-1",+ source: "session",+ isInstanceAdmin: true,+ companyIds: [companyId],+ memberships: [{ companyId, membershipRole: "admin", status: "active" }],+ };+}++function createApp(db: ReturnType<typeof createDb>, actor: Express.Request["actor"]) {+ const app = express();+ app.use(express.json());+ app.use((req, _res, next) => {+ req.actor = actor;+ next();+ });+ app.use("/api", projectRoutes(db));+ app.use(errorHandler);+ return app;+}++describeEmbeddedPostgres("project list archived route defaults", () => {+ let db!: ReturnType<typeof createDb>;+ let tempDb: Awaited<ReturnType<typeof startEmbeddedPostgresTestDatabase>> | null = null;++ beforeAll(async () => {+ tempDb = await startEmbeddedPostgresTestDatabase("paperclip-projects-list-archived-");+ db = createDb(tempDb.connectionString);+ }, 20_000);++ afterEach(async () => {+ await db.delete(projects);+ await db.delete(companies);+ });++ afterAll(async () => {+ await tempDb?.cleanup();+ });++ async function seed() {+ const companyId = randomUUID();+ const activeProjectId = randomUUID();+ const archivedProjectId = randomUUID();++ await db.insert(companies).values({+ id: companyId,+ name: "Paperclip",+ issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,+ requireBoardApprovalForNewAgents: false,+ });+ await db.insert(projects).values([+ { id: activeProjectId, companyId, name: "Active Project", status: "in_progress" },+ {+ id: archivedProjectId,+ companyId,+ name: "Archived Project",+ status: "completed",+ archivedAt: new Date(),+ },+ ]);++ return { activeProjectId, archivedProjectId, companyId };+ }++ it("omits archived projects by default", async () => {+ const { activeProjectId, archivedProjectId, companyId } = await seed();+ const app = createApp(db, boardActor(companyId));++ const res = await request(app).get(`/api/companies/${companyId}/projects`);++ expect(res.status).toBe(200);+ expect(res.body.map((project: { id: string }) => project.id)).toEqual([activeProjectId]);+ expect(res.body.map((project: { id: string }) => project.id)).not.toContain(archivedProjectId);+ });++ it("includes archived projects when includeArchived is true", async () => {+ const { activeProjectId, archivedProjectId, companyId } = await seed();+ const app = createApp(db, boardActor(companyId));++ const res = await request(app).get(`/api/companies/${companyId}/projects?includeArchived=true`);++ expect(res.status).toBe(200);+ expect(res.body.map((project: { id: string }) => project.id)).toEqual([activeProjectId, archivedProjectId]);+ });+});diff --git a/server/src/routes/projects.ts b/server/src/routes/projects.tsindex 7d472c36d8..5476db84f5 100644--- a/server/src/routes/projects.ts+++ b/server/src/routes/projects.ts@@ -129,7 +129,8 @@ export function projectRoutes(db: Db) {router.get("/companies/:companyId/projects", async (req, res) => {const companyId = req.params.companyId as string;assertCompanyAccess(req, companyId);- const result = await svc.list(companyId);+ const includeArchived = req.query.includeArchived === "true";+ const result = await svc.list(companyId, { includeArchived });res.json(await filterProjectsForActor(req, result));});diff --git a/server/src/services/projects.ts b/server/src/services/projects.tsindex 7cb38f676d..5ac1b50e4c 100644--- a/server/src/services/projects.ts+++ b/server/src/services/projects.ts@@ -1,4 +1,4 @@-import { and, asc, desc, eq, inArray, sql } from "drizzle-orm";+import { and, asc, desc, eq, inArray, isNull, sql } from "drizzle-orm";import type { Db } from "@paperclipai/db";import {projects,@@ -589,8 +589,17 @@ export function projectService(db: Db) {};return {- list: async (companyId: string): Promise<ProjectWithGoals[]> => {- const rows = await db.select().from(projects).where(eq(projects.companyId, companyId));+ list: async (companyId: string, opts: { includeArchived?: boolean } = {}): Promise<ProjectWithGoals[]> => {+ // NOTE: this service default is intentionally the inverse of the HTTP route default.+ // The route (`GET /companies/:companyId/projects`) defaults `includeArchived` to `false`+ // (active-only) for its callers, but the service defaults to `true` so that existing+ // server-internal callers that pass no opts keep their pre-existing "return everything,+ // including archived" behaviour. Pass `{ includeArchived: false }` explicitly for active-only.+ const includeArchived = opts.includeArchived ?? true;+ const where = includeArchived+ ? eq(projects.companyId, companyId)+ : and(eq(projects.companyId, companyId), isNull(projects.archivedAt));+ const rows = await db.select().from(projects).where(where);const withGoals = await attachGoals(db, rows);const withWorkspaces = await attachWorkspaces(db, withGoals);return attachListMetrics(db, companyId, withWorkspaces);diff --git a/ui/src/api/projects.ts b/ui/src/api/projects.tsindex e975f829c1..af1c736a52 100644--- a/ui/src/api/projects.ts+++ b/ui/src/api/projects.ts@@ -18,7 +18,12 @@ function projectPath(id: string, companyId?: string, suffix = "") {}export const projectsApi = {- list: (companyId: string) => api.get<Project[]>(`/companies/${companyId}/projects`),+ list: (companyId: string, opts: { includeArchived?: boolean } = {}) => {+ const params = new URLSearchParams();+ if (opts.includeArchived) params.set("includeArchived", "true");+ const query = params.toString();+ return api.get<Project[]>("/companies/" + encodeURIComponent(companyId) + "/projects" + (query ? "?" + query : ""));+ },get: (id: string, companyId?: string) => api.get<Project>(projectPath(id, companyId)),create: (companyId: string, data: Record<string, unknown>) =>api.post<Project>(`/companies/${companyId}/projects`, data),diff --git a/ui/src/components/IssueProperties.test.tsx b/ui/src/components/IssueProperties.test.tsxindex 892f94f546..de9467a8b6 100644--- a/ui/src/components/IssueProperties.test.tsx+++ b/ui/src/components/IssueProperties.test.tsx@@ -1230,6 +1230,31 @@ describe("IssueProperties", () => {act(() => root.unmount());});+ it("keeps the current archived project visible in the project property", async () => {+ mockProjectsApi.list.mockResolvedValue([+ createProject({+ id: "archived-project",+ name: "Archived Project",+ archivedAt: new Date("2026-04-08T00:00:00.000Z"),+ }),+ ]);++ const root = renderProperties(container, {+ issue: createIssue({ projectId: "archived-project" }),+ childIssues: [],+ onUpdate: vi.fn(),+ inline: true,+ });+ await flush();++ expect(mockProjectsApi.list).toHaveBeenCalledWith("company-1", { includeArchived: true });+ await waitForAssertion(() => {+ expect(findRowTrigger(container, "Project")?.textContent).toContain("Archived Project");+ });++ act(() => root.unmount());+ });+it("shows a green service link above the workspace row for a live non-main workspace", async () => {mockProjectsApi.list.mockResolvedValue([createProject()]);const serviceUrl = "http://127.0.0.1:62475";diff --git a/ui/src/components/NewProjectDialog.tsx b/ui/src/components/NewProjectDialog.tsxindex df90e3f99c..f7268c4d43 100644--- a/ui/src/components/NewProjectDialog.tsx+++ b/ui/src/components/NewProjectDialog.tsx@@ -180,7 +180,7 @@ export function NewProjectDialog() {await projectsApi.createWorkspace(created.id, workspacePayload);}- queryClient.invalidateQueries({ queryKey: queryKeys.projects.list(selectedCompanyId) });+ queryClient.invalidateQueries({ queryKey: queryKeys.projects.all(selectedCompanyId) });queryClient.invalidateQueries({ queryKey: queryKeys.projects.detail(created.id) });reset();closeNewProject();diff --git a/ui/src/components/ProjectProperties.tsx b/ui/src/components/ProjectProperties.tsxindex a7ba99d228..c078e317db 100644--- a/ui/src/components/ProjectProperties.tsx+++ b/ui/src/components/ProjectProperties.tsx@@ -325,7 +325,7 @@ export function ProjectProperties({ project, onUpdate, onFieldUpdate, getFieldSaqueryClient.invalidateQueries({ queryKey: queryKeys.projects.detail(project.urlKey) });}if (selectedCompanyId) {- queryClient.invalidateQueries({ queryKey: queryKeys.projects.list(selectedCompanyId) });+ queryClient.invalidateQueries({ queryKey: queryKeys.projects.all(selectedCompanyId) });}};diff --git a/ui/src/components/ProjectWorkspacesContent.tsx b/ui/src/components/ProjectWorkspacesContent.tsxindex f73c53aa10..7ffd3cba00 100644--- a/ui/src/components/ProjectWorkspacesContent.tsx+++ b/ui/src/components/ProjectWorkspacesContent.tsx@@ -45,7 +45,7 @@ export function ProjectWorkspacesContent({queryClient.invalidateQueries({ queryKey: queryKeys.executionWorkspaces.list(companyId) });queryClient.invalidateQueries({ queryKey: queryKeys.executionWorkspaces.list(companyId, { projectId }) });queryClient.invalidateQueries({ queryKey: queryKeys.projects.detail(projectId) });- queryClient.invalidateQueries({ queryKey: queryKeys.projects.list(companyId) });+ queryClient.invalidateQueries({ queryKey: queryKeys.projects.all(companyId) });queryClient.invalidateQueries({ queryKey: queryKeys.issues.list(companyId) });queryClient.invalidateQueries({ queryKey: queryKeys.issues.listByProject(companyId, projectId) });},@@ -109,7 +109,7 @@ export function ProjectWorkspacesContent({queryClient.invalidateQueries({ queryKey: queryKeys.executionWorkspaces.list(companyId) });queryClient.invalidateQueries({ queryKey: queryKeys.executionWorkspaces.list(companyId, { projectId }) });queryClient.invalidateQueries({ queryKey: queryKeys.projects.detail(projectId) });- queryClient.invalidateQueries({ queryKey: queryKeys.projects.list(companyId) });+ queryClient.invalidateQueries({ queryKey: queryKeys.projects.all(companyId) });queryClient.invalidateQueries({ queryKey: queryKeys.issues.list(companyId) });queryClient.invalidateQueries({ queryKey: queryKeys.issues.listByProject(companyId, projectId) });setClosingWorkspace(null);diff --git a/ui/src/components/issue-properties/IssueProperties.tsx b/ui/src/components/issue-properties/IssueProperties.tsxindex 1da295b16e..acf0131eae 100644--- a/ui/src/components/issue-properties/IssueProperties.tsx+++ b/ui/src/components/issue-properties/IssueProperties.tsx@@ -231,8 +231,8 @@ export function IssueProperties({enabled: !!companyId,});const { data: projects } = useQuery({- queryKey: queryKeys.projects.list(companyId!),- queryFn: () => projectsApi.list(companyId!),+ queryKey: queryKeys.projects.list(companyId!, { includeArchived: true }),+ queryFn: () => projectsApi.list(companyId!, { includeArchived: true }),enabled: !!companyId,});const activeProjects = useMemo(diff --git a/ui/src/context/LiveUpdatesProvider.tsx b/ui/src/context/LiveUpdatesProvider.tsxindex 99d63b5cc0..b7ffeec361 100644--- a/ui/src/context/LiveUpdatesProvider.tsx+++ b/ui/src/context/LiveUpdatesProvider.tsx@@ -1030,7 +1030,7 @@ function invalidateActivityQueries(}if (entityType === "project") {- queryClient.invalidateQueries({ queryKey: queryKeys.projects.list(companyId) });+ queryClient.invalidateQueries({ queryKey: queryKeys.projects.all(companyId) });if (entityId) queryClient.invalidateQueries({ queryKey: queryKeys.projects.detail(entityId) });return;}diff --git a/ui/src/lib/queryKeys.test.ts b/ui/src/lib/queryKeys.test.tsnew file mode 100644index 0000000000..243f3cca96--- /dev/null+++ b/ui/src/lib/queryKeys.test.ts@@ -0,0 +1,21 @@+import { describe, expect, it } from "vitest";+import { queryKeys } from "./queryKeys";++describe("project query keys", () => {+ it("separates default and includeArchived project list caches", () => {+ expect(queryKeys.projects.list("company-1")).toEqual([+ "projects",+ "company-1",+ { includeArchived: false },+ ]);+ expect(queryKeys.projects.list("company-1", { includeArchived: true })).toEqual([+ "projects",+ "company-1",+ { includeArchived: true },+ ]);+ expect(queryKeys.projects.list("company-1")).not.toEqual(+ queryKeys.projects.list("company-1", { includeArchived: true }),+ );+ expect(queryKeys.projects.all("company-1")).toEqual(["projects", "company-1"]);+ });+});diff --git a/ui/src/lib/queryKeys.ts b/ui/src/lib/queryKeys.tsindex 98526f6648..f5de053b05 100644--- a/ui/src/lib/queryKeys.ts+++ b/ui/src/lib/queryKeys.ts@@ -243,7 +243,9 @@ export const queryKeys = {["environment-custom-image-setup-sessions", sessionId] as const,},projects: {- list: (companyId: string) => ["projects", companyId] as const,+ all: (companyId: string) => ["projects", companyId] as const,+ list: (companyId: string, opts: { includeArchived?: boolean } = {}) =>+ ["projects", companyId, { includeArchived: opts.includeArchived === true }] as const,detail: (id: string) => ["projects", "detail", id] as const,},cases: {diff --git a/ui/src/pages/Cases.tsx b/ui/src/pages/Cases.tsxindex 43fb327007..284ef37d25 100644--- a/ui/src/pages/Cases.tsx+++ b/ui/src/pages/Cases.tsx@@ -807,8 +807,8 @@ export function Cases() {enabled: !!selectedCompanyId,});const projectsQuery = useQuery({- queryKey: queryKeys.projects.list(selectedCompanyId ?? ""),- queryFn: () => projectsApi.list(selectedCompanyId!),+ queryKey: queryKeys.projects.list(selectedCompanyId ?? "", { includeArchived: true }),+ queryFn: () => projectsApi.list(selectedCompanyId!, { includeArchived: true }),enabled: !!selectedCompanyId,});const labelsQuery = useQuery({@@ -1272,7 +1272,7 @@ export function Cases() {checked={viewState.projectFilters.includes(ALL)}onCheckedChange={(checked) => toggleStringFilter("projectFilters", ALL, checked)}/>- {(projectsQuery.data ?? []).map((project) => (+ {(projectsQuery.data ?? []).filter((project) => !project.archivedAt).map((project) => (<FilterCheckboxRowkey={project.id}label={project.name}diff --git a/ui/src/pages/Costs.tsx b/ui/src/pages/Costs.tsxindex a50d712b7a..a314c5ffb6 100644--- a/ui/src/pages/Costs.tsx+++ b/ui/src/pages/Costs.tsx@@ -204,7 +204,7 @@ export function Costs() {queryClient.invalidateQueries({ queryKey: queryKeys.budgets.overview(selectedCompanyId) });queryClient.invalidateQueries({ queryKey: queryKeys.dashboard(selectedCompanyId) });queryClient.invalidateQueries({ queryKey: queryKeys.agents.list(selectedCompanyId) });- queryClient.invalidateQueries({ queryKey: queryKeys.projects.list(selectedCompanyId) });+ queryClient.invalidateQueries({ queryKey: queryKeys.projects.all(selectedCompanyId) });};const policyMutation = useMutation({diff --git a/ui/src/pages/Dashboard.tsx b/ui/src/pages/Dashboard.tsxindex 869ed1d0c9..5146c19191 100644--- a/ui/src/pages/Dashboard.tsx+++ b/ui/src/pages/Dashboard.tsx@@ -91,8 +91,8 @@ export function Dashboard() {});const { data: projects } = useQuery({- queryKey: queryKeys.projects.list(selectedCompanyId!),- queryFn: () => projectsApi.list(selectedCompanyId!),+ queryKey: queryKeys.projects.list(selectedCompanyId!, { includeArchived: true }),+ queryFn: () => projectsApi.list(selectedCompanyId!, { includeArchived: true }),enabled: !!selectedCompanyId,});diff --git a/ui/src/pages/GoalDetail.tsx b/ui/src/pages/GoalDetail.tsxindex 4d52988d61..f22ce4604b 100644--- a/ui/src/pages/GoalDetail.tsx+++ b/ui/src/pages/GoalDetail.tsx@@ -72,8 +72,8 @@ export function GoalDetail() {});const { data: allProjects } = useQuery({- queryKey: queryKeys.projects.list(resolvedCompanyId!),- queryFn: () => projectsApi.list(resolvedCompanyId!),+ queryKey: queryKeys.projects.list(resolvedCompanyId!, { includeArchived: true }),+ queryFn: () => projectsApi.list(resolvedCompanyId!, { includeArchived: true }),enabled: !!resolvedCompanyId});diff --git a/ui/src/pages/Inbox.tsx b/ui/src/pages/Inbox.tsxindex 2c8788f94a..21036ad089 100644--- a/ui/src/pages/Inbox.tsx+++ b/ui/src/pages/Inbox.tsx@@ -760,8 +760,8 @@ export function Inbox() {});const { data: projects } = useQuery({- queryKey: queryKeys.projects.list(selectedCompanyId!),- queryFn: () => projectsApi.list(selectedCompanyId!),+ queryKey: queryKeys.projects.list(selectedCompanyId!, { includeArchived: true }),+ queryFn: () => projectsApi.list(selectedCompanyId!, { includeArchived: true }),enabled: !!selectedCompanyId,});const { data: labels } = useQuery({diff --git a/ui/src/pages/Issues.tsx b/ui/src/pages/Issues.tsxindex 97e367c0e7..1cd3e03a2e 100644--- a/ui/src/pages/Issues.tsx+++ b/ui/src/pages/Issues.tsx@@ -92,8 +92,8 @@ export function Issues() {});const { data: projects } = useQuery({- queryKey: queryKeys.projects.list(selectedCompanyId!),- queryFn: () => projectsApi.list(selectedCompanyId!),+ queryKey: queryKeys.projects.list(selectedCompanyId!, { includeArchived: true }),+ queryFn: () => projectsApi.list(selectedCompanyId!, { includeArchived: true }),enabled: !!selectedCompanyId,});diff --git a/ui/src/pages/ProjectDetail.tsx b/ui/src/pages/ProjectDetail.tsxindex 4a7c4b9ed7..5a0fbe47db 100644--- a/ui/src/pages/ProjectDetail.tsx+++ b/ui/src/pages/ProjectDetail.tsx@@ -475,7 +475,7 @@ export function ProjectDetail() {queryClient.invalidateQueries({ queryKey: queryKeys.projects.detail(routeProjectRef) });queryClient.invalidateQueries({ queryKey: queryKeys.projects.detail(projectLookupRef) });if (resolvedCompanyId) {- queryClient.invalidateQueries({ queryKey: queryKeys.projects.list(resolvedCompanyId) });+ queryClient.invalidateQueries({ queryKey: queryKeys.projects.all(resolvedCompanyId) });}};@@ -670,7 +670,7 @@ export function ProjectDetail() {queryClient.invalidateQueries({ queryKey: queryKeys.budgets.overview(resolvedCompanyId) });queryClient.invalidateQueries({ queryKey: queryKeys.projects.detail(routeProjectRef) });queryClient.invalidateQueries({ queryKey: queryKeys.projects.detail(projectLookupRef) });- queryClient.invalidateQueries({ queryKey: queryKeys.projects.list(resolvedCompanyId) });+ queryClient.invalidateQueries({ queryKey: queryKeys.projects.all(resolvedCompanyId) });queryClient.invalidateQueries({ queryKey: queryKeys.dashboard(resolvedCompanyId) });},});diff --git a/ui/src/pages/ProjectWorkspaceDetail.tsx b/ui/src/pages/ProjectWorkspaceDetail.tsxindex b67e84bd9b..1d4411ff69 100644--- a/ui/src/pages/ProjectWorkspaceDetail.tsx+++ b/ui/src/pages/ProjectWorkspaceDetail.tsx@@ -340,7 +340,7 @@ export function ProjectWorkspaceDetail() {queryClient.invalidateQueries({ queryKey: queryKeys.projects.detail(project.id) });queryClient.invalidateQueries({ queryKey: queryKeys.projects.detail(project.urlKey) });if (lookupCompanyId) {- queryClient.invalidateQueries({ queryKey: queryKeys.projects.list(lookupCompanyId) });+ queryClient.invalidateQueries({ queryKey: queryKeys.projects.all(lookupCompanyId) });}};diff --git a/ui/src/pages/RoutineDetail.test.tsx b/ui/src/pages/RoutineDetail.test.tsxnew file mode 100644index 0000000000..e1536a16ea--- /dev/null+++ b/ui/src/pages/RoutineDetail.test.tsx@@ -0,0 +1,18 @@+import { describe, expect, it } from "vitest";+import { buildRoutineProjectOptions } from "./RoutineDetail";++describe("RoutineDetail project selector options", () => {+ it("excludes archived projects from the editor selector", () => {+ expect(buildRoutineProjectOptions([+ { id: "active-project", name: "Active Project", description: "Visible", archivedAt: null },+ {+ id: "archived-project",+ name: "Archived Project",+ description: "Hidden",+ archivedAt: new Date("2026-04-02T00:00:00.000Z"),+ },+ ])).toEqual([+ { id: "active-project", label: "Active Project", searchText: "Visible" },+ ]);+ });+});diff --git a/ui/src/pages/RoutineDetail.tsx b/ui/src/pages/RoutineDetail.tsxindex b2fedbcd66..6460fb4fde 100644--- a/ui/src/pages/RoutineDetail.tsx+++ b/ui/src/pages/RoutineDetail.tsx@@ -69,6 +69,18 @@ import type {const LAST_SECTION_STORAGE_KEY = "paperclip.routineLastSection";+export function buildRoutineProjectOptions(+ projects: ReadonlyArray<{ id: string; name: string; description?: string | null; archivedAt?: Date | string | null }>,+): InlineEntityOption[] {+ return projects+ .filter((project) => !project.archivedAt)+ .map((project) => ({+ id: project.id,+ label: project.name,+ searchText: project.description ?? "",+ }));+}+const SECTION_TITLES: Record<RoutineSectionKey, string> = {overview: "Overview",triggers: "Triggers",@@ -220,8 +232,8 @@ export function RoutineDetail() {enabled: !!selectedCompanyId,});const { data: projects } = useQuery({- queryKey: queryKeys.projects.list(selectedCompanyId!),- queryFn: () => projectsApi.list(selectedCompanyId!),+ queryKey: queryKeys.projects.list(selectedCompanyId!, { includeArchived: true }),+ queryFn: () => projectsApi.list(selectedCompanyId!, { includeArchived: true }),enabled: !!selectedCompanyId,});const { data: companyMembers } = useQuery({@@ -567,16 +579,15 @@ export function RoutineDetail() {[agents, recentAssigneeIds],);const projectOptions = useMemo<InlineEntityOption[]>(- () =>- (projects ?? []).map((project) => ({- id: project.id,- label: project.name,- searchText: project.description ?? "",- })),+ () => buildRoutineProjectOptions(projects ?? []),[projects],);const mentionOptions = useMemo<MentionOption[]>(- () => buildMarkdownMentionOptions({ agents, projects, members: companyMembers?.users }),+ () => buildMarkdownMentionOptions({+ agents,+ projects: (projects ?? []).filter((project) => !project.archivedAt),+ members: companyMembers?.users,+ }),[agents, companyMembers?.users, projects],);diff --git a/ui/src/pages/Routines.test.tsx b/ui/src/pages/Routines.test.tsxindex bda84cbce5..9e1dae7e8f 100644--- a/ui/src/pages/Routines.test.tsx+++ b/ui/src/pages/Routines.test.tsx@@ -26,6 +26,7 @@ const markdownEditorRenderMock = vi.fn((props: { mentions?: Array<{ id: string;const issuesListRenderMock = vi.fn(({ issues }: { issues: Issue[] }) => (<div data-testid="issues-list">{issues.map((issue) => issue.title).join(", ")}</div>));+const inlineEntitySelectorRenderMock = vi.fn((props: { options?: Array<{ id: string }> }) => props);vi.mock("@/lib/router", () => ({Link: ({ to, children, ...props }: AnchorHTMLAttributes<HTMLAnchorElement> & { to: string; children: ReactNode }) => (@@ -180,6 +181,29 @@ vi.mock("../api/projects", () => ({createdAt: new Date("2026-04-01T00:00:00.000Z"),updatedAt: new Date("2026-04-01T00:00:00.000Z"),},+ {+ id: "project-archived",+ companyId: "company-1",+ urlKey: "project-archived",+ goalId: null,+ goalIds: [],+ goals: [],+ name: "Archived Project",+ description: null,+ status: "completed",+ leadAgentId: null,+ targetDate: null,+ color: "#94a3b8",+ pauseReason: null,+ pausedAt: null,+ archivedAt: new Date("2026-04-02T00:00:00.000Z"),+ executionWorkspacePolicy: null,+ codebase: null,+ workspaces: [],+ primaryWorkspace: null,+ createdAt: new Date("2026-04-01T00:00:00.000Z"),+ updatedAt: new Date("2026-04-01T00:00:00.000Z"),+ },]),},}));@@ -237,7 +261,10 @@ vi.mock("../components/MarkdownEditor", () => ({}));vi.mock("../components/InlineEntitySelector", () => ({- InlineEntitySelector: () => <button type="button">selector</button>,+ InlineEntitySelector: (props: { options?: Array<{ id: string }> }) => {+ inlineEntitySelectorRenderMock(props);+ return <button type="button">selector</button>;+ },}));vi.mock("../components/RoutineRunVariablesDialog", () => ({@@ -365,6 +392,7 @@ describe("Routines page", () => {issuesListMock.mockReset();markdownEditorRenderMock.mockClear();issuesListRenderMock.mockClear();+ inlineEntitySelectorRenderMock.mockClear();localStorage.clear();});@@ -792,6 +820,56 @@ describe("Routines page", () => {});});+ it("excludes archived projects from the create composer project selector", async () => {+ routinesListMock.mockResolvedValue([]);+ issuesListMock.mockResolvedValue([]);++ const root = createRoot(container);+ const queryClient = new QueryClient({+ defaultOptions: {+ queries: { retry: false },+ },+ });++ await act(async () => {+ root.render(+ <QueryClientProvider client={queryClient}>+ <Routines />+ </QueryClientProvider>,+ );+ await flush();+ });++ let createButton = Array.from(container.querySelectorAll("button")).find((button) =>+ button.textContent?.includes("Create routine"),+ );+ for (let attempts = 0; attempts < 5 && !createButton; attempts += 1) {+ await act(async () => {+ await flush();+ });+ createButton = Array.from(container.querySelectorAll("button")).find((button) =>+ button.textContent?.includes("Create routine"),+ );+ }++ await act(async () => {+ createButton?.click();+ await flush();+ });++ const projectSelectorCall = inlineEntitySelectorRenderMock.mock.calls.find(([props]) => {+ const ids = (props.options ?? []).map((option) => option.id);+ return ids.includes("project-1") && ids.includes("project-2");+ });++ expect(projectSelectorCall).toBeTruthy();+ expect(projectSelectorCall?.[0].options?.map((option) => option.id)).toEqual(["project-1", "project-2"]);++ await act(async () => {+ root.unmount();+ });+ });+it("passes company mention options to the routine description editor", async () => {routinesListMock.mockResolvedValue([]);issuesListMock.mockResolvedValue([]);diff --git a/ui/src/pages/Routines.tsx b/ui/src/pages/Routines.tsxindex a3a3fedbfd..a0add0acff 100644--- a/ui/src/pages/Routines.tsx+++ b/ui/src/pages/Routines.tsx@@ -357,8 +357,8 @@ export function Routines() {enabled: !!selectedCompanyId,});const { data: projects } = useQuery({- queryKey: queryKeys.projects.list(selectedCompanyId!),- queryFn: () => projectsApi.list(selectedCompanyId!),+ queryKey: queryKeys.projects.list(selectedCompanyId!, { includeArchived: true }),+ queryFn: () => projectsApi.list(selectedCompanyId!, { includeArchived: true }),enabled: !!selectedCompanyId,});const { data: companyMembers } = useQuery({@@ -396,7 +396,7 @@ export function Routines() {const mentionOptions = useMemo<MentionOption[]>(() => {return buildMarkdownMentionOptions({agents,- projects,+ projects: (projects ?? []).filter((project) => !project.archivedAt),members: companyMembers?.users,});}, [agents, companyMembers?.users, projects]);@@ -602,7 +602,7 @@ export function Routines() {);const projectOptions = useMemo<InlineEntityOption[]>(() =>- (projects ?? []).map((project) => ({+ (projects ?? []).filter((project) => !project.archivedAt).map((project) => ({id: project.id,label: project.name,searchText: project.description ?? "",diff --git a/ui/src/pages/Search.tsx b/ui/src/pages/Search.tsxindex 25bdf62e98..51625bd02b 100644--- a/ui/src/pages/Search.tsx+++ b/ui/src/pages/Search.tsx@@ -225,8 +225,8 @@ export function Search() {});const { data: projects = [] } = useQuery({- queryKey: queryKeys.projects.list(selectedCompanyId!),- queryFn: () => projectsApi.list(selectedCompanyId!),+ queryKey: queryKeys.projects.list(selectedCompanyId!, { includeArchived: true }),+ queryFn: () => projectsApi.list(selectedCompanyId!, { includeArchived: true }),enabled: !!selectedCompanyId,});diff --git a/ui/src/pages/Training.tsx b/ui/src/pages/Training.tsxindex bae39b5b4c..751385455d 100644--- a/ui/src/pages/Training.tsx+++ b/ui/src/pages/Training.tsx@@ -99,8 +99,8 @@ export function TrainingLibrary() {enabled: Boolean(selectedCompanyId),});const projectsQuery = useQuery({- queryKey: ["projects", selectedCompanyId],- queryFn: () => projectsApi.list(selectedCompanyId!),+ queryKey: queryKeys.projects.list(selectedCompanyId ?? "", { includeArchived: true }),+ queryFn: () => projectsApi.list(selectedCompanyId!, { includeArchived: true }),enabled: Boolean(selectedCompanyId),});const records = recordsQuery.data ?? [];diff --git a/ui/src/pages/apps/gateways/GatewayDetail.tsx b/ui/src/pages/apps/gateways/GatewayDetail.tsxindex d8ed2e7ac2..e19ea2c4dc 100644--- a/ui/src/pages/apps/gateways/GatewayDetail.tsx+++ b/ui/src/pages/apps/gateways/GatewayDetail.tsx@@ -62,8 +62,8 @@ export function GatewayDetail() {enabled: !!selectedCompanyId,});const projectsQuery = useQuery({- queryKey: queryKeys.projects.list(selectedCompanyId ?? "__none__"),- queryFn: () => projectsApi.list(selectedCompanyId!),+ queryKey: queryKeys.projects.list(selectedCompanyId ?? "__none__", { includeArchived: true }),+ queryFn: () => projectsApi.list(selectedCompanyId!, { includeArchived: true }),enabled: !!selectedCompanyId,});diff --git a/ui/src/pages/tools/GatewaysTab.tsx b/ui/src/pages/tools/GatewaysTab.tsxindex 7cf84d8e76..4c561db496 100644--- a/ui/src/pages/tools/GatewaysTab.tsx+++ b/ui/src/pages/tools/GatewaysTab.tsx@@ -138,8 +138,8 @@ export function GatewaysTab({ companyId }: { companyId: string }) {queryFn: () => agentsApi.list(companyId),});const projectsQuery = useQuery({- queryKey: queryKeys.projects.list(companyId),- queryFn: () => projectsApi.list(companyId),+ queryKey: queryKeys.projects.list(companyId, { includeArchived: true }),+ queryFn: () => projectsApi.list(companyId, { includeArchived: true }),});const origin = useMemo(() => {diff --git a/ui/src/pages/tools/PoliciesTab.tsx b/ui/src/pages/tools/PoliciesTab.tsxindex d3a71efb07..a1f758ff00 100644--- a/ui/src/pages/tools/PoliciesTab.tsx+++ b/ui/src/pages/tools/PoliciesTab.tsx@@ -812,8 +812,8 @@ export function PoliciesTab({ companyId }: { companyId: string }) {queryFn: () => agentsApi.list(companyId),});const projects = useQuery({- queryKey: queryKeys.projects.list(companyId),- queryFn: () => projectsApi.list(companyId),+ queryKey: queryKeys.projects.list(companyId, { includeArchived: true }),+ queryFn: () => projectsApi.list(companyId, { includeArchived: true }),});const applications = useQuery({queryKey: queryKeys.tools.applications(companyId),@@ -958,7 +958,7 @@ export function PoliciesTab({ companyId }: { companyId: string }) {const saving = createPolicy.isPending || updatePolicy.isPending;const agentsList = agents.data ?? [];- const projectsList = projects.data ?? [];+ const projectsList = (projects.data ?? []).filter((project) => !project.archivedAt);const applicationList = applications.data?.applications ?? [];if (form) {diff --git a/ui/src/pages/tools/ProfilesTab.tsx b/ui/src/pages/tools/ProfilesTab.tsxindex ecaacc1535..6b58e00806 100644--- a/ui/src/pages/tools/ProfilesTab.tsx+++ b/ui/src/pages/tools/ProfilesTab.tsx@@ -312,8 +312,8 @@ function useLookupData(companyId: string) {queryFn: () => agentsApi.list(companyId),});const projects = useQuery({- queryKey: queryKeys.projects.list(companyId),- queryFn: () => projectsApi.list(companyId),+ queryKey: queryKeys.projects.list(companyId, { includeArchived: true }),+ queryFn: () => projectsApi.list(companyId, { includeArchived: true }),});const routines = useQuery({queryKey: queryKeys.routines.list(companyId),@@ -702,7 +702,7 @@ export function ProfilesTab({ companyId }: { companyId: string }) {const applicationOptions = lookups.applications.data?.applications ?? [];const connectionOptions = lookups.connections.data?.connections ?? [];const agentOptions = lookups.agents.data ?? [];- const projectOptions = lookups.projects.data ?? [];+ const projectOptions = (lookups.projects.data ?? []).filter((project) => !project.archivedAt);const routineOptions = lookups.routines.data ?? [];const invalidateProfiles = () => {diff --git a/ui/src/plugins/bridge-init.ts b/ui/src/plugins/bridge-init.tsindex f6370417bd..4c8f876900 100644--- a/ui/src/plugins/bridge-init.ts+++ b/ui/src/plugins/bridge-init.ts@@ -267,8 +267,8 @@ function PluginSdkIssuesList({enabled: !!companyId,});const { data: projects } = useQuery({- queryKey: queryKeys.projects.list(companyId ?? "__no-company__"),- queryFn: () => projectsApi.list(companyId!),+ queryKey: queryKeys.projects.list(companyId ?? "__no-company__", { includeArchived: true }),+ queryFn: () => projectsApi.list(companyId!, { includeArchived: true }),enabled: !!companyId,});const liveRunsQueryKey = queryKeys.liveRuns(companyId ?? "__no-company__");@@ -464,8 +464,8 @@ function PluginSdkProjectPicker({});const currentUserId = session?.user?.id ?? session?.session?.userId ?? null;const { data: projects } = useQuery({- queryKey: queryKeys.projects.list(resolvedCompanyId ?? "__no-company__"),- queryFn: () => projectsApi.list(resolvedCompanyId!),+ queryKey: queryKeys.projects.list(resolvedCompanyId ?? "__no-company__", { includeArchived }),+ queryFn: () => projectsApi.list(resolvedCompanyId!, { includeArchived }),enabled: !!resolvedCompanyId,});const visibleProjects = useMemo(