Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lasryaric committed Oct 11, 2023
1 parent c1a58aa commit 09bb9a3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 32 deletions.
36 changes: 8 additions & 28 deletions front/components/assistant/conversation/ContentFragment.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,17 @@
import {
DocumentTextIcon,
ExternalLinkIcon,
IconButton,
SlackLogo,
} from "@dust-tt/sparkle";
import Link from "next/link";
import { Citation } from "@dust-tt/sparkle";

import { classNames } from "@app/lib/utils";
import { assertNever } from "@app/lib/utils";
import { ContentFragmentType } from "@app/types/assistant/conversation";

export function ContentFragment({ message }: { message: ContentFragmentType }) {
let logo = <DocumentTextIcon className="h-5 w-5 text-slate-500" />;
let logoType: "document" | "slack" = "document";
switch (message.contentType) {
case "slack_thread_content":
logo = <SlackLogo className="h-5 w-5 text-slate-500" />;
logoType = "slack";
break;

default:
assertNever(message.contentType);
}
return (
<div
className={classNames(
"flex w-48 flex-none flex-col gap-2 rounded-xl border border-structure-100 bg-white p-3 sm:w-64"
)}
>
<div className="flex items-center gap-1.5">
<div className="h-5 w-5">{logo}</div>
<div className="flex-grow text-xs" />
{message.url && (
<Link href={message.url} target="_blank">
<IconButton icon={ExternalLinkIcon} size="xs" variant="primary" />
</Link>
)}
</div>
<div className="text-xs font-bold text-element-900">{message.title}</div>
</div>
);
return <Citation title={message.title} type={logoType} href={message.url} />;
}
4 changes: 4 additions & 0 deletions front/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,7 @@ export function ioTsEnum<EnumType>(
t.identity
);
}

export function assertNever(x: never): never {
throw new Error(`${x} is not of type never. This should never happen.`);
}
10 changes: 6 additions & 4 deletions sparkle/src/components/Citation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface CitationProps {
description?: string;
index?: ReactNode;
isBlinking?: boolean;
href: string;
href?: string;
}

const typeIcons = {
Expand Down Expand Up @@ -46,9 +46,11 @@ export function Citation({
)}
<Icon visual={typeIcons[type]} size="sm" />
<div className="s-flex-grow s-text-xs" />
<a target="_blank" rel="noopener noreferrer" href={href}>
<IconButton icon={ExternalLinkIcon} size="sm" variant="primary" />
</a>
{href && (
<a target="_blank" rel="noopener noreferrer" href={href}>
<IconButton icon={ExternalLinkIcon} size="sm" variant="primary" />
</a>
)}
</div>
<div className="s-text-sm s-font-bold s-text-element-900">{title}</div>
{description && (
Expand Down

0 comments on commit 09bb9a3

Please sign in to comment.