Skip to content

Commit 5dc4153

Browse files
t3dotggclaude
andcommitted
feat(clients): show and switch the machine in the new project step
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 897076a commit 5dc4153

2 files changed

Lines changed: 83 additions & 27 deletions

File tree

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

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,14 @@ function FolderBrowser(props: {
933933
*/
934934
export function AddProjectNewScreen(props: { readonly environmentId?: string | string[] }) {
935935
const navigation = useNavigation();
936-
const environment = useEnvironmentFromParam(props.environmentId);
936+
// Starts on the machine picked in Add project; the rows below switch it.
937+
const environmentOptions = useEnvironmentOptions().filter(
938+
(option) => option.newProjectsRoot !== null,
939+
);
940+
const [selectedEnvironmentId, setSelectedEnvironmentId] = useState(
941+
() => stringParam(props.environmentId) as EnvironmentId | null,
942+
);
943+
const environment = resolveAddProjectEnvironment(environmentOptions, selectedEnvironmentId);
937944
const createNew = useAtomCommand(projectEnvironment.createNew, { reportFailure: false });
938945
const publishRepository = useAtomCommand(sourceControlEnvironment.publishRepository, {
939946
reportFailure: false,
@@ -1040,8 +1047,39 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | s
10401047
{trimmedName.length > 0
10411048
? `Creates ${pathPreview}`
10421049
: `Goes in ${environment.newProjectsRoot}`}
1050+
{environmentOptions.length > 1 ? ` on ${environment.label}` : null}
10431051
</Text>
10441052
) : null}
1053+
{environmentOptions.length > 1 ? (
1054+
<ListSection>
1055+
{environmentOptions.map((option, index) => (
1056+
<ListRow
1057+
key={option.environmentId}
1058+
title={option.label}
1059+
icon={
1060+
<EnvironmentMachineSymbol
1061+
kind={option.machine}
1062+
size={Platform.OS === "android" ? 24 : 17}
1063+
tintColorClassName="accent-icon"
1064+
/>
1065+
}
1066+
selected={option.environmentId === environment.environmentId}
1067+
isFirst={index === 0}
1068+
right={
1069+
option.environmentId === environment.environmentId ? (
1070+
<SymbolView
1071+
name="checkmark"
1072+
size={Platform.OS === "android" ? 20 : 14}
1073+
tintColorClassName="accent-icon"
1074+
type="monochrome"
1075+
/>
1076+
) : null
1077+
}
1078+
onPress={() => setSelectedEnvironmentId(option.environmentId)}
1079+
/>
1080+
))}
1081+
</ListSection>
1082+
) : null}
10451083
{githubTarget !== null ? (
10461084
<ListSection>
10471085
<ListRow

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

Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import * as Option from "effect/Option";
4646
import {
4747
ArrowLeftIcon,
4848
ChartNoAxesColumnIcon,
49+
CheckIcon,
4950
ChevronRightIcon,
5051
CornerLeftUpIcon,
5152
FileSearchIcon,
@@ -1793,30 +1794,11 @@ function OpenCommandPaletteDialog(props: {
17931794
startAddProjectSourceSelection,
17941795
]);
17951796

1796-
// New project goes straight to the name step when only one environment offers it.
1797+
// New project starts on this device (options list it first); the name step
1798+
// lists the other machines when there is a choice.
17971799
const openNewProjectFlow = () => {
1798-
const onlyOption =
1799-
newProjectEnvironmentOptions.length === 1 ? newProjectEnvironmentOptions[0] : null;
1800-
if (onlyOption) {
1801-
startNewProject(onlyOption.environmentId);
1802-
return;
1803-
}
1804-
pushPaletteView({
1805-
addonIcon: <FolderGit2Icon className={ADDON_ICON_CLASS} />,
1806-
groups: [
1807-
{
1808-
value: "new-project-environments",
1809-
label: "Environments",
1810-
items: newProjectEnvironmentOptions.map((option) =>
1811-
buildEnvironmentItem(
1812-
option,
1813-
`action:new-project:environment:${option.environmentId}`,
1814-
startNewProject,
1815-
),
1816-
),
1817-
},
1818-
],
1819-
});
1800+
const firstOption = newProjectEnvironmentOptions[0];
1801+
if (firstOption) startNewProject(firstOption.environmentId);
18201802
};
18211803

18221804
useLayoutEffect(() => {
@@ -2790,6 +2772,39 @@ function OpenCommandPaletteDialog(props: {
27902772
popView();
27912773
if (!openedFromSources) startAddProjectSourceSelection(environmentId);
27922774
};
2775+
// Switching machines keeps the typed name; the GitHub option follows the
2776+
// machine because source control discovery reads addProjectEnvironmentId.
2777+
const switchNewProjectEnvironment = (environmentId: EnvironmentId) => {
2778+
setNewProjectFlow({ environmentId });
2779+
setAddProjectEnvironmentId(environmentId);
2780+
};
2781+
const newProjectEnvironmentLabel =
2782+
newProjectFlow !== null && newProjectEnvironmentOptions.length > 1
2783+
? (newProjectEnvironmentOptions.find(
2784+
(option) => option.environmentId === newProjectFlow.environmentId,
2785+
)?.label ?? null)
2786+
: null;
2787+
const newProjectMachineGroup: CommandPaletteView["groups"][number] | null =
2788+
newProjectEnvironmentLabel === null || newProjectFlow === null
2789+
? null
2790+
: {
2791+
value: "new-project-machines",
2792+
label: "Environments",
2793+
items: newProjectEnvironmentOptions.map((option) => ({
2794+
...buildEnvironmentItem(
2795+
option,
2796+
`new-project:environment:${option.environmentId}`,
2797+
switchNewProjectEnvironment,
2798+
),
2799+
...(option.environmentId === newProjectFlow.environmentId
2800+
? {
2801+
titleTrailingContent: (
2802+
<CheckIcon className="ms-auto size-4 shrink-0 text-muted-foreground/70" />
2803+
),
2804+
}
2805+
: {}),
2806+
})),
2807+
};
27932808
const newProjectExistingGroup: CommandPaletteView["groups"][number] | null =
27942809
newProjectFlow === null
27952810
? null
@@ -2848,9 +2863,11 @@ function OpenCommandPaletteDialog(props: {
28482863

28492864
let displayedGroups: CommandPaletteView["groups"] = filteredGroups;
28502865
if (newProjectFlow !== null) {
2851-
displayedGroups = newProjectExistingGroup
2852-
? [...newProjectOptionGroups, newProjectExistingGroup]
2853-
: newProjectOptionGroups;
2866+
displayedGroups = [
2867+
...(newProjectMachineGroup ? [newProjectMachineGroup] : []),
2868+
...newProjectOptionGroups,
2869+
...(newProjectExistingGroup ? [newProjectExistingGroup] : []),
2870+
];
28542871
} else if (addProjectCloneFlow?.step === "repository") {
28552872
displayedGroups = [];
28562873
} else if (addProjectCloneFlow?.step === "confirm") {
@@ -3319,6 +3336,7 @@ function OpenCommandPaletteDialog(props: {
33193336
{newProjectName.length > 0
33203337
? `Creates ${newProjectPathPreview}`
33213338
: `Goes in ${newProjectsRoot}`}
3339+
{newProjectEnvironmentLabel === null ? null : ` on ${newProjectEnvironmentLabel}`}
33223340
</span>
33233341
</span>
33243342
</div>

0 commit comments

Comments
 (0)