Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(llm-connections): ensure dialog remains open when switching tabs (#8391)

marliessophiec5b781d3f601
diff --git a/web/src/components/ModelParameters/index.tsx b/web/src/components/ModelParameters/index.tsx
index f21c6215e0..ff0401fec5 100644
--- a/web/src/components/ModelParameters/index.tsx
+++ b/web/src/components/ModelParameters/index.tsx
@@ -61,6 +61,9 @@ export const ModelParameters: React.FC<ModelParamsContext> = ({
const [modelSettingsOpen, setModelSettingsOpen] = useState(false);
const [modelSettingsUsed, setModelSettingsUsed] = useState(false);
+ const [createLlmApiKeyDialogOpen, setCreateLlmApiKeyDialogOpen] =
+ useState(false);
+
useEffect(() => {
const hasEnabledModelSetting = Object.keys(modelParams).some(
(key) =>
@@ -88,7 +91,10 @@ export const ModelParameters: React.FC<ModelParamsContext> = ({
</div>
)}
<p className="text-xs">No LLM API key set in project. </p>
- <CreateLLMApiKeyDialog />
+ <CreateLLMApiKeyDialog
+ open={createLlmApiKeyDialogOpen}
+ setOpen={setCreateLlmApiKeyDialogOpen}
+ />
</div>
);
}
@@ -204,7 +210,10 @@ export const ModelParameters: React.FC<ModelParamsContext> = ({
</SelectItem>
))}
<SelectSeparator />
- <CreateLLMApiKeyDialog />
+ <CreateLLMApiKeyDialog
+ open={createLlmApiKeyDialogOpen}
+ setOpen={setCreateLlmApiKeyDialogOpen}
+ />
</SelectContent>
</Select>
{modelParamsDescription ? (
@@ -304,6 +313,9 @@ const ModelParamsSelect = ({
modelParamsDescription,
layout = "vertical",
}: ModelParamsSelectProps) => {
+ const [createLlmApiKeyDialogOpen, setCreateLlmApiKeyDialogOpen] =
+ useState(false);
+
// Compact layout - simplified, space-efficient (no individual labels)
if (layout === "compact") {
return (
@@ -328,7 +340,10 @@ const ModelParamsSelect = ({
</SelectItem>
))}
<SelectSeparator />
- <CreateLLMApiKeyDialog />
+ <CreateLLMApiKeyDialog
+ open={createLlmApiKeyDialogOpen}
+ setOpen={setCreateLlmApiKeyDialogOpen}
+ />
</SelectContent>
</Select>
{modelParamsDescription ? (
@@ -374,7 +389,10 @@ const ModelParamsSelect = ({
</SelectItem>
))}
<SelectSeparator />
- <CreateLLMApiKeyDialog />
+ <CreateLLMApiKeyDialog
+ open={createLlmApiKeyDialogOpen}
+ setOpen={setCreateLlmApiKeyDialogOpen}
+ />
</SelectContent>
</Select>
{modelParamsDescription ? (
diff --git a/web/src/features/public-api/components/CreateLLMApiKeyDialog.tsx b/web/src/features/public-api/components/CreateLLMApiKeyDialog.tsx
index a39e3ed991..485b38487c 100644
--- a/web/src/features/public-api/components/CreateLLMApiKeyDialog.tsx
+++ b/web/src/features/public-api/components/CreateLLMApiKeyDialog.tsx
@@ -1,6 +1,4 @@
import { PlusIcon } from "lucide-react";
-import { useState } from "react";
-
import { Button } from "@/src/components/ui/button";
import {
Dialog,
@@ -14,9 +12,14 @@ import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";
import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";
import { CreateLLMApiKeyForm } from "@/src/features/public-api/components/CreateLLMApiKeyForm";
-export function CreateLLMApiKeyDialog() {
+export function CreateLLMApiKeyDialog({
+ open,
+ setOpen,
+}: {
+ open: boolean;
+ setOpen: (open: boolean) => void;
+}) {
const projectId = useProjectIdFromURL();
- const [open, setOpen] = useState(false);
const hasAccess = useHasProjectAccess({
projectId,
scope: "llmApiKeys:create",
diff --git a/web/src/features/public-api/components/LLMApiKeyList.tsx b/web/src/features/public-api/components/LLMApiKeyList.tsx
index 075d835cee..54ee892bc5 100644
--- a/web/src/features/public-api/components/LLMApiKeyList.tsx
+++ b/web/src/features/public-api/components/LLMApiKeyList.tsx
@@ -29,6 +29,7 @@ import { UpdateLLMApiKeyDialog } from "./UpdateLLMApiKeyDialog";
export function LlmApiKeyList(props: { projectId: string }) {
const [editingKeyId, setEditingKeyId] = useState<string | null>(null);
+ const [open, setOpen] = useState(false);
const hasAccess = useHasProjectAccess({
projectId: props.projectId,
@@ -148,7 +149,7 @@ export function LlmApiKeyList(props: { projectId: string }) {
</TableBody>
</Table>
</Card>
- <CreateLLMApiKeyDialog />
+ <CreateLLMApiKeyDialog open={open} setOpen={setOpen} />
</div>
);
}