@@ -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