Skip to content

Commit b61d565

Browse files
authored
fix: BYO agent wizard back navigation (#84)
- Add exitEnabled prop to Screen component - Disable Screen's exit handler when in BYO sub-steps - Esc now goes back one step instead of exiting entirely
1 parent a231709 commit b61d565

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/cli/tui/components/Screen.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ interface ScreenProps {
1414
/** Optional content to display above the help text at the bottom */
1515
footerContent?: ReactNode;
1616
children: ReactNode;
17+
/** Whether Escape key triggers onExit (default: true). Set to false when sub-components handle their own back navigation. */
18+
exitEnabled?: boolean;
1719
}
1820

1921
/**
@@ -23,8 +25,17 @@ interface ScreenProps {
2325
* - Exit handling (Escape / Ctrl+Q)
2426
* - Help text at the bottom
2527
*/
26-
export function Screen({ title, color, onExit, helpText, headerContent, footerContent, children }: ScreenProps) {
27-
useExitHandler(onExit);
28+
export function Screen({
29+
title,
30+
color,
31+
onExit,
32+
helpText,
33+
headerContent,
34+
footerContent,
35+
children,
36+
exitEnabled = true,
37+
}: ScreenProps) {
38+
useExitHandler(onExit, exitEnabled);
2839

2940
const displayHelpText = helpText ?? HELP_TEXT.EXIT;
3041

src/cli/tui/screens/agent/AddAgentScreen.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,16 @@ export function AddAgentScreen({ existingAgentNames, onComplete, onExit }: AddAg
356356
}
357357

358358
// BYO path
359+
// Disable Screen's exit handler when not on first step (sub-components handle back navigation)
360+
const byoExitEnabled = byoCurrentIndex === 0;
359361
return (
360-
<Screen title="Add Agent" onExit={onExit} helpText={getHelpText()} headerContent={renderStepIndicator()}>
362+
<Screen
363+
title="Add Agent"
364+
onExit={onExit}
365+
helpText={getHelpText()}
366+
headerContent={renderStepIndicator()}
367+
exitEnabled={byoExitEnabled}
368+
>
361369
<Panel>
362370
{byoStep === 'codeLocation' && (
363371
<CodeLocationInput

0 commit comments

Comments
 (0)