Skip to content

Commit 636049c

Browse files
committed
refactor: remove source/language/host steps, existing-endpoint is the only flow
1 parent 642fade commit 636049c

2 files changed

Lines changed: 12 additions & 114 deletions

File tree

src/cli/tui/screens/mcp/AddGatewayTargetScreen.tsx

Lines changed: 2 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,8 @@ import type { SelectableItem } from '../../components';
44
import { HELP_TEXT } from '../../constants';
55
import { useListNavigation } from '../../hooks';
66
import { generateUniqueName } from '../../utils';
7-
import type { AddGatewayTargetConfig, ComputeHost, TargetLanguage } from './types';
8-
import {
9-
COMPUTE_HOST_OPTIONS,
10-
MCP_TOOL_STEP_LABELS,
11-
SKIP_FOR_NOW,
12-
SOURCE_OPTIONS,
13-
TARGET_LANGUAGE_OPTIONS,
14-
} from './types';
7+
import type { AddGatewayTargetConfig } from './types';
8+
import { MCP_TOOL_STEP_LABELS, SKIP_FOR_NOW } from './types';
159
import { useAddGatewayTargetWizard } from './useAddGatewayTargetWizard';
1610
import { Box, Text } from 'ink';
1711
import React, { useMemo } from 'react';
@@ -31,16 +25,6 @@ export function AddGatewayTargetScreen({
3125
}: AddGatewayTargetScreenProps) {
3226
const wizard = useAddGatewayTargetWizard(existingGateways);
3327

34-
const sourceItems: SelectableItem[] = useMemo(
35-
() => SOURCE_OPTIONS.map(o => ({ id: o.id, title: o.title, description: o.description })),
36-
[]
37-
);
38-
39-
const languageItems: SelectableItem[] = useMemo(
40-
() => TARGET_LANGUAGE_OPTIONS.map(o => ({ id: o.id, title: o.title, description: o.description })),
41-
[]
42-
);
43-
4428
const gatewayItems: SelectableItem[] = useMemo(
4529
() => [
4630
...existingGateways.map(g => ({ id: g, title: g })),
@@ -49,47 +33,18 @@ export function AddGatewayTargetScreen({
4933
[existingGateways]
5034
);
5135

52-
const hostItems: SelectableItem[] = useMemo(
53-
() => COMPUTE_HOST_OPTIONS.map(o => ({ id: o.id, title: o.title, description: o.description })),
54-
[]
55-
);
56-
57-
const isSourceStep = wizard.step === 'source';
58-
const isLanguageStep = wizard.step === 'language';
5936
const isGatewayStep = wizard.step === 'gateway';
60-
const isHostStep = wizard.step === 'host';
6137
const isTextStep = wizard.step === 'name' || wizard.step === 'endpoint';
6238
const isConfirmStep = wizard.step === 'confirm';
6339
const noGatewaysAvailable = isGatewayStep && existingGateways.length === 0;
6440

65-
const sourceNav = useListNavigation({
66-
items: sourceItems,
67-
onSelect: item => wizard.setSource(item.id as 'existing-endpoint' | 'create-new'),
68-
onExit: () => wizard.goBack(),
69-
isActive: isSourceStep,
70-
});
71-
72-
const languageNav = useListNavigation({
73-
items: languageItems,
74-
onSelect: item => wizard.setLanguage(item.id as TargetLanguage),
75-
onExit: () => onExit(),
76-
isActive: isLanguageStep,
77-
});
78-
7941
const gatewayNav = useListNavigation({
8042
items: gatewayItems,
8143
onSelect: item => wizard.setGateway(item.id),
8244
onExit: () => wizard.goBack(),
8345
isActive: isGatewayStep && !noGatewaysAvailable,
8446
});
8547

86-
const hostNav = useListNavigation({
87-
items: hostItems,
88-
onSelect: item => wizard.setHost(item.id as ComputeHost),
89-
onExit: () => wizard.goBack(),
90-
isActive: isHostStep,
91-
});
92-
9348
useListNavigation({
9449
items: [{ id: 'confirm', title: 'Confirm' }],
9550
onSelect: () => onComplete(wizard.config),
@@ -108,19 +63,6 @@ export function AddGatewayTargetScreen({
10863
return (
10964
<Screen title="Add MCP Tool" onExit={onExit} helpText={helpText} headerContent={headerContent}>
11065
<Panel>
111-
{isSourceStep && (
112-
<WizardSelect
113-
title="Select source"
114-
description="How would you like to create this MCP tool?"
115-
items={sourceItems}
116-
selectedIndex={sourceNav.selectedIndex}
117-
/>
118-
)}
119-
120-
{isLanguageStep && (
121-
<WizardSelect title="Select language" items={languageItems} selectedIndex={languageNav.selectedIndex} />
122-
)}
123-
12466
{isGatewayStep && !noGatewaysAvailable && (
12567
<WizardSelect
12668
title="Select gateway"
@@ -132,15 +74,6 @@ export function AddGatewayTargetScreen({
13274

13375
{noGatewaysAvailable && <NoGatewaysMessage />}
13476

135-
{isHostStep && (
136-
<WizardSelect
137-
title="Select compute host"
138-
description="Where will this tool run?"
139-
items={hostItems}
140-
selectedIndex={hostNav.selectedIndex}
141-
/>
142-
)}
143-
14477
{isTextStep && (
14578
<TextInput
14679
key={wizard.step}
Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
import { APP_DIR, MCP_APP_SUBDIR } from '../../../../lib';
22
import type { ToolDefinition } from '../../../../schema';
3-
import type { AddGatewayTargetConfig, AddGatewayTargetStep, ComputeHost, TargetLanguage } from './types';
3+
import type { AddGatewayTargetConfig, AddGatewayTargetStep } from './types';
44
import { SKIP_FOR_NOW } from './types';
55
import { useCallback, useMemo, useState } from 'react';
66

77
/**
8-
* Dynamic steps based on source.
9-
* - Existing endpoint: name → source → endpoint → gateway → confirm
10-
* - Create new: name → source → language → gateway → confirm
8+
* Steps for adding a gateway target (existing endpoint only).
9+
* name → endpoint → gateway → confirm
1110
*/
12-
function getSteps(source?: 'existing-endpoint' | 'create-new'): AddGatewayTargetStep[] {
13-
if (source === 'existing-endpoint') {
14-
return ['name', 'source', 'endpoint', 'gateway', 'confirm'];
15-
}
16-
return ['name', 'source', 'language', 'gateway', 'confirm'];
11+
function getSteps(): AddGatewayTargetStep[] {
12+
return ['name', 'endpoint', 'gateway', 'confirm'];
1713
}
1814

1915
function deriveToolDefinition(name: string): ToolDefinition {
@@ -29,6 +25,7 @@ function getDefaultConfig(): AddGatewayTargetConfig {
2925
name: '',
3026
description: '',
3127
sourcePath: '',
28+
source: 'existing-endpoint',
3229
language: 'Python',
3330
host: 'Lambda',
3431
toolDefinition: deriveToolDefinition(''),
@@ -39,16 +36,15 @@ export function useAddGatewayTargetWizard(existingGateways: string[] = []) {
3936
const [config, setConfig] = useState<AddGatewayTargetConfig>(getDefaultConfig);
4037
const [step, setStep] = useState<AddGatewayTargetStep>('name');
4138

42-
const steps = useMemo(() => getSteps(config.source), [config.source]);
39+
const steps = useMemo(() => getSteps(), []);
4340
const currentIndex = steps.indexOf(step);
4441

4542
const goBack = useCallback(() => {
46-
// Recalculate steps in case source changed
47-
const currentSteps = getSteps(config.source);
43+
const currentSteps = getSteps();
4844
const idx = currentSteps.indexOf(step);
4945
const prevStep = currentSteps[idx - 1];
5046
if (prevStep) setStep(prevStep);
51-
}, [config.source, step]);
47+
}, [step]);
5248

5349
const setName = useCallback((name: string) => {
5450
setConfig(c => ({
@@ -58,19 +54,7 @@ export function useAddGatewayTargetWizard(existingGateways: string[] = []) {
5854
sourcePath: `${APP_DIR}/${MCP_APP_SUBDIR}/${name}`,
5955
toolDefinition: deriveToolDefinition(name),
6056
}));
61-
setStep('source');
62-
}, []);
63-
64-
const setSource = useCallback((source: 'existing-endpoint' | 'create-new') => {
65-
setConfig(c => ({
66-
...c,
67-
source,
68-
}));
69-
if (source === 'existing-endpoint') {
70-
setStep('endpoint');
71-
} else {
72-
setStep('language');
73-
}
57+
setStep('endpoint');
7458
}, []);
7559

7660
const setEndpoint = useCallback((endpoint: string) => {
@@ -81,14 +65,6 @@ export function useAddGatewayTargetWizard(existingGateways: string[] = []) {
8165
setStep('gateway');
8266
}, []);
8367

84-
const setLanguage = useCallback((language: TargetLanguage) => {
85-
setConfig(c => ({
86-
...c,
87-
language,
88-
}));
89-
setStep('gateway');
90-
}, []);
91-
9268
const setGateway = useCallback((gateway: string) => {
9369
setConfig(c => {
9470
const isSkipped = gateway === SKIP_FOR_NOW;
@@ -97,14 +73,6 @@ export function useAddGatewayTargetWizard(existingGateways: string[] = []) {
9773
});
9874
}, []);
9975

100-
const setHost = useCallback((host: ComputeHost) => {
101-
setConfig(c => ({
102-
...c,
103-
host,
104-
}));
105-
setStep('confirm');
106-
}, []);
107-
10876
const reset = useCallback(() => {
10977
setConfig(getDefaultConfig());
11078
setStep('name');
@@ -118,11 +86,8 @@ export function useAddGatewayTargetWizard(existingGateways: string[] = []) {
11886
existingGateways,
11987
goBack,
12088
setName,
121-
setSource,
12289
setEndpoint,
123-
setLanguage,
12490
setGateway,
125-
setHost,
12691
reset,
12792
};
12893
}

0 commit comments

Comments
 (0)