Skip to content

Commit 2549bb6

Browse files
feat(projects): new projects can be published to any ready host
New project only offered "Create private repository on GitHub". Every host implements createRepository, so the flow now lists each ready host whose definition can place the repository (newRepositoryOwner), with GitHub first. The palette shows an inline host select beside the toggle; mobile lists the hosts under the switch while it is on. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent a311fe1 commit 2549bb6

12 files changed

Lines changed: 261 additions & 64 deletions

File tree

‎apps/mobile/src/features/projects/AddProjectScreen.tsx‎

Lines changed: 52 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ import {
1515
getCloneDestinationPath,
1616
getCloneDirectoryName,
1717
getDefaultCloneUrl,
18-
getNewProjectGitHubRepository,
19-
getNewProjectGitHubTarget,
2018
getNewProjectPathPreview,
19+
getNewProjectPublishTarget,
20+
getNewProjectPublishTargets,
21+
getNewProjectRepository,
2122
normalizePastedCloneUrl,
2223
parseAddProjectRemoteSource,
2324
resolveAddProjectPath,
@@ -995,9 +996,12 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | s
995996
input: {},
996997
}),
997998
);
998-
const githubTarget = getNewProjectGitHubTarget(discoveryState.data);
999+
const publishTargets = getNewProjectPublishTargets(discoveryState.data);
9991000
const [name, setName] = useState("");
1000-
const [publishesToGitHub, setPublishesToGitHub] = useState(false);
1001+
const [publishes, setPublishes] = useState(false);
1002+
// Null takes the first ready host, GitHub when it is ready.
1003+
const [publishKind, setPublishKind] = useState<SourceControlProviderKind | null>(null);
1004+
const publishTarget = getNewProjectPublishTarget(publishTargets, publishKind);
10011005
const [isSubmitting, setIsSubmitting] = useState(false);
10021006
const [error, setError] = useState<string | null>(null);
10031007
const trimmedName = name.trim();
@@ -1066,19 +1070,19 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | s
10661070
if (commitError !== undefined) {
10671071
Alert.alert("Created without a first commit", commitError);
10681072
}
1069-
if (publishesToGitHub && githubTarget !== null) {
1073+
if (publishes && publishTarget !== null) {
10701074
void publishRepository({
10711075
environmentId: environment.environmentId,
10721076
input: {
10731077
cwd: workspaceRoot,
1074-
provider: SourceControlProviderKind.make("github"),
1075-
repository: getNewProjectGitHubRepository(githubTarget, workspaceRoot),
1078+
provider: publishTarget.definition.kind,
1079+
repository: getNewProjectRepository(publishTarget, workspaceRoot),
10761080
visibility: "private",
10771081
},
10781082
}).then((publishResult) => {
10791083
if (AsyncResult.isFailure(publishResult)) {
10801084
Alert.alert(
1081-
"Could not create the GitHub repository",
1085+
`Could not create the ${publishTarget.definition.label} repository`,
10821086
errorMessage(Cause.squash(publishResult.cause)),
10831087
);
10841088
}
@@ -1133,32 +1137,63 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | s
11331137
</Text>
11341138
) : null}
11351139
{machineRows}
1136-
{githubTarget !== null ? (
1140+
{publishTarget !== null ? (
11371141
<ListSection>
11381142
<ListRow
1139-
title="Create private repository on GitHub"
1143+
title={`Create private repository on ${publishTarget.definition.label}`}
11401144
subtitle={
11411145
trimmedName.length > 0 && pathPreview !== null
1142-
? getNewProjectGitHubRepository(githubTarget, pathPreview)
1143-
: githubTarget.account
1146+
? getNewProjectRepository(publishTarget, pathPreview)
1147+
: publishTarget.owner
11441148
}
11451149
icon={
11461150
<SourceControlIcon
1147-
kind={sourceControlClients.get("github").icon}
1151+
kind={publishTarget.definition.icon}
11481152
size={Platform.OS === "android" ? 24 : 18}
11491153
colorClassName="accent-icon"
11501154
/>
11511155
}
11521156
isFirst
11531157
right={
11541158
<ThemedSwitch
1155-
accessibilityLabel="Create private repository on GitHub"
1156-
value={publishesToGitHub}
1157-
onValueChange={setPublishesToGitHub}
1159+
accessibilityLabel={`Create private repository on ${publishTarget.definition.label}`}
1160+
value={publishes}
1161+
onValueChange={setPublishes}
11581162
/>
11591163
}
1160-
onPress={() => setPublishesToGitHub((publishes) => !publishes)}
1164+
onPress={() => setPublishes((current) => !current)}
11611165
/>
1166+
{publishes && publishTargets.length > 1
1167+
? publishTargets.map((target) => {
1168+
const selected = target.definition.kind === publishTarget.definition.kind;
1169+
return (
1170+
<ListRow
1171+
key={target.definition.kind}
1172+
title={target.definition.label}
1173+
icon={
1174+
<SourceControlIcon
1175+
kind={target.definition.icon}
1176+
size={Platform.OS === "android" ? 24 : 17}
1177+
colorClassName="accent-icon"
1178+
/>
1179+
}
1180+
selected={selected}
1181+
disabled={isSubmitting}
1182+
right={
1183+
selected ? (
1184+
<SymbolView
1185+
name="checkmark"
1186+
size={Platform.OS === "android" ? 20 : 14}
1187+
tintColorClassName="accent-icon"
1188+
type="monochrome"
1189+
/>
1190+
) : null
1191+
}
1192+
onPress={() => setPublishKind(target.definition.kind)}
1193+
/>
1194+
);
1195+
})
1196+
: null}
11621197
</ListSection>
11631198
) : null}
11641199
<PrimaryActionButton

‎apps/web/src/components/CommandPalette.tsx‎

Lines changed: 78 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ import {
1010
getCloneDestinationPath,
1111
getCloneDirectoryName,
1212
getDefaultCloneUrl,
13-
getNewProjectGitHubRepository,
14-
getNewProjectGitHubTarget,
1513
getNewProjectPathPreview,
14+
getNewProjectPublishTarget,
15+
getNewProjectPublishTargets,
16+
getNewProjectRepository,
17+
type NewProjectPublishTarget,
1618
normalizePastedCloneUrl,
1719
addProjectRemoteSourceLabel,
1820
addProjectRemoteSourcePathHint,
@@ -195,7 +197,6 @@ import {
195197
CommandPaletteVirtualizedResults,
196198
scrollCommandPaletteRowIntoView,
197199
} from "./CommandPaletteResults";
198-
import { GitHubIcon } from "./Icons";
199200
import { sourceControlIcon } from "~/sourceControlPresentation";
200201
import { EnvironmentMachineIcon } from "./EnvironmentMachineIcon";
201202
import { Checkbox } from "./ui/checkbox";
@@ -221,6 +222,7 @@ import { resolveShortcutCommand, threadJumpIndexFromCommand } from "../keybindin
221222
import { CommandDialog, CommandDialogPopup, CommandFooterAction } from "./ui/command";
222223
import { Button } from "./ui/button";
223224
import { Kbd, KbdGroup } from "./ui/kbd";
225+
import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "./ui/select";
224226
import { stackedThreadToast, toastManager } from "./ui/toast";
225227
import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
226228
import { ComposerHandleContext, useComposerHandleContext } from "../composerHandleContext";
@@ -280,6 +282,11 @@ function remoteProjectSourceIcon(source: AddProjectRemoteSource, className: stri
280282
return <Icon className={className} />;
281283
}
282284

285+
function newProjectPublishIcon(target: NewProjectPublishTarget): ReactNode {
286+
const Icon = sourceControlIcon(target.definition);
287+
return <Icon className={ITEM_ICON_CLASS} />;
288+
}
289+
283290
function projectFaviconIcon(project: Project): ReactNode {
284291
return <ProjectFavicon project={project} className={ITEM_ICON_CLASS} />;
285292
}
@@ -762,7 +769,10 @@ function OpenCommandPaletteDialog(props: {
762769
/** Machine of the Add project sources view under this step; null from the palette root. */
763770
readonly sourcesEnvironmentId: EnvironmentId | null;
764771
} | null>(null);
765-
const [newProjectPublishesToGitHub, setNewProjectPublishesToGitHub] = useState(false);
772+
const [newProjectPublishes, setNewProjectPublishes] = useState(false);
773+
// The host picked beside the publish toggle; null takes the first ready host, GitHub when ready.
774+
const [newProjectPublishKind, setNewProjectPublishKind] =
775+
useState<SourceControlProviderKind | null>(null);
766776
const [isCreatingNewProject, setIsCreatingNewProject] = useState(false);
767777
// State lags a render behind, so a repeated Enter could start a second create.
768778
const newProjectSubmittingRef = useRef(false);
@@ -1482,7 +1492,8 @@ function OpenCommandPaletteDialog(props: {
14821492
setAddProjectEnvironmentId(environmentId);
14831493
setAddProjectCloneFlow(null);
14841494
setNewProjectFlow({ environmentId, sourcesEnvironmentId });
1485-
setNewProjectPublishesToGitHub(false);
1495+
setNewProjectPublishes(false);
1496+
setNewProjectPublishKind(null);
14861497
pushPaletteView({
14871498
addonIcon: <FolderGit2Icon className={ADDON_ICON_CLASS} />,
14881499
groups: [],
@@ -2417,8 +2428,12 @@ function OpenCommandPaletteDialog(props: {
24172428
],
24182429
);
24192430

2420-
const newProjectGitHubTarget =
2421-
newProjectFlow === null ? null : getNewProjectGitHubTarget(sourceControlDiscovery.data ?? null);
2431+
const newProjectPublishTargets =
2432+
newProjectFlow === null ? [] : getNewProjectPublishTargets(sourceControlDiscovery.data ?? null);
2433+
const newProjectPublishTarget = getNewProjectPublishTarget(
2434+
newProjectPublishTargets,
2435+
newProjectPublishKind,
2436+
);
24222437
const newProjectName = query.trim();
24232438
const canSubmitNewProject =
24242439
newProjectFlow !== null &&
@@ -2436,7 +2451,7 @@ function OpenCommandPaletteDialog(props: {
24362451
const created = await createNewProject({
24372452
environmentId: newProjectFlow.environmentId,
24382453
name: newProjectName,
2439-
github: newProjectPublishesToGitHub ? newProjectGitHubTarget : null,
2454+
publishTo: newProjectPublishes ? newProjectPublishTarget : null,
24402455
});
24412456
if (created) setOpen(false);
24422457
} finally {
@@ -2742,7 +2757,7 @@ function OpenCommandPaletteDialog(props: {
27422757
const newProjectsRoot = newProjectFlow ? newProjectsRootFor(newProjectFlow.environmentId) : null;
27432758
const newProjectPathPreview =
27442759
newProjectsRoot === null ? null : getNewProjectPathPreview(newProjectsRoot, newProjectName);
2745-
const newProjectGitHubToggleValue = "new-project:github";
2760+
const newProjectPublishToggleValue = "new-project:publish";
27462761
// The name step's way out to folders and clones, for the selected machine.
27472762
// It replaces the name step (and a sources view for another machine under
27482763
// it), so Back returns to wherever New project was opened from.
@@ -2829,7 +2844,7 @@ function OpenCommandPaletteDialog(props: {
28292844
],
28302845
};
28312846
const newProjectOptionGroups: CommandPaletteView["groups"] =
2832-
newProjectGitHubTarget === null || newProjectPathPreview === null
2847+
newProjectPublishTarget === null || newProjectPathPreview === null
28332848
? []
28342849
: [
28352850
{
@@ -2838,22 +2853,66 @@ function OpenCommandPaletteDialog(props: {
28382853
items: [
28392854
{
28402855
kind: "action",
2841-
value: newProjectGitHubToggleValue,
2856+
value: newProjectPublishToggleValue,
28422857
searchTerms: [],
2843-
title: "Create private repository on GitHub",
2858+
title:
2859+
newProjectPublishTargets.length > 1
2860+
? "Create private repository"
2861+
: `Create private repository on ${newProjectPublishTarget.definition.label}`,
28442862
description:
28452863
newProjectName.length > 0
2846-
? getNewProjectGitHubRepository(newProjectGitHubTarget, newProjectPathPreview)
2847-
: (newProjectGitHubTarget.account ?? "Your GitHub account"),
2848-
icon: <GitHubIcon className={ITEM_ICON_CLASS} />,
2864+
? getNewProjectRepository(newProjectPublishTarget, newProjectPathPreview)
2865+
: (newProjectPublishTarget.owner ??
2866+
`Your ${newProjectPublishTarget.definition.label} account`),
2867+
icon: newProjectPublishIcon(newProjectPublishTarget),
28492868
titleTrailingContent: (
2850-
<span className="pointer-events-none ms-auto flex">
2851-
<Checkbox checked={newProjectPublishesToGitHub} tabIndex={-1} aria-hidden />
2869+
<span className="ms-auto flex items-center gap-2">
2870+
{newProjectPublishTargets.length > 1 ? (
2871+
// The row toggles on click, so the picker keeps its clicks to itself.
2872+
<span
2873+
className="flex"
2874+
onClick={(event) => event.stopPropagation()}
2875+
onMouseDown={(event) => event.stopPropagation()}
2876+
>
2877+
<Select
2878+
value={newProjectPublishTarget.definition.kind}
2879+
onValueChange={(kind) => {
2880+
if (kind !== null) setNewProjectPublishKind(kind);
2881+
}}
2882+
>
2883+
<SelectTrigger
2884+
size="xs"
2885+
variant="ghost"
2886+
aria-label="Host for the new repository"
2887+
>
2888+
<SelectValue>
2889+
{(kind: SourceControlProviderKind) =>
2890+
sourceControlClients.get(kind).label
2891+
}
2892+
</SelectValue>
2893+
</SelectTrigger>
2894+
<SelectPopup align="end" alignItemWithTrigger={false}>
2895+
{newProjectPublishTargets.map((target) => (
2896+
<SelectItem
2897+
key={target.definition.kind}
2898+
hideIndicator
2899+
value={target.definition.kind}
2900+
>
2901+
{target.definition.label}
2902+
</SelectItem>
2903+
))}
2904+
</SelectPopup>
2905+
</Select>
2906+
</span>
2907+
) : null}
2908+
<span className="pointer-events-none flex">
2909+
<Checkbox checked={newProjectPublishes} tabIndex={-1} aria-hidden />
2910+
</span>
28522911
</span>
28532912
),
28542913
keepOpen: true,
28552914
run: async () => {
2856-
setNewProjectPublishesToGitHub((publishes) => !publishes);
2915+
setNewProjectPublishes((publishes) => !publishes);
28572916
},
28582917
},
28592918
],
@@ -3327,7 +3386,7 @@ function OpenCommandPaletteDialog(props: {
33273386
newProjectFlow !== null
33283387
? highlightedItemValue === null
33293388
? "Create"
3330-
: highlightedItemValue === newProjectGitHubToggleValue
3389+
: highlightedItemValue === newProjectPublishToggleValue
33313390
? "Toggle"
33323391
: "Select"
33333392
: addProjectCloneFlow?.step === "repository"

0 commit comments

Comments
 (0)