Skip to content

Commit

Permalink
various improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
pablonyx committed Jan 16, 2025
1 parent 0b88052 commit 85d515f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 69 deletions.
2 changes: 0 additions & 2 deletions web/src/app/assistants/SidebarWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ export default function SidebarWrapper<T extends object>({
{" "}
<HistorySidebar
setShowAssistantsModal={setShowAssistantsModal}
assistants={assistants}
page={"chat"}
explicitlyUntoggle={explicitlyUntoggle}
ref={sidebarElementRef}
Expand All @@ -126,7 +125,6 @@ export default function SidebarWrapper<T extends object>({
existingChats={chatSessions}
currentChatSession={null}
folders={folders}
openedFolders={openedFolders}
/>
</div>
</div>
Expand Down
4 changes: 0 additions & 4 deletions web/src/app/chat/ChatPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2158,20 +2158,16 @@ export function ChatPage({
<div className="w-full relative">
<HistorySidebar
setShowAssistantsModal={setShowAssistantsModal}
assistants={assistants}
explicitlyUntoggle={explicitlyUntoggle}
stopGenerating={stopGenerating}
reset={() => setMessage("")}
page="chat"
ref={innerSidebarElementRef}
toggleSidebar={toggleSidebar}
toggled={toggledSidebar}
backgroundToggled={toggledSidebar || showHistorySidebar}
currentAssistantId={liveAssistant?.id}
existingChats={chatSessions}
currentChatSession={selectedChatSession}
folders={folders}
openedFolders={openedFolders}
removeToggle={removeToggle}
showShareModal={showShareModal}
showDeleteAllModal={() => setShowDeleteAllModal(true)}
Expand Down
9 changes: 2 additions & 7 deletions web/src/app/chat/RegenerateOption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function RegenerateDropdown({
};

const Dropdown = (
<div className="max-h-[var(--radix-dropdown-menu-content-available-height)] overflow-y-auto py-2 min-w-fit bg-white dark:bg-gray-800 rounded-md shadow-lg">
<div className="overflow-y-auto py-2 min-w-fit bg-white dark:bg-gray-800 rounded-md shadow-lg">
<div className="mb-1 flex items-center justify-between px-5 pt-2">
<span className="text-sm text-text-500 dark:text-text-400">
Regenerate with
Expand All @@ -58,12 +58,7 @@ export function RegenerateDropdown({
<div className="flex grow items-center justify-between gap-2">
<div>
<div className="flex items-center gap-3">
<div>
{getDisplayNameForModel(option.name)}
<div className="text-text-500 dark:text-text-400 text-xs">
{option.description || "Model description"}
</div>
</div>
<div>{getDisplayNameForModel(option.name)}</div>
</div>
</div>
</div>
Expand Down
10 changes: 0 additions & 10 deletions web/src/app/chat/sessionSidebar/HistorySidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use client";

import { FiEdit, FiFolderPlus, FiMoreHorizontal, FiPlus } from "react-icons/fi";
import React, {
ForwardedRef,
forwardRef,
Expand Down Expand Up @@ -54,18 +53,14 @@ interface HistorySidebarProps {
existingChats?: ChatSession[];
currentChatSession?: ChatSession | null | undefined;
folders?: Folder[];
openedFolders?: { [key: number]: boolean };
toggleSidebar?: () => void;
toggled?: boolean;
removeToggle?: () => void;
reset?: () => void;
showShareModal?: (chatSession: ChatSession) => void;
showDeleteModal?: (chatSession: ChatSession) => void;
stopGenerating?: () => void;
explicitlyUntoggle: () => void;
showDeleteAllModal?: () => void;
backgroundToggled?: boolean;
assistants: Persona[];
currentAssistantId?: number | null;
setShowAssistantsModal: (show: boolean) => void;
}
Expand Down Expand Up @@ -148,17 +143,13 @@ export const HistorySidebar = forwardRef<HTMLDivElement, HistorySidebarProps>(
page,
existingChats,
currentChatSession,
assistants,
folders,
openedFolders,
explicitlyUntoggle,
toggleSidebar,
removeToggle,
stopGenerating = () => null,
showShareModal,
showDeleteModal,
showDeleteAllModal,
backgroundToggled,
currentAssistantId,
},
ref: ForwardedRef<HTMLDivElement>
Expand Down Expand Up @@ -364,7 +355,6 @@ export const HistorySidebar = forwardRef<HTMLDivElement, HistorySidebarProps>(

<PagesTab
setNewFolderId={setNewFolderId}
newFolderId={newFolderId}
showDeleteModal={showDeleteModal}
showShareModal={showShareModal}
closeSidebar={removeToggle}
Expand Down
55 changes: 10 additions & 45 deletions web/src/app/chat/sessionSidebar/PagesTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ import {
import { Folder } from "../folders/interfaces";
import { usePopup } from "@/components/admin/connectors/Popup";
import { useRouter } from "next/navigation";
import { pageType } from "./types";
import { FiPlus, FiTrash2, FiEdit, FiCheck, FiX } from "react-icons/fi";
import { FiPlus, FiTrash2, FiCheck, FiX } from "react-icons/fi";
import { NEXT_PUBLIC_DELETE_ALL_CHATS_ENABLED } from "@/lib/constants";
import { FolderDropdown } from "../folders/FolderDropdown";
import { ChatSessionDisplay } from "./ChatSessionDisplay";
import { useState, useCallback, useRef, useEffect } from "react";
import { useState, useCallback, useRef } from "react";
import { Caret } from "@/components/icons/icons";
import { CaretCircleDown } from "@phosphor-icons/react";
import { groupSessionsByDateRange } from "../lib";
import React from "react";
import {
Expand All @@ -36,7 +34,6 @@ import {
} from "@dnd-kit/sortable";
import { useSortable } from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities";
import { DragHandle } from "@/components/table/DragHandle";
import { useChatContext } from "@/components/context/ChatContext";

interface SortableFolderProps {
Expand All @@ -52,50 +49,20 @@ interface SortableFolderProps {
}

const SortableFolder: React.FC<SortableFolderProps> = (props) => {
const {
attributes,
listeners,
setNodeRef,
transform,
transition,
isDragging,
} = useSortable({
id: props.folder.folder_id?.toString() ?? "",
data: {
activationConstraint: {
distance: 8,
const { attributes, listeners, setNodeRef, transform, transition } =
useSortable({
id: props.folder.folder_id?.toString() ?? "",
data: {
activationConstraint: {
distance: 8,
},
},
},
});
});
const ref = useRef<HTMLDivElement>(null);
const style = {
transform: CSS.Transform.toString(transform),
transition,
};
const [isHovering, setIsHovering] = useState(false);

useEffect(() => {
const handleMouseMove = (event: MouseEvent) => {
if (ref.current) {
const rect = ref.current.getBoundingClientRect();
const isInside =
event.clientX >= rect.left &&
event.clientX <= rect.right &&
event.clientY >= rect.top &&
event.clientY <= rect.bottom;
if (isInside) {
setIsHovering(true);
} else {
setIsHovering(false);
}
}
};

document.addEventListener("mousemove", handleMouseMove);
return () => {
document.removeEventListener("mousemove", handleMouseMove);
};
}, []);

return (
<div
Expand All @@ -113,7 +80,6 @@ export function PagesTab({
currentChatId,
folders,
closeSidebar,
newFolderId,
showShareModal,
showDeleteModal,
showDeleteAllModal,
Expand All @@ -123,7 +89,6 @@ export function PagesTab({
currentChatId?: string;
folders?: Folder[];
closeSidebar?: () => void;
newFolderId: number | null;
showShareModal?: (chatSession: ChatSession) => void;
showDeleteModal?: (chatSession: ChatSession) => void;
showDeleteAllModal?: () => void;
Expand Down
5 changes: 4 additions & 1 deletion web/src/components/WebResultIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
import { ValidSources } from "@/lib/types";
import { SourceIcon } from "./SourceIcon";
import { useState } from "react";
import { OnyxIcon } from "./icons/icons";

export function WebResultIcon({ url }: { url: string }) {
const [error, setError] = useState(false);
const hostname = new URL(url).hostname;
return (
<>
{!error ? (
{hostname == "docs.onyx.app" ? (
<OnyxIcon size={18} />
) : !error ? (
<img
className="my-0 w-5 h-5 rounded-full py-0"
src={`https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=https://${hostname}&size=128`}
Expand Down

0 comments on commit 85d515f

Please sign in to comment.