Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

943 B
Raw Blame
import { useQuery } from "@tanstack/react-query";
import { useMemo } from "react";

import { useTeamHubRuntime } from "@/features/teamhub/teamhub-runtime";

import { roomMessageRunStatusesQueryOptions } from "../room-queries";

export function useRoomMessageRunStatuses({
  messageIds,
  roomId,
  tenantId,
}: {
  messageIds: readonly string[];
  roomId: string;
  tenantId: string;
}) {
  const { client } = useTeamHubRuntime();
  const normalizedMessageIds = useMemo(
    () => normalizeRuntimePresentationMessageIds(messageIds),
    [messageIds],
  );
  const query = useQuery({
    ...roomMessageRunStatusesQueryOptions(
      client,
      tenantId,
      roomId,
      normalizedMessageIds,
    ),
    enabled: normalizedMessageIds.length > 0,
  });
  return query.data?.items ?? [];
}

export function normalizeRuntimePresentationMessageIds(
  messageIds: readonly string[],
) {
  return [...new Set(messageIds.slice(-100))].sort();
}