@@ -97,14 +110,8 @@ export default function NewDatasetPage() {
const { getToken } = useAppAuth();
const createDataset = useMutation(api.datasets.create);
- const usage = useQuery(
- api.quota.getMy,
- isAuthenticated ? {} : "skip",
- );
+ const usage = useQuery(api.quota.getMy, isAuthenticated ? {} : "skip");
- // Page-view event: fires once when the wizard becomes visible (after
- // auth resolves and the user is authenticated; we don't want to fire
- // for unauth visitors who'll be redirected to /sign-in).
const startFired = useRef(false);
useEffect(() => {
if (!startFired.current && !isLoading && isAuthenticated) {
@@ -139,7 +146,7 @@ export default function NewDatasetPage() {
schema.dataset_name
.split("_")
.map((w) => w.charAt(0).toUpperCase() + w.slice(1))
- .join(" ")
+ .join(" "),
);
setRetrievalStrategy(schema.retrieval_strategy);
setSourceHint(schema.source_hint);
@@ -153,9 +160,13 @@ export default function NewDatasetPage() {
}
}
- function handleUpdateColumn(id: string, field: "name" | "type" | "description", value: string) {
+ function handleUpdateColumn(
+ id: string,
+ field: "name" | "type" | "description",
+ value: string,
+ ) {
setColumns((prev) =>
- prev.map((c) => (c.id === id ? { ...c, [field]: value } : c))
+ prev.map((c) => (c.id === id ? { ...c, [field]: value } : c)),
);
}
@@ -166,26 +177,38 @@ export default function NewDatasetPage() {
function handleAddColumn() {
setColumns((prev) => [
...prev,
- { id: String(Date.now()), name: "New Column", type: "text", description: "", isPrimaryKey: false },
+ {
+ id: String(Date.now()),
+ name: "New Column",
+ type: "text",
+ description: "",
+ isPrimaryKey: false,
+ },
]);
}
async function handleConfirm() {
if (isCreating) return;
+
const maxRowCount = Number(maxRowCountInput);
+
if (!Number.isInteger(maxRowCount) || maxRowCount < 1) {
setError("Max rows must be a whole number greater than 0.");
return;
}
+
if (usage && maxRowCount > usage.remaining) {
setError(
`Max rows cannot exceed your remaining monthly quota of ${usage.remaining.toLocaleString()} row operations.`,
);
return;
}
+
setIsCreating(true);
setError(null);
+
let datasetId: string;
+
try {
datasetId = await createDataset({
name: datasetName,
@@ -202,7 +225,9 @@ export default function NewDatasetPage() {
sourceHint: sourceHint || undefined,
});
} catch (err) {
- const message = err instanceof Error ? err.message : "Failed to create dataset";
+ const message =
+ err instanceof Error ? err.message : "Failed to create dataset";
+
setError(
message.includes("quota exceeded")
? "You've used all of this month's free-tier quota. New datasets will be available again at the start of next month."
@@ -211,6 +236,7 @@ export default function NewDatasetPage() {
setIsCreating(false);
return;
}
+
try {
track(EVENTS.DATASET_CREATED, {
datasetId,
@@ -219,6 +245,7 @@ export default function NewDatasetPage() {
maxRowCount,
});
} catch {}
+
router.push(`/dataset/${datasetId}`);
}
@@ -227,8 +254,16 @@ export default function NewDatasetPage() {
-
-
+
+ /
New Dataset
@@ -244,12 +279,15 @@ export default function NewDatasetPage() {
Create a new dataset
- Describe what data you want to collect. Our agents will figure out the schema; you can start populating it from the dataset page.
+ Describe what data you want to collect. Our agents will figure out
+ the schema; you can start populating it from the dataset page.
-
+
{error && (
-
+
{error}
)}
@@ -279,11 +320,17 @@ export default function NewDatasetPage() {
- Analyzing your request...
+
+ Analyzing your request...
+
-
Figuring out what columns and data sources to use
-
“{prompt}”
+
+ Figuring out what columns and data sources to use
+
+
+ “{prompt}”
+
)}
@@ -301,7 +348,9 @@ export default function NewDatasetPage() {
-
+
-
+
- My Prompt...
+
+ My Prompt...
+
-
Your prompt
-
{prompt}
+
+ Your prompt
+
+
+ {prompt}
+
@@ -325,7 +384,9 @@ export default function NewDatasetPage() {
-
+
{REFRESH_CADENCE_OPTIONS.map((opt) => (
-
+
- Type
- Name
- Description
+
+ Type
+
+
+ Name
+
+
+ Description
+