Skip to content

Commit 62bdf4d

Browse files
committed
fix(sidebar): address PR review feedback for pin tasks
1 parent 5fbce44 commit 62bdf4d

2 files changed

Lines changed: 19 additions & 26 deletions

File tree

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workflow-list/components/context-menu/context-menu.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ interface ContextMenuProps {
249249
showMarkAsUnread?: boolean
250250
showPin?: boolean
251251
isPinned?: boolean
252-
disablePin?: boolean
253252
showRename?: boolean
254253
showCreate?: boolean
255254
showCreateFolder?: boolean
@@ -307,7 +306,6 @@ export function ContextMenu({
307306
showMarkAsUnread = false,
308307
showPin = false,
309308
isPinned = false,
310-
disablePin = false,
311309
showRename = true,
312310
showCreate = false,
313311
showCreateFolder = false,
@@ -461,7 +459,6 @@ export function ContextMenu({
461459
)}
462460
{showPin && onTogglePin && (
463461
<DropdownMenuItem
464-
disabled={disablePin}
465462
onSelect={() => {
466463
onTogglePin()
467464
onClose()

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/sidebar.tsx

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,10 @@ export const Sidebar = memo(function Sidebar() {
797797
: [],
798798
[fetchedTasks, workspaceId]
799799
)
800+
const tasksRef = useRef(tasks)
801+
useEffect(() => {
802+
tasksRef.current = tasks
803+
}, [tasks])
800804

801805
const { data: fetchedTables = [] } = useTablesList(workspaceId)
802806
const { data: fetchedFiles = [] } = useWorkspaceFiles(workspaceId)
@@ -941,10 +945,10 @@ export const Sidebar = memo(function Sidebar() {
941945
const { taskIds: ids } = contextMenuSelectionRef.current
942946
if (ids.length !== 1) return
943947
const taskId = ids[0]
944-
const task = tasks.find((t) => t.id === taskId)
948+
const task = tasksRef.current.find((t) => t.id === taskId)
945949
if (!task) return
946950
setTaskPinnedMutation.mutate({ chatId: taskId, pinned: !task.isPinned })
947-
}, [tasks])
951+
}, [])
948952

949953
const handleStartTaskRename = useCallback(() => {
950954
const { taskIds: ids } = contextMenuSelectionRef.current
@@ -1014,12 +1018,6 @@ export const Sidebar = memo(function Sidebar() {
10141018
})
10151019
}, [workflowId, workflowsLoading])
10161020

1017-
useEffect(() => {
1018-
if (!isOnWorkflowPage && !isCollapsed) {
1019-
setSidebarWidth(SIDEBAR_WIDTH.MIN)
1020-
}
1021-
}, [isOnWorkflowPage, isCollapsed, setSidebarWidth])
1022-
10231021
const handleCreateWorkflow = useCallback(async () => {
10241022
const workflowId = await createWorkflow()
10251023
if (workflowId) {
@@ -1820,21 +1818,19 @@ export const Sidebar = memo(function Sidebar() {
18201818
</div>
18211819
</aside>
18221820

1823-
{(isCollapsed || isOnWorkflowPage) && (
1824-
<div
1825-
className={cn(
1826-
'absolute top-0 right-0 bottom-0 z-20 w-[8px] translate-x-1/2',
1827-
isCollapsed ? 'cursor-e-resize' : 'cursor-ew-resize'
1828-
)}
1829-
onMouseDown={isCollapsed ? undefined : handleMouseDown}
1830-
onClick={isCollapsed ? toggleCollapsed : undefined}
1831-
onKeyDown={handleEdgeKeyDown}
1832-
role={isCollapsed ? 'button' : 'separator'}
1833-
tabIndex={0}
1834-
aria-orientation={isCollapsed ? undefined : 'vertical'}
1835-
aria-label={isCollapsed ? 'Expand sidebar' : 'Resize sidebar'}
1836-
/>
1837-
)}
1821+
<div
1822+
className={cn(
1823+
'absolute top-0 right-0 bottom-0 z-20 w-[8px] translate-x-1/2',
1824+
isCollapsed ? 'cursor-e-resize' : 'cursor-ew-resize'
1825+
)}
1826+
onMouseDown={isCollapsed ? undefined : handleMouseDown}
1827+
onClick={isCollapsed ? toggleCollapsed : undefined}
1828+
onKeyDown={handleEdgeKeyDown}
1829+
role={isCollapsed ? 'button' : 'separator'}
1830+
tabIndex={0}
1831+
aria-orientation={isCollapsed ? undefined : 'vertical'}
1832+
aria-label={isCollapsed ? 'Expand sidebar' : 'Resize sidebar'}
1833+
/>
18381834
</div>
18391835

18401836
<SearchModal

0 commit comments

Comments
 (0)