Revert "Upgrade linter and formatter to Ultracite" (#1226)
This commit is contained in:
parent
0e320b391d
commit
1aff7d9868
177 changed files with 8334 additions and 6943 deletions
|
|
@ -1,32 +1,33 @@
|
|||
import { memo } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { useArtifact } from "@/hooks/use-artifact";
|
||||
import type { ArtifactKind } from "./artifact";
|
||||
import { FileIcon, LoaderIcon, MessageIcon, PencilEditIcon } from "./icons";
|
||||
import { memo } from 'react';
|
||||
|
||||
import type { ArtifactKind } from './artifact';
|
||||
import { FileIcon, LoaderIcon, MessageIcon, PencilEditIcon } from './icons';
|
||||
import { toast } from 'sonner';
|
||||
import { useArtifact } from '@/hooks/use-artifact';
|
||||
|
||||
const getActionText = (
|
||||
type: "create" | "update" | "request-suggestions",
|
||||
tense: "present" | "past"
|
||||
type: 'create' | 'update' | 'request-suggestions',
|
||||
tense: 'present' | 'past',
|
||||
) => {
|
||||
switch (type) {
|
||||
case "create":
|
||||
return tense === "present" ? "Creating" : "Created";
|
||||
case "update":
|
||||
return tense === "present" ? "Updating" : "Updated";
|
||||
case "request-suggestions":
|
||||
return tense === "present"
|
||||
? "Adding suggestions"
|
||||
: "Added suggestions to";
|
||||
case 'create':
|
||||
return tense === 'present' ? 'Creating' : 'Created';
|
||||
case 'update':
|
||||
return tense === 'present' ? 'Updating' : 'Updated';
|
||||
case 'request-suggestions':
|
||||
return tense === 'present'
|
||||
? 'Adding suggestions'
|
||||
: 'Added suggestions to';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
type DocumentToolResultProps = {
|
||||
type: "create" | "update" | "request-suggestions";
|
||||
interface DocumentToolResultProps {
|
||||
type: 'create' | 'update' | 'request-suggestions';
|
||||
result: { id: string; title: string; kind: ArtifactKind };
|
||||
isReadonly: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
function PureDocumentToolResult({
|
||||
type,
|
||||
|
|
@ -37,11 +38,12 @@ function PureDocumentToolResult({
|
|||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className="flex w-fit cursor-pointer flex-row items-start gap-3 rounded-xl border bg-background px-3 py-2"
|
||||
onClick={(event) => {
|
||||
if (isReadonly) {
|
||||
toast.error(
|
||||
"Viewing files in shared chats is currently not supported."
|
||||
'Viewing files in shared chats is currently not supported.',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
|
@ -58,26 +60,25 @@ function PureDocumentToolResult({
|
|||
setArtifact({
|
||||
documentId: result.id,
|
||||
kind: result.kind,
|
||||
content: "",
|
||||
content: '',
|
||||
title: result.title,
|
||||
isVisible: true,
|
||||
status: "idle",
|
||||
status: 'idle',
|
||||
boundingBox,
|
||||
});
|
||||
}}
|
||||
type="button"
|
||||
>
|
||||
<div className="mt-1 text-muted-foreground">
|
||||
{type === "create" ? (
|
||||
{type === 'create' ? (
|
||||
<FileIcon />
|
||||
) : type === "update" ? (
|
||||
) : type === 'update' ? (
|
||||
<PencilEditIcon />
|
||||
) : type === "request-suggestions" ? (
|
||||
) : type === 'request-suggestions' ? (
|
||||
<MessageIcon />
|
||||
) : null}
|
||||
</div>
|
||||
<div className="text-left">
|
||||
{`${getActionText(type, "past")} "${result.title}"`}
|
||||
{`${getActionText(type, 'past')} "${result.title}"`}
|
||||
</div>
|
||||
</button>
|
||||
);
|
||||
|
|
@ -85,14 +86,14 @@ function PureDocumentToolResult({
|
|||
|
||||
export const DocumentToolResult = memo(PureDocumentToolResult, () => true);
|
||||
|
||||
type DocumentToolCallProps = {
|
||||
type: "create" | "update" | "request-suggestions";
|
||||
interface DocumentToolCallProps {
|
||||
type: 'create' | 'update' | 'request-suggestions';
|
||||
args:
|
||||
| { title: string; kind: ArtifactKind } // for create
|
||||
| { id: string; description: string } // for update
|
||||
| { documentId: string }; // for request-suggestions
|
||||
isReadonly: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
function PureDocumentToolCall({
|
||||
type,
|
||||
|
|
@ -103,11 +104,12 @@ function PureDocumentToolCall({
|
|||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className="cursor pointer flex w-fit flex-row items-start justify-between gap-3 rounded-xl border px-3 py-2"
|
||||
onClick={(event) => {
|
||||
if (isReadonly) {
|
||||
toast.error(
|
||||
"Viewing files in shared chats is currently not supported."
|
||||
'Viewing files in shared chats is currently not supported.',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
|
@ -127,28 +129,27 @@ function PureDocumentToolCall({
|
|||
boundingBox,
|
||||
}));
|
||||
}}
|
||||
type="button"
|
||||
>
|
||||
<div className="flex flex-row items-start gap-3">
|
||||
<div className="mt-1 text-zinc-500">
|
||||
{type === "create" ? (
|
||||
{type === 'create' ? (
|
||||
<FileIcon />
|
||||
) : type === "update" ? (
|
||||
) : type === 'update' ? (
|
||||
<PencilEditIcon />
|
||||
) : type === "request-suggestions" ? (
|
||||
) : type === 'request-suggestions' ? (
|
||||
<MessageIcon />
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<div className="text-left">
|
||||
{`${getActionText(type, "present")} ${
|
||||
type === "create" && "title" in args && args.title
|
||||
{`${getActionText(type, 'present')} ${
|
||||
type === 'create' && 'title' in args && args.title
|
||||
? `"${args.title}"`
|
||||
: type === "update" && "description" in args
|
||||
: type === 'update' && 'description' in args
|
||||
? `"${args.description}"`
|
||||
: type === "request-suggestions"
|
||||
? "for document"
|
||||
: ""
|
||||
: type === 'request-suggestions'
|
||||
? 'for document'
|
||||
: ''
|
||||
}`}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue