From a92013a1f381f82c9b9e84af83d1afacc9356bc6 Mon Sep 17 00:00:00 2001 From: Andrew Jiang Date: Mon, 16 Dec 2024 12:01:32 -0500 Subject: [PATCH] fix: delete old chat code (#1899) --- packages/ui/app/package.json | 6 +- packages/ui/app/src/atoms/cohere.ts | 5 - packages/ui/app/src/atoms/index.ts | 1 - packages/ui/app/src/css/globals.scss | 1 - packages/ui/app/src/search/SearchDialog.tsx | 12 +- packages/ui/app/src/search/SearchHits.tsx | 56 +-- .../ui/app/src/search/cohere/AskCohereHit.tsx | 65 --- .../src/search/cohere/CohereChatButton.tsx | 43 -- .../src/search/cohere/CohereChatbotModal.tsx | 109 ----- packages/ui/app/tailwind.config.cjs | 1 - packages/ui/app/tsconfig.json | 3 - packages/ui/chatbot/.depcheckrc.json | 4 - packages/ui/chatbot/.eslintrc.cjs | 11 - packages/ui/chatbot/.gitignore | 24 -- packages/ui/chatbot/.prettierrc.cjs | 1 - packages/ui/chatbot/.stylelintrc.json | 1 - packages/ui/chatbot/README.md | 30 -- packages/ui/chatbot/index.html | 13 - packages/ui/chatbot/package.json | 71 ---- packages/ui/chatbot/postcss.config.js | 6 - packages/ui/chatbot/src/App.scss | 59 --- packages/ui/chatbot/src/App.tsx | 15 - .../src/atoms/atomWithSessionStorage.ts | 68 ---- .../ui/chatbot/src/components/AskInput.tsx | 40 -- .../src/components/ChatConversation.tsx | 29 -- .../chatbot/src/components/ChatbotModal.tsx | 139 ------- .../ui/chatbot/src/components/FernAvatar.tsx | 10 - .../src/components/MarkdownContent.tsx | 50 --- .../src/components/ResponseMessage.tsx | 74 ---- .../ui/chatbot/src/components/SendButton.tsx | 17 - .../ui/chatbot/src/components/TextArea.tsx | 28 -- .../ui/chatbot/src/components/UserMessage.tsx | 12 - packages/ui/chatbot/src/icons/CohereIcon.tsx | 31 -- packages/ui/chatbot/src/icons/FernIcon.tsx | 18 - packages/ui/chatbot/src/icons/SendIcon.tsx | 22 - packages/ui/chatbot/src/index.scss | 11 - packages/ui/chatbot/src/index.ts | 3 - packages/ui/chatbot/src/main.tsx | 9 - packages/ui/chatbot/src/types.ts | 24 -- packages/ui/chatbot/src/vite-env.d.ts | 1 - packages/ui/chatbot/tailwind.config.js | 54 --- packages/ui/chatbot/tsconfig.json | 9 - packages/ui/docs-bundle/next.config.mjs | 1 - packages/ui/docs-bundle/package.json | 1 - packages/ui/docs-bundle/tailwind.config.js | 1 - packages/ui/docs-bundle/tsconfig.json | 3 - packages/ui/fern-docs-search-ui/package.json | 2 +- .../ui/local-preview-bundle/next.config.mjs | 1 - pnpm-lock.yaml | 379 ++++++++---------- tsconfig.json | 3 - 50 files changed, 182 insertions(+), 1395 deletions(-) delete mode 100644 packages/ui/app/src/atoms/cohere.ts delete mode 100644 packages/ui/app/src/search/cohere/AskCohereHit.tsx delete mode 100644 packages/ui/app/src/search/cohere/CohereChatButton.tsx delete mode 100644 packages/ui/app/src/search/cohere/CohereChatbotModal.tsx delete mode 100644 packages/ui/chatbot/.depcheckrc.json delete mode 100644 packages/ui/chatbot/.eslintrc.cjs delete mode 100644 packages/ui/chatbot/.gitignore delete mode 100644 packages/ui/chatbot/.prettierrc.cjs delete mode 100644 packages/ui/chatbot/.stylelintrc.json delete mode 100644 packages/ui/chatbot/README.md delete mode 100644 packages/ui/chatbot/index.html delete mode 100644 packages/ui/chatbot/package.json delete mode 100644 packages/ui/chatbot/postcss.config.js delete mode 100644 packages/ui/chatbot/src/App.scss delete mode 100644 packages/ui/chatbot/src/App.tsx delete mode 100644 packages/ui/chatbot/src/atoms/atomWithSessionStorage.ts delete mode 100644 packages/ui/chatbot/src/components/AskInput.tsx delete mode 100644 packages/ui/chatbot/src/components/ChatConversation.tsx delete mode 100644 packages/ui/chatbot/src/components/ChatbotModal.tsx delete mode 100644 packages/ui/chatbot/src/components/FernAvatar.tsx delete mode 100644 packages/ui/chatbot/src/components/MarkdownContent.tsx delete mode 100644 packages/ui/chatbot/src/components/ResponseMessage.tsx delete mode 100644 packages/ui/chatbot/src/components/SendButton.tsx delete mode 100644 packages/ui/chatbot/src/components/TextArea.tsx delete mode 100644 packages/ui/chatbot/src/components/UserMessage.tsx delete mode 100644 packages/ui/chatbot/src/icons/CohereIcon.tsx delete mode 100644 packages/ui/chatbot/src/icons/FernIcon.tsx delete mode 100644 packages/ui/chatbot/src/icons/SendIcon.tsx delete mode 100644 packages/ui/chatbot/src/index.scss delete mode 100644 packages/ui/chatbot/src/index.ts delete mode 100644 packages/ui/chatbot/src/main.tsx delete mode 100644 packages/ui/chatbot/src/types.ts delete mode 100644 packages/ui/chatbot/src/vite-env.d.ts delete mode 100644 packages/ui/chatbot/tailwind.config.js delete mode 100644 packages/ui/chatbot/tsconfig.json diff --git a/packages/ui/app/package.json b/packages/ui/app/package.json index d609392e59..3d0c7f852e 100644 --- a/packages/ui/app/package.json +++ b/packages/ui/app/package.json @@ -38,7 +38,6 @@ "@fern-api/fdr-sdk": "workspace:*", "@fern-api/template-resolver": "workspace:*", "@fern-api/ui-core-utils": "workspace:*", - "@fern-ui/chatbot": "workspace:*", "@fern-ui/components": "workspace:*", "@fern-ui/fdr-utils": "workspace:*", "@fern-ui/fern-docs-mdx": "workspace:*", @@ -79,8 +78,8 @@ "hast-util-to-string": "^3.0.0", "iconoir-react": "^7.7.0", "jose": "^5.2.3", - "jotai": "^2.8.1", - "jotai-effect": "^1.0.0", + "jotai": "^2.10.4", + "jotai-effect": "^1.0.5", "jotai-location": "^0.5.5", "jsonpath": "^1.1.1", "launchdarkly-js-client-sdk": "^3.4.0", @@ -147,7 +146,6 @@ "@vitejs/plugin-react": "^4.2.1", "autoprefixer": "^10.4.16", "chromatic": "^11.3.0", - "cohere-ai": "^7.9.5", "depcheck": "^1.4.3", "eslint": "^8.56.0", "eslint-plugin-storybook": "^0.8.0", diff --git a/packages/ui/app/src/atoms/cohere.ts b/packages/ui/app/src/atoms/cohere.ts deleted file mode 100644 index 77d1847ded..0000000000 --- a/packages/ui/app/src/atoms/cohere.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { atom } from "jotai"; - -export const COHERE_ASK_AI = atom(false); - -export const COHERE_INITIAL_MESSAGE = atom(""); diff --git a/packages/ui/app/src/atoms/index.ts b/packages/ui/app/src/atoms/index.ts index bd9a764913..feedd43abe 100644 --- a/packages/ui/app/src/atoms/index.ts +++ b/packages/ui/app/src/atoms/index.ts @@ -1,7 +1,6 @@ export * from "./announcement"; export * from "./apis"; export * from "./auth"; -export * from "./cohere"; export * from "./docs"; export * from "./files"; export * from "./flags"; diff --git a/packages/ui/app/src/css/globals.scss b/packages/ui/app/src/css/globals.scss index 7770ccb840..fb1f1537a4 100644 --- a/packages/ui/app/src/css/globals.scss +++ b/packages/ui/app/src/css/globals.scss @@ -4,7 +4,6 @@ @import "./rmiz"; @import "./base"; @import "@fern-ui/components/src/index.scss"; -@import "@fern-ui/chatbot/src/index.scss"; @import "@fern-ui/fern-docs-syntax-highlighter/src/index.scss"; @import "@fern-ui/fern-docs-search-ui/src/index.scss"; @import "./components"; diff --git a/packages/ui/app/src/search/SearchDialog.tsx b/packages/ui/app/src/search/SearchDialog.tsx index e39345e969..27380c19d3 100644 --- a/packages/ui/app/src/search/SearchDialog.tsx +++ b/packages/ui/app/src/search/SearchDialog.tsx @@ -24,11 +24,6 @@ import { InkeepChatButton } from "./inkeep/InkeepChatButton"; import { InkeepCustomTrigger } from "./inkeep/InkeepCustomTrigger"; import { useSearchTrigger } from "./useSearchTrigger"; -// const CohereChatButton = dynamic( -// () => import("./cohere/CohereChatButton").then(({ CohereChatButton }) => CohereChatButton), -// { ssr: false }, -// ); - export const SearchDialog = (): ReactNode => { const isSearchV2Enabled = useFeatureFlag("isSearchV2Enabled"); if (isSearchV2Enabled) { @@ -54,12 +49,7 @@ const InternalSearchDialog = (): ReactNode => { } if (config.inkeep == null) { - return ( - <> - - {/* {isAskAiEnabled && } */} - - ); + return ; } else { return ( <> diff --git a/packages/ui/app/src/search/SearchHits.tsx b/packages/ui/app/src/search/SearchHits.tsx index 1294e2527e..77b32f6eb9 100644 --- a/packages/ui/app/src/search/SearchHits.tsx +++ b/packages/ui/app/src/search/SearchHits.tsx @@ -3,21 +3,18 @@ import { FernButton, FernScrollArea } from "@fern-ui/components"; import { useKeyboardPress } from "@fern-ui/react-commons"; import { getSlugForSearchRecord, type SearchRecord } from "@fern-ui/search-utils"; import { Minus, Xmark } from "iconoir-react"; -import { useSetAtom } from "jotai"; import { useRouter } from "next/router"; import React, { PropsWithChildren, useEffect, useMemo, useRef, useState } from "react"; import { useInfiniteHits, useInstantSearch } from "react-instantsearch"; -import { COHERE_ASK_AI, COHERE_INITIAL_MESSAGE, useBasePath, useCloseSearchDialog, useFeatureFlags } from "../atoms"; +import { useBasePath, useCloseSearchDialog } from "../atoms"; import { Separator } from "../components/Separator"; import { useToHref } from "../hooks/useHref"; import { SearchHit } from "./SearchHit"; -import { AskCohereHit } from "./cohere/AskCohereHit"; export const EmptyStateView: React.FC = ({ children }) => { return
{children}
; }; -const COHERE_AI_HIT_ID = "cohere-ai-hit"; const SEARCH_HITS_PER_SECTION = 3; const expandHits = (expanded: boolean, hits: SearchRecord[]) => { @@ -144,7 +141,7 @@ export const SearchHits: React.FC = () => { useEffect(() => { const [firstHit] = hits; if (firstHit != null) { - setHoveredSearchHitId((id) => id ?? (isAskAiEnabled ? COHERE_AI_HIT_ID : firstHit.objectID)); + setHoveredSearchHitId((id) => id ?? firstHit.objectID); } }, [hits]); @@ -154,9 +151,6 @@ export const SearchHits: React.FC = () => { if (hoveredSearchHit == null) { setHoveredSearchHitId(null); return; - } else if (hoveredSearchHit.index === 0 && isAskAiEnabled) { - setHoveredSearchHitId(COHERE_AI_HIT_ID); - return; } const previousHit = orderedHits[hoveredSearchHit.index - 1]; @@ -173,15 +167,6 @@ export const SearchHits: React.FC = () => { useKeyboardPress({ key: "Down", onPress: () => { - if (hoveredSearchHitId === COHERE_AI_HIT_ID) { - setHoveredSearchHitId(orderedHits[0]?.objectID ?? null); - return; - } - - if (hoveredSearchHit == null && isAskAiEnabled) { - setHoveredSearchHitId(COHERE_AI_HIT_ID); - return; - } const nextHit = orderedHits[hoveredSearchHit != null ? hoveredSearchHit.index + 1 : 0]; if (nextHit != null) { setHoveredSearchHitId(nextHit.objectID); @@ -193,22 +178,9 @@ export const SearchHits: React.FC = () => { capture: true, }); - const setOpenCohere = useSetAtom(COHERE_ASK_AI); - const setCohereInitialMessage = useSetAtom(COHERE_INITIAL_MESSAGE); - - const openCohere = () => { - setCohereInitialMessage(`Can you tell me about ${search.results.query}?`); - setOpenCohere(true); - }; - const toHref = useToHref(); const navigateToHoveredHit = async () => { if (hoveredSearchHit == null) { - if (isAskAiEnabled && hoveredSearchHitId === COHERE_AI_HIT_ID && search.results.query.length > 0) { - closeSearchDialog(); - openCohere(); - } - return; } const slug = FernNavigation.Slug(getSlugForSearchRecord(hoveredSearchHit.record, basePath)); @@ -245,18 +217,6 @@ export const SearchHits: React.FC = () => { className="p-2" scrollbars="vertical" > - {isAskAiEnabled && ( - { - if (elem != null) { - refs.current.set(COHERE_AI_HIT_ID, elem); - } - }} - message={search.results.query} - isHovered={hoveredSearchHitId === COHERE_AI_HIT_ID} - onMouseEnter={() => setHoveredSearchHitId(COHERE_AI_HIT_ID)} - /> - )} {pageHits.length > 0 && ( { }; export const SearchMobileHits: React.FC = ({ children }) => { - const { isAskAiEnabled } = useFeatureFlags(); const { hits } = useInfiniteHits(); const search = useInstantSearch(); const [expandEndpoints, setExpandEndpoints] = useState(false); @@ -305,17 +264,6 @@ export const SearchMobileHits: React.FC = ({ children }) => { return ( - {isAskAiEnabled && ( - { - if (elem != null) { - refs.current.set(COHERE_AI_HIT_ID, elem); - } - }} - message={search.results.query} - isHovered={true} - /> - )} {pageHits.length > 0 && ( void; - message: string; - isHovered?: boolean; - onMouseEnter?: () => void; - onMouseLeave?: () => void; - } -} - -export const AskCohereHit: React.FC = ({ - setRef, - message, - isHovered = false, - onMouseEnter, - onMouseLeave, -}) => { - const closeMobileSidebar = useCloseMobileSidebar(); - const closeSearchDialog = useCloseSearchDialog(); - const setOpenCohere = useSetAtom(COHERE_ASK_AI); - const setCohereInitialMessage = useSetAtom(COHERE_INITIAL_MESSAGE); - - const openCohere = () => { - setCohereInitialMessage(`Can you tell me about ${message}?`); - setOpenCohere(true); - }; - - return ( - setRef?.(elem)} - className={cn("flex w-full items-center space-x-4 space-y-1 rounded-md px-3 py-2 cursor-pointer", { - "bg-accent-highlight": isHovered, - })} - onMouseEnter={onMouseEnter} - onMouseLeave={onMouseLeave} - onClick={() => { - closeMobileSidebar(); - closeSearchDialog(); - openCohere(); - }} - > -
- -
-
- Can you tell me about {message}? -
-
Ask Cohere
-
- -
-
- ); -}; diff --git a/packages/ui/app/src/search/cohere/CohereChatButton.tsx b/packages/ui/app/src/search/cohere/CohereChatButton.tsx deleted file mode 100644 index d29694a42b..0000000000 --- a/packages/ui/app/src/search/cohere/CohereChatButton.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import { CohereIcon } from "@fern-ui/chatbot"; -import * as Dialog from "@radix-ui/react-dialog"; -import { useAtom } from "jotai"; -import { ReactElement } from "react"; -import { createPortal } from "react-dom"; -import { COHERE_ASK_AI } from "../../atoms"; -import { useRouteChangeComplete } from "../../hooks/useRouteChanged"; -import { useSearchConfig } from "../../services/useSearchService"; -import { CohereChatbotModal } from "./CohereChatbotModal"; - -export function CohereChatButton(): ReactElement | null { - const config = useSearchConfig(); - const [enabled, setEnabled] = useAtom(COHERE_ASK_AI); - - // Close the dialog when the route changes - useRouteChangeComplete(() => { - setEnabled(false); - }); - - if (!config.isAvailable || config.inkeep != null || typeof window === "undefined") { - return null; - } - - return ( - - {createPortal( - - - , - document.body, - )} - - - - - - - - ); -} diff --git a/packages/ui/app/src/search/cohere/CohereChatbotModal.tsx b/packages/ui/app/src/search/cohere/CohereChatbotModal.tsx deleted file mode 100644 index 563a5e1dfc..0000000000 --- a/packages/ui/app/src/search/cohere/CohereChatbotModal.tsx +++ /dev/null @@ -1,109 +0,0 @@ -import { ChatbotMessage, ChatbotModal, ChatbotModalRef, Citation } from "@fern-ui/chatbot"; -import { Cohere } from "cohere-ai"; -import { useAtomValue } from "jotai"; -import { ReactElement, isValidElement, useRef } from "react"; -import { useCallbackOne } from "use-memo-one"; -import { COHERE_INITIAL_MESSAGE, useAtomEffect } from "../../atoms"; -import { CURRENT_VERSION_ID_ATOM } from "../../atoms/navigation"; -import { FernLink } from "../../components/FernLink"; -import { useApiRoute } from "../../hooks/useApiRoute"; -import { CodeBlock } from "../../mdx/components/code"; -import { Stream } from "../../playground/Stream"; -import { BuiltWithFern } from "../../sidebar/BuiltWithFern"; - -export function CohereChatbotModal({ className }: { className?: string }): ReactElement { - const versionId = useAtomValue(CURRENT_VERSION_ID_ATOM); - - const ref = useRef(null); - - useAtomEffect( - useCallbackOne((get, set) => { - const initialMessage = get.peek(COHERE_INITIAL_MESSAGE); - if (initialMessage.trim().length === 0) { - return; - } - ref.current?.sendMessage(initialMessage); - set(COHERE_INITIAL_MESSAGE, ""); - }, []), - ); - - const cohereApiRoute = useApiRoute("/api/fern-docs/search/cohere"); - - const chatStream = async (message: string, conversationId: string) => { - const abortController = new AbortController(); - const body = await fetch(cohereApiRoute, { - method: "POST", - signal: abortController.signal, - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ conversationId, message, versionId }), - }).then((res) => res.body); - - if (body == null) { - return [undefined, abortController] as const; - } - - let text = ""; - const citations: Citation[] = []; - - const stream = new Stream({ - stream: body, - parse: async (val) => { - const event = val as Cohere.StreamedChatResponse; - if (event.eventType === "text-generation") { - text += event.text; - } - - if (event.eventType === "citation-generation") { - event.citations.forEach((citation) => { - citations.push({ - text: citation.text, - start: citation.start, - end: citation.end, - slugs: citation.documentIds, - }); - }); - } - - return { message: text, role: "AI", citations }; - }, - terminator: "\n", - }); - - return [stream, abortController] as const; - }; - return ( - ; - } - } - return
;
-                },
-                a({ href, ...props }) {
-                    if (href == null) {
-                        return ;
-                    }
-                    return ;
-                },
-            }}
-            belowInput={
-                
- - Powered by Cohere (command-r-plus) - - -
- } - /> - ); -} diff --git a/packages/ui/app/tailwind.config.cjs b/packages/ui/app/tailwind.config.cjs index 11a8e9cb17..fbcd2b69ea 100644 --- a/packages/ui/app/tailwind.config.cjs +++ b/packages/ui/app/tailwind.config.cjs @@ -8,7 +8,6 @@ module.exports = { "./src/**/*.{ts,tsx}", "../tailwind.config.cjs", path.join(path.dirname(require.resolve("@fern-ui/components")), "**/*.{ts,tsx}"), - path.join(path.dirname(require.resolve("@fern-ui/chatbot")), "**/*.{ts,tsx}"), path.join(path.dirname(require.resolve("@fern-ui/fern-docs-search-ui")), "src/components/**/*.{ts,tsx}") ] }; diff --git a/packages/ui/app/tsconfig.json b/packages/ui/app/tsconfig.json index e0989400d8..0bc4419a62 100644 --- a/packages/ui/app/tsconfig.json +++ b/packages/ui/app/tsconfig.json @@ -32,9 +32,6 @@ { "path": "../../template-resolver" }, - { - "path": "../chatbot" - }, { "path": "../fern-docs-auth" }, diff --git a/packages/ui/chatbot/.depcheckrc.json b/packages/ui/chatbot/.depcheckrc.json deleted file mode 100644 index 9db66a5db6..0000000000 --- a/packages/ui/chatbot/.depcheckrc.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "ignores": ["@fern-platform/configs", "@types/node", "vite", "@types/react", "typescript"], - "ignore-patterns": ["dist"] -} diff --git a/packages/ui/chatbot/.eslintrc.cjs b/packages/ui/chatbot/.eslintrc.cjs deleted file mode 100644 index 2d4b9f6ba8..0000000000 --- a/packages/ui/chatbot/.eslintrc.cjs +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - root: true, - env: { browser: true, es2020: true }, - extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:react-hooks/recommended"], - ignorePatterns: ["dist", ".eslintrc.cjs"], - parser: "@typescript-eslint/parser", - plugins: ["react-refresh"], - rules: { - "react-refresh/only-export-components": ["warn", { allowConstantExport: true }] - } -}; diff --git a/packages/ui/chatbot/.gitignore b/packages/ui/chatbot/.gitignore deleted file mode 100644 index a547bf36d8..0000000000 --- a/packages/ui/chatbot/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* -lerna-debug.log* - -node_modules -dist -dist-ssr -*.local - -# Editor directories and files -.vscode/* -!.vscode/extensions.json -.idea -.DS_Store -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? diff --git a/packages/ui/chatbot/.prettierrc.cjs b/packages/ui/chatbot/.prettierrc.cjs deleted file mode 100644 index 39cf0d0b8c..0000000000 --- a/packages/ui/chatbot/.prettierrc.cjs +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("../../../.prettierrc.json"); diff --git a/packages/ui/chatbot/.stylelintrc.json b/packages/ui/chatbot/.stylelintrc.json deleted file mode 100644 index 0d2e3ff61d..0000000000 --- a/packages/ui/chatbot/.stylelintrc.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": ["../../../shared/stylelintrc.shared.json"] } diff --git a/packages/ui/chatbot/README.md b/packages/ui/chatbot/README.md deleted file mode 100644 index 85a6989e12..0000000000 --- a/packages/ui/chatbot/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# React + TypeScript + Vite - -This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. - -Currently, two official plugins are available: - -- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh -- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh - -## Expanding the ESLint configuration - -If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: - -- Configure the top-level `parserOptions` property like this: - -```js -export default { - // other rules... - parserOptions: { - ecmaVersion: "latest", - sourceType: "module", - project: ["./tsconfig.json", "./tsconfig.node.json", "./tsconfig.app.json"], - tsconfigRootDir: __dirname, - }, -}; -``` - -- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` -- Optionally add `plugin:@typescript-eslint/stylistic-type-checked` -- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list diff --git a/packages/ui/chatbot/index.html b/packages/ui/chatbot/index.html deleted file mode 100644 index e0ef3be833..0000000000 --- a/packages/ui/chatbot/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - Vite + React + TS - - -
- - - diff --git a/packages/ui/chatbot/package.json b/packages/ui/chatbot/package.json deleted file mode 100644 index 0e694a2081..0000000000 --- a/packages/ui/chatbot/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "name": "@fern-ui/chatbot", - "private": true, - "version": "0.0.0", - "repository": { - "type": "git", - "url": "git+https://github.com/fern-api/fern-platform.git", - "directory": "packages/ui/chatbot" - }, - "type": "module", - "exports": { - ".": "./src/index.ts", - "./src/index.scss": "./src/index.scss" - }, - "files": [ - "src" - ], - "sideEffects": [ - "*.css", - "*.scss" - ], - "scripts": { - "test": "vitest --run --passWithNoTests --globals", - "compile": "tsc --build", - "lint:eslint": "eslint --max-warnings 0 . --ignore-path=../../../.eslintignore", - "lint:eslint:fix": "pnpm lint:eslint --fix", - "lint:style": "stylelint 'src/**/*.scss' --allow-empty-input --max-warnings 0", - "lint:style:fix": "pnpm lint:style --fix", - "format": "prettier --write --ignore-unknown --ignore-path ../../../shared/.prettierignore \"**\"", - "format:check": "prettier --check --ignore-unknown --ignore-path ../../../shared/.prettierignore \"**\"", - "organize-imports": "organize-imports-cli tsconfig.json", - "depcheck": "depcheck" - }, - "dependencies": { - "@fern-ui/components": "workspace:*", - "@radix-ui/colors": "^3.0.0", - "clsx": "^2.1.1", - "es-toolkit": "^1.27.0", - "hastscript": "^9.0.0", - "jotai": "^2.8.1", - "react-markdown": "^9.0.1", - "remark-gfm": "^4.0.0", - "uuid": "^9.0.0" - }, - "peerDependencies": { - "react": "^18", - "react-dom": "^18" - }, - "devDependencies": { - "react": "^18", - "react-dom": "^18", - "@fern-platform/configs": "workspace:*", - "@tailwindcss/typography": "^0.5.10", - "@types/hast": "^3.0.4", - "@types/react": "^18", - "@types/react-dom": "^18", - "@types/uuid": "^9.0.1", - "@typescript-eslint/eslint-plugin": "^7.15.0", - "@typescript-eslint/parser": "^7.15.0", - "depcheck": "^1.4.3", - "eslint": "^8.57.0", - "eslint-plugin-react-hooks": "^4.6.2", - "eslint-plugin-react-refresh": "^0.4.7", - "organize-imports-cli": "^0.10.0", - "prettier": "^3.3.2", - "stylelint": "^16.1.0", - "tailwindcss": "^3.4.3", - "typescript": "5.4.3", - "vitest": "^2.1.4" - } -} diff --git a/packages/ui/chatbot/postcss.config.js b/packages/ui/chatbot/postcss.config.js deleted file mode 100644 index 49c0612d5c..0000000000 --- a/packages/ui/chatbot/postcss.config.js +++ /dev/null @@ -1,6 +0,0 @@ -export default { - plugins: { - tailwindcss: {}, - autoprefixer: {}, - }, -}; diff --git a/packages/ui/chatbot/src/App.scss b/packages/ui/chatbot/src/App.scss deleted file mode 100644 index 603aec9e16..0000000000 --- a/packages/ui/chatbot/src/App.scss +++ /dev/null @@ -1,59 +0,0 @@ -@import "tailwindcss/base"; -@import "tailwindcss/components"; -@import "tailwindcss/utilities"; -@import "@radix-ui/colors/gray"; -@import "@radix-ui/colors/gray-dark"; -@import "@radix-ui/colors/gray-alpha"; -@import "@radix-ui/colors/gray-dark-alpha"; -@import "./index"; - -@layer components { - .icon-2xl { - @apply size-8 shrink-0; - - stroke-width: 1.5; - } -} - -@layer utilities { - .mask-grad-y-6 { - mask-image: linear-gradient(to bottom, transparent 0, black 24px, black calc(100% - 24px), transparent 100%); - } -} - -#root { - max-width: 1280px; - margin: 0 auto; - padding: 2rem; -} - -:root { - color-scheme: light dark; - font-synthesis: none; - text-rendering: optimizelegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - - --fern-chatbot-modal-bg: #f9fafb; - --fern-chatbot-link: #3182ce; - --fern-chatbot-link-hover: #2c5282; - --tag-default: #e2e8f0; - --border-accent-muted: #e2e8f0; -} - -.dark { - --fern-chatbot-modal-bg: #1a202c; - --fern-chatbot-link: #63b3ed; - --fern-chatbot-link-hover: #4299e1; - --tag-default: #2d3748; - --border-accent-muted: #2d3748; -} - -body { - margin: 0; - display: flex; - place-items: center; - min-width: 320px; - min-height: 100vh; - background-color: black; -} diff --git a/packages/ui/chatbot/src/App.tsx b/packages/ui/chatbot/src/App.tsx deleted file mode 100644 index 908586ecbf..0000000000 --- a/packages/ui/chatbot/src/App.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import "./App.scss"; -import { ChatbotModal } from "./components/ChatbotModal"; - -function App() { - return ( -
- [undefined, new AbortController()]} - className="bg-grayscale-2 rounded-lg w-full text-black dark:text-white" - /> -
- ); -} - -export default App; diff --git a/packages/ui/chatbot/src/atoms/atomWithSessionStorage.ts b/packages/ui/chatbot/src/atoms/atomWithSessionStorage.ts deleted file mode 100644 index 3af5318e93..0000000000 --- a/packages/ui/chatbot/src/atoms/atomWithSessionStorage.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { atomWithStorage, RESET } from "jotai/utils"; -import type { WritableAtom } from "jotai/vanilla"; - -export function atomWithSessionStorage( - key: string, - initialValue: Value, -): WritableAtom Value | typeof RESET)], void> { - return atomWithStorage(key, initialValue, { - getItem: (key, initialValue) => { - if (typeof window === "undefined") { - return initialValue; - } - - try { - const stored: string | null = window.sessionStorage.getItem(key); - if (stored == null) { - return initialValue; - } - return JSON.parse(stored); - } catch (e) { - console.error(e); - } - return initialValue; - }, - setItem: (key, newValue) => { - if (typeof window === "undefined") { - return; - } - - try { - window.sessionStorage.setItem(key, JSON.stringify(newValue)); - } catch (e) { - console.error(e); - } - }, - removeItem: (key) => { - if (typeof window === "undefined") { - return; - } - - try { - window.sessionStorage.removeItem(key); - } catch (e) { - console.error(e); - } - }, - subscribe: (key, callback) => { - if (typeof window === "undefined") { - return () => {}; - } - - const listener = (event: StorageEvent) => { - if (event.key === key && event.storageArea === window.sessionStorage) { - if (event.newValue === null) { - callback(initialValue); - } else { - callback(JSON.parse(event.newValue)); - } - } - }; - - window.addEventListener("storage", listener); - return () => { - window.removeEventListener("storage", listener); - }; - }, - }); -} diff --git a/packages/ui/chatbot/src/components/AskInput.tsx b/packages/ui/chatbot/src/components/AskInput.tsx deleted file mode 100644 index 3a46cf7464..0000000000 --- a/packages/ui/chatbot/src/components/AskInput.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import clsx from "clsx"; -import { ReactElement, useState } from "react"; -import { SendButton } from "./SendButton"; -import { TextArea } from "./TextArea"; - -interface AskInputProps { - className?: string; - onSend: (message: string) => void; -} - -export function AskInput({ onSend, className }: AskInputProps): ReactElement { - const [value, setValue] = useState(""); - - return ( -
-
-
-
-