Skip to content

Commit bd8721a

Browse files
jonathanlabclaude
andauthored
feat: improve command menu and fix session view theming (#264)
Co-authored-by: Claude <[email protected]>
1 parent c38c5a6 commit bd8721a

File tree

2 files changed

+89
-63
lines changed

2 files changed

+89
-63
lines changed

apps/array/src/renderer/features/command/components/CommandMenu.tsx

Lines changed: 88 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
import { Command } from "@features/command/components/Command";
22
import { CommandKeyHints } from "@features/command/components/CommandKeyHints";
3-
import { useTasks } from "@features/tasks/hooks/useTasks";
4-
import { FileTextIcon, ListBulletIcon } from "@radix-ui/react-icons";
3+
import { useRightSidebarStore } from "@features/right-sidebar";
4+
import { useSidebarStore } from "@features/sidebar/stores/sidebarStore";
5+
import {
6+
FileTextIcon,
7+
GearIcon,
8+
HomeIcon,
9+
MoonIcon,
10+
SunIcon,
11+
ViewVerticalIcon,
12+
} from "@radix-ui/react-icons";
513
import { Flex, Text } from "@radix-ui/themes";
6-
import type { Task } from "@shared/types";
714
import { useNavigationStore } from "@stores/navigationStore";
15+
import { useRegisteredFoldersStore } from "@stores/registeredFoldersStore";
16+
import { useThemeStore } from "@stores/themeStore";
817
import { useCallback, useEffect, useRef } from "react";
918
import { useHotkeys } from "react-hotkeys-hook";
1019

@@ -14,38 +23,45 @@ interface CommandMenuProps {
1423
}
1524

1625
export function CommandMenu({ open, onOpenChange }: CommandMenuProps) {
17-
const { navigateToTaskList, navigateToTask, navigateToTaskInput } =
18-
useNavigationStore();
19-
const { data: tasks = [] } = useTasks();
26+
const { navigateToTaskInput, navigateToSettings } = useNavigationStore();
27+
const { folders } = useRegisteredFoldersStore();
28+
const { isDarkMode, toggleDarkMode } = useThemeStore();
29+
const toggleLeftSidebar = useSidebarStore((state) => state.toggle);
30+
const toggleRightSidebar = useRightSidebarStore((state) => state.toggle);
2031
const commandRef = useRef<HTMLDivElement>(null);
2132

22-
// Close handlers
23-
const handleClose = useCallback(() => {
24-
onOpenChange(false);
25-
}, [onOpenChange]);
33+
const close = useCallback(() => onOpenChange(false), [onOpenChange]);
2634

27-
useHotkeys("escape", handleClose, {
35+
const runAndClose = useCallback(
36+
<T extends unknown[]>(fn: (...args: T) => void) =>
37+
(...args: T) => {
38+
fn(...args);
39+
close();
40+
},
41+
[close],
42+
);
43+
44+
useHotkeys("escape", close, {
2845
enabled: open,
2946
enableOnContentEditable: true,
3047
enableOnFormTags: true,
3148
preventDefault: true,
3249
});
3350

34-
useHotkeys("mod+k", handleClose, {
51+
useHotkeys("mod+k", close, {
3552
enabled: open,
3653
enableOnContentEditable: true,
3754
enableOnFormTags: true,
3855
preventDefault: true,
3956
});
4057

41-
useHotkeys("mod+p", handleClose, {
58+
useHotkeys("mod+p", close, {
4259
enabled: open,
4360
enableOnContentEditable: true,
4461
enableOnFormTags: true,
4562
preventDefault: true,
4663
});
4764

48-
// Handle click outside
4965
useEffect(() => {
5066
if (!open) return;
5167

@@ -54,30 +70,13 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) {
5470
commandRef.current &&
5571
!commandRef.current.contains(event.target as Node)
5672
) {
57-
onOpenChange(false);
73+
close();
5874
}
5975
};
6076

6177
document.addEventListener("mousedown", handleClickOutside);
62-
return () => {
63-
document.removeEventListener("mousedown", handleClickOutside);
64-
};
65-
}, [open, onOpenChange]);
66-
67-
const handleNavigateToTasks = () => {
68-
navigateToTaskList();
69-
onOpenChange(false);
70-
};
71-
72-
const handleCreateTask = () => {
73-
navigateToTaskInput();
74-
onOpenChange(false);
75-
};
76-
77-
const handleNavigateToTaskClick = (task: Task) => {
78-
navigateToTask(task);
79-
onOpenChange(false);
80-
};
78+
return () => document.removeEventListener("mousedown", handleClickOutside);
79+
}, [open, close]);
8180

8281
if (!open) return null;
8382

@@ -95,7 +94,7 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) {
9594
<Command.Root className="min-h-0 flex-1">
9695
<div className="flex items-center border-gray-6 border-b px-3">
9796
<Command.Input
98-
placeholder="Search for tasks, navigate to sections..."
97+
placeholder="Search commands..."
9998
autoFocus={true}
10099
style={{ fontSize: "12px" }}
101100
className="w-full bg-transparent py-3 outline-none placeholder:text-gray-9"
@@ -105,43 +104,70 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) {
105104
<Command.List style={{ maxHeight: "400px" }}>
106105
<Command.Empty>No results found.</Command.Empty>
107106

108-
<Command.Group heading="Actions">
109-
<Command.Item value="Create new task" onSelect={handleCreateTask}>
110-
<FileTextIcon className="mr-3 h-3 w-3 text-gray-11" />
111-
<Text size="1">Create new task</Text>
107+
<Command.Group heading="Navigation">
108+
<Command.Item
109+
value="Home"
110+
onSelect={runAndClose(navigateToTaskInput)}
111+
>
112+
<HomeIcon className="mr-3 h-3 w-3 text-gray-11" />
113+
<Text size="1">Home</Text>
114+
</Command.Item>
115+
<Command.Item
116+
value="Settings"
117+
onSelect={runAndClose(navigateToSettings)}
118+
>
119+
<GearIcon className="mr-3 h-3 w-3 text-gray-11" />
120+
<Text size="1">Settings</Text>
112121
</Command.Item>
113122
</Command.Group>
114123

115-
<Command.Group heading="Navigation">
124+
<Command.Group heading="Actions">
116125
<Command.Item
117-
value="Go to tasks"
118-
onSelect={handleNavigateToTasks}
126+
value="Toggle theme dark light mode"
127+
onSelect={runAndClose(toggleDarkMode)}
119128
>
120-
<ListBulletIcon className="mr-3 h-3 w-3 text-gray-11" />
121-
<Text size="1">Go to tasks</Text>
129+
{isDarkMode ? (
130+
<SunIcon className="mr-3 h-3 w-3 text-gray-11" />
131+
) : (
132+
<MoonIcon className="mr-3 h-3 w-3 text-gray-11" />
133+
)}
134+
<Text size="1">Toggle theme</Text>
135+
</Command.Item>
136+
<Command.Item
137+
value="Toggle left sidebar"
138+
onSelect={runAndClose(toggleLeftSidebar)}
139+
>
140+
<ViewVerticalIcon className="mr-3 h-3 w-3 text-gray-11" />
141+
<Text size="1">Toggle left sidebar</Text>
142+
</Command.Item>
143+
<Command.Item
144+
value="Toggle right sidebar"
145+
onSelect={runAndClose(toggleRightSidebar)}
146+
>
147+
<ViewVerticalIcon className="mr-3 h-3 w-3 rotate-180 text-gray-11" />
148+
<Text size="1">Toggle right sidebar</Text>
149+
</Command.Item>
150+
<Command.Item
151+
value="Create new task"
152+
onSelect={runAndClose(navigateToTaskInput)}
153+
>
154+
<FileTextIcon className="mr-3 h-3 w-3 text-gray-11" />
155+
<Text size="1">New task</Text>
122156
</Command.Item>
123157
</Command.Group>
124158

125-
{tasks.length > 0 && (
126-
<Command.Group heading="Tasks">
127-
{tasks.map((task) => (
159+
{folders.length > 0 && (
160+
<Command.Group heading="New task in folder">
161+
{folders.map((folder) => (
128162
<Command.Item
129-
key={task.id}
130-
value={`${task.id} ${task.title}`}
131-
onSelect={() => handleNavigateToTaskClick(task)}
132-
className="items-start"
163+
key={folder.id}
164+
value={`New task in ${folder.name} folder ${folder.path}`}
165+
onSelect={runAndClose(() => navigateToTaskInput(folder.id))}
133166
>
134-
<FileTextIcon className="mt-0.5 mr-3 h-4 w-4 flex-shrink-0 text-gray-11" />
135-
<Flex direction="column" flexGrow="1" className="min-w-0">
136-
<Text size="1" weight="medium" className="truncate">
137-
{task.title}
138-
</Text>
139-
{task.description && (
140-
<Text size="1" color="gray" className="mt-1 truncate">
141-
{task.description}
142-
</Text>
143-
)}
144-
</Flex>
167+
<FileTextIcon className="mr-3 h-3 w-3 text-gray-11" />
168+
<Text size="1">
169+
New task in <Text weight="bold">{folder.name}</Text>
170+
</Text>
145171
</Command.Item>
146172
))}
147173
</Command.Group>

apps/array/src/renderer/features/sessions/components/ConversationView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export function ConversationView({
6060
return (
6161
<div
6262
ref={scrollRef}
63-
className="scrollbar-hide flex-1 overflow-auto bg-blackA-5 p-2 pb-16"
63+
className="scrollbar-hide flex-1 overflow-auto bg-white p-2 pb-16 dark:bg-gray-1"
6464
>
6565
<div className="flex flex-col gap-3">
6666
{turns.map((turn) => (

0 commit comments

Comments
 (0)