🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
chore(playground): Disable run all button without model (#10740)
Michael Fröhlicheb40cd95ebbf
diff --git a/web/src/features/playground/page/components/NoModelConfiguredAlert.tsx b/web/src/features/playground/page/components/NoModelConfiguredAlert.tsxnew file mode 100644index 0000000000..9bd100e339--- /dev/null+++ b/web/src/features/playground/page/components/NoModelConfiguredAlert.tsx@@ -0,0 +1,35 @@+import { AlertCircle, Settings } from "lucide-react";+import Link from "next/link";+import { Alert, AlertDescription, AlertTitle } from "@/src/components/ui/alert";++interface NoModelConfiguredAlertProps {+ projectId: string;+}++export function NoModelConfiguredAlert({+ projectId,+}: NoModelConfiguredAlertProps) {+ return (+ <div className="p-4">+ <Alert+ variant="default"+ className="border-yellow-500/50 bg-yellow-50 dark:bg-yellow-950/20"+ >+ <AlertCircle className="h-4 w-4 text-yellow-600 dark:text-yellow-500" />+ <AlertTitle className="text-yellow-800 dark:text-yellow-400">+ No Model Configured+ </AlertTitle>+ <AlertDescription className="text-yellow-700 dark:text-yellow-500">+ To use the playground, you need to configure a model first. Go to{" "}+ <Link+ href={`/project/${projectId}/settings/llm-connections`}+ className="font-medium underline underline-offset-4 hover:text-yellow-900 dark:hover:text-yellow-300"+ >+ <Settings className="inline h-3 w-3" /> LLM Connection Settings+ </Link>{" "}+ to add an LLM API key and configure your models.+ </AlertDescription>+ </Alert>+ </div>+ );+}diff --git a/web/src/features/playground/page/context/index.tsx b/web/src/features/playground/page/context/index.tsxindex 9b16643372..c867d4df5b 100644--- a/web/src/features/playground/page/context/index.tsx+++ b/web/src/features/playground/page/context/index.tsx@@ -557,6 +557,9 @@ export const PlaygroundProvider: React.FC<PlaygroundProviderProps> = ({isStreamingRef.current = false;},getIsStreaming: () => isStreamingRef.current,+ hasModelConfigured: () => {+ return Boolean(modelParams.provider.value && modelParams.model.value);+ },};registerWindow(effectiveWindowId, playgroundHandle);@@ -610,7 +613,15 @@ export const PlaygroundProvider: React.FC<PlaygroundProviderProps> = ({handleGlobalStop,);};- }, [windowId, handleSubmit, registerWindow, unregisterWindow, messages]);+ }, [+ windowId,+ handleSubmit,+ registerWindow,+ unregisterWindow,+ messages,+ modelParams.provider.value,+ modelParams.model.value,+ ]);// Keep ref in sync with state for external consumersuseEffect(() => {@@ -628,6 +639,21 @@ export const PlaygroundProvider: React.FC<PlaygroundProviderProps> = ({);}, [windowId, isStreaming]);+ // Notify when model configuration changes+ useEffect(() => {+ const playgroundEventBus = getPlaygroundEventBus();+ playgroundEventBus.dispatchEvent(+ new CustomEvent(PLAYGROUND_EVENTS.WINDOW_MODEL_CONFIG_CHANGE, {+ detail: {+ windowId: windowId || MULTI_WINDOW_CONFIG.DEFAULT_WINDOW_ID,+ hasModel: Boolean(+ modelParams.provider.value && modelParams.model.value,+ ),+ },+ }),+ );+ }, [windowId, modelParams.provider.value, modelParams.model.value]);+return (<PlaygroundContext.Providervalue={{diff --git a/web/src/features/playground/page/hooks/useWindowCoordination.ts b/web/src/features/playground/page/hooks/useWindowCoordination.tsindex 47d339287b..f91ffab369 100644--- a/web/src/features/playground/page/hooks/useWindowCoordination.ts+++ b/web/src/features/playground/page/hooks/useWindowCoordination.ts@@ -1,4 +1,4 @@-import { useCallback, useRef, useState } from "react";+import { useCallback, useEffect, useRef, useState } from "react";import {type PlaygroundHandle,type WindowCoordinationReturn,@@ -34,8 +34,21 @@ const playgroundEventBus = new EventTarget();*/export const useWindowCoordination = (): WindowCoordinationReturn => {const [isExecutingAll, setIsExecutingAll] = useState(false);+ const [hasAnyModelConfigured, setHasAnyModelConfigured] = useState(false);const executionTimeoutRef = useRef<NodeJS.Timeout | null>(null);+ /**+ * Check if any registered window has a model configured+ * Updates the hasAnyModelConfigured state+ */+ const checkModelConfiguration = useCallback(() => {+ const registeredWindows = Array.from(playgroundWindowRegistry.values());+ const hasModel = registeredWindows.some((handle) =>+ handle.hasModelConfigured(),+ );+ setHasAnyModelConfigured(hasModel);+ }, []);+/*** Register a playground window with the global coordination system* Adds the window to the registry and dispatches a registration event@@ -47,6 +60,9 @@ export const useWindowCoordination = (): WindowCoordinationReturn => {(windowId: string, handle: PlaygroundHandle) => {playgroundWindowRegistry.set(windowId, handle);+ // Check model configuration after registration+ checkModelConfiguration();+// Dispatch registration event for potential listenersplaygroundEventBus.dispatchEvent(new CustomEvent(PLAYGROUND_EVENTS.WINDOW_REGISTERED, {@@ -54,7 +70,7 @@ export const useWindowCoordination = (): WindowCoordinationReturn => {}),);},- [],+ [checkModelConfiguration],);/**@@ -63,19 +79,25 @@ export const useWindowCoordination = (): WindowCoordinationReturn => {** @param windowId - Unique identifier for the window to remove*/- const unregisterWindow = useCallback((windowId: string) => {- const wasRegistered = playgroundWindowRegistry.has(windowId);- playgroundWindowRegistry.delete(windowId);+ const unregisterWindow = useCallback(+ (windowId: string) => {+ const wasRegistered = playgroundWindowRegistry.has(windowId);+ playgroundWindowRegistry.delete(windowId);- if (wasRegistered) {- // Dispatch unregistration event for potential listeners- playgroundEventBus.dispatchEvent(- new CustomEvent(PLAYGROUND_EVENTS.WINDOW_UNREGISTERED, {- detail: { windowId },- }),- );- }- }, []);+ if (wasRegistered) {+ // Check model configuration after unregistration+ checkModelConfiguration();++ // Dispatch unregistration event for potential listeners+ playgroundEventBus.dispatchEvent(+ new CustomEvent(PLAYGROUND_EVENTS.WINDOW_UNREGISTERED, {+ detail: { windowId },+ }),+ );+ }+ },+ [checkModelConfiguration],+ );/*** Execute all registered playground windows in parallel@@ -96,6 +118,15 @@ export const useWindowCoordination = (): WindowCoordinationReturn => {return;}+ // Check if any window has a model configured+ const hasModel = registeredWindows.some((handle) =>+ handle.hasModelConfigured(),+ );+ if (!hasModel) {+ // Don't show error toast - the UI already shows a clear alert banner+ return;+ }+// Dispatch execute-all event firstplaygroundEventBus.dispatchEvent(new CustomEvent(PLAYGROUND_EVENTS.EXECUTE_ALL),@@ -201,6 +232,25 @@ export const useWindowCoordination = (): WindowCoordinationReturn => {return `Executing ${executingCount} of ${totalCount} windows`;}, []);+ // Listen for model configuration changes+ useEffect(() => {+ const handleModelConfigChange = () => {+ checkModelConfiguration();+ };++ playgroundEventBus.addEventListener(+ PLAYGROUND_EVENTS.WINDOW_MODEL_CONFIG_CHANGE,+ handleModelConfigChange,+ );++ return () => {+ playgroundEventBus.removeEventListener(+ PLAYGROUND_EVENTS.WINDOW_MODEL_CONFIG_CHANGE,+ handleModelConfigChange,+ );+ };+ }, [checkModelConfiguration]);+return {registerWindow,unregisterWindow,@@ -208,6 +258,7 @@ export const useWindowCoordination = (): WindowCoordinationReturn => {stopAllWindows,getExecutionStatus,isExecutingAll,+ hasAnyModelConfigured,};};diff --git a/web/src/features/playground/page/index.tsx b/web/src/features/playground/page/index.tsxindex 417a0975aa..871eab521c 100644--- a/web/src/features/playground/page/index.tsx+++ b/web/src/features/playground/page/index.tsx@@ -8,6 +8,8 @@ import useCommandEnter from "@/src/features/playground/page/hooks/useCommandEnteimport { type MultiWindowState } from "@/src/features/playground/page/types";import Page from "@/src/components/layouts/page";import MultiWindowPlayground from "@/src/features/playground/page/components/MultiWindowPlayground";+import { NoModelConfiguredAlert } from "@/src/features/playground/page/components/NoModelConfiguredAlert";+import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";/*** PlaygroundPage Component@@ -31,6 +33,7 @@ import MultiWindowPlayground from "@/src/features/playground/page/components/Mul* - Clean single-header design*/export default function PlaygroundPage() {+ const projectId = useProjectIdFromURL();const { windowIds, isLoaded, addWindowWithCopy, removeWindowId } =usePersistedWindowIds();@@ -39,6 +42,7 @@ export default function PlaygroundPage() {executeAllWindows,getExecutionStatus,isExecutingAll: globalIsExecutingAll,+ hasAnyModelConfigured,} = useWindowCoordination();/**@@ -105,7 +109,7 @@ export default function PlaygroundPage() {? getExecutionStatus() ||`Executing ${windowIds.length} window${windowIds.length === 1 ? "" : "s"}`: getExecutionStatus();- const isRunAllDisabled = globalIsExecutingAll;+ const isRunAllDisabled = globalIsExecutingAll || !hasAnyModelConfigured;const windowState: MultiWindowState = {windowIds,@@ -150,9 +154,13 @@ export default function PlaygroundPage() {onClick={handleExecuteAll}disabled={isRunAllDisabled}className="hidden flex-shrink-0 gap-1 md:flex"- title="Execute all playground windows simultaneously"+ title={+ !hasAnyModelConfigured+ ? "Please configure a model in Project Settings first"+ : "Execute all playground windows simultaneously"+ }>- {isRunAllDisabled ? (+ {globalIsExecutingAll ? (<Loader2 className="h-3 w-3 animate-spin" />) : (<Play className="h-3 w-3" />@@ -166,11 +174,18 @@ export default function PlaygroundPage() {),}}>- <MultiWindowPlayground- windowState={windowState}- onRemoveWindow={removeWindow}- onAddWindow={addWindow}- />+ <div className="flex h-full flex-col">+ {!hasAnyModelConfigured && projectId && (+ <NoModelConfiguredAlert projectId={projectId} />+ )}+ <div className="flex-1 overflow-hidden">+ <MultiWindowPlayground+ windowState={windowState}+ onRemoveWindow={removeWindow}+ onAddWindow={addWindow}+ />+ </div>+ </div></Page>);}diff --git a/web/src/features/playground/page/types.ts b/web/src/features/playground/page/types.tsindex 15ff0597f5..4bd952cc8d 100644--- a/web/src/features/playground/page/types.ts+++ b/web/src/features/playground/page/types.ts@@ -52,6 +52,8 @@ export interface PlaygroundHandle {stopExecution: () => void;/** Getter for current streaming state */getIsStreaming: () => boolean;+ /** Getter for whether a model is configured */+ hasModelConfigured: () => boolean;}/**@@ -71,6 +73,8 @@ export interface WindowCoordinationReturn {getExecutionStatus: () => string | null;/** Whether any windows are currently executing */isExecutingAll: boolean;+ /** Whether any window has a model configured */+ hasAnyModelConfigured: boolean;}/**@@ -104,6 +108,7 @@ export const PLAYGROUND_EVENTS = {WINDOW_REGISTERED: "playground:window-registered",WINDOW_UNREGISTERED: "playground:window-unregistered",WINDOW_EXECUTION_STATE_CHANGE: "playground:window-execution-state-change",+ WINDOW_MODEL_CONFIG_CHANGE: "playground:window-model-config-change",} as const;/**