Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/admin/chat-on-thread-view #772

Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion ui/admin/app/components/header/HeaderNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function RouteBreadcrumbs() {
</>
)}

{routeInfo?.path === "/thread/:id" && (
{routeInfo?.path === "/threads/:id" && (
<>
<BreadcrumbItem>
<BreadcrumbLink asChild>
Expand Down
41 changes: 18 additions & 23 deletions ui/admin/app/components/thread/ThreadMeta.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Link } from "@remix-run/react";
import { EditIcon, ExternalLink, FileIcon, FilesIcon } from "lucide-react";
import { $path } from "remix-routes";

Expand All @@ -17,8 +16,8 @@ import {
AccordionTrigger,
} from "~/components/ui/accordion";
import { Badge } from "~/components/ui/badge";
import { Button } from "~/components/ui/button";
import { Card, CardContent } from "~/components/ui/card";
import { Link } from "~/components/ui/link";

interface ThreadMetaProps {
for: Agent | Workflow;
Expand All @@ -34,9 +33,13 @@ export function ThreadMeta({
files,
className,
}: ThreadMetaProps) {
const from = $path("/thread/:id", { id: thread.id });
const from = $path("/threads/:id", { id: thread.id });
const isAgent = entity.id.startsWith("a");

const assistantLink = isAgent
? $path("/agents/:agent", { agent: entity.id }, { from })
: $path("/workflows/:workflow", { workflow: entity.id });

return (
<Card className={cn("h-full bg-0", className)}>
<CardContent className="space-y-4 pt-6">
Expand All @@ -58,27 +61,19 @@ export function ThreadMeta({
<td className="text-right">
<div className="flex items-center justify-end gap-2">
<span>{entity.name}</span>
<Button
variant="ghost"
size="icon"
asChild

<Link
to={assistantLink}
as="button"
buttonVariant="ghost"
buttonSize="icon"
>
<Link
to={$path(
isAgent
? "/agents/:agent"
: "/workflows/:workflow",
{ workflow: entity.id },
{ from }
)}
>
{isAgent ? (
<EditIcon className="w-4 h-4" />
) : (
<ExternalLink className="w-4 h-4" />
)}
</Link>
</Button>
{isAgent ? (
<EditIcon className="w-4 h-4" />
) : (
<ExternalLink className="w-4 h-4" />
)}
</Link>
</div>
</td>
</tr>
Expand Down
6 changes: 3 additions & 3 deletions ui/admin/app/lib/service/routeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ export const RouteHelperMap = {
path: "/oauth-apps",
schema: z.null(),
},
"/thread/:id": {
regex: exactRegex($path("/thread/:id", { id: "(.+)" })),
path: "/thread/:id",
"/threads/:id": {
regex: exactRegex($path("/threads/:id", { id: "(.+)" })),
path: "/threads/:id",
schema: z.null(),
},
"/threads": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const clientLoader = async ({
request,
}: ClientLoaderFunctionArgs) => {
const routeInfo = RouteService.getRouteInfo(
"/thread/:id",
"/threads/:id",
new URL(request.url),
params
);
Expand Down Expand Up @@ -71,51 +71,50 @@ export default function ChatAgent() {
throw new Error("Trying to view a thread with an unsupported parent.");
};

return (
<ChatProvider
id={agent?.id || ""}
mode="agent"
threadId={thread.id}
readOnly
>
<div className="h-full flex flex-col overflow-hidden relative">
<Tooltip>
<Button
variant="outline"
size="icon"
className="absolute top-4 left-4 z-10"
asChild
>
<TooltipTrigger>
<Link to="/threads">
<ArrowLeftIcon className="h-4 w-4" />
</Link>
</TooltipTrigger>
</Button>
<TooltipContent>Go Back</TooltipContent>
</Tooltip>
const [isAgent, entity] = [agent !== null, getEntity()];

<ResizablePanelGroup
direction="horizontal"
className="flex-auto"
return (
<div className="h-full flex flex-col overflow-hidden relative">
<Tooltip>
<Button
variant="outline"
size="icon"
className="absolute top-4 left-4 z-10"
asChild
>
<ResizablePanel defaultSize={70} minSize={25}>
<TooltipTrigger>
<Link to="/threads">
<ArrowLeftIcon className="h-4 w-4" />
</Link>
</TooltipTrigger>
</Button>
<TooltipContent>Go Back</TooltipContent>
</Tooltip>

<ResizablePanelGroup direction="horizontal" className="flex-auto">
<ResizablePanel defaultSize={70} minSize={25}>
<ChatProvider
id={entity.id}
mode="agent"
threadId={thread.id}
readOnly={!isAgent}
>
<Chat />
</ResizablePanel>
<ResizableHandle />
<ResizablePanel defaultSize={30} minSize={25}>
<ScrollArea className="h-full">
<ThreadMeta
className="rounded-none border-none"
thread={thread}
for={getEntity()}
files={files}
knowledge={knowledge}
/>
</ScrollArea>
</ResizablePanel>
</ResizablePanelGroup>
</div>
</ChatProvider>
</ChatProvider>
</ResizablePanel>
<ResizableHandle />
<ResizablePanel defaultSize={30} minSize={25}>
<ScrollArea className="h-full">
<ThreadMeta
className="rounded-none border-none"
thread={thread}
for={entity}
files={files}
knowledge={knowledge}
/>
</ScrollArea>
</ResizablePanel>
</ResizablePanelGroup>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export default function Threads() {
cell.id.includes("actions")
}
onRowClick={(row) => {
navigate($path("/thread/:id", { id: row.id }));
navigate($path("/threads/:id", { id: row.id }));
}}
/>
</div>
Expand Down Expand Up @@ -231,7 +231,7 @@ export default function Threads() {
<TooltipTrigger asChild>
<Button variant="ghost" size="icon" asChild>
<Link
to={$path("/thread/:id", {
to={$path("/threads/:id", {
id: row.original.id,
})}
>
Expand Down