Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

1.0 KB
Raw Blame
import { isSessionArchived } from '@service-agent-harness/session-archive';
import type { AgentsMode } from './mode';
import {
  type AgentConversationEntity,
  conversationTimestamp,
} from './recent-conversations';

/** Select the current user's active coding sessions with open pull requests. */
export function selectOpenPullRequests(
  conversations: readonly AgentConversationEntity[],
  ownerId: string | undefined,
  modeForConversation: (conversation: AgentConversationEntity) => AgentsMode
): AgentConversationEntity[] {
  if (!ownerId) return [];

  return conversations
    .filter(
      (conversation) =>
        conversation.type === 'agent_session' &&
        conversation.ownerId === ownerId &&
        !isSessionArchived(conversation) &&
        modeForConversation(conversation) === 'code' &&
        (conversation.pullRequestState === 'open' ||
          conversation.pullRequestState === 'draft')
    )
    .toSorted(
      (left, right) =>
        conversationTimestamp(right) - conversationTimestamp(left)
    );
}