Skip to content

Commit a779d44

Browse files
authored
fix: unable to quit when auth dialog is opened (QwenLM#804)
1 parent 4081094 commit a779d44

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

packages/cli/src/ui/App.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,21 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => {
913913
return;
914914
}
915915

916-
// 1. Close other dialogs (highest priority)
916+
/**
917+
* For AuthDialog it is required to complete the authentication process,
918+
* otherwise user cannot proceed to the next step.
919+
* So a quit on AuthDialog should go with normal two press quit
920+
* and without quit-confirm dialog.
921+
*/
922+
if (isAuthDialogOpen) {
923+
setPressedOnce(true);
924+
timerRef.current = setTimeout(() => {
925+
setPressedOnce(false);
926+
}, 500);
927+
return;
928+
}
929+
930+
//1. Close other dialogs (highest priority)
917931
if (closeAnyOpenDialog()) {
918932
return; // Dialog closed, end processing
919933
}
@@ -934,6 +948,7 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => {
934948
handleSlashCommand('/quit-confirm');
935949
},
936950
[
951+
isAuthDialogOpen,
937952
handleSlashCommand,
938953
quitConfirmationRequest,
939954
closeAnyOpenDialog,

packages/cli/src/ui/components/QwenOAuthProgress.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ describe('QwenOAuthProgress', () => {
8181
const output = lastFrame();
8282
expect(output).toContain('MockSpinner(dots)');
8383
expect(output).toContain('Waiting for Qwen OAuth authentication...');
84-
expect(output).toContain('(Press ESC to cancel)');
84+
expect(output).toContain('(Press ESC or CTRL+C to cancel)');
8585
});
8686

8787
it('should render loading state with gray border', () => {
@@ -105,7 +105,7 @@ describe('QwenOAuthProgress', () => {
105105
expect(output).toContain('MockSpinner(dots)');
106106
expect(output).toContain('Waiting for authorization');
107107
expect(output).toContain('Time remaining: 5:00');
108-
expect(output).toContain('(Press ESC to cancel)');
108+
expect(output).toContain('(Press ESC or CTRL+C to cancel)');
109109
});
110110

111111
it('should display correct URL in Static component when QR code is generated', async () => {

packages/cli/src/ui/components/QwenOAuthProgress.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function StatusDisplay({
110110
<Text color={Colors.Gray}>
111111
Time remaining: {formatTime(timeRemaining)}
112112
</Text>
113-
<Text color={Colors.AccentPurple}>(Press ESC to cancel)</Text>
113+
<Text color={Colors.AccentPurple}>(Press ESC or CTRL+C to cancel)</Text>
114114
</Box>
115115
</Box>
116116
);
@@ -132,7 +132,7 @@ export function QwenOAuthProgress({
132132
if (authStatus === 'timeout') {
133133
// Any key press in timeout state should trigger cancel to return to auth dialog
134134
onCancel();
135-
} else if (key.escape) {
135+
} else if (key.escape || (key.ctrl && input === 'c')) {
136136
onCancel();
137137
}
138138
});
@@ -250,7 +250,9 @@ export function QwenOAuthProgress({
250250
Time remaining: {Math.floor(timeRemaining / 60)}:
251251
{(timeRemaining % 60).toString().padStart(2, '0')}
252252
</Text>
253-
<Text color={Colors.AccentPurple}>(Press ESC to cancel)</Text>
253+
<Text color={Colors.AccentPurple}>
254+
(Press ESC or CTRL+C to cancel)
255+
</Text>
254256
</Box>
255257
</Box>
256258
);

packages/cli/src/ui/hooks/useDialogClose.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,6 @@ export function useDialogClose(options: DialogCloseOptions) {
6161
return true;
6262
}
6363

64-
if (options.isAuthDialogOpen) {
65-
// Mimic ESC behavior: only close if already authenticated (same as AuthDialog ESC logic)
66-
if (options.selectedAuthType !== undefined) {
67-
// Note: We don't await this since we want non-blocking behavior like ESC
68-
void options.handleAuthSelect(undefined, SettingScope.User);
69-
}
70-
// Note: AuthDialog prevents ESC exit if not authenticated, we follow same logic
71-
return true;
72-
}
73-
7464
if (options.isEditorDialogOpen) {
7565
// Mimic ESC behavior: call onExit() directly
7666
options.exitEditorDialog();

0 commit comments

Comments
 (0)