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.

749 B
Raw Blame
'use client';

import type { AiChatThread } from '@/lib/api/endpoints/agentChat';
import { useLoadedAgentThreads } from '@/services/aiAgents.service';

// The saved thread the panel is showing, which is what carries the facts about the
// conversation that are not in its transcript: the session an external agent's runner
// keeps for it, and the context size of its last answer. Null until the thread list
// holds it — a fresh chat has no thread yet.
export function useShownThread(
  projectKey: string,
  agentId: number | null,
  threadId: string | null,
): AiChatThread | null {
  const threads = useLoadedAgentThreads(projectKey, agentId);
  if (!threadId) return null;
  return threads.find((thread) => thread.id === threadId) ?? null;
}