Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { useLingui } from "@lingui/react/macro";
import type { AppRouter } from "@superset/host-service/trpc";
import { workspaceTrpc } from "@superset/workspace-client";
import {
keepPreviousData,
QueryClient,
useQuery,
useQueryClient,
} from "@tanstack/react-query";
import { TRPCClientError } from "@trpc/client";
import { observable } from "@trpc/server/observable";
import { type ReactNode, useEffect } from "react";
import { cloudTrpc } from "renderer/lib/cloud-trpc";
import { electronQueryClient } from "renderer/providers/ElectronTRPCProvider";
Expand All @@ -23,6 +28,21 @@ const PREFETCHED_CHATS = 5;
const STALE_MS = 60_000;
const NO_PROMPTS: never[] = [];

/** Transcript rows call workspace hooks, which need a client even with no box to reach. */
const noHostClient = workspaceTrpc.createClient({
links: [
() => () =>
observable((observer) =>
observer.error(
new TRPCClientError<AppRouter>("The workspace has no host yet"),
),
),
],
});
const noHostQueryClient = new QueryClient({
defaultOptions: { queries: { retry: false } },
});

/**
* A cloud workspace's newest chat as the database holds it, while the
* workspace waits for its box to answer, else `fallback`. It is cached under
Expand Down Expand Up @@ -86,11 +106,16 @@ export function StoredCloudChat({
})
}
/>
<StoredChatTranscript
chatId={chatId}
pending={NO_PROMPTS}
snapshot={stored.data}
/>
<workspaceTrpc.Provider
client={noHostClient}
queryClient={noHostQueryClient}
>
<StoredChatTranscript
chatId={chatId}
pending={NO_PROMPTS}
snapshot={stored.data}
/>
</workspaceTrpc.Provider>
<div className="h-6" />
</div>
);
Expand Down
Loading