Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
23 changes: 16 additions & 7 deletions src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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<Record<string, string>>({})
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -2228,8 +2235,13 @@ function DesktopApp(): JSX.Element {
>
{singleScreenMode && <AppTitleSegment />}
</div>
<div className="flex-1 flex items-center justify-center text-dim">
{worktrees.length === 0 ? 'Create a worktree to get started' : 'Select a worktree to begin'}
<div className="flex-1 flex items-center justify-center">
<CenterEmptyState
mode={centerEmptyMode({ onboardingVisible, tourHomePath })}
newWorktreeBinding={resolvedHotkeys.newWorktree}
onTourStart={handleTourStart}
onNewWorktree={() => setShowNewWorktree(true)}
/>
</div>
</div>
)}
Expand All @@ -2255,10 +2267,7 @@ function DesktopApp(): JSX.Element {
<FirstRunTour
tour={tour}
homePath={tourHomePath}
onStart={async () => {
const result = await backend.tourStartSomethingNew().catch(() => ({ ok: false as const }))
if (result.ok) setActiveWorktreeId(result.worktreePath)
}}
onStart={handleTourStart}
onDismiss={() => void backend.tourDismiss().catch(() => {})}
/>
)}
Expand Down
16 changes: 16 additions & 0 deletions src/renderer/components/CenterEmptyState.test.ts
Original file line number Diff line number Diff line change
@@ -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')
})
})
64 changes: 64 additions & 0 deletions src/renderer/components/CenterEmptyState.tsx
Original file line number Diff line number Diff line change
@@ -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<void>
onNewWorktree: () => void
}): JSX.Element {
if (mode === 'tour-home') {
return (
<div className="flex flex-col items-center gap-4 text-center max-w-sm px-6">
<Sparkles className="icon-xl text-accent" />
<div className="text-base text-fg-bright font-medium">Your project is ready</div>
<div className="text-sm text-dim">
Start something new and an agent will set up a workspace for it.
</div>
<TourStartButton onStart={onTourStart} />
</div>
)
}

return (
<div className="flex flex-col items-center gap-4 text-center max-w-sm px-6">
<div className="text-sm text-dim">Pick a project on the left, or start a new task</div>
<button className={secondaryButton} onClick={onNewWorktree}>
<Plus className="icon-sm" />
New task
{newWorktreeBinding && (
<kbd className={kbdChip}>{formatBindingGlyphs(bindingToString(newWorktreeBinding), '')}</kbd>
)}
</button>
</div>
)
}
44 changes: 28 additions & 16 deletions src/renderer/components/FirstRunTour.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>
className?: string
}): JSX.Element {
const [starting, setStarting] = useState(false)
return (
<button
className={`${primaryButton} ${className}`}
disabled={starting}
onClick={() => {
setStarting(true)
void onStart().finally(() => setStarting(false))
}}
>
{starting && <Loader2 className="icon-sm animate-spin" />}
Start something new
</button>
)
}

/** The two first-run popouts. `homePath` is the tour project's main
* workspace row, resolved by the caller from the worktree list. */
Expand All @@ -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') {
Expand All @@ -169,19 +193,7 @@ export function FirstRunTour({
icon={<Sparkles className="icon-base text-accent" />}
eyebrow="Main workspace"
onDismiss={onDismiss}
action={
<button
className={primaryButton}
disabled={starting}
onClick={() => {
setStarting(true)
void onStart().finally(() => setStarting(false))
}}
>
{starting && <Loader2 className="icon-sm animate-spin" />}
Start something new
</button>
}
action={<TourStartButton onStart={onStart} className="w-full" />}
>
This is your main workspace for this project. Agents here can spin up worktrees for any
work that you might want to do.
Expand All @@ -197,7 +209,7 @@ export function FirstRunTour({
eyebrow="New worktree"
onDismiss={onDismiss}
action={
<button className={primaryButton} onClick={onDismiss}>
<button className={`${primaryButton} w-full`} onClick={onDismiss}>
Got it
</button>
}
Expand Down
Loading