diff --git a/desktop/src/components/layout/TabBar.test.tsx b/desktop/src/components/layout/TabBar.test.tsx index 1ff869c5..1a288d19 100644 --- a/desktop/src/components/layout/TabBar.test.tsx +++ b/desktop/src/components/layout/TabBar.test.tsx @@ -149,7 +149,8 @@ describe('TabBar', () => { render() }) - expect(screen.getByTestId('tab-bar')).toHaveAttribute('data-tauri-drag-region') + expect(screen.getByTestId('tab-bar')).not.toHaveAttribute('data-tauri-drag-region') + expect(screen.getByTestId('tab-bar-drag-gutter')).toHaveAttribute('data-tauri-drag-region') }) it('starts dragging when clicking the empty tab-bar gutter', async () => { @@ -214,4 +215,39 @@ describe('TabBar', () => { expect(startDraggingMock).not.toHaveBeenCalled() }) + + it('reorders tabs via drag and drop', async () => { + const { TabBar } = await import('./TabBar') + const { useTabStore } = await import('../../stores/tabStore') + const { useChatStore } = await import('../../stores/chatStore') + + useTabStore.setState({ + tabs: [ + { sessionId: 'tab-1', title: 'First Session', type: 'session', status: 'idle' }, + { sessionId: 'tab-2', title: 'Second Session', type: 'session', status: 'idle' }, + ], + activeTabId: 'tab-1', + }) + useChatStore.setState({ + sessions: {}, + disconnectSession: vi.fn(), + } as Partial>) + + await act(async () => { + render() + }) + + const firstTab = screen.getByText('First Session').closest('[draggable="true"]') + const secondTab = screen.getByText('Second Session').closest('[draggable="true"]') + + expect(firstTab).toBeTruthy() + expect(secondTab).toBeTruthy() + + fireEvent.dragStart(firstTab!) + fireEvent.dragOver(secondTab!) + fireEvent.drop(secondTab!) + fireEvent.dragEnd(firstTab!) + + expect(useTabStore.getState().tabs.map((tab) => tab.sessionId)).toEqual(['tab-2', 'tab-1']) + }) }) diff --git a/desktop/src/components/layout/TabBar.tsx b/desktop/src/components/layout/TabBar.tsx index b4089000..5b6595f6 100644 --- a/desktop/src/components/layout/TabBar.tsx +++ b/desktop/src/components/layout/TabBar.tsx @@ -169,7 +169,6 @@ export function TabBar() { return (
@@ -202,6 +201,15 @@ export function TabBar() { ))}
+ {isTauri && ( +