Skip to content

Conversation

micheleriva
Copy link
Contributor

This PR supersedes #7971 and integrates the new Orama components, powered by the new OramaCore backend.

Description

New components - React-based to replace the old WebComponents-based ones. New backend (OramaCore instead of old Orama Cloud), all hosted and maintained on https://app.orama.com. Credentials have been shared privately with the repository maintainers on Slack.

Validation

Tested locally and on remote demo environment.

Related Issues

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run pnpm format to ensure the code follows the style guide.
  • I have run pnpm test to check if all tests are passing.
  • I have run pnpm build to check if the website builds without errors.
  • I've covered new added functionality with unit tests if necessary.

g-francesca and others added 30 commits July 9, 2025 11:54
Co-authored-by: Aviv Keller <[email protected]>
Signed-off-by: Aileen Villanueva Lecuona <[email protected]>
Co-authored-by: Aviv Keller <[email protected]>
Signed-off-by: Aileen Villanueva Lecuona <[email protected]>
Co-authored-by: Aviv Keller <[email protected]>
Signed-off-by: Aileen Villanueva Lecuona <[email protected]>
Co-authored-by: Aviv Keller <[email protected]>
Signed-off-by: Aileen Villanueva Lecuona <[email protected]>
Co-authored-by: Aviv Keller <[email protected]>
Signed-off-by: Aileen Villanueva Lecuona <[email protected]>
@g-francesca
Copy link

  1. getDocuments is a function
image

Thanks @avivkeller. So I've updated the HTML element targeted as search-results wrapper (I've targeted the wrong one before by mistake). I tried to run the playwright tests locally, and they're passing.
Screenshot 2025-10-07 alle 11 04 56

@avivkeller
Copy link
Member

setIsMobileScreen(window.innerWidth < 1024);
};
checkScreenSize();
window.addEventListener('resize', checkScreenSize);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these be passive listeners?

setOpen(!open);
};

useEffect(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@canerakdas is there any Radix component we could use for handling these? Maybe Dialog? https://www.radix-ui.com/primitives/docs/components/dialog

I'd like to avoid wiring manual useEffects and hardcoding these.

{!isMobileScreen && mode === 'chat' && (
<SlidingChatPanel
open={isChatOpen}
onClose={() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like we should use React Reducers to manage the lifecycle of the SearchBox and Dialog IMO, could we do that?

}
};

const handleChatOpened = (): void => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these feel like lifecycle hooks that could be done either via Hooks or Reducers.

const displaySearch =
!isMobileScreen || (isMobileScreen && mode === 'search');

useEffect(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please use this? https://github.com/nodejs/nodejs.org/blob/main/apps/site/hooks/react-client/useMediaQuery.ts using resize effects is inefficient.

};
}, []);

const handleSelectMode = (newMode: 'search' | 'chat') => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lifecycle Hooks 👀

import { Search } from './Search';
import { SlidingChatPanel } from './SlidingChatPanel';

const orama =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel orama should be instantiated somewhere else and not inside a component. It should probably be provided by a React Provider so that you wrap the search box with <OramaProvider> and then use const orama = useOrama()

@@ -0,0 +1,11 @@
export const uppercaseFirst = (word: string) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this be done with CSS?

>
<DocumentTextIcon />
<div>
{typeof hit.document?.pageSectionTitle ===
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you extract this to a proper function? Too much complexity in a single component.

} = useSearch();
const containerRef = useRef<HTMLDivElement>(null);

const clearAll = useCallback(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lifecycle Hooks (React Reducer)

dispatch({ type: 'SET_RESULTS', payload: { results: [] } });
}, [dispatch]);

useEffect(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lifecycle Hooks

};
}, [clearAll]);

useEffect(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm strongly against using querySelectors within React, it breaks the nature of React.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This component is just too big, please break it down into smaller parts 🙇


const oramaLogo = `https://website-assets.oramasearch.com/orama-when-${resolvedTheme}.svg`;

const clearAll = useCallback(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lifecycle Hooks

ovflowd

This comment was marked as outdated.

Copy link
Member

@ovflowd ovflowd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Searching on this branch is broken?

Image

There are a few things here and there I believe need to be addressed. Some components are too big, some have way too many Effects that can become React Reducers for Lifecycle management.

I genuinely appreciate the effort done here ❤️ and 100% value the effort and time Orama team is spending on this PR 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants