Skip to content

Commit f38fcf3

Browse files
authored
feat: remove sidebar options, go for history only and pin (#506)
### TL;DR Simplified the sidebar by consolidating pinned tasks into the history view and removing the folder/repository view. ### What changed? - Removed the view mode selector and consolidated all views into a single unified view - Integrated pinned tasks directly into the History view as a separate section at the top - Removed the standalone `PinnedView` component and merged its functionality into `HistoryView` - Removed repository/folder-related components and functionality: - Deleted `SortableFolderSection.tsx` - Deleted `ViewModeSelector.tsx` - Deleted `NewTaskItem.tsx` - Simplified the sidebar footer to only show the "New task" button (removed the "Add repository" button) - Updated the sidebar data handling to filter out pinned tasks from the regular history sections ### How to test? 1. Open the application and check that the sidebar now shows a unified view with pinned tasks at the top (if any exist) 2. Pin a task and verify it appears in the "Pinned" section at the top of the sidebar 3. Unpin a task and verify it moves back to the appropriate history section 4. Create a new task and verify it appears in the history view 5. Verify that the sidebar footer consistently shows the "New task" button ### Why make this change? This change simplifies the user interface by consolidating multiple views into a single, more intuitive view. By removing the separate modes (history, pinned, folders) and integrating pinned tasks directly into the main view, the sidebar becomes more straightforward and requires fewer clicks to navigate between different types of tasks. This streamlined approach improves usability by keeping important tasks visible and accessible at all times.
1 parent fa2f6ff commit f38fcf3

9 files changed

Lines changed: 92 additions & 525 deletions

File tree

apps/array/src/renderer/features/sidebar/components/HistoryView.tsx

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import { useTaskExecutionStore } from "@features/task-detail/stores/taskExecutionStore";
22
import { Button, Flex } from "@radix-ui/themes";
33
import { useWorkspaceStore } from "@/renderer/features/workspace/stores/workspaceStore";
4-
import type { HistoryData, HistoryTaskData } from "../hooks/useSidebarData";
4+
import type {
5+
HistoryData,
6+
HistoryTaskData,
7+
PinnedData,
8+
TaskData,
9+
} from "../hooks/useSidebarData";
510
import { useSidebarStore } from "../stores/sidebarStore";
611
import { TaskItem } from "./items/TaskItem";
712

813
interface HistoryViewProps {
914
historyData: HistoryData;
15+
pinnedData: PinnedData;
1016
activeTaskId: string | null;
1117
onTaskClick: (taskId: string) => void;
1218
onTaskContextMenu: (taskId: string, e: React.MouseEvent) => void;
@@ -65,8 +71,52 @@ function HistoryTaskItem({
6571
);
6672
}
6773

74+
interface PinnedTaskItemProps {
75+
task: TaskData;
76+
isActive: boolean;
77+
onClick: () => void;
78+
onContextMenu: (e: React.MouseEvent) => void;
79+
onDelete: () => void;
80+
onTogglePin: () => void;
81+
}
82+
83+
function PinnedTaskItem({
84+
task,
85+
isActive,
86+
onClick,
87+
onContextMenu,
88+
onDelete,
89+
onTogglePin,
90+
}: PinnedTaskItemProps) {
91+
const workspaces = useWorkspaceStore.use.workspaces();
92+
const taskStates = useTaskExecutionStore((state) => state.taskStates);
93+
94+
const workspace = workspaces[task.id];
95+
const taskState = taskStates[task.id];
96+
97+
return (
98+
<TaskItem
99+
id={task.id}
100+
label={task.title}
101+
isActive={isActive}
102+
worktreeName={workspace?.worktreeName ?? undefined}
103+
worktreePath={workspace?.worktreePath ?? workspace?.folderPath}
104+
workspaceMode={taskState?.workspaceMode}
105+
lastActivityAt={task.lastActivityAt}
106+
isGenerating={task.isGenerating}
107+
isUnread={task.isUnread}
108+
isPinned={task.isPinned}
109+
onClick={onClick}
110+
onContextMenu={onContextMenu}
111+
onDelete={onDelete}
112+
onTogglePin={onTogglePin}
113+
/>
114+
);
115+
}
116+
68117
export function HistoryView({
69118
historyData,
119+
pinnedData,
70120
activeTaskId,
71121
onTaskClick,
72122
onTaskContextMenu,
@@ -76,11 +126,32 @@ export function HistoryView({
76126
const loadMoreHistory = useSidebarStore((state) => state.loadMoreHistory);
77127
const { activeTasks, recentTasks, hasMore } = historyData;
78128

129+
const hasPinnedTasks = pinnedData.tasks.length > 0;
79130
const hasActiveTasks = activeTasks.length > 0;
80131
const hasRecentTasks = recentTasks.length > 0;
81132

82133
return (
83134
<Flex direction="column">
135+
{hasPinnedTasks && (
136+
<>
137+
<HistorySectionLabel label="Pinned" />
138+
{pinnedData.tasks.map((task) => (
139+
<PinnedTaskItem
140+
key={task.id}
141+
task={task}
142+
isActive={activeTaskId === task.id}
143+
onClick={() => onTaskClick(task.id)}
144+
onContextMenu={(e) => onTaskContextMenu(task.id, e)}
145+
onDelete={() => onTaskDelete(task.id)}
146+
onTogglePin={() => onTaskTogglePin(task.id)}
147+
/>
148+
))}
149+
{(hasActiveTasks || hasRecentTasks) && (
150+
<div className="mx-2 my-2 border-gray-6 border-t" />
151+
)}
152+
</>
153+
)}
154+
84155
{hasActiveTasks && (
85156
<>
86157
<HistorySectionLabel label="Active" />

apps/array/src/renderer/features/sidebar/components/PinnedView.tsx

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

apps/array/src/renderer/features/sidebar/components/SidebarFooter.tsx

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,16 @@
11
import { Plus } from "@phosphor-icons/react";
22
import { GearIcon } from "@radix-ui/react-icons";
33
import { Box, Button, Flex, IconButton } from "@radix-ui/themes";
4-
import { useRegisteredFoldersStore } from "@renderer/stores/registeredFoldersStore";
5-
import { trpcVanilla } from "@renderer/trpc";
64
import { useNavigationStore } from "@stores/navigationStore";
75
import { useCallback } from "react";
8-
import { useSidebarStore } from "../stores/sidebarStore";
96

107
export function SidebarFooter() {
11-
const addFolder = useRegisteredFoldersStore((state) => state.addFolder);
128
const { toggleSettings, navigateToTaskInput } = useNavigationStore();
13-
const viewMode = useSidebarStore((state) => state.viewMode);
14-
15-
const handleAddRepository = useCallback(async () => {
16-
const selectedPath = await trpcVanilla.os.selectDirectory.query();
17-
if (selectedPath) {
18-
await addFolder(selectedPath);
19-
}
20-
}, [addFolder]);
219

2210
const handleNewTask = useCallback(() => {
2311
navigateToTaskInput();
2412
}, [navigateToTaskInput]);
2513

26-
const showNewTaskButton = viewMode !== "folders";
27-
2814
return (
2915
<Box
3016
style={{
@@ -38,22 +24,10 @@ export function SidebarFooter() {
3824
}}
3925
>
4026
<Flex align="center" gap="2" justify="between">
41-
{showNewTaskButton ? (
42-
<Button size="1" variant="ghost" color="gray" onClick={handleNewTask}>
43-
<Plus size={14} weight="bold" />
44-
New task
45-
</Button>
46-
) : (
47-
<Button
48-
size="1"
49-
variant="ghost"
50-
color="gray"
51-
onClick={handleAddRepository}
52-
>
53-
<Plus size={14} weight="bold" />
54-
Add repository
55-
</Button>
56-
)}
27+
<Button size="1" variant="ghost" color="gray" onClick={handleNewTask}>
28+
<Plus size={14} weight="bold" />
29+
New task
30+
</Button>
5731

5832
<IconButton
5933
size="1"

0 commit comments

Comments
 (0)