Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

1.3 KB
Raw Blame
import type { PendingHumanReviewModel } from "@/app/api/__generated__/models/pendingHumanReviewModel";

/**
 * Deep link to wherever a pending human review can be acted on.
 *
 * Lives here rather than next to a component so review surfaces (copilot
 * home, thread, library) share one definition of these routes instead of
 * each embedding path literals.
 *
 * `session_id` is set on every chat review; `library_agent_id` comes from
 * the backend's enrichment of reviews raised by a real graph execution.
 *
 * The library route selects a run via `activeTab`/`activeItem` — those are
 * the params `NewAgentLibraryView` actually parses, so anything else lands
 * on the agent page without opening the run.
 *
 * The morning briefing composes these same two routes server-side, in
 * `backend/copilot/briefing/generate.py` (`_run_link` and the decision-link
 * branch of `compose_briefing`) — change both together.
 */
export function getReviewLink(review: PendingHumanReviewModel): string {
  if (review.session_id) {
    return `/copilot?sessionId=${encodeURIComponent(review.session_id)}`;
  }
  if (review.library_agent_id && review.graph_exec_id) {
    return (
      `/library/agents/${encodeURIComponent(review.library_agent_id)}` +
      `?activeTab=runs&activeItem=${encodeURIComponent(review.graph_exec_id)}`
    );
  }
  return "/library";
}