Skip to content
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/renderer/src/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,42 @@
them visible while pointer devices preserve the reveal-on-hover behavior. */
@custom-variant can-hover (@media (hover: hover));

.worktree-create-touch-hidden {
display: none;
}

@media (hover: hover) {
.worktree-create-touch-hidden {
display: inline-flex;
}
}

.worktree-mobile-create-fab {
display: block;
}

.worktree-mobile-create-button {
/* Why: floating action buttons escape the row surface, so they use the
documented floating elevation instead of a component-local shadow. */
box-shadow: 0 10px 24px rgb(0 0 0 / 0.18);
}

@media (hover: hover) {
.worktree-mobile-create-fab {
display: none;
}
}

.worktree-mobile-create-scroll-padding {
padding-bottom: calc(5rem + env(safe-area-inset-bottom));
}

@media (hover: hover) {
.worktree-mobile-create-scroll-padding {
padding-bottom: 0;
}
}

.theme-transition-disabled *,
.theme-transition-disabled *::before,
.theme-transition-disabled *::after {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,57 @@ describe('openWorkspaceCreationComposerWithTourHandoff', () => {
expect(requestContextualTourWhenReady).not.toHaveBeenCalled()
})

it('preserves an initial repo when opening outside the tour handoff path', () => {
const openModal = vi.fn()
vi.spyOn(useAppStore, 'getState').mockImplementation(
() =>
({
activeContextualTourId: null,
activeContextualTourStepIndex: 0,
activeContextualTourSource: null,
activeModal: 'none',
contextualToursSeenIds: [],
repos: [{ id: 'repo-1' }],
openModal
}) as unknown as ReturnType<typeof useAppStore.getState>
)

openWorkspaceCreationComposerWithTourHandoff({ initialRepoId: 'repo-1' })

expect(openModal).toHaveBeenCalledWith('new-workspace-composer', {
telemetrySource: 'sidebar',
initialRepoId: 'repo-1'
})
})

it('preserves an initial repo when opening through the handoff path', () => {
const openModal = vi.fn()
const detachContextualTourSource = vi.fn()
const completeContextualTour = vi.fn()
vi.spyOn(useAppStore, 'getState').mockImplementation(
() =>
({
activeContextualTourId: 'workspace-agent-sessions',
activeContextualTourStepIndex: 1,
activeContextualTourSource: 'setup_guide_parallel_work',
activeModal: 'none',
contextualToursSeenIds: [],
repos: [{ id: 'repo-1' }],
detachContextualTourSource,
completeContextualTour,
openModal
}) as unknown as ReturnType<typeof useAppStore.getState>
)

openWorkspaceCreationComposerWithTourHandoff({ initialRepoId: 'repo-1' })

expect(openModal).toHaveBeenCalledWith('new-workspace-composer', {
telemetrySource: 'sidebar',
initialRepoId: 'repo-1',
contextualTourSource: 'workspace_creation_modal'
})
})

it('hands off from the agent sessions create-worktree step to the workspace-creation tour', () => {
const openModal = vi.fn()
const detachContextualTourSource = vi.fn()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { useAppStore } from '@/store'
import { requestContextualTourWhenReady } from './request-contextual-tour-when-ready'

export function openWorkspaceCreationComposerWithTourHandoff(): void {
export function openWorkspaceCreationComposerWithTourHandoff(
options: {
initialRepoId?: string
} = {}
): void {
const state = useAppStore.getState()
const hasProjects = state.repos.length > 0

Expand All @@ -20,6 +24,7 @@ export function openWorkspaceCreationComposerWithTourHandoff(): void {

state.openModal('new-workspace-composer', {
telemetrySource: 'sidebar',
...(options.initialRepoId ? { initialRepoId: options.initialRepoId } : {}),
...(shouldHandoffFromAgentSessionsTour
? { contextualTourSource: 'workspace_creation_modal' }
: {})
Expand Down
43 changes: 43 additions & 0 deletions src/renderer/src/components/sidebar/SidebarHeader.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import type { ReactNode } from 'react'
import { renderToStaticMarkup } from 'react-dom/server'
import { describe, expect, it, vi } from 'vitest'
import SidebarHeader from './SidebarHeader'

const mocks = vi.hoisted(() => ({
state: {
groupBy: 'repo',
openModal: vi.fn(),
repos: [{ id: 'repo-1' }]
}
}))

vi.mock('@/store', () => ({
useAppStore: (selector: (state: typeof mocks.state) => unknown) => selector(mocks.state)
}))

vi.mock('@/hooks/useShortcutLabel', () => ({
useShortcutLabel: () => 'Ctrl+Shift+N'
}))

vi.mock('../contextual-tours/workspace-creation-tour-handoff', () => ({
openWorkspaceCreationComposerWithTourHandoff: vi.fn()
}))

vi.mock('@/components/ui/tooltip', () => ({
Tooltip: ({ children }: { children: ReactNode }) => <>{children}</>,
TooltipTrigger: ({ children }: { children: ReactNode }) => <>{children}</>,
TooltipContent: ({ children }: { children: ReactNode }) => <>{children}</>
}))

vi.mock('./SidebarWorkspaceOptionsMenu', () => ({
default: () => <button type="button">Options</button>
}))

describe('SidebarHeader', () => {
it('keeps the top workspace create button hidden on touch layouts', () => {
const markup = renderToStaticMarkup(<SidebarHeader onWorkspaceBoardMenuOpenChange={vi.fn()} />)

expect(markup).toContain('aria-label="New workspace"')
expect(markup).toContain('worktree-create-touch-hidden')
})
})
1 change: 1 addition & 0 deletions src/renderer/src/components/sidebar/SidebarHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const SidebarHeader = React.memo(function SidebarHeader({
<Button
variant="ghost"
size="icon-xs"
className="worktree-create-touch-hidden"
onClick={() => {
if (!canCreateWorkspace) {
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ function setLineageState(
mockStore.state = {
...makeFolderWorkspacePathStatusMockState(),
activeModal: '',
activeRepoId: repo.id,
activeView: 'terminal',
activeWorktreeId: null,
agentStatusByPaneKey: {},
Expand Down Expand Up @@ -485,6 +486,69 @@ describe('WorktreeList real child WorktreeCard integration', () => {
)
})

it('opens the workspace composer from the rendered mobile add button', async () => {
const container = await renderWorktreeList()
const mobileAddButton = container.querySelector<HTMLButtonElement>(
'[data-mobile-worktree-add-fab] button[aria-label="Create workspace"]'
)

expect(mobileAddButton).not.toBeNull()
expect(mobileAddButton?.closest('[data-mobile-worktree-add-fab]')?.className).toContain(
'worktree-mobile-create-fab'
)

await act(async () => {
mobileAddButton!.click()
})

expect(mockStore.openModal).toHaveBeenCalledWith('new-workspace-composer', {
initialRepoId: 'repo-1',
telemetrySource: 'sidebar'
})
})

it('hides the mobile add button when repo filters exclude all repo targets', async () => {
mockStore.state.filterRepoIds = ['other-repo']

const container = await renderWorktreeList()

expect(container.querySelector('[data-mobile-worktree-add-fab]')).toBeNull()
})

it('uses the filtered repo target for the mobile add button in an empty filtered view', async () => {
mockStore.state.repos = [
...(mockStore.state.repos as Repo[]),
{
...makeRepo(),
id: 'repo-2',
path: '/tmp/lineage-real-card-2',
displayName: 'filtered repo'
}
]
mockStore.state.filterRepoIds = ['repo-2']
mockStore.state.worktreesByRepo = {
...(mockStore.state.worktreesByRepo as Record<string, Worktree[]>),
'repo-2': []
}

const container = await renderWorktreeList()
const mobileAddButton = container.querySelector<HTMLButtonElement>(
'[data-mobile-worktree-add-fab] button[aria-label="Create workspace"]'
)

expect(container.textContent).toContain('No workspaces found')
expect(mobileAddButton).not.toBeNull()

await act(async () => {
mobileAddButton!.click()
})

expect(mockStore.openModal).toHaveBeenCalledWith('new-workspace-composer', {
initialRepoId: 'repo-2',
telemetrySource: 'sidebar'
})
})

it('does not activate a nested child while it is deleting', async () => {
setLineageState({ deletingChild: true })
const container = await renderWorktreeList()
Expand Down
Loading
Loading