Files
kandev/apps/web/components/task/chat/composer-workspace.ts
T
José Almeida 7de788ceed feat: add cross-integration entity references (#1862)
* feat: add cross-integration entity references

* fix(web): anchor entity reference menu to composer

* fix: keep Kandev tasks under @ mentions

* fix: address entity reference review findings

* test(e2e): use option role for prompt menu

* test(e2e): update passthrough mention roles

* fix: preserve queued references and paginate Azure PRs
2026-07-23 09:03:56 +01:00

27 lines
1.1 KiB
TypeScript

type TaskIdentity = { id: string };
type WorkflowIdentity = { id: string; workspaceId: string };
type QuickChatIdentity = { sessionId: string; workspaceId: string };
type WorkflowSnapshot = { workflowId: string; tasks: readonly TaskIdentity[] };
export function resolveComposerWorkspaceId(args: {
sessionId: string | null;
taskId: string | null;
quickChatSessions: readonly QuickChatIdentity[];
activeWorkflowId: string | null;
activeTasks: readonly TaskIdentity[];
snapshots: readonly WorkflowSnapshot[];
workflows: readonly WorkflowIdentity[];
}): string | null {
const quickChat = args.quickChatSessions.find((item) => item.sessionId === args.sessionId);
if (quickChat) return quickChat.workspaceId;
if (!args.taskId) return null;
const activeWorkflowOwnsTask = args.activeTasks.some((task) => task.id === args.taskId);
const workflowId = activeWorkflowOwnsTask
? args.activeWorkflowId
: (args.snapshots.find((snapshot) => snapshot.tasks.some((task) => task.id === args.taskId))
?.workflowId ?? null);
if (!workflowId) return null;
return args.workflows.find((workflow) => workflow.id === workflowId)?.workspaceId ?? null;
}