Skip to content

⭐️⭐️⭐️ 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.

refactor(web): move isForeignAgent out of the issue feature (#520)

Pasqual Troncone0937c33a5c7e
diff --git a/apps/web/src/features/issue/hooks/useCandidatePickItem.tsx b/apps/web/src/features/issue/hooks/useCandidatePickItem.tsx
index 00b5c5d7..a9f2256a 100644
--- a/apps/web/src/features/issue/hooks/useCandidatePickItem.tsx
+++ b/apps/web/src/features/issue/hooks/useCandidatePickItem.tsx
@@ -3,7 +3,7 @@ import type { Assignee } from '@/lib/api/endpoints/projects';
import { useSession } from '@/lib/auth-client';
import Avatar from '@/components/common/Avatar';
import type { PickItem } from '@/components/common/fields/PopoverPick';
-import { isForeignAgent } from '../utils/delegates';
+import { isForeignAgent } from '@/utils/foreignAgent';
// Builds the row one candidate gets in a picker over the project's people and agents,
// shared by the controls that write such a candidate to an issue. An agent bound to
diff --git a/apps/web/src/features/issue/utils/delegates.ts b/apps/web/src/features/issue/utils/delegates.ts
index cc92b8c0..b1d57f2f 100644
--- a/apps/web/src/features/issue/utils/delegates.ts
+++ b/apps/web/src/features/issue/utils/delegates.ts
@@ -1,10 +1,5 @@
import type { Assignee } from '@/lib/api/endpoints/projects';
-
-// An 'owner'-scoped agent only receives the runs of the member it belongs to, so
-// delegating it to anyone else queues work its runner never picks up.
-export function isForeignAgent(a: Assignee, currentUserId: string | null): boolean {
- return a.restrictedToUserId != null && a.restrictedToUserId !== currentUserId;
-}
+import { isForeignAgent } from '@/utils/foreignAgent';
// The agents a picker without room for an explanation should offer.
export function delegatableAgents(assignees: Assignee[], currentUserId: string | null): Assignee[] {
diff --git a/apps/web/src/hooks/useMentionCandidates.ts b/apps/web/src/hooks/useMentionCandidates.ts
index be2b5980..e4592dea 100644
--- a/apps/web/src/hooks/useMentionCandidates.ts
+++ b/apps/web/src/hooks/useMentionCandidates.ts
@@ -3,7 +3,7 @@ import { ShellCtx } from '@/context/shellContext';
import { useSession } from '@/lib/auth-client';
import type { Assignee } from '@/lib/api/endpoints/projects';
import { type MentionCandidate } from '@/lib/tiptap-mention';
-import { isForeignAgent } from '@/features/issue/utils/delegates';
+import { isForeignAgent } from '@/utils/foreignAgent';
// An agent is offered only when a mention by this user would start a run: one that
// does not answer mentions, or works only for another member, would stay silent.
diff --git a/apps/web/src/utils/foreignAgent.ts b/apps/web/src/utils/foreignAgent.ts
new file mode 100644
index 00000000..265a79e6
--- /dev/null
+++ b/apps/web/src/utils/foreignAgent.ts
@@ -0,0 +1,7 @@
+import type { Assignee } from '@/lib/api/endpoints/projects';
+
+// An 'owner'-scoped agent only receives the runs of the member it belongs to, so
+// delegating it to anyone else queues work its runner never picks up.
+export function isForeignAgent(a: Assignee, currentUserId: string | null): boolean {
+ return a.restrictedToUserId != null && a.restrictedToUserId !== currentUserId;
+}