Skip to content

The open-source app everyone uses to manage agents at work

fix: enable @-mention autocomplete in new project description editor

dottaa6ca3a941865
diff --git a/ui/src/components/NewProjectDialog.tsx b/ui/src/components/NewProjectDialog.tsx
index 4561ac937d..afdb057aa2 100644
--- a/ui/src/components/NewProjectDialog.tsx
+++ b/ui/src/components/NewProjectDialog.tsx
@@ -1,8 +1,9 @@
-import { useRef, useState } from "react";
+import { useMemo, useRef, useState } from "react";
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
import { useDialog } from "../context/DialogContext";
import { useCompany } from "../context/CompanyContext";
import { projectsApi } from "../api/projects";
+import { agentsApi } from "../api/agents";
import { goalsApi } from "../api/goals";
import { assetsApi } from "../api/assets";
import { queryKeys } from "../lib/queryKeys";
@@ -32,7 +33,7 @@ import {
} from "@/components/ui/tooltip";
import { PROJECT_COLORS } from "@paperclipai/shared";
import { cn } from "../lib/utils";
-import { MarkdownEditor, type MarkdownEditorRef } from "./MarkdownEditor";
+import { MarkdownEditor, type MarkdownEditorRef, type MentionOption } from "./MarkdownEditor";
import { StatusBadge } from "./StatusBadge";
import { ChoosePathButton } from "./PathInstructionsModal";
@@ -68,6 +69,29 @@ export function NewProjectDialog() {
enabled: !!selectedCompanyId && newProjectOpen,
});
+ const { data: agents } = useQuery({
+ queryKey: queryKeys.agents.list(selectedCompanyId!),
+ queryFn: () => agentsApi.list(selectedCompanyId!),
+ enabled: !!selectedCompanyId && newProjectOpen,
+ });
+
+ const mentionOptions = useMemo<MentionOption[]>(() => {
+ const options: MentionOption[] = [];
+ const activeAgents = [...(agents ?? [])]
+ .filter((agent) => agent.status !== "terminated")
+ .sort((a, b) => a.name.localeCompare(b.name));
+ for (const agent of activeAgents) {
+ options.push({
+ id: `agent:${agent.id}`,
+ name: agent.name,
+ kind: "agent",
+ agentId: agent.id,
+ agentIcon: agent.icon,
+ });
+ }
+ return options;
+ }, [agents]);
+
const createProject = useMutation({
mutationFn: (data: Record<string, unknown>) =>
projectsApi.create(selectedCompanyId!, data),
@@ -250,6 +274,7 @@ export function NewProjectDialog() {
onChange={setDescription}
placeholder="Add description..."
bordered={false}
+ mentions={mentionOptions}
contentClassName={cn("text-sm text-muted-foreground", expanded ? "min-h-[220px]" : "min-h-[120px]")}
imageUploadHandler={async (file) => {
const asset = await uploadDescriptionImage.mutateAsync(file);