The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): make the left titlebar toggle positional like the right
Brooklyn Nicholson80342bbc56e1
diff --git a/apps/desktop/src/app/shell/titlebar-controls.tsx b/apps/desktop/src/app/shell/titlebar-controls.tsxindex 06029237fe2..a5d90022576 100644--- a/apps/desktop/src/app/shell/titlebar-controls.tsx+++ b/apps/desktop/src/app/shell/titlebar-controls.tsx@@ -20,11 +20,11 @@ import { toggleHud } from '@/store/hud'import { $interfaceMode, shownInMode, type Tiered } from '@/store/interface-mode'import {$fileBrowserOpen,+ $leftSideOpen,$panesFlipped,- $sidebarOpen,+ toggleLeftSide,togglePanesFlipped,- toggleRightSide,- toggleSidebarOpen+ toggleRightSide} from '@/store/layout'import { $unreadSessionCount } from '@/store/session-dot-state'import { $titlebarAppActionsSide, TITLEBAR_FIXED_TOOLS } from '@/store/titlebar-app-actions'@@ -140,8 +140,8 @@ export function TitlebarControls({ leftTools = [], tools = [], onOpenSettings }:const location = useLocation()const modHeld = useModifierHeld()const fileBrowserOpen = useStore($fileBrowserOpen)+ const leftSideOpen = useStore($leftSideOpen)const panesFlipped = useStore($panesFlipped)- const sidebarOpen = useStore($sidebarOpen)const unreadCount = useStore($unreadSessionCount)const appActionsSide = useStore($titlebarAppActionsSide)const interfaceMode = useStore($interfaceMode)@@ -160,11 +160,11 @@ export function TitlebarControls({ leftTools = [], tools = [], onOpenSettings }:// POSITIONAL toggles: each button shows/hides everything on its physical// side of the main zone (the layout tree collapses the whole side), so they- // stay correct through flips and rearranges. $sidebarOpen ≙ left side; the- // right toggle resolves its column from the live tree (see toggleRightSide)- // — the browser column, the files column, whatever is physically right.- // Never an active highlight — plain show/hide affordances.- const leftEdge = { open: sidebarOpen, toggle: toggleSidebarOpen }+ // stay correct through flips and rearranges. Both edges resolve their column+ // from the live tree (see toggleLeftSide / toggleRightSide) — the browser+ // column, the sessions column, whatever is physically left / right. Never an+ // active highlight — plain show/hide affordances.+ const leftEdge = { open: leftSideOpen, toggle: toggleLeftSide }const rightEdge = { open: fileBrowserOpen, toggle: toggleRightSide }const leftLabel = leftEdge.open ? t.titlebar.hideSidebar : t.titlebar.showSidebarconst rightLabel = rightEdge.open ? t.titlebar.hideRightSidebar : t.titlebar.showRightSidebardiff --git a/apps/desktop/src/store/layout.ts b/apps/desktop/src/store/layout.tsindex f89aa64236d..44e985476d4 100644--- a/apps/desktop/src/store/layout.ts+++ b/apps/desktop/src/store/layout.ts@@ -5,6 +5,8 @@ import { PANE_TOGGLE_REVEAL_EVENT } from '@/components/pane-shell'import { allPaneIds, type GroupNode } from '@/components/pane-shell/tree/model'import {$collapsedTreeSides,+ $hiddenTreePanes,+ $layoutTree,layoutHasRootSide,paneRootSide,restoreHiddenTreeSideTabs,@@ -582,6 +584,56 @@ export function toggleSidebarOpen() {}}+// POSITIONAL left-side toggle — the mirror of toggleRightSide below. ⌘B and the+// left titlebar button mean "the sessions sidebar" (pane-bound, above) — but+// the titlebar's POSITIONAL contract (see titlebar-controls.tsx) says the left+// button folds everything physically left of main. After ⌘\ the sidebar sits+// right and the file tree left, so the pane-bound button folds the wrong+// column; resolve the target from the TREE instead, exactly like the right+// side: the outermost root-row column left of main, then fold/unfold it+// through the tree's zone minimize (round-trips like the zone chevron).+export function toggleLeftSide() {+ if (revealNarrowPane(CHAT_SIDEBAR_PANE_ID, 'toggle')) {+ return+ }++ const group = leftSideGroup()++ if (!group) {+ // No foldable column on the left: fall back to the semantic sidebar+ // branch, never the right side.+ toggleSidebarOpen()++ return+ }++ if (leftSideShown(group)) {+ setTreeGroupMinimized(group.id, true)++ return+ }++ // Hidden — minimized, or its side collapsed by the side's owner (the files+ // toggle when flipped, or the sidebar). Reopen through that owner so the+ // store the titlebar reads agrees, then restore the zone like its+ // rail/chevron does.+ const pane = group.active ?? group.panes[0]+ const side = paneRootSide(pane)++ if (side && $collapsedTreeSides.get().has(side)) {+ const openSide = side === sidebarSide() ? setSidebarOpen : setFileBrowserOpen++ openSide(true)+ }++ restoreTreePane(pane)+}++/** ⌘-positional-left's dispatch gate: something foldable lives left of main. */+export function layoutHasLeftSide(): boolean {+ return leftSideGroup() !== null || layoutHasRootSide('left')+}+export function toggleFileBrowserOpen() {if (revealNarrowPane(FILE_BROWSER_PANE_ID, 'toggle')) {return@@ -677,6 +729,42 @@ function rightSideGroup(): GroupNode | null {return row.children.some(child => allPaneIds(child).some(isMainSurface)) ? edge : null}+// The POSITIONAL left side, derived from the live tree — the mirror of+// rightSideGroup: the outermost root-row column, when it is a leaf group+// physically LEFT of main. Catches the same "dragged/preview column" cases the+// right walk does (here: the file tree after a ⌘\ flip). Null when main is+// leftmost or the left is a nested split — callers fall back to the semantic+// sidebar toggle.+function leftSideGroup(): GroupNode | null {+ const row = rootRow()+ const edge = row?.children.at(0)++ if (!row || edge?.type !== 'group' || edge.panes.some(isMainSurface)) {+ return null+ }++ return row.children.some(child => allPaneIds(child).some(isMainSurface)) ? edge : null+}++// Shown-state for the positional left column, same shape as rightSideShown.+function leftSideShown(group: GroupNode): boolean {+ const side = paneRootSide(allPaneIds(group)[0])++ return !group.minimized && !(side && $collapsedTreeSides.get().has(side)) && shownPanesInGroup(group).length > 0+}++// The positional LEFT edge's open state, for the titlebar button. Falls back+// to the semantic sidebar flag whenever no leaf column lives left of main+// (nested split, main leftmost) — the same fallback toggleLeftSide presses.+export const $leftSideOpen: ReadableAtom<boolean> = computed(+ [$layoutTree, $collapsedTreeSides, $hiddenTreePanes, $sidebarOpen],+ () => {+ const group = leftSideGroup()++ return group ? leftSideShown(group) : $sidebarOpen.get()+ }+)+// Is the zone actually on screen? `minimized` alone isn't the whole state: a// side collapse or chrome-hidden panes take it off screen un-minimized.function rightSideShown(group: GroupNode): boolean {diff --git a/apps/desktop/src/store/right-side-toggle.test.ts b/apps/desktop/src/store/right-side-toggle.test.tsindex be1380bc190..34fb658babf 100644--- a/apps/desktop/src/store/right-side-toggle.test.ts+++ b/apps/desktop/src/store/right-side-toggle.test.ts@@ -3,7 +3,16 @@ import { beforeAll, beforeEach, describe, expect, it } from 'vitest'import { findGroupOfPane, group, type LayoutNode, split } from '@/components/pane-shell/tree/model'import { $collapsedTreeSides, $hiddenTreePanes, $layoutTree } from '@/components/pane-shell/tree/store'import { registry } from '@/contrib/registry'-import { $fileBrowserOpen, setFileBrowserOpen, setSidebarOpen, toggleRightSide } from '@/store/layout'+import {+ $fileBrowserOpen,+ $leftSideOpen,+ $panesFlipped,+ $sidebarOpen,+ setFileBrowserOpen,+ setSidebarOpen,+ toggleLeftSide,+ toggleRightSide+} from '@/store/layout'// The right-side toggle must be POSITIONAL: it acts on whatever column is// physically rightmost in the root row — including a preview-tile column@@ -102,3 +111,80 @@ describe('positional right-side toggle', () => {expect($fileBrowserOpen.get()).toBe(true)})})++// The LEFT titlebar button has the same positional contract (#66357): after a+// ⌘\ flip the sessions pane sits physically RIGHT and the file tree LEFT, so+// the old pane-bound left toggle folded the sessions column from the LEFT+// button — leaving the physically-left file tree unreachable and BOTH+// buttons acting on the same column.+describe('positional left-side toggle', () => {+ // Flipped arrangement: files physically left, main, sessions right.+ const filesLeft = () => {+ $panesFlipped.set(true)+ $layoutTree.set(split('row', [group(['files']), group(['workspace']), group(['sessions'])]))+ }++ it('folds the physically-left files column after a flip, never the sessions pane', () => {+ filesLeft()++ toggleLeftSide()++ expect(Boolean(groupOf('files')?.minimized)).toBe(true)+ expect(Boolean(groupOf('sessions')?.minimized)).toBe(false)+ })++ it('round-trips: a second press restores the zone', () => {+ filesLeft()++ toggleLeftSide()+ toggleLeftSide()++ expect(Boolean(groupOf('files')?.minimized)).toBe(false)+ })++ it('folds the sessions leaf column on the unflipped layout, not the right column', () => {+ $layoutTree.set(split('row', [group(['sessions']), group(['workspace']), group(['files'])]))++ toggleLeftSide()++ expect(Boolean(groupOf('sessions')?.minimized)).toBe(true)+ expect(Boolean(groupOf('files')?.minimized)).toBe(false)+ })++ // Nothing left of main: the search must never cross main into the right+ // column — it falls back to the semantic sidebar branch instead.+ it('falls back to the sidebar branch when main is leftmost', () => {+ $panesFlipped.set(false)+ $layoutTree.set(split('row', [group(['workspace']), group(['files'])]))++ toggleLeftSide()++ expect($collapsedTreeSides.get().has('right')).toBe(false)+ expect($sidebarOpen.get()).toBe(false)+ })++ it('first press reopens a left side collapsed by setSidebarOpen(false) when flipped', () => {+ filesLeft()+ setFileBrowserOpen(false)++ toggleLeftSide()++ expect($collapsedTreeSides.get().has('left')).toBe(false)+ expect(Boolean(groupOf('files')?.minimized)).toBe(false)+ expect($fileBrowserOpen.get()).toBe(true)+ })++ it('$leftSideOpen tracks the physically-left column, not the sidebar pane', () => {+ filesLeft()+ setFileBrowserOpen(false)++ expect($leftSideOpen.get()).toBe(false)++ setFileBrowserOpen(true)+ expect($leftSideOpen.get()).toBe(true)++ // Folding the zone through the toggle flips it too.+ toggleLeftSide()+ expect($leftSideOpen.get()).toBe(false)+ })+})