Skip to content

Commit

Permalink
fix: delete old chat code (#1899)
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity authored Dec 16, 2024
1 parent ddb0038 commit a92013a
Show file tree
Hide file tree
Showing 50 changed files with 182 additions and 1,395 deletions.
6 changes: 2 additions & 4 deletions packages/ui/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
5 changes: 0 additions & 5 deletions packages/ui/app/src/atoms/cohere.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/ui/app/src/atoms/index.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
1 change: 0 additions & 1 deletion packages/ui/app/src/css/globals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
12 changes: 1 addition & 11 deletions packages/ui/app/src/search/SearchDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -54,12 +49,7 @@ const InternalSearchDialog = (): ReactNode => {
}

if (config.inkeep == null) {
return (
<>
<AlgoliaSearchDialog />
{/* {isAskAiEnabled && <CohereChatButton />} */}
</>
);
return <AlgoliaSearchDialog />;
} else {
return (
<>
Expand Down
56 changes: 2 additions & 54 deletions packages/ui/app/src/search/SearchHits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<PropsWithChildren> = ({ children }) => {
return <div className="justify t-muted flex h-24 w-full flex-col hits-center py-3">{children}</div>;
};

const COHERE_AI_HIT_ID = "cohere-ai-hit";
const SEARCH_HITS_PER_SECTION = 3;

const expandHits = (expanded: boolean, hits: SearchRecord[]) => {
Expand Down Expand Up @@ -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]);

Expand All @@ -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];
Expand All @@ -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);
Expand All @@ -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));
Expand Down Expand Up @@ -245,18 +217,6 @@ export const SearchHits: React.FC = () => {
className="p-2"
scrollbars="vertical"
>
{isAskAiEnabled && (
<AskCohereHit
setRef={(elem) => {
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 && (
<SearchSection
title="Pages"
Expand Down Expand Up @@ -284,7 +244,6 @@ export const SearchHits: React.FC = () => {
};

export const SearchMobileHits: React.FC<PropsWithChildren> = ({ children }) => {
const { isAskAiEnabled } = useFeatureFlags();
const { hits } = useInfiniteHits<SearchRecord>();

Check warning on line 247 in packages/ui/app/src/search/SearchHits.tsx

View workflow job for this annotation

GitHub Actions / lint

'hits' is deprecated. use `items` instead
const search = useInstantSearch();
const [expandEndpoints, setExpandEndpoints] = useState(false);
Expand All @@ -305,17 +264,6 @@ export const SearchMobileHits: React.FC<PropsWithChildren> = ({ children }) => {

return (
<FernScrollArea rootClassName="min-h-[80vh]" className="mask-grad-top-4 px-2 pt-4">
{isAskAiEnabled && (
<AskCohereHit
setRef={(elem) => {
if (elem != null) {
refs.current.set(COHERE_AI_HIT_ID, elem);
}
}}
message={search.results.query}
isHovered={true}
/>
)}
{pageHits.length > 0 && (
<MobileSearchSection
title="Pages"
Expand Down
65 changes: 0 additions & 65 deletions packages/ui/app/src/search/cohere/AskCohereHit.tsx

This file was deleted.

43 changes: 0 additions & 43 deletions packages/ui/app/src/search/cohere/CohereChatButton.tsx

This file was deleted.

Loading

0 comments on commit a92013a

Please sign in to comment.