Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 27 additions & 11 deletions source/wizards/steps/provider-step.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ interface TemplateOption {
value: string;
}

const DONE_SHORTCUT_KEY = 'd';

/**
* Find the best matching template for an existing provider config.
* Match by id, name, or baseUrl — then fall back to custom.
Expand Down Expand Up @@ -155,13 +157,11 @@ export function ProviderStep({
{label: 'Add custom provider manually', value: 'custom'},
];

const getTemplateOptions = (): TemplateOption[] => [
...PROVIDER_TEMPLATES.map(template => ({
const getTemplateOptions = (): TemplateOption[] =>
PROVIDER_TEMPLATES.map(template => ({
label: template.name,
value: template.id,
})),
...(providers.length > 0 ? [{label: 'Done & Save', value: 'done'}] : []),
];
}));

const editOptions: TemplateOption[] = providers.map((provider, index) => ({
label: provider.name,
Expand Down Expand Up @@ -190,11 +190,6 @@ export function ProviderStep({
};

const handleTemplateSelect = (item: TemplateOption) => {
if (item.value === 'done') {
onComplete(providers);
return;
}

// Adding new provider
const template = PROVIDER_TEMPLATES.find(t => t.id === item.value);
if (template) {
Expand Down Expand Up @@ -509,7 +504,21 @@ export function ProviderStep({
setMode('field-input');
};

useInput((_input, key) => {
useInput((input, key) => {
// "Done & Save" shortcut
if (
mode === 'template-selection' &&
providers.length > 0 &&
typeof input === 'string' &&
input.length > 0 &&
input.toLowerCase() === DONE_SHORTCUT_KEY &&
!key.ctrl &&
!key.meta
) {
onComplete(providers);
return;
}
Comment thread
Sukumarsawant marked this conversation as resolved.
Comment thread
Sukumarsawant marked this conversation as resolved.
Comment on lines +507 to +520

// Handle Shift+Tab for going back
if (key.shift && key.tab) {
if (mode === 'field-input') {
Expand Down Expand Up @@ -611,6 +620,13 @@ export function ProviderStep({
items={getTemplateOptions()}
onSelect={(item: TemplateOption) => handleTemplateSelect(item)}
/>
{providers.length > 0 && (
<Box marginTop={1}>
<Text color={colors.success}>
Done is always available: press {DONE_SHORTCUT_KEY}
</Text>
Comment on lines +623 to +627
</Box>
)}
Comment thread
Sukumarsawant marked this conversation as resolved.
</Box>
);
}
Expand Down