Skip to content
Merged
Show file tree
Hide file tree
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
16 changes: 9 additions & 7 deletions apps/opik-frontend/src/plugins/comet/AssistantSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ import useRunnerBridgeSync from "@/hooks/useRunnerBridgeSync";
import { BASE_API_URL } from "@/api/api";
import { Spinner } from "@/ui/spinner";
import AssistantErrorState from "@/plugins/comet/AssistantErrorState";
import {
ASSISTANT_DEV_BASE_URL,
IS_ASSISTANT_DEV,
} from "@/plugins/comet/constants/assistant";

const DEV_BASE_URL = import.meta.env.VITE_ASSISTANT_SIDEBAR_BASE_URL;
const IS_DEV = import.meta.env.DEV;
const BRIDGE_PROTOCOL_VERSION = 1;

const LOADER_DEFAULT_WIDTH = 400;
Expand Down Expand Up @@ -219,7 +221,7 @@ const createBridge = (refs: BridgeRefs): AssistantSidebarBridge => ({
);
break;
default:
if (IS_DEV) {
if (IS_ASSISTANT_DEV) {
console.warn(
`[AssistantBridge] Unhandled sidebar event: "${event}"`,
data,
Expand Down Expand Up @@ -298,7 +300,7 @@ interface AssistantMeta {
}

function resolveManifestUrl(backendUrl: string | null): string | null {
if (DEV_BASE_URL) return `${DEV_BASE_URL}/manifest.json`;
if (ASSISTANT_DEV_BASE_URL) return `${ASSISTANT_DEV_BASE_URL}/manifest.json`;
if (backendUrl) return `${backendUrl}/console/manifest.json`;
return null;
}
Expand Down Expand Up @@ -326,16 +328,16 @@ function useAssistantMeta(backendUrl: string | null): AssistantMeta | null {
return {
scriptUrl: `${manifestBase}/${manifest.js}`,
cssUrl: manifest.css ? `${manifestBase}/${manifest.css}` : undefined,
shellUrl: `${manifestBase}/${manifest.shell}`,
shellUrl: `/assistant/${manifest.shell}`,
version: manifest.ver,
};
},
enabled: !(IS_DEV && DEV_BASE_URL) && !!manifestUrl,
enabled: !IS_ASSISTANT_DEV && !!manifestUrl,
staleTime: Infinity,
retry: 1,
});

if (IS_DEV && DEV_BASE_URL) return DEV_META;
if (IS_ASSISTANT_DEV) return DEV_META;

return data ?? null;
}
Expand Down
4 changes: 4 additions & 0 deletions apps/opik-frontend/src/plugins/comet/constants/assistant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const ASSISTANT_DEV_BASE_URL =
(import.meta.env.VITE_ASSISTANT_SIDEBAR_BASE_URL as string) ?? "";

export const IS_ASSISTANT_DEV = ASSISTANT_DEV_BASE_URL !== "";
10 changes: 5 additions & 5 deletions apps/opik-frontend/src/plugins/comet/useAssistantBackend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { useCallback, useEffect, useRef, useState } from "react";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import cometApi from "@/plugins/comet/api";
import { useActiveWorkspaceName } from "@/store/AppStore";
import { IS_ASSISTANT_DEV } from "@/plugins/comet/constants/assistant";

const IS_DEV = import.meta.env.DEV;
const HEALTH_POLL_INTERVAL_MS = 5000;
const HEALTH_POLL_TIMEOUT_MS = 2 * 60 * 1000; // 2 minutes
const HEALTH_KEEPALIVE_MS = 30_000; // 30s keepalive after ready
Expand Down Expand Up @@ -92,14 +92,14 @@ export default function useAssistantBackend(
);
return { baseUrl, enabled: true };
},
enabled: !IS_DEV && configEnabled && !!workspaceName,
enabled: !IS_ASSISTANT_DEV && configEnabled && !!workspaceName,
staleTime: Infinity,
retry: 2,
});

const baseUrl = computeResult?.baseUrl ?? null;
const computeEnabled = computeResult?.enabled ?? false;
const shouldPollHealth = !IS_DEV && !!baseUrl && computeEnabled;
const shouldPollHealth = !IS_ASSISTANT_DEV && !!baseUrl && computeEnabled;

// Track when health polling started — only reset when baseUrl changes
// (not on transient shouldPollHealth flickers)
Expand Down Expand Up @@ -218,8 +218,8 @@ export default function useAssistantBackend(
queueMicrotask(() => resetBackend());
}

// Dev mode — static URL, no network calls (queries are disabled via enabled: !IS_DEV)
if (IS_DEV) return DEV_RESULT;
// Dev mode or local override — static URL, no network calls
if (IS_ASSISTANT_DEV) return DEV_RESULT;

if (computeResult && !computeResult.enabled)
return notReadyResult(null, "disabled", retry, retryCount);
Expand Down
Loading