11import { Box , Button , Flex , Spinner , Text } from "@radix-ui/themes" ;
22import type { Task } from "@shared/types" ;
3- import { useCallback , useEffect , useRef , useState } from "react" ;
3+ import { useCallback , useEffect , useRef } from "react" ;
44import { useTasks } from "../../hooks/useTasks" ;
55import { useUsers } from "../../hooks/useUsers" ;
66import { useAuthStore } from "../../stores/authStore" ;
77import { useLayoutStore } from "../../stores/layoutStore" ;
88import { useStatusBarStore } from "../../stores/statusBarStore" ;
99import { useTaskStore } from "../../stores/taskStore" ;
1010import { CliTaskPanel } from "./CliTaskPanel" ;
11+ import { useCliPanelResize } from "./hooks/useCliPanelResize" ;
1112import { useTaskDragDrop } from "./hooks/useTaskDragDrop" ;
1213import { useTaskFiltering } from "./hooks/useTaskFiltering" ;
1314import { useTaskGrouping } from "./hooks/useTaskGrouping" ;
@@ -50,9 +51,6 @@ export function TaskList({ onSelectTask }: TaskListProps) {
5051 const setCliPanelWidth = useLayoutStore ( ( state ) => state . setCliPanelWidth ) ;
5152 const listRef = useRef < HTMLDivElement > ( null ) ;
5253
53- // Resize state
54- const [ isResizing , setIsResizing ] = useState ( false ) ;
55-
5654 // Custom hooks
5755 const filteredTasks = useTaskFiltering (
5856 tasks ,
@@ -61,6 +59,7 @@ export function TaskList({ onSelectTask }: TaskListProps) {
6159 filter ,
6260 ) ;
6361 const groupedTasks = useTaskGrouping ( filteredTasks , groupBy , users ) ;
62+ const { isResizing, handleMouseDown } = useCliPanelResize ( setCliPanelWidth ) ;
6463
6564 const handleMoveTask = useCallback (
6665 ( fromIndex : number , toIndex : number ) => {
@@ -94,33 +93,6 @@ export function TaskList({ onSelectTask }: TaskListProps) {
9493
9594 useTaskScrolling ( listRef , selectedIndex , filteredTasks . length ) ;
9695
97- // Resize handler
98- const handleMouseDown = useCallback ( ( ) => {
99- setIsResizing ( true ) ;
100- } , [ ] ) ;
101-
102- useEffect ( ( ) => {
103- if ( ! isResizing ) return ;
104-
105- const handleMouseMove = ( e : MouseEvent ) => {
106- const newWidth =
107- ( ( window . innerWidth - e . clientX ) / window . innerWidth ) * 100 ;
108- setCliPanelWidth ( Math . max ( 20 , Math . min ( 50 , newWidth ) ) ) ; // clamp between 20% and 50%
109- } ;
110-
111- const handleMouseUp = ( ) => {
112- setIsResizing ( false ) ;
113- } ;
114-
115- document . addEventListener ( "mousemove" , handleMouseMove ) ;
116- document . addEventListener ( "mouseup" , handleMouseUp ) ;
117-
118- return ( ) => {
119- document . removeEventListener ( "mousemove" , handleMouseMove ) ;
120- document . removeEventListener ( "mouseup" , handleMouseUp ) ;
121- } ;
122- } , [ isResizing , setCliPanelWidth ] ) ;
123-
12496 // Status bar
12597 useEffect ( ( ) => {
12698 setStatusBar ( {
0 commit comments