Skip to content

Commit bc65a03

Browse files
authored
Onboarding Flow (#100)
1 parent 77079eb commit bc65a03

File tree

95 files changed

+9227
-6688
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+9227
-6688
lines changed

.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
BACKEND_URL=http://localhost:8000
1+
BACKEND_URL=http://localhost:8000
2+
NEXT_PUBLIC_GOOGLE_CLIENT_ID=your-google-client-id.apps.googleusercontent.com

app/(main)/configurations/page.tsx

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import { useRouter } from "next/navigation";
1010
import Sidebar from "@/app/components/Sidebar";
1111
import PageHeader from "@/app/components/PageHeader";
1212
import { colors } from "@/app/lib/colors";
13-
import { usePaginatedList } from "@/app/hooks/usePaginatedList";
14-
import { useInfiniteScroll } from "@/app/hooks/useInfiniteScroll";
13+
import { usePaginatedList, useInfiniteScroll } from "@/app/hooks";
1514
import ConfigCard from "@/app/components/ConfigCard";
1615
import Loader, { LoaderBox } from "@/app/components/Loader";
1716
import { EvalJob } from "@/app/components/types";
@@ -46,8 +45,8 @@ export default function ConfigLibraryPage() {
4645
Record<string, number>
4746
>({});
4847
const { sidebarCollapsed } = useApp();
49-
const { activeKey } = useAuth();
50-
const apiKey = activeKey?.key;
48+
const { activeKey, isAuthenticated } = useAuth();
49+
const apiKey = activeKey?.key ?? "";
5150
const [searchInput, setSearchInput] = useState("");
5251
const [debouncedQuery, setDebouncedQuery] = useState("");
5352
const [columnCount, setColumnCount] = useState(3);
@@ -101,11 +100,11 @@ export default function ConfigLibraryPage() {
101100

102101
useEffect(() => {
103102
const fetchEvaluationCounts = async () => {
104-
if (!activeKey) return;
103+
if (!isAuthenticated) return;
105104
try {
106105
const data = await apiFetch<EvalJob[] | { data: EvalJob[] }>(
107106
"/api/evaluations",
108-
activeKey.key,
107+
apiKey,
109108
);
110109
const jobs: EvalJob[] = Array.isArray(data) ? data : data.data || [];
111110
const counts: Record<string, number> = {};
@@ -130,7 +129,7 @@ export default function ConfigLibraryPage() {
130129
await existing;
131130
return;
132131
}
133-
if (!apiKey) return;
132+
if (!isAuthenticated) return;
134133

135134
const loadPromise = (async () => {
136135
const res = await apiFetch<{
@@ -145,15 +144,15 @@ export default function ConfigLibraryPage() {
145144
pendingVersionLoads.set(configId, loadPromise);
146145
await loadPromise;
147146
},
148-
[apiKey],
147+
[apiKey, isAuthenticated],
149148
);
150149

151150
const loadSingleVersion = useCallback(
152151
async (configId: string, version: number): Promise<SavedConfig | null> => {
153152
const key = `${configId}:${version}`;
154153
const existing = pendingSingleVersionLoads.get(key);
155154
if (existing) return existing;
156-
if (!apiKey) return null;
155+
if (!isAuthenticated) return null;
157156

158157
const configPublic =
159158
configs.find((c) => c.id === configId) ??
@@ -180,7 +179,7 @@ export default function ConfigLibraryPage() {
180179
pendingSingleVersionLoads.set(key, loadPromise);
181180
return loadPromise;
182181
},
183-
[apiKey, configs],
182+
[apiKey, configs, isAuthenticated],
184183
);
185184

186185
const handleCreateNew = () => {
@@ -278,17 +277,7 @@ export default function ConfigLibraryPage() {
278277
) : error ? (
279278
<div className="rounded-lg p-6 text-center bg-[#fef2f2] border border-[#fecaca]">
280279
<WarningTriangleIcon className="w-12 h-12 mx-auto mb-3 text-[#dc2626]" />
281-
<p className="text-sm font-medium text-[#dc2626]">{error}</p>
282-
<button
283-
onClick={() => router.push("/keystore")}
284-
className="mt-4 px-4 py-2 rounded-md text-sm font-medium transition-colors"
285-
style={{
286-
backgroundColor: colors.accent.primary,
287-
color: colors.bg.primary,
288-
}}
289-
>
290-
Go to Keystore
291-
</button>
280+
<p className="text-sm font-medium text-status-error">{error}</p>
292281
</div>
293282
) : configs.length === 0 ? (
294283
<div

app/(main)/configurations/prompt-editor/page.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { useToast } from "@/app/components/Toast";
1919
import Loader from "@/app/components/Loader";
2020
import { useApp } from "@/app/lib/context/AppContext";
2121
import { useAuth } from "@/app/lib/context/AuthContext";
22-
import { useConfigs } from "@/app/hooks/useConfigs";
22+
import { useConfigs } from "@/app/hooks";
2323
import {
2424
SavedConfig,
2525
ConfigCreate,
@@ -36,7 +36,7 @@ function PromptEditorContent() {
3636
const toast = useToast();
3737
const searchParams = useSearchParams();
3838
const { sidebarCollapsed } = useApp();
39-
const { activeKey } = useAuth();
39+
const { activeKey, isAuthenticated } = useAuth();
4040
const urlConfigId = searchParams.get("config");
4141
const urlVersion = searchParams.get("version");
4242
const showHistory = searchParams.get("history") === "true";
@@ -253,9 +253,9 @@ function PromptEditorContent() {
253253
return;
254254
}
255255

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

0 commit comments

Comments
 (0)