diff --git a/src/renderer/src/components/new-workspace/NewWorkspaceComposerProjectSection.tsx b/src/renderer/src/components/new-workspace/NewWorkspaceComposerProjectSection.tsx
index 01d55b10318..6e10d81777e 100644
--- a/src/renderer/src/components/new-workspace/NewWorkspaceComposerProjectSection.tsx
+++ b/src/renderer/src/components/new-workspace/NewWorkspaceComposerProjectSection.tsx
@@ -159,6 +159,7 @@ export function NewWorkspaceComposerProjectSection({
cloudRepoValue={cloudOnly?.picked?.fullName ?? null}
onCloudRepoSelected={cloudOnly?.pick}
onMoreCloudAccess={cloudOnly?.moreAccess}
+ onShowMoreCloudRepos={cloudOnly?.showMore ?? null}
placeholder={
projectPlaceholder ??
t('auto.components.NewWorkspaceComposerCard.dccd26d4e4', 'Choose project')
diff --git a/src/renderer/src/components/new-workspace/ProjectCombobox.tsx b/src/renderer/src/components/new-workspace/ProjectCombobox.tsx
index a972f0d688c..33ae17272fe 100644
--- a/src/renderer/src/components/new-workspace/ProjectCombobox.tsx
+++ b/src/renderer/src/components/new-workspace/ProjectCombobox.tsx
@@ -19,6 +19,7 @@ import type { OrcaCloudGitHubRepository } from '@/lib/orca-cloud/use-orca-cloud-
import {
CLOUD_REPO_KEY_PREFIX,
CLOUD_REPO_MORE_KEY,
+ CLOUD_REPO_SHOW_MORE_KEY,
cloudRepoKey,
filterCloudRepos,
ProjectComboboxCloudSection
@@ -40,6 +41,8 @@ type ProjectComboboxProps = {
cloudRepoValue?: string | null
onCloudRepoSelected?: (fullName: string) => void
onMoreCloudAccess?: () => void
+ /** Present while GitHub has more repositories than are listed. */
+ onShowMoreCloudRepos?: (() => void) | null
}
const ADD_PROJECT_KEY = 'add-project'
@@ -59,7 +62,8 @@ export default function ProjectCombobox({
cloudRepos = null,
cloudRepoValue = null,
onCloudRepoSelected,
- onMoreCloudAccess
+ onMoreCloudAccess,
+ onShowMoreCloudRepos = null
}: ProjectComboboxProps): React.JSX.Element {
const t = useTranslate()
const [tooltipOpen, setTooltipOpen] = useState(false)
@@ -76,10 +80,11 @@ export default function ProjectCombobox({
...(cloudRepos
? filterCloudRepos(cloudRepos, query).map((repo) => cloudRepoKey(repo.fullName))
: []),
+ ...(cloudRepos && onShowMoreCloudRepos ? [CLOUD_REPO_SHOW_MORE_KEY] : []),
...(cloudRepos && onMoreCloudAccess ? [CLOUD_REPO_MORE_KEY] : []),
...(onAddProject ? [ADD_PROJECT_KEY] : [])
],
- [cloudRepos, onAddProject, onMoreCloudAccess, options, recentIds]
+ [cloudRepos, onAddProject, onMoreCloudAccess, onShowMoreCloudRepos, options, recentIds]
)
const {
query,
@@ -123,6 +128,11 @@ export default function ProjectCombobox({
if (key === null) {
return
}
+ if (key === CLOUD_REPO_SHOW_MORE_KEY) {
+ // Keep the list open: the next page appends in place.
+ onShowMoreCloudRepos?.()
+ return
+ }
close()
if (key === ADD_PROJECT_KEY) {
onAddProject?.()
@@ -139,7 +149,15 @@ export default function ProjectCombobox({
onValueChange(key)
onValueSelected?.(key)
},
- [close, onAddProject, onCloudRepoSelected, onMoreCloudAccess, onValueChange, onValueSelected]
+ [
+ close,
+ onAddProject,
+ onCloudRepoSelected,
+ onMoreCloudAccess,
+ onShowMoreCloudRepos,
+ onValueChange,
+ onValueSelected
+ ]
)
const handleKeyDown = useCallback(
@@ -358,6 +376,7 @@ export default function ProjectCombobox({
onArm={arm}
onCommit={commit}
showMoreAccess={Boolean(onMoreCloudAccess)}
+ showMoreRepos={Boolean(onShowMoreCloudRepos)}
/>
) : null}
diff --git a/src/renderer/src/components/new-workspace/ProjectComboboxCloudSection.tsx b/src/renderer/src/components/new-workspace/ProjectComboboxCloudSection.tsx
index 60789fc1246..c1f234a570b 100644
--- a/src/renderer/src/components/new-workspace/ProjectComboboxCloudSection.tsx
+++ b/src/renderer/src/components/new-workspace/ProjectComboboxCloudSection.tsx
@@ -2,13 +2,14 @@
// Cloud can reach with no clone on this computer, plus a way to give it access to more. Shown only
// while Orca Cloud is the Run on target.
import React from 'react'
-import { Check, Github, Plus } from 'lucide-react'
+import { Check, ChevronDown, Github, Plus } from 'lucide-react'
import { cn } from '@/lib/utils'
import { useTranslate } from '@/i18n/use-translate'
import type { OrcaCloudGitHubRepository } from '@/lib/orca-cloud/use-orca-cloud-github-repositories'
export const CLOUD_REPO_KEY_PREFIX = 'github:'
export const CLOUD_REPO_MORE_KEY = 'github-more-access'
+export const CLOUD_REPO_SHOW_MORE_KEY = 'github-show-more'
export function cloudRepoKey(fullName: string): string {
return `${CLOUD_REPO_KEY_PREFIX}${fullName}`
@@ -30,7 +31,8 @@ export function ProjectComboboxCloudSection({
armedId,
onArm,
onCommit,
- showMoreAccess
+ showMoreAccess,
+ showMoreRepos = false
}: {
repos: readonly OrcaCloudGitHubRepository[]
value: string | null
@@ -39,6 +41,8 @@ export function ProjectComboboxCloudSection({
onArm: (key: string) => void
onCommit: (key: string) => void
showMoreAccess: boolean
+ /** GitHub has more pages than are listed. */
+ showMoreRepos?: boolean
}): React.JSX.Element | null {
const t = useTranslate()
if (repos.length === 0 && !showMoreAccess) {
@@ -65,11 +69,17 @@ export function ProjectComboboxCloudSection({
)
return (
-
- {heading}
+
+
+ {heading}
+
+ {/* Said once for the section; rows carry what tells them apart. */}
+
+ {t(
+ 'components.newWorkspace.cloudOnly.detail',
+ 'Orca Cloud clones it. No copy on this computer needed.'
+ )}
+
{repos.map((repo) => {
const key = cloudRepoKey(repo.fullName)
@@ -85,10 +95,13 @@ export function ProjectComboboxCloudSection({
{repo.fullName}
- {t(
- 'components.newWorkspace.cloudOnly.detail',
- 'Orca Cloud clones it. No copy on this computer needed.'
- )}
+ {repo.private
+ ? t('components.newWorkspace.cloudOnly.private', '{{owner}} · Private', {
+ owner: repo.fullName.split('/')[0] ?? repo.fullName
+ })
+ : t('components.newWorkspace.cloudOnly.public', '{{owner}} · Public', {
+ owner: repo.fullName.split('/')[0] ?? repo.fullName
+ })}
{current ? (
@@ -102,6 +115,19 @@ export function ProjectComboboxCloudSection({
>
)
})}
+ {showMoreRepos
+ ? row(
+ CLOUD_REPO_SHOW_MORE_KEY,
+ <>
+
+
+
+
+ {t('components.newWorkspace.cloudOnly.showMore', 'Show more repositories…')}
+
+ >
+ )
+ : null}
{showMoreAccess
? row(
CLOUD_REPO_MORE_KEY,
diff --git a/src/renderer/src/components/new-workspace/run-on/CloudStart.fixture.tsx b/src/renderer/src/components/new-workspace/run-on/CloudStart.fixture.tsx
index 715ec07d1e8..6243f7b8b6e 100644
--- a/src/renderer/src/components/new-workspace/run-on/CloudStart.fixture.tsx
+++ b/src/renderer/src/components/new-workspace/run-on/CloudStart.fixture.tsx
@@ -219,7 +219,8 @@ export const d3NotOnGitHub = defineFixture({
})
const cloudRepos = [
{ fullName: 'acme/billing', url: 'https://github.com/acme/billing', private: true },
- { fullName: 'acme/infra', url: 'https://github.com/acme/infra', private: true }
+ { fullName: 'acme/infra', url: 'https://github.com/acme/infra', private: true },
+ { fullName: 'acme/docs', url: 'https://github.com/acme/docs', private: false }
]
/** D4: Orca Cloud picked; the Project picker adds GitHub repositories with no clone here. */
export const d4GitHubProjects = defineFixture({
diff --git a/src/renderer/src/components/new-workspace/run-on/cloud-start-preview-fixture.tsx b/src/renderer/src/components/new-workspace/run-on/cloud-start-preview-fixture.tsx
index 9364f0a18ce..f37728369fb 100644
--- a/src/renderer/src/components/new-workspace/run-on/cloud-start-preview-fixture.tsx
+++ b/src/renderer/src/components/new-workspace/run-on/cloud-start-preview-fixture.tsx
@@ -102,6 +102,7 @@ export function ComposerPreview({
? {
cloudOnly: {
repos: cloudRepos,
+ showMore: () => {},
picked: cloudRepos.find((repo) => repo.fullName === picked) ?? null,
githubStep: null,
pick: setPicked,
diff --git a/src/renderer/src/components/new-workspace/run-on/use-cloud-only-repo.ts b/src/renderer/src/components/new-workspace/run-on/use-cloud-only-repo.ts
index 65db379965f..b59b7b3ac88 100644
--- a/src/renderer/src/components/new-workspace/run-on/use-cloud-only-repo.ts
+++ b/src/renderer/src/components/new-workspace/run-on/use-cloud-only-repo.ts
@@ -14,6 +14,8 @@ import type { CloudSetupStep } from './cloud-start-model'
export type CloudOnlyRepo = {
repos: readonly OrcaCloudGitHubRepository[] | null
+ /** Fetches GitHub's next pages; null when everything is listed. */
+ showMore: (() => void) | null
picked: OrcaCloudGitHubRepository | null
/** The GitHub row is done for a repository listed from the team's installations. */
githubStep: CloudSetupStep | null
@@ -32,7 +34,7 @@ export function useCloudOnlyRepo({
/** The list needs an account; signed out, setup comes first. */
signedIn: boolean
}): CloudOnlyRepo {
- const repos = useOrcaCloudGitHubRepositories(enabled && signedIn)
+ const { repos, showMore } = useOrcaCloudGitHubRepositories(enabled && signedIn)
const [pickedName, setPickedName] = useState
(null)
const picked = useMemo(
() => (enabled ? (repos?.find((repo) => repo.fullName === pickedName) ?? null) : null),
@@ -66,7 +68,7 @@ export function useCloudOnlyRepo({
: Promise.resolve(false),
[picked]
)
- return { repos, picked, githubStep, pick: setPickedName, clear, moreAccess, start }
+ return { repos, showMore, picked, githubStep, pick: setPickedName, clear, moreAccess, start }
}
/**
diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json
index e038d19dfbd..852474c1cf5 100644
--- a/src/renderer/src/i18n/locales/en.json
+++ b/src/renderer/src/i18n/locales/en.json
@@ -23137,7 +23137,10 @@
"notOnThisComputer": "Not on this computer · Orca Cloud only",
"startFailed": "Couldn’t start the cloud workspace. Nothing was created, and you weren’t charged.",
"starting": "Starting {{repo}} in Orca Cloud…",
- "openLater": "Your cloud workspace started, but this computer couldn’t open it yet. Open it from Cloud workspaces."
+ "openLater": "Your cloud workspace started, but this computer couldn’t open it yet. Open it from Cloud workspaces.",
+ "private": "{{owner}} · Private",
+ "public": "{{owner}} · Public",
+ "showMore": "Show more repositories…"
}
},
"JiraIssueWorkspace": {
diff --git a/src/renderer/src/lib/orca-cloud/use-orca-cloud-github-repositories.ts b/src/renderer/src/lib/orca-cloud/use-orca-cloud-github-repositories.ts
index 9abce1317a7..64c5860b936 100644
--- a/src/renderer/src/lib/orca-cloud/use-orca-cloud-github-repositories.ts
+++ b/src/renderer/src/lib/orca-cloud/use-orca-cloud-github-repositories.ts
@@ -1,7 +1,7 @@
// Repositories Orca Cloud can reach on GitHub that have no clone on this computer (cloud-start D4,
// N12): the Project picker lists them under "On GitHub · Orca Cloud only" while Orca Cloud is
// picked, because a sandbox clones from GitHub anyway.
-import { useEffect, useMemo, useState } from 'react'
+import { useCallback, useEffect, useMemo, useState } from 'react'
import { useAppStore } from '@/store'
import type { HostedGithubRepositoriesResponse } from '../../../../shared/hosted-sandbox/hosted-github-wire'
import { orcaCloudGitHubRepoUrl } from './use-orca-cloud-repo-access'
@@ -13,39 +13,53 @@ export type OrcaCloudGitHubRepository = {
private: boolean
}
-/** Two pages cover nearly every team; the rest is a search away on GitHub's own page. */
-const MAX_PAGES = 2
+/** Two pages at a time cover nearly every team; "Show more repositories…" fetches the next two. */
+const PAGES_PER_LOAD = 2
const CACHE_MS = 5 * 60_000
-let cache: { at: number; value: Promise } | null = null
+type Listing = { repos: OrcaCloudGitHubRepository[]; nextCursor: string | null }
-async function fetchAll(): Promise {
- const out: OrcaCloudGitHubRepository[] = []
- let cursor: string | null = null
- for (let page = 0; page < MAX_PAGES; page += 1) {
+let cache: { at: number; value: Promise } | null = null
+
+async function fetchPages(after: Listing): Promise {
+ const repos = [...after.repos]
+ let cursor = after.nextCursor
+ for (let page = 0; page < PAGES_PER_LOAD; page += 1) {
const result = await window.api.orcaCloudWorkspace.listGitHubRepositories({ cursor })
if (!result.ok) {
break
}
const value: HostedGithubRepositoriesResponse = result.value
for (const repo of value.repositories) {
- out.push({ fullName: repo.fullName, url: repo.url, private: repo.private })
+ repos.push({ fullName: repo.fullName, url: repo.url, private: repo.private })
}
cursor = value.nextCursor
if (!cursor) {
break
}
}
- return out
+ return { repos, nextCursor: cursor }
}
-function loadRepositories(): Promise {
+function loadRepositories(more = false): Promise {
const now = Date.now()
if (!cache || now - cache.at >= CACHE_MS) {
- const entry = { at: now, value: fetchAll().catch(() => []) }
- cache = entry
+ cache = { at: now, value: fetchPages({ repos: [], nextCursor: null }) }
+ } else if (more) {
+ const previous = cache.value
+ cache = {
+ at: cache.at,
+ value: previous.then((listing) => (listing.nextCursor ? fetchPages(listing) : listing))
+ }
}
- return cache.value
+ const entry = cache
+ // A failed read isn't cached: the next open asks again.
+ return entry.value.catch(() => {
+ if (cache === entry) {
+ cache = null
+ }
+ return { repos: [], nextCursor: null }
+ })
}
/** Forget the list after the user gives Orca Cloud access to more repositories. */
@@ -75,33 +89,38 @@ export function selectCloudOnlyRepositories(
.sort((a, b) => a.fullName.localeCompare(b.fullName))
}
-export function useOrcaCloudGitHubRepositories(
- enabled: boolean
-): OrcaCloudGitHubRepository[] | null {
+export function useOrcaCloudGitHubRepositories(enabled: boolean): {
+ repos: OrcaCloudGitHubRepository[] | null
+ /** Present while GitHub has more pages than are listed. */
+ showMore: (() => void) | null
+} {
const repos = useAppStore((s) => s.repos)
- const [reachable, setReachable] = useState(null)
+ const [listing, setListing] = useState(null)
+ const [moreRequests, setMoreRequests] = useState(0)
useEffect(() => {
if (!enabled) {
return
}
let cancelled = false
- void loadRepositories().then((value) => {
+ void loadRepositories(moreRequests > 0).then((value) => {
if (!cancelled) {
- setReachable(value)
+ setListing(value)
}
})
return () => {
cancelled = true
}
- }, [enabled])
- return useMemo(
+ }, [enabled, moreRequests])
+ const visible = useMemo(
() =>
- enabled && reachable
+ enabled && listing
? selectCloudOnlyRepositories(
- reachable,
+ listing.repos,
repos.map((repo) => orcaCloudGitHubRepoUrl(repo))
)
: null,
- [enabled, reachable, repos]
+ [enabled, listing, repos]
)
+ const showMore = useCallback(() => setMoreRequests((n) => n + 1), [])
+ return { repos: visible, showMore: enabled && listing?.nextCursor ? showMore : null }
}