diff --git a/apps/cf-ai-backend/src/index.ts b/apps/cf-ai-backend/src/index.ts
index dbc0989b..78e1c596 100644
--- a/apps/cf-ai-backend/src/index.ts
+++ b/apps/cf-ai-backend/src/index.ts
@@ -375,10 +375,6 @@ app.post(
// SLICED to 5 to avoid too many queries
for (const space of spaces.slice(0, 5)) {
if (space && space.length >= 1) {
- console.log(
- "this is the key being used",
- `space-${query.user}-${space}`,
- );
// it's possible for space list to be [undefined] so we only add space filter conditionally
filter[`space-${query.user}-${space}`] = 1;
}
diff --git a/apps/web/app/(auth)/signin/page.tsx b/apps/web/app/(auth)/signin/page.tsx
index b117716e..bfb341ff 100644
--- a/apps/web/app/(auth)/signin/page.tsx
+++ b/apps/web/app/(auth)/signin/page.tsx
@@ -1,14 +1,20 @@
import Image from "next/image";
import Link from "next/link";
import Logo from "@/public/logo.svg";
-import { signIn } from "@/server/auth";
+import { auth, signIn } from "@/server/auth";
import { Google } from "@repo/ui/components/icons";
import gradientStyle from "./_components/TextGradient/gradient.module.css";
import { cn } from "@repo/ui/lib/utils";
+import { redirect } from "next/navigation";
export const runtime = "edge";
async function Signin() {
+ const user = await auth();
+
+ if (user) {
+ await redirect("/home");
+ }
return (
diff --git a/apps/web/app/(dash)/chat/chatWindow.tsx b/apps/web/app/(dash)/chat/chatWindow.tsx
index 99c997e4..32c45246 100644
--- a/apps/web/app/(dash)/chat/chatWindow.tsx
+++ b/apps/web/app/(dash)/chat/chatWindow.tsx
@@ -412,7 +412,7 @@ function ChatWindow({
mini
className="w-full shadow-md"
initialQuery={""}
- initialSpaces={[]}
+ initialSpaces={spaces}
handleSubmit={async (q, spaces) => {
setChatHistory((prevChatHistory) => {
return [
diff --git a/apps/web/app/(dash)/header.tsx b/apps/web/app/(dash)/header/header.tsx
similarity index 78%
rename from apps/web/app/(dash)/header.tsx
rename to apps/web/app/(dash)/header/header.tsx
index 1265fc93..9154ead8 100644
--- a/apps/web/app/(dash)/header.tsx
+++ b/apps/web/app/(dash)/header/header.tsx
@@ -1,11 +1,10 @@
import React from "react";
import Image from "next/image";
import Link from "next/link";
-import Logo from "../../public/logo.svg";
-import { AddIcon, ChatIcon } from "@repo/ui/icons";
+import Logo from "../../../public/logo.svg";
-import { db } from "@/server/db";
-import { getChatHistory } from "../actions/fetchers";
+import { getChatHistory } from "../../actions/fetchers";
+import NewChatButton from "./newChatButton";
async function Header() {
const chatThreads = await getChatHistory();
@@ -26,10 +25,7 @@ async function Header() {
-
+
diff --git a/apps/web/app/(dash)/home/queryinput.tsx b/apps/web/app/(dash)/home/queryinput.tsx
index 868f93f9..3c944c05 100644
--- a/apps/web/app/(dash)/home/queryinput.tsx
+++ b/apps/web/app/(dash)/home/queryinput.tsx
@@ -8,6 +8,8 @@ import { useRouter } from "next/navigation";
import { getSpaces } from "@/app/actions/fetchers";
import Combobox from "@repo/ui/shadcn/combobox";
import { MinusIcon } from "lucide-react";
+import { toast } from "sonner";
+import { createSpace } from "@/app/actions/doers";
function QueryInput({
initialQuery = "",
@@ -16,6 +18,7 @@ function QueryInput({
className,
mini = false,
handleSubmit,
+ setInitialSpaces,
}: {
initialQuery?: string;
initialSpaces?: {
@@ -26,6 +29,9 @@ function QueryInput({
className?: string;
mini?: boolean;
handleSubmit: (q: string, spaces: { id: number; name: string }[]) => void;
+ setInitialSpaces?: React.Dispatch<
+ React.SetStateAction<{ id: number; name: string }[]>
+ >;
}) {
const [q, setQ] = useState(initialQuery);
@@ -104,6 +110,7 @@ function QueryInput({
setSelectedSpaces((prev) => {
if (v === "") {
@@ -112,8 +119,33 @@ function QueryInput({
return [...prev, parseInt(v)];
})
}
- onSubmit={() => {}}
- placeholder="Filter spaces..."
+ onSubmit={async (spaceName) => {
+ const space = options.find((x) => x.label === spaceName);
+ toast.info("Creating space...");
+
+ if (space) {
+ toast.error("A space with that name already exists.");
+ }
+
+ const creationTask = await createSpace(spaceName);
+ if (creationTask.success && creationTask.data) {
+ toast.success("Space created " + creationTask.data);
+ setInitialSpaces?.((prev) => [
+ ...prev,
+ {
+ name: spaceName,
+ id: creationTask.data!,
+ },
+ ]);
+ setSelectedSpaces((prev) => [...prev, creationTask.data!]);
+ } else {
+ toast.error(
+ "Space creation failed: " + creationTask.error ??
+ "Unknown error",
+ );
+ }
+ }}
+ placeholder="Chat with a space..."
/>
diff --git a/apps/web/app/(dash)/layout.tsx b/apps/web/app/(dash)/layout.tsx
index 3ae4e76d..edac6048 100644
--- a/apps/web/app/(dash)/layout.tsx
+++ b/apps/web/app/(dash)/layout.tsx
@@ -1,4 +1,4 @@
-import Header from "./header";
+import Header from "./header/header";
import Menu from "./menu";
import { redirect } from "next/navigation";
import { auth } from "../../server/auth";
diff --git a/apps/web/app/(dash)/menu.tsx b/apps/web/app/(dash)/menu.tsx
index 29d25574..4b03604f 100644
--- a/apps/web/app/(dash)/menu.tsx
+++ b/apps/web/app/(dash)/menu.tsx
@@ -5,7 +5,7 @@ import Image from "next/image";
import Link from "next/link";
import { MemoriesIcon, ExploreIcon, CanvasIcon, AddIcon } from "@repo/ui/icons";
import { Button } from "@repo/ui/shadcn/button";
-import { PlusCircleIcon } from "lucide-react";
+import { MinusIcon, PlusCircleIcon } from "lucide-react";
import {
Dialog,
DialogContent,
@@ -34,8 +34,9 @@ import {
TooltipTrigger,
} from "@repo/ui/shadcn/tooltip";
import { InformationCircleIcon } from "@heroicons/react/24/outline";
-import { createMemory } from "../actions/doers";
+import { createMemory, createSpace } from "../actions/doers";
import { Input } from "@repo/ui/shadcn/input";
+import ComboboxWithCreate from "@repo/ui/shadcn/combobox";
function Menu() {
const [spaces, setSpaces] = useState([]);
@@ -77,7 +78,7 @@ function Menu() {
];
const [content, setContent] = useState("");
- const [selectedSpace, setSelectedSpace] = useState(null);
+ const [selectedSpaces, setSelectedSpaces] = useState([]);
const autoDetectedType = useMemo(() => {
if (content.length === 0) {
@@ -97,6 +98,15 @@ function Menu() {
const [dialogOpen, setDialogOpen] = useState(false);
+ const options = useMemo(
+ () =>
+ spaces.map((x) => ({
+ label: x.name,
+ value: x.id.toString(),
+ })),
+ [spaces],
+ );
+
const handleSubmit = async (content?: string, space?: string) => {
setDialogOpen(false);
@@ -212,7 +222,7 @@ function Menu() {
className="text-[#858B92] flex items-center gap-1 duration-200 transform transition-transform"
htmlFor="space"
>
- Space
+ Spaces
@@ -227,26 +237,81 @@ function Menu() {
-
+
+ ({
+ label: x.name,
+ value: x.id.toString(),
+ }))}
+ onSelect={(v) =>
+ setSelectedSpaces((prev) => {
+ if (v === "") {
+ return [];
+ }
+ return [...prev, parseInt(v)];
+ })
+ }
+ onSubmit={async (spaceName) => {
+ const space = options.find((x) => x.label === spaceName);
+ toast.info("Creating space...");
+
+ if (space) {
+ toast.error("A space with that name already exists.");
+ }
+
+ const creationTask = await createSpace(spaceName);
+ if (creationTask.success && creationTask.data) {
+ toast.success("Space created " + creationTask.data);
+ setSpaces?.((prev) => [
+ ...prev,
+ {
+ name: spaceName,
+ id: creationTask.data!,
+ },
+ ]);
+ setSelectedSpaces((prev) => [
+ ...prev,
+ creationTask.data!,
+ ]);
+ } else {
+ toast.error(
+ "Space creation failed: " + creationTask.error ??
+ "Unknown error",
+ );
+ }
+ }}
+ placeholder="Save or create space by typing."
+ className="bg-[#2B3237] h-min rounded-md mt-2 mb-4"
+ />
+
+