mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 17:27:54 +00:00
fix: improve quit confirmation UX with cancel option
- Add CANCEL option to QuitChoice enum - Move cancel option to bottom of dialog (UI best practice) - Fix escape key behavior to cancel instead of quit - Update quit confirmation logic to handle cancellation - Enable true two-step confirmation for Ctrl+C/Ctrl+D
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
import { useKeypress } from '../hooks/useKeypress.js';
|
||||
|
||||
export enum QuitChoice {
|
||||
CANCEL = 'cancel',
|
||||
QUIT = 'quit',
|
||||
SAVE_AND_QUIT = 'save_and_quit',
|
||||
SUMMARY_AND_QUIT = 'summary_and_quit',
|
||||
@@ -29,7 +30,7 @@ export const QuitConfirmationDialog: React.FC<QuitConfirmationDialogProps> = ({
|
||||
useKeypress(
|
||||
(key) => {
|
||||
if (key.name === 'escape') {
|
||||
onSelect(QuitChoice.QUIT);
|
||||
onSelect(QuitChoice.CANCEL);
|
||||
}
|
||||
},
|
||||
{ isActive: true },
|
||||
@@ -48,6 +49,10 @@ export const QuitConfirmationDialog: React.FC<QuitConfirmationDialogProps> = ({
|
||||
label: 'Save conversation and quit (/chat save)',
|
||||
value: QuitChoice.SAVE_AND_QUIT,
|
||||
},
|
||||
{
|
||||
label: 'Cancel (stay in application)',
|
||||
value: QuitChoice.CANCEL,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
|
||||
@@ -419,6 +419,10 @@ export const useSlashCommandProcessor = (
|
||||
setQuitConfirmationRequest({
|
||||
onConfirm: (shouldQuit: boolean, action?: string) => {
|
||||
setQuitConfirmationRequest(null);
|
||||
if (!shouldQuit) {
|
||||
// User cancelled the quit operation - do nothing
|
||||
return;
|
||||
}
|
||||
if (shouldQuit) {
|
||||
if (action === 'save_and_quit') {
|
||||
// First save conversation with auto-generated tag, then quit
|
||||
|
||||
@@ -17,7 +17,9 @@ export const useQuitConfirmation = () => {
|
||||
const handleQuitConfirmationSelect = useCallback((choice: QuitChoice) => {
|
||||
setIsQuitConfirmationOpen(false);
|
||||
|
||||
if (choice === QuitChoice.QUIT) {
|
||||
if (choice === QuitChoice.CANCEL) {
|
||||
return { shouldQuit: false, action: 'cancel' };
|
||||
} else if (choice === QuitChoice.QUIT) {
|
||||
return { shouldQuit: true, action: 'quit' };
|
||||
} else if (choice === QuitChoice.SAVE_AND_QUIT) {
|
||||
return { shouldQuit: true, action: 'save_and_quit' };
|
||||
@@ -25,8 +27,8 @@ export const useQuitConfirmation = () => {
|
||||
return { shouldQuit: true, action: 'summary_and_quit' };
|
||||
}
|
||||
|
||||
// Default to quit if unknown choice
|
||||
return { shouldQuit: true, action: 'quit' };
|
||||
// Default to cancel if unknown choice
|
||||
return { shouldQuit: false, action: 'cancel' };
|
||||
}, []);
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user