Skip to content

Commit 1789f4e

Browse files
raunakabaponcedeleonch
authored andcommitted
refactor: Update location of sidebar (onyx-dot-app#5067)
* Use props instead of inline type def * Add new AppProvider * Remove unused component file * Move `sessionSidebar` to be inside of `components` instead of `app/chat` * Change name of `sessionSidebar` to `sidebar` * Remove `AppModeProvider` * Fix bug in how the cookies were set
1 parent 2d8b102 commit 1789f4e

File tree

12 files changed

+33
-51
lines changed

12 files changed

+33
-51
lines changed

web/src/app/assistants/SidebarWrapper.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { useRouter } from "next/navigation";
99
import FixedLogo from "../../components/logo/FixedLogo";
1010
import { SettingsContext } from "@/components/settings/SettingsProvider";
1111
import { useChatContext } from "@/components/context/ChatContext";
12-
import { HistorySidebar } from "../chat/sessionSidebar/HistorySidebar";
12+
import { HistorySidebar } from "@/components/sidebar/HistorySidebar";
1313
import { useAssistants } from "@/components/context/AssistantsContext";
1414
import AssistantModal from "./mine/AssistantModal";
1515
import { useSidebarShortcut } from "@/lib/browserUtilities";
@@ -35,11 +35,9 @@ export default function SidebarWrapper<T extends object>({
3535
const toggleSidebar = useCallback(() => {
3636
Cookies.set(
3737
SIDEBAR_TOGGLED_COOKIE_NAME,
38-
String(!sidebarVisible).toLocaleLowerCase()
39-
),
40-
{
41-
path: "/",
42-
};
38+
String(!sidebarVisible).toLocaleLowerCase(),
39+
{ path: "/" }
40+
);
4341
setSidebarVisible((sidebarVisible) => !sidebarVisible);
4442
}, [sidebarVisible]);
4543

web/src/app/chat/ChatPage.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828

2929
import Prism from "prismjs";
3030
import Cookies from "js-cookie";
31-
import { HistorySidebar } from "./sessionSidebar/HistorySidebar";
31+
import { HistorySidebar } from "@/components/sidebar/HistorySidebar";
3232
import { MinimalPersonaSnapshot } from "../admin/assistants/interfaces";
3333
import { HealthCheckBanner } from "@/components/health/healthcheck";
3434
import {
@@ -150,6 +150,15 @@ export enum UploadIntent {
150150
ADD_TO_DOCUMENTS, // For files uploaded via FilePickerModal or similar (just add to repo)
151151
}
152152

153+
type ChatPageProps = {
154+
toggle: (toggled?: boolean) => void;
155+
documentSidebarInitialWidth?: number;
156+
sidebarVisible: boolean;
157+
firstMessage?: string;
158+
initialFolders?: any;
159+
initialFiles?: any;
160+
};
161+
153162
// ---
154163
// File Attachment Behavior in ChatPage
155164
//
@@ -171,14 +180,7 @@ export function ChatPage({
171180
firstMessage,
172181
initialFolders,
173182
initialFiles,
174-
}: {
175-
toggle: (toggled?: boolean) => void;
176-
documentSidebarInitialWidth?: number;
177-
sidebarVisible: boolean;
178-
firstMessage?: string;
179-
initialFolders?: any;
180-
initialFiles?: any;
181-
}) {
183+
}: ChatPageProps) {
182184
const router = useRouter();
183185
const searchParams = useSearchParams();
184186

web/src/app/chat/folders/FolderList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import React, { useState, useEffect, useRef } from "react";
44
import { Folder } from "./interfaces";
5-
import { ChatSessionDisplay } from "../sessionSidebar/ChatSessionDisplay"; // Ensure this is correctly imported
5+
import { ChatSessionDisplay } from "@/components/sidebar/ChatSessionDisplay"; // Ensure this is correctly imported
66
import {
77
FiChevronDown,
88
FiChevronRight,

web/src/app/chat/sessionSidebar/ChatGroup.tsx

Lines changed: 0 additions & 20 deletions
This file was deleted.

web/src/app/providers.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ const isPostHogEnabled = !!(
77
process.env.NEXT_PUBLIC_POSTHOG_KEY && process.env.NEXT_PUBLIC_POSTHOG_HOST
88
);
99

10-
export function PHProvider({ children }: { children: React.ReactNode }) {
10+
type PHProviderProps = { children: React.ReactNode };
11+
12+
export function PHProvider({ children }: PHProviderProps) {
1113
useEffect(() => {
1214
if (isPostHogEnabled) {
1315
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {

web/src/components/UserDropdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Popover } from "./popover/Popover";
1010
import { LOGOUT_DISABLED } from "@/lib/constants";
1111
import { SettingsContext } from "./settings/SettingsProvider";
1212
import { BellIcon, LightSettingsIcon, UserIcon } from "./icons/icons";
13-
import { pageType } from "@/app/chat/sessionSidebar/types";
13+
import { pageType } from "@/components/sidebar/types";
1414
import { NavigationItem, Notification } from "@/app/admin/settings/interfaces";
1515
import DynamicFaIcon, { preloadIcons } from "./icons/DynamicFaIcon";
1616
import { useUser } from "./user/UserProvider";

web/src/components/chat/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { FiShare2 } from "react-icons/fi";
44
import { SetStateAction, useContext, useEffect } from "react";
55
import { ChatSession } from "@/app/chat/interfaces";
66
import Link from "next/link";
7-
import { pageType } from "@/app/chat/sessionSidebar/types";
7+
import { pageType } from "@/components/sidebar/types";
88
import { useRouter } from "next/navigation";
99
import { ChatBanner } from "@/app/chat/ChatBanner";
1010
import LogoWithText from "../header/LogoWithText";

web/src/components/header/LogoWithText.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
TooltipProvider,
1010
TooltipTrigger,
1111
} from "@/components/ui/tooltip";
12-
import { pageType } from "@/app/chat/sessionSidebar/types";
12+
import { pageType } from "@/components/sidebar/types";
1313
import { Logo } from "../logo/Logo";
1414
import Link from "next/link";
1515
import { LogoComponent } from "@/components/logo/FixedLogo";

web/src/app/chat/sessionSidebar/ChatSessionDisplay.tsx renamed to web/src/components/sidebar/ChatSessionDisplay.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"use client";
22

33
import { useRouter } from "next/navigation";
4-
import { ChatSession } from "../interfaces";
4+
import { ChatSession } from "@/app/chat/interfaces";
55
import { useState, useEffect, useContext, useRef, useCallback } from "react";
66
import {
77
deleteChatSession,
88
getChatRetentionInfo,
99
renameChatSession,
10-
} from "../lib";
10+
} from "@/app/chat/lib";
1111
import { BasicSelectable } from "@/components/BasicClickable";
1212
import Link from "next/link";
1313
import {
@@ -20,7 +20,7 @@ import {
2020
} from "react-icons/fi";
2121
import { DefaultDropdownElement } from "@/components/Dropdown";
2222
import { Popover } from "@/components/popover/Popover";
23-
import { ShareChatSessionModal } from "../modal/ShareChatSessionModal";
23+
import { ShareChatSessionModal } from "@/app/chat/modal/ShareChatSessionModal";
2424
import { CHAT_SESSION_ID_KEY, FOLDER_ID_KEY } from "@/lib/drag/constants";
2525
import { SettingsContext } from "@/components/settings/SettingsProvider";
2626
import { DragHandle } from "@/components/table/DragHandle";

web/src/app/chat/sessionSidebar/HistorySidebar.tsx renamed to web/src/components/sidebar/HistorySidebar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import {
1515
} from "@/components/ui/tooltip";
1616

1717
import { useRouter, useSearchParams } from "next/navigation";
18-
import { ChatSession } from "../interfaces";
19-
import { Folder } from "../folders/interfaces";
18+
import { ChatSession } from "@/app/chat/interfaces";
19+
import { Folder } from "@/app/chat/folders/interfaces";
2020
import { SettingsContext } from "@/components/settings/SettingsProvider";
2121

2222
import {
@@ -31,7 +31,7 @@ import { MinimalPersonaSnapshot } from "@/app/admin/assistants/interfaces";
3131
import { DragEndEvent } from "@dnd-kit/core";
3232
import { useAssistants } from "@/components/context/AssistantsContext";
3333
import { AssistantIcon } from "@/components/assistants/AssistantIcon";
34-
import { buildChatUrl } from "../lib";
34+
import { buildChatUrl } from "@/app/chat/lib";
3535
import { reorderPinnedAssistants } from "@/lib/assistants/updateAssistantPreferences";
3636
import { useUser } from "@/components/user/UserProvider";
3737
import { DragHandle } from "@/components/table/DragHandle";

0 commit comments

Comments
 (0)