1+ import { useHasFileChanges } from "@features/right-sidebar/hooks/useHasFileChanges" ;
12import { RightSidebarTrigger } from "@features/right-sidebar/components/RightSidebarTrigger" ;
23import { useRightSidebarStore } from "@features/right-sidebar/stores/rightSidebarStore" ;
34import { SidebarTrigger } from "@features/sidebar/components/SidebarTrigger" ;
45import { useSidebarStore } from "@features/sidebar/stores/sidebarStore" ;
56import { Box , Flex } from "@radix-ui/themes" ;
67import { useHeaderStore } from "@stores/headerStore" ;
78import { useNavigationStore } from "@stores/navigationStore" ;
9+ import type React from "react" ;
10+ import { useEffect } from "react" ;
811
912export const HEADER_HEIGHT = 36 ;
1013const COLLAPSED_WIDTH = 110 ;
1114
12- export function HeaderRow ( ) {
13- const content = useHeaderStore ( ( state ) => state . content ) ;
14- const view = useNavigationStore ( ( state ) => state . view ) ;
15-
16- const sidebarOpen = useSidebarStore ( ( state ) => state . open ) ;
17- const sidebarWidth = useSidebarStore ( ( state ) => state . width ) ;
18- const isResizing = useSidebarStore ( ( state ) => state . isResizing ) ;
19- const setIsResizing = useSidebarStore ( ( state ) => state . setIsResizing ) ;
20-
15+ function RightSidebarHeaderSection ( { taskId } : { taskId : string } ) {
16+ const hasChanges = useHasFileChanges ( taskId ) ;
2117 const rightSidebarOpen = useRightSidebarStore ( ( state ) => state . open ) ;
2218 const rightSidebarWidth = useRightSidebarStore ( ( state ) => state . width ) ;
2319 const rightSidebarIsResizing = useRightSidebarStore (
@@ -26,19 +22,71 @@ export function HeaderRow() {
2622 const setRightSidebarIsResizing = useRightSidebarStore (
2723 ( state ) => state . setIsResizing ,
2824 ) ;
25+ const setOpenAuto = useRightSidebarStore ( ( state ) => state . setOpenAuto ) ;
2926
30- const showRightSidebarSection = view . type === "task-detail" ;
27+ useEffect ( ( ) => {
28+ setOpenAuto ( hasChanges ) ;
29+ } , [ hasChanges , setOpenAuto ] ) ;
3130
32- const handleLeftSidebarMouseDown = ( e : React . MouseEvent ) => {
31+ const handleRightSidebarMouseDown = ( e : React . MouseEvent ) => {
3332 e . preventDefault ( ) ;
34- setIsResizing ( true ) ;
33+ setRightSidebarIsResizing ( true ) ;
3534 document . body . style . cursor = "col-resize" ;
3635 document . body . style . userSelect = "none" ;
3736 } ;
3837
39- const handleRightSidebarMouseDown = ( e : React . MouseEvent ) => {
38+ return (
39+ < Flex
40+ align = "center"
41+ justify = "between"
42+ px = "2"
43+ pl = "3"
44+ style = { {
45+ width : rightSidebarOpen
46+ ? `${ rightSidebarWidth } px`
47+ : `${ COLLAPSED_WIDTH } px` ,
48+ minWidth : `${ COLLAPSED_WIDTH } px` ,
49+ height : "100%" ,
50+ borderLeft : "1px solid var(--gray-6)" ,
51+ transition : rightSidebarIsResizing
52+ ? "none"
53+ : "width 0.2s ease-in-out" ,
54+ position : "relative" ,
55+ } }
56+ >
57+ < RightSidebarTrigger />
58+ { rightSidebarOpen && (
59+ < Box
60+ onMouseDown = { handleRightSidebarMouseDown }
61+ className = "no-drag"
62+ style = { {
63+ position : "absolute" ,
64+ left : 0 ,
65+ top : 0 ,
66+ bottom : 0 ,
67+ width : "4px" ,
68+ cursor : "col-resize" ,
69+ backgroundColor : "transparent" ,
70+ zIndex : 100 ,
71+ } }
72+ />
73+ ) }
74+ </ Flex >
75+ ) ;
76+ }
77+
78+ export function HeaderRow ( ) {
79+ const content = useHeaderStore ( ( state ) => state . content ) ;
80+ const view = useNavigationStore ( ( state ) => state . view ) ;
81+
82+ const sidebarOpen = useSidebarStore ( ( state ) => state . open ) ;
83+ const sidebarWidth = useSidebarStore ( ( state ) => state . width ) ;
84+ const isResizing = useSidebarStore ( ( state ) => state . isResizing ) ;
85+ const setIsResizing = useSidebarStore ( ( state ) => state . setIsResizing ) ;
86+
87+ const handleLeftSidebarMouseDown = ( e : React . MouseEvent ) => {
4088 e . preventDefault ( ) ;
41- setRightSidebarIsResizing ( true ) ;
89+ setIsResizing ( true ) ;
4290 document . body . style . cursor = "col-resize" ;
4391 document . body . style . userSelect = "none" ;
4492 } ;
@@ -98,43 +146,8 @@ export function HeaderRow() {
98146 </ Flex >
99147 ) }
100148
101- { showRightSidebarSection && view . type === "task-detail" && view . data && (
102- < Flex
103- align = "center"
104- justify = "between"
105- px = "2"
106- pl = "3"
107- style = { {
108- width : rightSidebarOpen
109- ? `${ rightSidebarWidth } px`
110- : `${ COLLAPSED_WIDTH } px` ,
111- minWidth : `${ COLLAPSED_WIDTH } px` ,
112- height : "100%" ,
113- borderLeft : "1px solid var(--gray-6)" ,
114- transition : rightSidebarIsResizing
115- ? "none"
116- : "width 0.2s ease-in-out" ,
117- position : "relative" ,
118- } }
119- >
120- < RightSidebarTrigger />
121- { rightSidebarOpen && (
122- < Box
123- onMouseDown = { handleRightSidebarMouseDown }
124- className = "no-drag"
125- style = { {
126- position : "absolute" ,
127- left : 0 ,
128- top : 0 ,
129- bottom : 0 ,
130- width : "4px" ,
131- cursor : "col-resize" ,
132- backgroundColor : "transparent" ,
133- zIndex : 100 ,
134- } }
135- />
136- ) }
137- </ Flex >
149+ { view . type === "task-detail" && view . data && (
150+ < RightSidebarHeaderSection taskId = { view . data . id } />
138151 ) }
139152 </ Flex >
140153 ) ;
0 commit comments