Skip to content

Commit 98554e5

Browse files
authored
feat: small projects UX tweaks (#5513)
1 parent dcd2cad commit 98554e5

File tree

17 files changed

+557
-519
lines changed

17 files changed

+557
-519
lines changed

.vscode/launch.template.jsonc

Lines changed: 372 additions & 395 deletions
Large diffs are not rendered by default.

backend/scripts/dev_run_background_jobs.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,17 @@ def run_jobs() -> None:
7272
"--queues=docprocessing",
7373
]
7474

75-
cmd_worker_user_files_indexing = [
75+
cmd_worker_user_files = [
7676
"celery",
7777
"-A",
78-
"onyx.background.celery.versioned_apps.docfetching",
78+
"onyx.background.celery.versioned_apps.user_file_processing",
7979
"worker",
8080
"--pool=threads",
8181
"--concurrency=1",
8282
"--prefetch-multiplier=1",
8383
"--loglevel=INFO",
84-
"--hostname=user_files_indexing@%n",
85-
"--queues=user_files_indexing",
84+
"--hostname=user_file_processing@%n",
85+
"--queues=user_file_processing,user_file_project_sync",
8686
]
8787

8888
cmd_worker_monitoring = [
@@ -152,8 +152,8 @@ def run_jobs() -> None:
152152
text=True,
153153
)
154154

155-
worker_user_files_indexing_process = subprocess.Popen(
156-
cmd_worker_user_files_indexing,
155+
worker_user_file_process = subprocess.Popen(
156+
cmd_worker_user_files,
157157
stdout=subprocess.PIPE,
158158
stderr=subprocess.STDOUT,
159159
text=True,
@@ -197,9 +197,9 @@ def run_jobs() -> None:
197197
worker_docprocessing_thread = threading.Thread(
198198
target=monitor_process, args=("DOCPROCESSING", worker_docprocessing_process)
199199
)
200-
worker_user_files_indexing_thread = threading.Thread(
200+
worker_user_file_thread = threading.Thread(
201201
target=monitor_process,
202-
args=("USER_FILES_INDEX", worker_user_files_indexing_process),
202+
args=("USER_FILE_PROCESSING", worker_user_file_process),
203203
)
204204
worker_monitoring_thread = threading.Thread(
205205
target=monitor_process, args=("MONITORING", worker_monitoring_process)
@@ -216,7 +216,7 @@ def run_jobs() -> None:
216216
worker_light_thread.start()
217217
worker_heavy_thread.start()
218218
worker_docprocessing_thread.start()
219-
worker_user_files_indexing_thread.start()
219+
worker_user_file_thread.start()
220220
worker_monitoring_thread.start()
221221
worker_kg_processing_thread.start()
222222
worker_docfetching_thread.start()
@@ -226,7 +226,7 @@ def run_jobs() -> None:
226226
worker_light_thread.join()
227227
worker_heavy_thread.join()
228228
worker_docprocessing_thread.join()
229-
worker_user_files_indexing_thread.join()
229+
worker_user_file_thread.join()
230230
worker_monitoring_thread.join()
231231
worker_kg_processing_thread.join()
232232
worker_docfetching_thread.join()

web/src/app/chat/WrappedChat.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { useChatContext } from "@/components/context/ChatContext";
44
import { ChatPage } from "./components/ChatPage";
5+
import { ProjectsProvider } from "./projects/ProjectsContext";
56
import { useCallback, useState } from "react";
67

78
export default function ChatLayout({
@@ -13,7 +14,7 @@ export default function ChatLayout({
1314
// we don't want to show the sidebar by default when the user opens the side panel
1415
defaultSidebarOff?: boolean;
1516
}) {
16-
const { sidebarInitiallyVisible } = useChatContext();
17+
const { sidebarInitiallyVisible, projects } = useChatContext();
1718

1819
const [sidebarVisible, setSidebarVisible] = useState(
1920
(sidebarInitiallyVisible && !defaultSidebarOff) ?? false
@@ -26,14 +27,14 @@ export default function ChatLayout({
2627
}, []);
2728

2829
return (
29-
<>
30+
<ProjectsProvider initialProjects={projects}>
3031
<div className="overscroll-y-contain overflow-y-scroll overscroll-contain left-0 top-0 w-full h-svh">
3132
<ChatPage
3233
toggle={toggle}
3334
sidebarVisible={sidebarVisible}
3435
firstMessage={firstMessage}
3536
/>
3637
</div>
37-
</>
38+
</ProjectsProvider>
3839
);
3940
}

web/src/app/chat/components/files/FilePicker.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,24 @@ export default function FilePicker({
6565
onChange={handleUploadChange}
6666
accept={"*/*"}
6767
/>
68-
<Menubar className="bg-transparent dark:bg-transparent p-0 border-0">
68+
<Menubar className="bg-transparent dark:bg-transparent p-0 border-0 h-8">
6969
<MenubarMenu>
70-
<MenubarTrigger className="relative cursor-pointer flex items-center group rounded-lg text-input-text py-1.5 px-0 h-8">
70+
<MenubarTrigger className="relative cursor-pointer flex items-center group rounded-lg text-input-text px-0 h-8">
7171
{showTriggerLabel ? (
7272
<div
7373
className={cn(
74-
"flex flex-row gap-2 items-center justify-center p-2 rounded-md bg-background-dark/75 hover:dark:bg-neutral-800/75 hover:bg-accent-background-hovered transition-all duration-150",
74+
"flex",
75+
"flex-row",
76+
"gap-2",
77+
"items-center",
78+
"justify-center",
79+
"p-2",
80+
"rounded-md",
81+
"bg-background-dark/75",
82+
"hover:dark:bg-neutral-800/75",
83+
"hover:bg-accent-background-hovered",
84+
"transition-all",
85+
"duration-150",
7586
triggerClassName
7687
)}
7788
>
@@ -166,7 +177,7 @@ export default function FilePicker({
166177
>
167178
<Row>
168179
<Paperclip size={16} />
169-
<div className="flex flex-col">
180+
<div className="flex flex-col cursor-pointer">
170181
<span className="font-semibold">Upload Files</span>
171182
<span className="text-xs font-description text-text-400 dark:text-neutral-400">
172183
Upload a file from your device

web/src/app/chat/components/folders/FolderDropdown.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useState, ReactNode, forwardRef } from "react";
22
import { Folder } from "./interfaces";
33
import { ChatSession } from "@/app/chat/interfaces";
44
import { Caret } from "@/components/icons/icons";
5+
import { cn } from "@/lib/utils";
56

67
interface FolderDropdownProps {
78
folder: Folder;
@@ -24,7 +25,19 @@ export const FolderDropdown = forwardRef<HTMLDivElement, FolderDropdownProps>(
2425
>
2526
<div
2627
ref={ref}
27-
className="flex overflow-visible items-center w-full text-text-darker rounded-md p-1 bg-background-sidebar dark:bg-[#000] sticky top-0"
28+
className={cn(
29+
"flex",
30+
"overflow-visible",
31+
"items-center",
32+
"w-full",
33+
"text-text-darker",
34+
"rounded-md",
35+
"p-1",
36+
"bg-background-sidebar",
37+
"dark:bg-[#000]",
38+
"sticky",
39+
"top-0"
40+
)}
2841
style={{ zIndex: 10 - index }}
2942
>
3043
<button

web/src/app/chat/components/input/ChatInputOption.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,23 @@ export const ChatInputOption: React.FC<ChatInputOptionProps> = ({
3838
<div
3939
ref={componentRef}
4040
className={`
41-
relative
42-
cursor-pointer
43-
flex
44-
items-center
41+
relative
42+
cursor-pointer
43+
flex
44+
items-center
4545
${name ? "space-x-1" : ""}
4646
group
4747
rounded-lg
4848
text-input-text
49-
group-hover:text-neutral-900
50-
dark:group-hover:text-neutral-50
49+
hover:text-neutral-900
50+
hover:bg-background-chat-hover
51+
dark:hover:text-neutral-50
52+
transition-all
53+
duration-300
54+
ease-in-out
5155
py-1.5
5256
px-2
57+
h-8
5358
${
5459
flexPriority === "shrink" &&
5560
"flex-shrink-100 flex-grow-0 flex-basis-auto min-w-[30px] whitespace-nowrap overflow-hidden"

web/src/app/chat/layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export default async function Layout({
3636
ccPairs,
3737
inputPrompts,
3838
proSearchToggled,
39+
projects,
3940
} = data;
4041

4142
return (
@@ -56,6 +57,7 @@ export default async function Layout({
5657
availableTools,
5758
shouldShowWelcomeModal,
5859
defaultAssistantId,
60+
projects,
5961
}}
6062
>
6163
{children}

web/src/app/chat/page.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { SEARCH_PARAMS } from "@/lib/extension/constants";
22
import ChatLayout from "./WrappedChat";
3-
import { ProjectsProvider } from "./projects/ProjectsContext";
43

54
export default async function Page(props: {
65
searchParams: Promise<{ [key: string]: string }>;
@@ -11,11 +10,9 @@ export default async function Page(props: {
1110
searchParams[SEARCH_PARAMS.DEFAULT_SIDEBAR_OFF] === "true";
1211

1312
return (
14-
<ProjectsProvider>
15-
<ChatLayout
16-
firstMessage={firstMessage}
17-
defaultSidebarOff={defaultSidebarOff}
18-
/>
19-
</ProjectsProvider>
13+
<ChatLayout
14+
firstMessage={firstMessage}
15+
defaultSidebarOff={defaultSidebarOff}
16+
/>
2017
);
2118
}

web/src/app/chat/projects/ProjectsContext.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,14 @@ const ProjectsContext = createContext<ProjectsContextType | undefined>(
7272

7373
interface ProjectsProviderProps {
7474
children: ReactNode;
75+
initialProjects?: Project[];
7576
}
7677

7778
export const ProjectsProvider: React.FC<ProjectsProviderProps> = ({
7879
children,
80+
initialProjects = [],
7981
}) => {
80-
const [projects, setProjects] = useState<Project[]>([]);
82+
const [projects, setProjects] = useState<Project[]>(initialProjects);
8183
const [recentFiles, setRecentFiles] = useState<ProjectFile[]>([]);
8284
const [currentProjectDetails, setCurrentProjectDetails] =
8385
useState<ProjectDetails | null>(null);
@@ -261,17 +263,17 @@ export const ProjectsProvider: React.FC<ProjectsProviderProps> = ({
261263
);
262264

263265
useEffect(() => {
264-
// Initial load
266+
// Initial load - only fetch recent files since projects come from props
265267
setIsLoading(true);
266-
Promise.all([fetchProjects(), getRecentFiles()])
267-
.then(([, recent]) => {
268+
getRecentFiles()
269+
.then((recent) => {
268270
setRecentFiles(recent);
269271
})
270272
.catch(() => {
271273
// errors captured in individual calls
272274
})
273275
.finally(() => setIsLoading(false));
274-
}, [fetchProjects, getRecentFiles]);
276+
}, [getRecentFiles]);
275277

276278
useEffect(() => {
277279
if (currentProjectId) {

web/src/app/ee/assistants/stats/[id]/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export default async function GalleryPage(props: {
3535
defaultAssistantId,
3636
inputPrompts,
3737
proSearchToggled,
38+
projects,
3839
} = data;
3940

4041
return (
@@ -54,6 +55,7 @@ export default async function GalleryPage(props: {
5455
llmProviders,
5556
shouldShowWelcomeModal,
5657
defaultAssistantId,
58+
projects,
5759
}}
5860
>
5961
{shouldShowWelcomeModal && (

0 commit comments

Comments
 (0)