Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

997 B
Raw Blame
import type { AssistantDotMatrixState } from "./assistant-dot-matrix";

interface AssistantActivityStateInput {
  isRunning: boolean;
  latestPartType: string | undefined;
  needsApproval: boolean;
  failed: boolean;
}

export const getRunningAssistantPartType = (
  messageStatusType: string | undefined,
  latestPartType: string | undefined,
  latestToolComplete = false,
) => {
  if (messageStatusType !== "running") return undefined;
  if (latestPartType === "tool-call" && latestToolComplete) return undefined;
  return latestPartType;
};

export const getAssistantActivityState = ({
  isRunning,
  latestPartType,
  needsApproval,
  failed,
}: AssistantActivityStateInput): AssistantDotMatrixState => {
  if (isRunning) {
    if (latestPartType === "tool-call") return "waiting";
    if (latestPartType === undefined || latestPartType === "reasoning") return "thinking";
    return "streaming";
  }
  if (needsApproval) return "waiting";
  if (failed) return "error";
  return "success";
};