Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
John committed Aug 31, 2024
1 parent c2e8efc commit 7a71cdb
Show file tree
Hide file tree
Showing 12 changed files with 285 additions and 78 deletions.
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@prisma/client": "^5.14.0",
"@radix-ui/react-alert-dialog": "^1.1.1",
"@radix-ui/react-checkbox": "^1.1.1",
"@radix-ui/react-dialog": "^1.1.1",
"@radix-ui/react-dropdown-menu": "^2.1.1",
"@radix-ui/react-hover-card": "^1.1.1",
"@radix-ui/react-scroll-area": "^1.1.0",
Expand All @@ -39,6 +40,7 @@
"react-dropzone": "^14.2.3",
"react-pdf": "^9.1.0",
"server-only": "^0.0.1",
"simple-icons": "^13.7.0",
"superjson": "^2.2.1",
"tailwind-merge": "^2.5.2",
"tailwindcss-animate": "^1.0.7",
Expand Down
1 change: 1 addition & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ model Analysis {
conclusion String
quote String
refPage Int
refContent String
refId Int
refTitle String
}
Binary file modified public/favicon.ico
Binary file not shown.
42 changes: 31 additions & 11 deletions src/app/_components/navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";
import * as React from "react";
import { Moon, Sun } from "lucide-react";
import { Moon, Sun, Github, Sigma } from "lucide-react";
import { useTheme } from "next-themes";

import { Button, buttonVariants } from "../../components/ui/button";
Expand All @@ -12,30 +12,50 @@ import {
} from "../../components/ui/dropdown-menu";
import Link from "next/link";
import { ModeToggle } from "./themetoggle";
import type { SimpleIcon } from "simple-icons";
import { siSimpleicons } from "simple-icons";
import { siGithub } from "simple-icons";
import {
HoverCard,
HoverCardContent,
HoverCardTrigger,
} from "~/components/ui/hover-card";

export function NavBar() {
const { setTheme } = useTheme();

return (
<div className="mx-auto flex w-full flex-row items-center justify-between gap-x-10 px-10 py-4">
<Link href={"/"} className="text-xl font-semibold">
Patense.ai
<Link href={"/"} className="text-2xl font-semibold">
Snorkle
</Link>
<div className="max-w-1/2 flex flex-row">
<Link
href={"/newAnalysis"}
className={buttonVariants({ variant: "link" })}
>
New Analysis
<Link href={"/new"} className={buttonVariants({ variant: "link" })}>
New Collection
</Link>
<Link
className={buttonVariants({ variant: "link" })}
href={"/dashboard"}
href={"/collections"}
>
All Analyses
All Collections
</Link>
</div>
<div className="flex flex-row items-center gap-x-4">
<Link href={"https://github.com/JohnZolton"}>
<svg
role="img"
viewBox="0 0 24 24"
width={28}
height={28}
xmlns="http://www.w3.org/2000/svg"
className="fill-primary"
>
<title>GitHub</title>
<path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12" />
</svg>
</Link>
<ModeToggle />
</div>
<ModeToggle />
</div>
);
}
130 changes: 84 additions & 46 deletions src/app/dashboard/[id]/page.tsx → src/app/collections/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ import {
AlertDialogTrigger,
} from "~/components/ui/alert-dialog";
import { useRouter } from "next/navigation";
import { FileText } from "lucide-react";
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "~/components/ui/dialog";

export default function JobDisplay({ params }: { params: { id: string } }) {
const queryClient = useQueryClient();
Expand All @@ -53,7 +62,7 @@ export default function JobDisplay({ params }: { params: { id: string } }) {
}
}

const { mutate: analyze } = api.job.analyzeFeature.useMutation({
const { mutate: analyze } = api.job.deepSearch.useMutation({
onSuccess: async (result) => {
setIsLoading(false);

Expand Down Expand Up @@ -91,9 +100,9 @@ export default function JobDisplay({ params }: { params: { id: string } }) {
});

return (
<div className="flex h-[calc(100vh-108px)] w-full flex-row justify-center">
<div className="flex h-[calc(100vh-96px)] w-full flex-row justify-start">
{/* Left sidebar for feature history */}
<div className="flex h-full w-48 flex-col justify-between gap-y-1 text-ellipsis">
<div className="flex h-[calc(100vh-96px)] w-48 flex-col justify-between gap-y-1 text-ellipsis">
<div>
<div className="text-center">History</div>
{job?.features.map((item, index) => (
Expand Down Expand Up @@ -121,14 +130,14 @@ export default function JobDisplay({ params }: { params: { id: string } }) {
<div className="flex items-center justify-center">
<AlertDialog>
<AlertDialogTrigger>
<Button variant={"destructive"}>Delete Job</Button>
<Button variant={"destructive"}>Delete Collection</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
<AlertDialogDescription>
This action cannot be undone. This will permanently delete the
analysis and all associated data.
collection and all associated data.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
Expand All @@ -150,66 +159,94 @@ export default function JobDisplay({ params }: { params: { id: string } }) {
</div>

{/* Main Display */}
<div className="flex h-full w-full max-w-4xl flex-col items-center justify-between px-4">
<div className="mx-auto flex h-full w-full max-w-4xl flex-col items-center justify-between px-4">
{/* Analysis Display */}
{!isLoading && (
<div className="flex flex-col items-center">
<div className="text-xl font-bold">{feature?.feature}</div>
<ScrollArea>
<div className="flex h-5/6 flex-col items-center">
<div className="text-2xl font-bold">{feature?.feature}</div>
<ScrollArea className="w-full rounded-md p-4">
{feature?.analysis.map((item, index) => (
<div
key={`analysis-display-${index}`}
className="my-2 flex flex-col items-center justify-center gap-y-2 rounded-md border border-border bg-accent p-2 shadow-sm"
className="my-2 flex flex-row items-center justify-between rounded-md border border-border bg-accent p-2 shadow-sm"
>
<div>{item.quote}</div>
<div className="text-xs">
{item.refTitle} - page {item.refPage}
<div className="flex flex-col items-start justify-start gap-y-2">
<div>{item.quote}</div>
<div className="text-xs">
{item.refTitle} - page {item.refPage}
</div>
</div>
<div className="flex items-center justify-end">
<Dialog>
<DialogTrigger>
<HoverCard>
<HoverCardTrigger>
<FileText />
</HoverCardTrigger>
<HoverCardContent>Show Context</HoverCardContent>
</HoverCard>
</DialogTrigger>
<DialogContent className="max-h-[425px]">
<DialogHeader>
<DialogTitle>
{item.refTitle} - page {item.refPage}
</DialogTitle>
<DialogDescription>
<ScrollArea className="mt-2 h-full max-h-[300px] px-4">
{item.refContent}
</ScrollArea>
</DialogDescription>
</DialogHeader>
</DialogContent>
</Dialog>
</div>
</div>
))}
</ScrollArea>
</div>
)}
{isLoading && <LoadingSpinner />}
<div className="flex w-full flex-col items-center justify-center">
<div className="flex h-1/6 w-full flex-col items-center justify-end">
{/* Reference toggle */}
<div className="grid w-full grid-cols-2">
{job?.references.map((ref, index) => (
<div
className="flex flex-row items-center justify-center gap-x-2"
key={index}
>
<Checkbox
id={`ref-${index}`}
className="peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground"
checked={searchRefs.includes(ref)}
onCheckedChange={(checked) => {
if (checked) {
setSearchRefs((prevRefs) => [...prevRefs, ref]);
} else {
setSearchRefs((prevRefs) =>
prevRefs.filter((r) => r.id !== ref.id),
);
}
}}
/>
<div>
<label
htmlFor={`ref-${index}`}
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
>
{ref.title}
</label>
<ScrollArea>
<div className="grid w-full grid-cols-2">
{job?.references.map((ref, index) => (
<div
className="flex flex-row items-center justify-center gap-x-2"
key={index}
>
<Checkbox
id={`ref-${index}`}
className="peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground"
checked={searchRefs.includes(ref)}
onCheckedChange={(checked) => {
if (checked) {
setSearchRefs((prevRefs) => [...prevRefs, ref]);
} else {
setSearchRefs((prevRefs) =>
prevRefs.filter((r) => r.id !== ref.id),
);
}
}}
/>
<div>
<label
htmlFor={`ref-${index}`}
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
>
{ref.title}
</label>
</div>
</div>
</div>
))}
</div>
))}
</div>
</ScrollArea>
{/* Search Bar */}
<div className="flex w-full max-w-3xl flex-row items-center justify-center gap-x-4 pt-2">
<Button onClick={toggleAll}>Toggle All Refs</Button>
<Button onClick={toggleAll}>Toggle All</Button>
<Input
onChange={(e) => setQuery(e.target.value)}
placeholder="Enter a feature to search for"
placeholder="Enter something to search for"
/>
{searchRefs.length === 0 || query.length === 0 ? (
<HoverCard>
Expand Down Expand Up @@ -239,6 +276,7 @@ export default function JobDisplay({ params }: { params: { id: string } }) {
</div>
</div>
</div>
<div className="w-48"></div>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function Dashboard() {
<div key={index}>
<Link
className={buttonVariants({ variant: "ghost" })}
href={`/dashboard/${job.id}`}
href={`/collections/${job.id}`}
>
Job {job.id} - {job.createdAt.toLocaleDateString()}
</Link>
Expand Down
6 changes: 3 additions & 3 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { type Metadata } from "next";
import { TRPCReactProvider } from "~/trpc/react";

export const metadata: Metadata = {
title: "Patense Local",
description: "100% Local AI Reference Analysis",
title: "Snorkle",
description: "100% Local AI Document Search",
icons: [{ rel: "icon", url: "/favicon.ico" }],
};

Expand All @@ -23,7 +23,7 @@ export default function RootLayout({
disableTransitionOnChange
attribute="class"
>
<main className="flex min-h-screen flex-col items-center">
<main className="flex max-h-screen flex-col items-center">
<NavBar />

<TRPCReactProvider>{children}</TRPCReactProvider>
Expand Down
Loading

0 comments on commit 7a71cdb

Please sign in to comment.