feat: add ability to share chats (#594)

This commit is contained in:
Jeremy 2024-12-06 13:36:56 +03:00 committed by GitHub
parent 64d1aad2bb
commit 4d901ba066
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 877 additions and 66 deletions

View file

@ -2,6 +2,7 @@ import { memo, type SetStateAction } from 'react';
import type { UIBlock } from './block';
import { FileIcon, LoaderIcon, MessageIcon, PencilEditIcon } from './icons';
import { toast } from 'sonner';
const getActionText = (
type: 'create' | 'update' | 'request-suggestions',
@ -26,18 +27,27 @@ interface DocumentToolResultProps {
result: { id: string; title: string };
block: UIBlock;
setBlock: (value: SetStateAction<UIBlock>) => void;
isReadonly: boolean;
}
function PureDocumentToolResult({
type,
result,
setBlock,
isReadonly,
}: DocumentToolResultProps) {
return (
<button
type="button"
className="bg-background cursor-pointer border py-2 px-3 rounded-xl w-fit flex flex-row gap-3 items-start"
onClick={(event) => {
if (isReadonly) {
toast.error(
'Viewing files in shared chats is currently not supported.',
);
return;
}
const rect = event.currentTarget.getBoundingClientRect();
const boundingBox = {
@ -79,14 +89,27 @@ interface DocumentToolCallProps {
type: 'create' | 'update' | 'request-suggestions';
args: { title: string };
setBlock: (value: SetStateAction<UIBlock>) => void;
isReadonly: boolean;
}
function PureDocumentToolCall({ type, args, setBlock }: DocumentToolCallProps) {
function PureDocumentToolCall({
type,
args,
setBlock,
isReadonly,
}: DocumentToolCallProps) {
return (
<button
type="button"
className="cursor pointer w-fit border py-2 px-3 rounded-xl flex flex-row items-start justify-between gap-3"
onClick={(event) => {
if (isReadonly) {
toast.error(
'Viewing files in shared chats is currently not supported.',
);
return;
}
const rect = event.currentTarget.getBoundingClientRect();
const boundingBox = {