mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
fix: unable to quit when auth dialog is opened (#804)
This commit is contained in:
@@ -913,7 +913,21 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. Close other dialogs (highest priority)
|
/**
|
||||||
|
* For AuthDialog it is required to complete the authentication process,
|
||||||
|
* otherwise user cannot proceed to the next step.
|
||||||
|
* So a quit on AuthDialog should go with normal two press quit
|
||||||
|
* and without quit-confirm dialog.
|
||||||
|
*/
|
||||||
|
if (isAuthDialogOpen) {
|
||||||
|
setPressedOnce(true);
|
||||||
|
timerRef.current = setTimeout(() => {
|
||||||
|
setPressedOnce(false);
|
||||||
|
}, 500);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//1. Close other dialogs (highest priority)
|
||||||
if (closeAnyOpenDialog()) {
|
if (closeAnyOpenDialog()) {
|
||||||
return; // Dialog closed, end processing
|
return; // Dialog closed, end processing
|
||||||
}
|
}
|
||||||
@@ -934,6 +948,7 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => {
|
|||||||
handleSlashCommand('/quit-confirm');
|
handleSlashCommand('/quit-confirm');
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
|
isAuthDialogOpen,
|
||||||
handleSlashCommand,
|
handleSlashCommand,
|
||||||
quitConfirmationRequest,
|
quitConfirmationRequest,
|
||||||
closeAnyOpenDialog,
|
closeAnyOpenDialog,
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ describe('QwenOAuthProgress', () => {
|
|||||||
const output = lastFrame();
|
const output = lastFrame();
|
||||||
expect(output).toContain('MockSpinner(dots)');
|
expect(output).toContain('MockSpinner(dots)');
|
||||||
expect(output).toContain('Waiting for Qwen OAuth authentication...');
|
expect(output).toContain('Waiting for Qwen OAuth authentication...');
|
||||||
expect(output).toContain('(Press ESC to cancel)');
|
expect(output).toContain('(Press ESC or CTRL+C to cancel)');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render loading state with gray border', () => {
|
it('should render loading state with gray border', () => {
|
||||||
@@ -105,7 +105,7 @@ describe('QwenOAuthProgress', () => {
|
|||||||
expect(output).toContain('MockSpinner(dots)');
|
expect(output).toContain('MockSpinner(dots)');
|
||||||
expect(output).toContain('Waiting for authorization');
|
expect(output).toContain('Waiting for authorization');
|
||||||
expect(output).toContain('Time remaining: 5:00');
|
expect(output).toContain('Time remaining: 5:00');
|
||||||
expect(output).toContain('(Press ESC to cancel)');
|
expect(output).toContain('(Press ESC or CTRL+C to cancel)');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display correct URL in Static component when QR code is generated', async () => {
|
it('should display correct URL in Static component when QR code is generated', async () => {
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ function StatusDisplay({
|
|||||||
<Text color={Colors.Gray}>
|
<Text color={Colors.Gray}>
|
||||||
Time remaining: {formatTime(timeRemaining)}
|
Time remaining: {formatTime(timeRemaining)}
|
||||||
</Text>
|
</Text>
|
||||||
<Text color={Colors.AccentPurple}>(Press ESC to cancel)</Text>
|
<Text color={Colors.AccentPurple}>(Press ESC or CTRL+C to cancel)</Text>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
@@ -132,7 +132,7 @@ export function QwenOAuthProgress({
|
|||||||
if (authStatus === 'timeout') {
|
if (authStatus === 'timeout') {
|
||||||
// Any key press in timeout state should trigger cancel to return to auth dialog
|
// Any key press in timeout state should trigger cancel to return to auth dialog
|
||||||
onCancel();
|
onCancel();
|
||||||
} else if (key.escape) {
|
} else if (key.escape || (key.ctrl && input === 'c')) {
|
||||||
onCancel();
|
onCancel();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -250,7 +250,9 @@ export function QwenOAuthProgress({
|
|||||||
Time remaining: {Math.floor(timeRemaining / 60)}:
|
Time remaining: {Math.floor(timeRemaining / 60)}:
|
||||||
{(timeRemaining % 60).toString().padStart(2, '0')}
|
{(timeRemaining % 60).toString().padStart(2, '0')}
|
||||||
</Text>
|
</Text>
|
||||||
<Text color={Colors.AccentPurple}>(Press ESC to cancel)</Text>
|
<Text color={Colors.AccentPurple}>
|
||||||
|
(Press ESC or CTRL+C to cancel)
|
||||||
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -61,16 +61,6 @@ export function useDialogClose(options: DialogCloseOptions) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.isAuthDialogOpen) {
|
|
||||||
// Mimic ESC behavior: only close if already authenticated (same as AuthDialog ESC logic)
|
|
||||||
if (options.selectedAuthType !== undefined) {
|
|
||||||
// Note: We don't await this since we want non-blocking behavior like ESC
|
|
||||||
void options.handleAuthSelect(undefined, SettingScope.User);
|
|
||||||
}
|
|
||||||
// Note: AuthDialog prevents ESC exit if not authenticated, we follow same logic
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.isEditorDialogOpen) {
|
if (options.isEditorDialogOpen) {
|
||||||
// Mimic ESC behavior: call onExit() directly
|
// Mimic ESC behavior: call onExit() directly
|
||||||
options.exitEditorDialog();
|
options.exitEditorDialog();
|
||||||
|
|||||||
Reference in New Issue
Block a user