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
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
BACKEND_URL=http://localhost:8000
BACKEND_URL=http://localhost:8000
NEXT_PUBLIC_GOOGLE_CLIENT_ID=your-google-client-id.apps.googleusercontent.com
31 changes: 10 additions & 21 deletions app/(main)/configurations/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import { useRouter } from "next/navigation";
import Sidebar from "@/app/components/Sidebar";
import PageHeader from "@/app/components/PageHeader";
import { colors } from "@/app/lib/colors";
import { usePaginatedList } from "@/app/hooks/usePaginatedList";
import { useInfiniteScroll } from "@/app/hooks/useInfiniteScroll";
import { usePaginatedList, useInfiniteScroll } from "@/app/hooks";
import ConfigCard from "@/app/components/ConfigCard";
import Loader, { LoaderBox } from "@/app/components/Loader";
import { EvalJob } from "@/app/components/types";
Expand Down Expand Up @@ -46,8 +45,8 @@ export default function ConfigLibraryPage() {
Record<string, number>
>({});
const { sidebarCollapsed } = useApp();
const { activeKey } = useAuth();
const apiKey = activeKey?.key;
const { activeKey, isAuthenticated } = useAuth();
const apiKey = activeKey?.key ?? "";
const [searchInput, setSearchInput] = useState("");
const [debouncedQuery, setDebouncedQuery] = useState("");
const [columnCount, setColumnCount] = useState(3);
Expand Down Expand Up @@ -101,11 +100,11 @@ export default function ConfigLibraryPage() {

useEffect(() => {
const fetchEvaluationCounts = async () => {
if (!activeKey) return;
if (!isAuthenticated) return;
try {
const data = await apiFetch<EvalJob[] | { data: EvalJob[] }>(
"/api/evaluations",
activeKey.key,
apiKey,
);
const jobs: EvalJob[] = Array.isArray(data) ? data : data.data || [];
const counts: Record<string, number> = {};
Expand All @@ -130,7 +129,7 @@ export default function ConfigLibraryPage() {
await existing;
return;
}
if (!apiKey) return;
if (!isAuthenticated) return;

const loadPromise = (async () => {
const res = await apiFetch<{
Expand All @@ -145,15 +144,15 @@ export default function ConfigLibraryPage() {
pendingVersionLoads.set(configId, loadPromise);
await loadPromise;
},
[apiKey],
[apiKey, isAuthenticated],
);

const loadSingleVersion = useCallback(
async (configId: string, version: number): Promise<SavedConfig | null> => {
const key = `${configId}:${version}`;
const existing = pendingSingleVersionLoads.get(key);
if (existing) return existing;
if (!apiKey) return null;
if (!isAuthenticated) return null;

const configPublic =
configs.find((c) => c.id === configId) ??
Expand All @@ -180,7 +179,7 @@ export default function ConfigLibraryPage() {
pendingSingleVersionLoads.set(key, loadPromise);
return loadPromise;
},
[apiKey, configs],
[apiKey, configs, isAuthenticated],
);

const handleCreateNew = () => {
Expand Down Expand Up @@ -278,17 +277,7 @@ export default function ConfigLibraryPage() {
) : error ? (
<div className="rounded-lg p-6 text-center bg-[#fef2f2] border border-[#fecaca]">
<WarningTriangleIcon className="w-12 h-12 mx-auto mb-3 text-[#dc2626]" />
<p className="text-sm font-medium text-[#dc2626]">{error}</p>
<button
onClick={() => router.push("/keystore")}
className="mt-4 px-4 py-2 rounded-md text-sm font-medium transition-colors"
style={{
backgroundColor: colors.accent.primary,
color: colors.bg.primary,
}}
>
Go to Keystore
</button>
<p className="text-sm font-medium text-status-error">{error}</p>
</div>
) : configs.length === 0 ? (
<div
Expand Down
10 changes: 5 additions & 5 deletions app/(main)/configurations/prompt-editor/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { useToast } from "@/app/components/Toast";
import Loader from "@/app/components/Loader";
import { useApp } from "@/app/lib/context/AppContext";
import { useAuth } from "@/app/lib/context/AuthContext";
import { useConfigs } from "@/app/hooks/useConfigs";
import { useConfigs } from "@/app/hooks";
import {
SavedConfig,
ConfigCreate,
Expand All @@ -36,7 +36,7 @@ function PromptEditorContent() {
const toast = useToast();
const searchParams = useSearchParams();
const { sidebarCollapsed } = useApp();
const { activeKey } = useAuth();
const { activeKey, isAuthenticated } = useAuth();
const urlConfigId = searchParams.get("config");
const urlVersion = searchParams.get("version");
const showHistory = searchParams.get("history") === "true";
Expand Down Expand Up @@ -253,9 +253,9 @@ function PromptEditorContent() {
return;
}

const apiKey = activeKey?.key;
if (!apiKey) {
toast.error("No API key found. Please add an API key in the Keystore.");
const apiKey = activeKey?.key ?? "";
if (!isAuthenticated) {
toast.error("Please log in to save configurations.");
return;
}

Expand Down
Loading
Loading