diff --git a/src/renderer/src/components/Landing.tsx b/src/renderer/src/components/Landing.tsx index 0d2c1d9a2b1..02fe5639671 100644 --- a/src/renderer/src/components/Landing.tsx +++ b/src/renderer/src/components/Landing.tsx @@ -5,7 +5,7 @@ import { } from './cloud-workspaces/CloudWorkspacesHome' import { useCloudWorkspaceHighlight } from './cloud-workspaces/cloud-workspace-links' import { useEffect, useEffectEvent, useMemo, useRef, useState } from 'react' -import { AlertTriangle, ExternalLink, FolderPlus, GitBranchPlus, Star, X } from 'lucide-react' +import { AlertTriangle, ExternalLink, Star, X } from 'lucide-react' import { cn } from '../lib/utils' import { useAppStore } from '../store' import { isGitRepoKind } from '../../../shared/repo-kind' @@ -23,7 +23,7 @@ import { useLandingPreflightRuntime } from './landing-preflight-runtime' import { useLandingOrcaStarState, type LandingStarState } from './landing-github-star-state' import { openAppHttpLink } from '@/lib/browser/navigation/app-http-link-open' import { - LANDING_ACTION_BUTTON_CLASS, + LandingActions, LandingBrand, LandingShortcutList, type LandingShortcutItem @@ -260,50 +260,43 @@ export default function Landing(): React.JSX.Element { return (
- {/* Centered when alone; with cloud workspaces below, a smaller brand block sits near the - top and the shortcut list steps aside so the list is the focus. */} + {/* Centered when alone. With the cloud list below, the list is the page (JA-30): no wordmark + or "select a workspace" line, just the primary actions as a top row aligned with it. */}
-
+
- + {!cloudListPresent && } {preflightIssues.length > 0 && ( )} -

- {hasProjects - ? t( - 'auto.components.Landing.9c00bd4adf', - 'Select a workspace from the sidebar to begin.' - ) - : t('auto.components.Landing.cd21242762', 'Add a project to get started.')} -

+ {/* With the cloud list showing, only the no-project hint stays: the list is what to pick. */} + {(!cloudListPresent || !hasProjects) && ( +

+ {hasProjects + ? t( + 'auto.components.Landing.9c00bd4adf', + 'Select a workspace from the sidebar to begin.' + ) + : t('auto.components.Landing.cd21242762', 'Add a project to get started.')} +

+ )} -
- - - -
+ openModal('add-repo')} + onCreate={() => openModal('new-workspace-composer', { telemetrySource: 'unknown' })} + /> {hasProjects ? : null} diff --git a/src/renderer/src/components/cloud-workspaces/CloudWorkspacesHome.fixture.tsx b/src/renderer/src/components/cloud-workspaces/CloudWorkspacesHome.fixture.tsx index 6cb4016d53f..e0d6d830c49 100644 --- a/src/renderer/src/components/cloud-workspaces/CloudWorkspacesHome.fixture.tsx +++ b/src/renderer/src/components/cloud-workspaces/CloudWorkspacesHome.fixture.tsx @@ -309,3 +309,38 @@ export const routineRunsShown = defineFixture({ await waitFor(() => document.querySelector('[aria-label="Routine run"]') !== null) } }) + +/** JA-30: a few workspaces (under 5) and no filter on: title and count only, no filter row. */ +export const fewWorkspaces = defineFixture({ + width: WIDTH, + store: { orcaProfileAuthStatus: AUTH_STATUS }, + setup: () => { + const rows = teamWorkspaces().slice(0, 3) + stubCloudWorkspacesApi(() => Promise.resolve({ ok: true, value: rows })) + }, + render: () => , + interact: () => waitFor(() => document.querySelector('[data-cloud-workspace-row]') !== null) +}) + +/** JA-30: Mine on a team where others have workspaces: "You don't have any…", same button. */ +export const emptyMine = defineFixture({ + width: WIDTH, + store: { orcaProfileAuthStatus: AUTH_STATUS }, + setup: () => { + const rows = teamWorkspaces() + stubCloudWorkspacesApi(() => Promise.resolve({ ok: true, value: rows })) + Object.assign(window.api.cloudWorkspaces, { + list: (query: { scope?: string }) => + Promise.resolve({ ok: true as const, value: query.scope === 'mine' ? [] : rows }) + }) + }, + render: () => , + interact: async () => { + await waitFor(() => document.querySelector('[data-cloud-workspace-row]') !== null) + const mine = [...document.querySelectorAll('[role="radio"], button')].find( + (el) => el.textContent?.trim() === 'Mine' + ) + mine?.click() + await waitFor(() => (document.querySelector('section')?.textContent ?? '').includes('yet.')) + } +}) diff --git a/src/renderer/src/components/cloud-workspaces/CloudWorkspacesHome.tsx b/src/renderer/src/components/cloud-workspaces/CloudWorkspacesHome.tsx index 18458de94f7..7a6c51d8a52 100644 --- a/src/renderer/src/components/cloud-workspaces/CloudWorkspacesHome.tsx +++ b/src/renderer/src/components/cloud-workspaces/CloudWorkspacesHome.tsx @@ -17,7 +17,7 @@ import { CloudWorkspaceRow } from './CloudWorkspaceRow' import { CloudWorkspaceGroupView, rowDragProps } from './CloudWorkspaceGroup' import { useCloudWorkspaceArrangement } from './use-cloud-workspace-arrangement' import { NEW_SECTION } from './CloudWorkspaceRowMenu' -import { ANY, CloudWorkspacesToolbar } from './CloudWorkspacesToolbar' +import { ANY, CloudWorkspacesToolbar, shouldShowCloudHomeFilters } from './CloudWorkspacesToolbar' import { EmptyState, ErrorState, NewSectionDialog, SkeletonRows } from './CloudWorkspacesStates' import { useCloudHomeFilters } from './use-cloud-home-filters' import { CloudWorkspaceConfirmDialog, type PendingConfirm } from './CloudWorkspaceConfirmDialog' @@ -259,8 +259,8 @@ export function CloudWorkspacesHome({ selfId={selfId} metaStale={stale} meta={ - state.status === 'ready' - ? // Why: no hours here. A sum over the listed workspaces isn't the team's month, and it + state.status === 'ready' && visible.length > 0 + ? // Why: no hours here. Empty: the empty card says so; no "0 workspaces" (JA-30). A sum over the listed workspaces isn't the team's month, and it // disagreed with Plan & billing and the account menu (JA-07). t('auto.components.cloudWorkspaces.listMetaCount', '{{count}} workspaces', { count: visible.length, @@ -271,6 +271,7 @@ export function CloudWorkspacesHome({ reading={reading} onRefresh={refresh} routineRuns={routineRuns} + showFilters={shouldShowCloudHomeFilters(all.length, filters, Boolean(orgId))} />
)} {state.status === 'ready' && diff --git a/src/renderer/src/components/cloud-workspaces/CloudWorkspacesStates.test.tsx b/src/renderer/src/components/cloud-workspaces/CloudWorkspacesStates.test.tsx index 4395a1f1718..6bbaa0fa414 100644 --- a/src/renderer/src/components/cloud-workspaces/CloudWorkspacesStates.test.tsx +++ b/src/renderer/src/components/cloud-workspaces/CloudWorkspacesStates.test.tsx @@ -1,7 +1,11 @@ // @vitest-environment happy-dom import { cleanup, fireEvent, render, screen } from '@testing-library/react' import { afterEach, expect, it, vi } from 'vitest' -import { ErrorState } from './CloudWorkspacesStates' +import { EmptyState, ErrorState } from './CloudWorkspacesStates' +import { + INITIAL_CLOUD_WORKSPACE_FILTERS as DEFAULTS, + shouldShowCloudHomeFilters +} from './CloudWorkspacesToolbar' afterEach(cleanup) @@ -38,3 +42,43 @@ it('at the running-sandbox limit offers Show cloud workspaces instead of a retry expect(screen.queryByRole('button', { name: 'Try again' })).toBeNull() expect(screen.getByRole('button', { name: 'Show cloud workspaces' })).toBeTruthy() }) + +it('an empty list invites the first cloud workspace, with one button (JA-30)', () => { + render() + expect(screen.getByText('Start your first cloud workspace')).toBeTruthy() + expect( + screen.getByText( + 'It runs in a sandbox, so your agents keep working even when this computer is off.' + ) + ).toBeTruthy() + expect(screen.getAllByRole('button').map((b) => b.textContent)).toEqual(['New cloud workspace']) +}) + +it('an empty Mine list on a team says yours is empty, with the same button', () => { + render() + expect(screen.getByText('You don’t have any cloud workspaces yet.')).toBeTruthy() + expect(screen.queryByText('Start your first cloud workspace')).toBeNull() + expect(screen.getByRole('button', { name: 'New cloud workspace' })).toBeTruthy() + cleanup() + // No team: Mine is the only list, so it is the first-run invitation. + render() + expect(screen.getByText('Start your first cloud workspace')).toBeTruthy() +}) + +it('filtered and archived empty lists keep their own copy and offer no create button', () => { + render() + expect(screen.getByText('Nothing matches these filters')).toBeTruthy() + expect(screen.queryByRole('button')).toBeNull() +}) + +it('shows the filters from 5 workspaces, or whenever a filter is on so it can be undone', () => { + expect(shouldShowCloudHomeFilters(0, DEFAULTS, true)).toBe(false) + expect(shouldShowCloudHomeFilters(4, DEFAULTS, true)).toBe(false) + expect(shouldShowCloudHomeFilters(5, DEFAULTS, true)).toBe(true) + expect(shouldShowCloudHomeFilters(0, { ...DEFAULTS, archived: true }, true)).toBe(true) + expect(shouldShowCloudHomeFilters(1, { ...DEFAULTS, scope: 'mine' }, true)).toBe(true) + expect(shouldShowCloudHomeFilters(1, { ...DEFAULTS, repo: 'https://x/y' }, true)).toBe(true) + expect(shouldShowCloudHomeFilters(1, { ...DEFAULTS, running: true }, true)).toBe(true) + // Without a team there is no Team/Mine choice: Mine is not a filter there. + expect(shouldShowCloudHomeFilters(1, { ...DEFAULTS, scope: 'mine' }, false)).toBe(false) +}) diff --git a/src/renderer/src/components/cloud-workspaces/CloudWorkspacesStates.tsx b/src/renderer/src/components/cloud-workspaces/CloudWorkspacesStates.tsx index d7a43ed3f09..e51a4a69d6c 100644 --- a/src/renderer/src/components/cloud-workspaces/CloudWorkspacesStates.tsx +++ b/src/renderer/src/components/cloud-workspaces/CloudWorkspacesStates.tsx @@ -143,13 +143,21 @@ export function SkeletonRows(): React.JSX.Element { export function EmptyState({ scope, archived, - filtered + filtered, + hasOrg = true }: { scope: 'team' | 'mine' archived: boolean filtered: boolean + /** On a team: an empty Mine list says it's yours that's empty, not that nobody has started one. */ + hasOrg?: boolean }): React.JSX.Element { const t = useTranslate() + // Nothing to filter or share yet: say how to start one (JA-30), in the glossary's own words. + const startBody = t( + 'components.cloudWorkspaces.emptyStartBody', + 'It runs in a sandbox, so your agents keep working even when this computer is off.' + ) const [title, body] = filtered ? [ t('auto.components.cloudWorkspaces.emptyFilteredTitle', 'Nothing matches these filters'), @@ -163,20 +171,17 @@ export function EmptyState({ 'Archived cloud workspaces show up here.' ) ] - : scope === 'team' + : scope === 'mine' && hasOrg ? [ - t('auto.components.cloudWorkspaces.emptyTeamTitle', 'No team workspaces yet'), t( - 'auto.components.cloudWorkspaces.emptyTeamBody', - 'Share a cloud workspace from its menu and everyone on your team can open it here.' - ) + 'components.cloudWorkspaces.emptyMineYoursTitle', + 'You don’t have any cloud workspaces yet.' + ), + startBody ] : [ - t('auto.components.cloudWorkspaces.emptyMineTitle', 'No cloud workspaces yet'), - t( - 'components.cloudWorkspaces.emptyMineStartBody', - 'Start one and it keeps running while your laptop sleeps.' - ) + t('components.cloudWorkspaces.emptyFirstTitle', 'Start your first cloud workspace'), + startBody ] // Spec E3: an empty Mine or Team list offers a real button, not just copy. const offerCreate = !filtered && !archived diff --git a/src/renderer/src/components/cloud-workspaces/CloudWorkspacesToolbar.tsx b/src/renderer/src/components/cloud-workspaces/CloudWorkspacesToolbar.tsx index d5fe14ac469..07948138d30 100644 --- a/src/renderer/src/components/cloud-workspaces/CloudWorkspacesToolbar.tsx +++ b/src/renderer/src/components/cloud-workspaces/CloudWorkspacesToolbar.tsx @@ -47,6 +47,28 @@ export const INITIAL_CLOUD_WORKSPACE_FILTERS: CloudWorkspacesFilters = { routines: false } +/** Below this many workspaces there is little to filter: the filters and refresh stay out of the way. */ +export const CLOUD_HOME_FILTERS_MIN = 5 + +/** + * Whether Home shows its filter row (and refresh): only with enough workspaces to filter (JA-30), + * but always while any filter is off its default, so a filter that hides rows can still be undone. + */ +export function shouldShowCloudHomeFilters( + count: number, + filters: CloudWorkspacesFilters, + hasOrg: boolean +): boolean { + const active = + (hasOrg && filters.scope !== INITIAL_CLOUD_WORKSPACE_FILTERS.scope) || + filters.by !== ANY || + filters.repo !== ANY || + filters.archived || + filters.running === true || + filters.routines === true + return active || count >= CLOUD_HOME_FILTERS_MIN +} + /** Row 1: title, count and cost, refresh. Row 2: whose, by whom, which repo, running, routine runs, archived. */ export function CloudWorkspacesToolbar({ filters, @@ -60,7 +82,8 @@ export function CloudWorkspacesToolbar({ metaStale, reading, onRefresh, - routineRuns + routineRuns, + showFilters = true }: { filters: CloudWorkspacesFilters onFiltersChange: (next: Partial) => void @@ -76,6 +99,8 @@ export function CloudWorkspacesToolbar({ onRefresh: () => void /** What the Routine runs switch hides; the switch exists only when the team has routines. */ routineRuns?: CloudWorkspaceRoutineRuns + /** False with only a few workspaces and no filter on: title and count only (JA-30). */ + showFilters?: boolean }): React.JSX.Element { const t = useTranslate() // Routines start cloud workspaces on their own, so they sit next to the list they fill. @@ -105,18 +130,20 @@ export function CloudWorkspacesToolbar({ {t('auto.components.cloudWorkspaces.routines', 'Routines')} ) : null} - + {showFilters ? ( + + ) : null}
-
+
{hasOrg && (
{} + +function row(width: number): React.JSX.Element { + return ( +
+
+ +
+
+
+ ) +} + +/** JA-30: over the cloud list in a wide centre column, the full-size top row. */ +export const actionsOverCloudListWide = defineFixture({ width: 800, render: () => row(768) }) + +/** JA-30: a narrow centre column (both side panels open): small buttons, still one row. */ +export const actionsOverCloudListNarrow = defineFixture({ width: 580, render: () => row(540) }) diff --git a/src/renderer/src/components/landing-layout.tsx b/src/renderer/src/components/landing-layout.tsx index 0efcf69ae2f..b46610c6cbd 100644 --- a/src/renderer/src/components/landing-layout.tsx +++ b/src/renderer/src/components/landing-layout.tsx @@ -1,3 +1,4 @@ +import { FolderPlus, GitBranchPlus } from 'lucide-react' import { cn } from '@/lib/utils' import { ShortcutKeyCombo } from './ShortcutKeyCombo' import type { ShortcutKeyComboDetails } from '@/hooks/useShortcutLabel' @@ -63,3 +64,44 @@ export function LandingShortcutList({
) } + +/** + * Home's two primary actions. Over the cloud list they sit as a top row aligned with it; in a + * narrow centre column (both side panels open) they shrink and stay on one row instead of + * stacking large buttons (JA-30). Needs an `@container` ancestor for the narrow case. + */ +export function LandingActions({ + overCloudList, + addProjectLabel, + createLabel, + onAddProject, + onCreate +}: { + overCloudList: boolean + addProjectLabel: string + createLabel: string + onAddProject: () => void + onCreate: () => void +}): React.JSX.Element { + const buttonClass = cn( + LANDING_ACTION_BUTTON_CLASS, + overCloudList && '@max-[600px]:px-2.5 @max-[600px]:py-1 @max-[600px]:text-xs' + ) + return ( +
+ + +
+ ) +} diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index 4ab74c57b4d..e6b1d1ca246 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -20979,9 +20979,6 @@ "emptyArchivedTitle": "No archived workspaces", "emptyFilteredBody": "Try another owner or repository.", "emptyFilteredTitle": "Nothing matches these filters", - "emptyMineTitle": "No cloud workspaces yet", - "emptyTeamBody": "Share a cloud workspace from its menu and everyone on your team can open it here.", - "emptyTeamTitle": "No team workspaces yet", "environmentName": "{{value0}} (cloud)", "errorConcurrencyLimit": "You're at your team's limit of running sandboxes. Put one to sleep or delete it, then try again.", "errorMemberConcurrencyLimit": "You're at your limit of running sandboxes. Put one to sleep or delete it, then try again.", @@ -23709,8 +23706,10 @@ } }, "cloudWorkspaces": { - "emptyMineStartBody": "Start one and it keeps running while your laptop sleeps.", - "newCloudWorkspace": "New cloud workspace" + "newCloudWorkspace": "New cloud workspace", + "emptyStartBody": "It runs in a sandbox, so your agents keep working even when this computer is off.", + "emptyMineYoursTitle": "You don’t have any cloud workspaces yet.", + "emptyFirstTitle": "Start your first cloud workspace" }, "worktreeCreation": { "pendingNativeChat": {