-
- {response.split("\n").map((line, index) => (
- // biome-ignore lint/suspicious/noArrayIndexKey: <>
-
- {line}
-
-
- ))}
-
+ {(chat.isPending || response) && (
+
+

+
+ {!response && (
+
+
+
+ )}
+
+ {response && (
+
+ {response.split("\n").map((line, index) => (
+ // biome-ignore lint/suspicious/noArrayIndexKey: <>
+
+ {line}
+
+
+ ))}
+
+ )}
)}
-
- {chat.isPending && (
-
-
-
- )}
-
-
+
{models.data && models.data.length > 0 && (
);
}
diff --git a/packages/frontend/src/lib/query/hooks/chat.ts b/packages/frontend/src/lib/query/hooks/chat.ts
index 83eaa93..1b8aee0 100644
--- a/packages/frontend/src/lib/query/hooks/chat.ts
+++ b/packages/frontend/src/lib/query/hooks/chat.ts
@@ -1,5 +1,5 @@
import type { ChatRequest, ChatResponse, ModelsResponse } from "@sprint/shared";
-import { useMutation } from "@tanstack/react-query";
+import { useMutation, useQuery } from "@tanstack/react-query";
import { apiClient } from "@/lib/server";
export function useChat() {
@@ -14,14 +14,17 @@ export function useChat() {
});
}
-export function useModels() {
- return useMutation
({
- mutationKey: ["ai", "models"],
- mutationFn: async () => {
+export function useModels(enabled: boolean) {
+ return useQuery({
+ queryKey: ["ai", "models"],
+ queryFn: async () => {
const { data, error } = await apiClient.aiModels();
if (error) throw new Error(error);
if (!data) throw new Error("failed to get models");
return data as ModelsResponse;
},
+ enabled,
+ retry: false,
+ staleTime: 5 * 60 * 1000,
});
}
diff --git a/packages/frontend/src/pages/Issues.tsx b/packages/frontend/src/pages/Issues.tsx
index 7645a4a..aeac8e6 100644
--- a/packages/frontend/src/pages/Issues.tsx
+++ b/packages/frontend/src/pages/Issues.tsx
@@ -667,15 +667,13 @@ export default function Issues() {
{selectedOrganisationId && selectedProjectId && issuesData.length > 0 && (
-
-
-
-
+
+
{selectedIssue && !showIssueModal && (