Refine issue workflow surfaces and live updates

This commit is contained in:
dotta 2026-04-09 10:26:17 -05:00
parent b4a58ba8a6
commit 03dff1a29a
48 changed files with 2800 additions and 1163 deletions

View file

@ -1,7 +1,7 @@
import { useMemo, useState } from "react";
import { Link } from "@/lib/router";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { heartbeatsApi, type ActiveRunForIssue, type LiveRunForIssue } from "../api/heartbeats";
import { heartbeatsApi, type LiveRunForIssue } from "../api/heartbeats";
import { queryKeys } from "../lib/queryKeys";
import { formatDateTime } from "../lib/utils";
import { ExternalLink, Square } from "lucide-react";
@ -13,8 +13,6 @@ import { useLiveRunTranscripts } from "./transcript/useLiveRunTranscripts";
interface LiveRunWidgetProps {
issueId: string;
companyId?: string | null;
liveRunsData?: LiveRunForIssue[];
activeRunData?: ActiveRunForIssue | null;
}
function toIsoString(value: string | Date | null | undefined): string | null {
@ -26,34 +24,24 @@ function isRunActive(status: string): boolean {
return status === "queued" || status === "running";
}
export function LiveRunWidget({
issueId,
companyId,
liveRunsData,
activeRunData,
}: LiveRunWidgetProps) {
export function LiveRunWidget({ issueId, companyId }: LiveRunWidgetProps) {
const queryClient = useQueryClient();
const [cancellingRunIds, setCancellingRunIds] = useState(new Set<string>());
const shouldFetchLiveRuns = liveRunsData === undefined;
const shouldFetchActiveRun = activeRunData === undefined;
const { data: fetchedLiveRuns } = useQuery({
const { data: liveRuns } = useQuery({
queryKey: queryKeys.issues.liveRuns(issueId),
queryFn: () => heartbeatsApi.liveRunsForIssue(issueId),
enabled: !!issueId && shouldFetchLiveRuns,
enabled: !!issueId,
refetchInterval: 3000,
});
const { data: fetchedActiveRun } = useQuery({
const { data: activeRun } = useQuery({
queryKey: queryKeys.issues.activeRun(issueId),
queryFn: () => heartbeatsApi.activeRunForIssue(issueId),
enabled: !!issueId && shouldFetchActiveRun,
enabled: !!issueId,
refetchInterval: 3000,
});
const liveRuns = liveRunsData ?? fetchedLiveRuns;
const activeRun = activeRunData ?? fetchedActiveRun;
const runs = useMemo(() => {
const deduped = new Map<string, LiveRunForIssue>();
for (const run of liveRuns ?? []) {