Skip to content

Commit

Permalink
adjusting layout and logic
Browse files Browse the repository at this point in the history
  • Loading branch information
varunthakkar1 committed Jul 3, 2024
1 parent 386c085 commit 5ba99f5
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 51 deletions.
2 changes: 1 addition & 1 deletion src/interfaces/coral_web/.env.development
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Client
NEXT_PUBLIC_API_HOSTNAME=http://localhost:8000
NEXT_PUBLIC_API_HOSTNAME=https://cohere-toolkit-backend-lfdlhmdyqa-uc.a.run.app/
NEXT_PUBLIC_HAS_CUSTOM_LOGO=false
19 changes: 16 additions & 3 deletions src/interfaces/coral_web/src/components/Citations/Citation.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Transition } from '@headlessui/react';
import { flatten, sortBy, uniqBy } from 'lodash';
import React, { useRef } from 'react';
import React, { useEffect, useRef } from 'react';
import { useMemo, useState } from 'react';

import { Document } from '@/cohere-client';
Expand Down Expand Up @@ -81,6 +81,19 @@ export const Citation = React.forwardRef<HTMLDivElement, Props>(function Citatio
'document_id'
);

console.log(highlightedDocumentIds)

useEffect(() => {
if (selectedCitation) {
const generationId = selectedCitation['generationId']
const minimapCitations = Object.values(citationReferences[generationId]).flat().filter(citation =>
citation.tool_name === 'MiniMap' && highlightedDocumentIds.includes(citation.document_id)
)
const minimapCitationsUnique = new Set(minimapCitations.map(c => c.url))
window.top && window.top.postMessage({ type: 'newCitations', urls: Array.from(minimapCitationsUnique) }, '*')
}
}, [highlightedDocumentIds, selectedCitation])

const handleMouseEnter = () => {
hoverCitation(generationId);
};
Expand Down Expand Up @@ -109,8 +122,8 @@ export const Citation = React.forwardRef<HTMLDivElement, Props>(function Citatio
...styles,
...(translateY !== 0 && isSelected
? {
'--selectedTranslateY': `${translateY}px`,
}
'--selectedTranslateY': `${translateY}px`,
}
: {}),
}}
className={cn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ const Messages = forwardRef<HTMLDivElement, MessagesProps>(function MessagesInte
const isConversationEmpty = messages.length === 0;
return (
<div className="flex h-full flex-col gap-y-4 px-4 py-6 md:gap-y-6" ref={ref}>
{startOptionsEnabled && (
{/* {startOptionsEnabled && (
<div className="flex h-full w-full flex-col justify-center p-4">
<StartModes show={isConversationEmpty} onPromptSelected={onPromptSelected} />
</div>
)}
)} */}

<div className="mt-auto flex flex-col gap-y-4 md:gap-y-6">
{messages.map((m, i) => {
Expand Down
11 changes: 0 additions & 11 deletions src/interfaces/coral_web/src/components/Conversation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,6 @@ const Conversation: React.FC<Props> = ({ conversationId, startOptionsEnabled = f
};
}, [handleClickOutside]);

useEffect(() => {
if (selectedCitation) {
const generationId = selectedCitation['generationId']
console.log(selectedCitation)
const minimapCitations = Object.values(citationReferences[generationId]).flat().filter(citation => citation.tool_name === 'MiniMap')
const minimapCitationsUnique = new Set(minimapCitations.map(c => c.url))
console.log(minimapCitationsUnique)
window.top && window.top.postMessage({ type: 'newCitations', urls: Array.from(minimapCitationsUnique) }, '*')
}
}, [selectedCitation])

const [isRouteChanging] = useRouteChange();

if (isRouteChanging) {
Expand Down
8 changes: 4 additions & 4 deletions src/interfaces/coral_web/src/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,18 @@ export const Layout: React.FC<Props> = ({ title = 'Chat', children }) => {
<>
<PageHead title={capitalize(title)} />
<div className="flex h-screen w-full flex-1 flex-col gap-3 bg-secondary-100 p-3">
<NavigationBar>
{/* <NavigationBar>
<span className="flex items-center gap-x-2">
<DeploymentsDropdown />
<EditEnvVariablesButton className="py-0" />
</span>
</NavigationBar>
</NavigationBar> */}
{bannerMessage && <Banner size="sm">{bannerMessage}</Banner>}

<div className={cn('relative flex h-full flex-grow flex-nowrap overflow-hidden')}>
<Transition
as="div"
show={isMobileConvListPanelOpen || (isConvListPanelOpen && isDesktop)}
show={false}
enterFrom={cn(
'-translate-x-full lg:translate-x-0',
'lg:mr-0 lg:opacity-0 lg:min-w-0 lg:max-w-0'
Expand Down Expand Up @@ -105,7 +105,7 @@ export const Layout: React.FC<Props> = ({ title = 'Chat', children }) => {
</Transition>
<Transition
as="main"
show={!isMobileConvListPanelOpen || isDesktop}
show={true}
enterFrom="translate-x-full lg:translate-x-0"
enterTo="translate-x-0"
leaveFrom="translate-x-0"
Expand Down
31 changes: 1 addition & 30 deletions src/interfaces/coral_web/src/components/StartModes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,37 +46,8 @@ export const StartModes: React.FC<Props> = ({ show, className = '', onPromptSele
className={cn('flex flex-col items-center gap-y-6', className)}
>
<Text styleAs="h5" className="text-center">
Choose an option to get started
Ask about news
</Text>

<div className={cn('w-full max-w-[820px]', 'rounded-lg border border-marble-400')}>
<Tabs
tabs={modes.map((m) => m.title)}
selectedIndex={selectedMode}
onChange={handleTabChange}
panelsClassName="lg:pt-5 pt-5 pb-4"
fitTabsContent={false}
tabClassName="pt-1"
tabGroupClassName="px-4"
>
{modes.map((m) => (
<div key={m.title} className="flex flex-col gap-y-5">
<Text>{m.description}</Text>
<div className="flex flex-col gap-2.5 md:flex-row">
{m.promptOptions.map((promptOption) => (
<PromptOptionButton
{...promptOption}
key={promptOption.title}
onClick={() => {
onPromptSelected?.({ prompt: promptOption.prompt, params: m.params });
}}
/>
))}
</div>
</div>
))}
</Tabs>
</div>
</Transition>
);
};
Expand Down
3 changes: 3 additions & 0 deletions src/interfaces/coral_web/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ module.exports = {
plugins: [require('@tailwindcss/typography')],
theme: {
extend: {
colors: {
'dark': "#121212"
},
screens: {
'3xl': '2000px',
},
Expand Down

0 comments on commit 5ba99f5

Please sign in to comment.