@@ -49,6 +49,12 @@ import { useWorkspaceRefreshOnFocus } from "./features/workspaces/hooks/useWorks
4949import { useWorkspaceRestore } from "./features/workspaces/hooks/useWorkspaceRestore" ;
5050import { useResizablePanels } from "./features/layout/hooks/useResizablePanels" ;
5151import { useLayoutMode } from "./features/layout/hooks/useLayoutMode" ;
52+ import { useSidebarToggles } from "./features/layout/hooks/useSidebarToggles" ;
53+ import {
54+ RightPanelCollapseButton ,
55+ SidebarCollapseButton ,
56+ TitlebarExpandControls ,
57+ } from "./features/layout/components/SidebarToggleControls" ;
5258import { useAppSettings } from "./features/settings/hooks/useAppSettings" ;
5359import { useUpdater } from "./features/update/hooks/useUpdater" ;
5460import { useComposerImages } from "./features/composer/hooks/useComposerImages" ;
@@ -111,6 +117,23 @@ function MainApp() {
111117 const isCompact = layoutMode !== "desktop" ;
112118 const isTablet = layoutMode === "tablet" ;
113119 const isPhone = layoutMode === "phone" ;
120+ const {
121+ sidebarCollapsed,
122+ rightPanelCollapsed,
123+ collapseSidebar,
124+ expandSidebar,
125+ collapseRightPanel,
126+ expandRightPanel,
127+ } = useSidebarToggles ( { isCompact } ) ;
128+ const sidebarToggleProps = {
129+ isCompact,
130+ sidebarCollapsed,
131+ rightPanelCollapsed,
132+ onCollapseSidebar : collapseSidebar ,
133+ onExpandSidebar : expandSidebar ,
134+ onCollapseRightPanel : collapseRightPanel ,
135+ onExpandRightPanel : expandRightPanel ,
136+ } ;
114137 const [ centerMode , setCenterMode ] = useState < "chat" | "diff" > ( "chat" ) ;
115138 const [ selectedDiffPath , setSelectedDiffPath ] = useState < string | null > ( null ) ;
116139 const [ gitPanelMode , setGitPanelMode ] = useState < "diff" | "log" | "issues" > (
@@ -644,6 +667,8 @@ function MainApp() {
644667 isPhone ? " layout-phone" : ""
645668 } ${ isTablet ? " layout-tablet" : "" } ${
646669 reduceTransparency ? " reduced-transparency" : ""
670+ } ${ ! isCompact && sidebarCollapsed ? " sidebar-collapsed" : "" } ${
671+ ! isCompact && rightPanelCollapsed ? " right-panel-collapsed" : ""
647672 } `;
648673 const {
649674 sidebarNode,
@@ -766,6 +791,9 @@ function MainApp() {
766791 onCopyThread : handleCopyThread ,
767792 onToggleTerminal : handleToggleTerminal ,
768793 showTerminalButton : ! isCompact ,
794+ mainHeaderActionsNode : ! isCompact && ! rightPanelCollapsed ? (
795+ < RightPanelCollapseButton { ...sidebarToggleProps } />
796+ ) : null ,
769797 filePanelMode,
770798 onToggleFilePanel : ( ) => {
771799 setFilePanelMode ( ( prev ) => ( prev === "git" ? "files" : "git" ) ) ;
@@ -879,13 +907,26 @@ function MainApp() {
879907 onGoProjects : ( ) => setActiveTab ( "projects" ) ,
880908 } ) ;
881909
910+ const desktopTopbarLeftNodeWithToggle = ! isCompact ? (
911+ < div className = "topbar-leading" >
912+ < SidebarCollapseButton { ...sidebarToggleProps } />
913+ { desktopTopbarLeftNode }
914+ </ div >
915+ ) : (
916+ desktopTopbarLeftNode
917+ ) ;
918+
882919 return (
883920 < div
884921 className = { appClassName }
885922 style = {
886923 {
887- "--sidebar-width" : `${ sidebarWidth } px` ,
888- "--right-panel-width" : `${ rightPanelWidth } px` ,
924+ "--sidebar-width" : `${
925+ isCompact ? sidebarWidth : sidebarCollapsed ? 0 : sidebarWidth
926+ } px`,
927+ "--right-panel-width" : `${
928+ isCompact ? rightPanelWidth : rightPanelCollapsed ? 0 : rightPanelWidth
929+ } px`,
889930 "--plan-panel-height" : `${ planPanelHeight } px` ,
890931 "--terminal-panel-height" : `${ terminalPanelHeight } px` ,
891932 "--debug-panel-height" : `${ debugPanelHeight } px` ,
@@ -894,6 +935,7 @@ function MainApp() {
894935 }
895936 >
896937 < div className = "drag-strip" id = "titlebar" data-tauri-drag-region />
938+ < TitlebarExpandControls { ...sidebarToggleProps } />
897939 { isPhone ? (
898940 < PhoneLayout
899941 approvalToastsNode = { approvalToastsNode }
@@ -939,7 +981,7 @@ function MainApp() {
939981 homeNode = { homeNode }
940982 showHome = { showHome }
941983 showWorkspace = { Boolean ( activeWorkspace && ! showHome ) }
942- topbarLeftNode = { desktopTopbarLeftNode }
984+ topbarLeftNode = { desktopTopbarLeftNodeWithToggle }
943985 centerMode = { centerMode }
944986 messagesNode = { messagesNode }
945987 gitDiffViewerNode = { gitDiffViewerNode }
0 commit comments