diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index d3ab4ac1..99ad025d 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -27,6 +27,7 @@ import { NewWorktreeScreen, onOpenForkIntoWorktree } from './components/NewWorkt import { CreatingWorktreeScreen } from './components/CreatingWorktreeScreen' import { DeletingWorktreeScreen } from './components/DeletingWorktreeScreen' import { FirstRunTour } from './components/FirstRunTour' +import { CenterEmptyState, centerEmptyMode } from './components/CenterEmptyState' import { WorkspaceView } from './components/WorkspaceView' import { QuakeTerminal } from './components/QuakeTerminal' import { RightColumn } from './components/RightColumn' @@ -311,7 +312,7 @@ function DesktopApp(): JSX.Element { // Pane trees across ALL backends. `usePanes()` would be the active // backend's slice only, which silently breaks every cross-backend lookup // below: `activeWorkspaceVisible` would find no tree for a remote - // worktree and render the "Select a worktree to begin" fallback at the + // worktree and render the empty-center fallback at the // same time as the workspace it claims isn't there. const panes = mergedData.panes const [activePaneId, setActivePaneId] = useState>({}) @@ -594,6 +595,12 @@ function DesktopApp(): JSX.Element { : null, [tour, worktrees] ) + // Shared by the tour popout and the center empty state so both drive the + // same kickoff and tour transition. + const handleTourStart = useCallback(async () => { + const result = await backend.tourStartSomethingNew().catch(() => ({ ok: false as const })) + if (result.ok) setActiveWorktreeId(result.worktreePath) + }, [backend]) const configLoadError = useConfigLoadError() @@ -2228,8 +2235,13 @@ function DesktopApp(): JSX.Element { > {singleScreenMode && } -
- {worktrees.length === 0 ? 'Create a worktree to get started' : 'Select a worktree to begin'} +
+ setShowNewWorktree(true)} + />
)} @@ -2255,10 +2267,7 @@ function DesktopApp(): JSX.Element { { - const result = await backend.tourStartSomethingNew().catch(() => ({ ok: false as const })) - if (result.ok) setActiveWorktreeId(result.worktreePath) - }} + onStart={handleTourStart} onDismiss={() => void backend.tourDismiss().catch(() => {})} /> )} diff --git a/src/renderer/components/CenterEmptyState.test.ts b/src/renderer/components/CenterEmptyState.test.ts new file mode 100644 index 00000000..a30e3b3d --- /dev/null +++ b/src/renderer/components/CenterEmptyState.test.ts @@ -0,0 +1,16 @@ +import { describe, expect, it } from 'vitest' +import { centerEmptyMode } from './CenterEmptyState' + +describe('centerEmptyMode', () => { + it('agrees with the tour popout while the tour is on its home row', () => { + expect(centerEmptyMode({ onboardingVisible: false, tourHomePath: '/repo' })).toBe('tour-home') + }) + + it('falls back to the generic prompt once the tour has moved on', () => { + expect(centerEmptyMode({ onboardingVisible: false, tourHomePath: null })).toBe('no-selection') + }) + + it('does not show the tour copy behind the welcome wizard', () => { + expect(centerEmptyMode({ onboardingVisible: true, tourHomePath: '/repo' })).toBe('no-selection') + }) +}) diff --git a/src/renderer/components/CenterEmptyState.tsx b/src/renderer/components/CenterEmptyState.tsx new file mode 100644 index 00000000..7ced4699 --- /dev/null +++ b/src/renderer/components/CenterEmptyState.tsx @@ -0,0 +1,64 @@ +import type { JSX } from 'react' +import { Plus, Sparkles } from 'lucide-react' +import { bindingToString, formatBindingGlyphs, type HotkeyBinding } from '../hotkeys' +import { TourStartButton } from './FirstRunTour' + +const secondaryButton = + 'inline-flex items-center justify-center gap-2 text-sm font-medium text-fg-bright px-4 py-2 rounded-lg border border-border-strong hover:bg-surface-hover transition-colors cursor-pointer' +const kbdChip = 'text-xs text-faint bg-bg px-1.5 py-0.5 rounded border border-border font-mono' + +export type CenterEmptyMode = 'tour-home' | 'no-selection' + +/** No zero-repo mode: with no repos the welcome wizard owns the screen, and + * repos whose worktree rows haven't landed yet (boot, a remote still + * connecting, a missing repo dir) still have a project to pick. */ +export function centerEmptyMode({ + onboardingVisible, + tourHomePath +}: { + onboardingVisible: boolean + tourHomePath: string | null +}): CenterEmptyMode { + return !onboardingVisible && tourHomePath ? 'tour-home' : 'no-selection' +} + +/** What the center pane shows when no workspace is open. While the + * first-run tour is on its `home` step the copy agrees with the popout and + * offers the same action, so the two never contradict each other. */ +export function CenterEmptyState({ + mode, + newWorktreeBinding, + onTourStart, + onNewWorktree +}: { + mode: CenterEmptyMode + newWorktreeBinding: HotkeyBinding | undefined + onTourStart: () => Promise + onNewWorktree: () => void +}): JSX.Element { + if (mode === 'tour-home') { + return ( +
+ +
Your project is ready
+
+ Start something new and an agent will set up a workspace for it. +
+ +
+ ) + } + + return ( +
+
Pick a project on the left, or start a new task
+ +
+ ) +} diff --git a/src/renderer/components/FirstRunTour.tsx b/src/renderer/components/FirstRunTour.tsx index 41e63e92..73cb90d9 100644 --- a/src/renderer/components/FirstRunTour.tsx +++ b/src/renderer/components/FirstRunTour.tsx @@ -140,7 +140,32 @@ function Popout({ } const primaryButton = - 'w-full inline-flex items-center justify-center gap-2 brand-gradient-bg text-white font-semibold text-sm px-4 py-2 rounded-lg hover:brightness-110 transition-all cursor-pointer disabled:opacity-70 disabled:cursor-default' + 'inline-flex items-center justify-center gap-2 brand-gradient-bg text-white font-semibold text-sm px-4 py-2 rounded-lg hover:brightness-110 transition-all cursor-pointer disabled:opacity-70 disabled:cursor-default' + +/** The tour's "Start something new" action. Shared with the center empty + * state so the two surfaces can't drift in look or busy behaviour. */ +export function TourStartButton({ + onStart, + className = '' +}: { + onStart: () => Promise + className?: string +}): JSX.Element { + const [starting, setStarting] = useState(false) + return ( + + ) +} /** The two first-run popouts. `homePath` is the tour project's main * workspace row, resolved by the caller from the worktree list. */ @@ -158,7 +183,6 @@ export function FirstRunTour({ const anchorPath = tour.step === 'home' ? homePath : tour.step === 'new-worktree' ? (tour.worktreePath ?? null) : null const anchor = useSidebarAnchor(anchorPath) - const [starting, setStarting] = useState(false) if (!anchor) return null if (tour.step === 'home') { @@ -169,19 +193,7 @@ export function FirstRunTour({ icon={} eyebrow="Main workspace" onDismiss={onDismiss} - action={ - - } + action={} > This is your main workspace for this project. Agents here can spin up worktrees for any work that you might want to do. @@ -197,7 +209,7 @@ export function FirstRunTour({ eyebrow="New worktree" onDismiss={onDismiss} action={ - }