The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(desktop): drag-to-new-session on a main lane switches only to a branch git lists
Austin Pickette1d7beb2af51
diff --git a/apps/desktop/src/app/chat/sidebar/sessions-section-new-session-drag.test.tsx b/apps/desktop/src/app/chat/sidebar/sessions-section-new-session-drag.test.tsxindex 22985d367cd..a79d713ca95 100644--- a/apps/desktop/src/app/chat/sidebar/sessions-section-new-session-drag.test.tsx+++ b/apps/desktop/src/app/chat/sidebar/sessions-section-new-session-drag.test.tsx@@ -4,7 +4,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import type { SessionInfo } from '@/hermes'import { $dismissedWorktreeIds, $sidebarShowAllSessions, dismissWorktree, restoreWorktree } from '@/store/layout'-import { removeWorktreePath, switchBranchInRepo } from '@/store/projects'+import { listRepoBranches, removeWorktreePath, switchBranchInRepo } from '@/store/projects'import {EnteredProjectContent,@@ -96,6 +96,7 @@ vi.mock('./projects/project-menu', () => ({vi.mock('@/store/projects', async () => ({...(await vi.importActual('@/store/projects')),+ listRepoBranches: vi.fn(),removeWorktreePath: vi.fn(),switchBranchInRepo: vi.fn()}))@@ -174,6 +175,7 @@ beforeEach(() => {noop.mockClear()startNewSessionDrag.mockReset()vi.mocked(switchBranchInRepo).mockReset()+ vi.mocked(listRepoBranches).mockReset().mockResolvedValue([])})describe('Show all sessions', () => {@@ -329,6 +331,9 @@ describe('project-associated new-session drag sources', () => {it('switches a main-checkout lane to its labeled branch before creating the dragged session', async () => {const onNewSessionSplit = vi.fn()vi.mocked(switchBranchInRepo).mockResolvedValue(undefined)+ vi.mocked(listRepoBranches).mockResolvedValue([+ { checkedOut: false, isDefault: true, isRemote: false, name: 'main', worktreePath: null }+ ])render(<SidebarSessionsSection@@ -356,6 +361,44 @@ describe('project-associated new-session drag sources', () => {)})+ it('opens on the current checkout when the lane label is not a branch git knows (#108694)', async () => {+ // A row with no recorded git_branch is labelled with the `main` fallback;+ // on a `master` repo `git switch main` dies, so the switch must be skipped.+ const onNewSessionSplit = vi.fn()+ vi.mocked(listRepoBranches).mockResolvedValue([+ { checkedOut: true, isDefault: true, isRemote: false, name: 'master', worktreePath: '/repo' }+ ])++ render(+ <SidebarSessionsSection+ {...baseProps()}+ groups={[+ group({+ id: '/repo::main',+ isMain: true,+ label: 'main',+ path: '/repo',+ sessions: [{ id: 'main-session' } as SessionInfo]+ })+ ]}+ onNewSessionSplit={onNewSessionSplit}+ />+ )++ fireEvent.pointerDown(screen.getByRole('button', { name: 'New session in main' }), { button: 0 })+ commitLatestDrag()++ await waitFor(() => {+ expect(onNewSessionSplit).toHaveBeenCalledWith('right', {+ anchor: 'workspace',+ before: 'session-tile:next',+ cwd: '/repo'+ })+ })+ expect(listRepoBranches).toHaveBeenCalledWith('/repo')+ expect(switchBranchInRepo).not.toHaveBeenCalled()+ })+it('does not run a branch switch for a non-git lane before creating the dragged session', async () => {// A plain non-git folder still gets an isMain lane from the backend// heuristic, but `git switch <folder-name>` there dies with "fatal: not a