mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-22 01:37:50 +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:
@@ -30,6 +30,16 @@ Slash commands provide meta-level control over the CLI itself.
|
||||
- **`delete`**
|
||||
- **Description:** Deletes a saved conversation checkpoint.
|
||||
- **Usage:** `/chat delete <tag>`
|
||||
- **`summary`**
|
||||
- **Description:** Generate a comprehensive project summary from the current conversation history and save it to `.qwen/PROJECT_SUMMARY.md`. This summary includes the overall goal, key knowledge, recent actions, and current plan, making it perfect for resuming work in future sessions.
|
||||
- **Usage:** `/chat summary`
|
||||
- **Features:**
|
||||
- Analyzes the entire conversation history to extract important context
|
||||
- Creates a structured markdown summary with sections for goals, knowledge, actions, and plans
|
||||
- Automatically saves to `.qwen/PROJECT_SUMMARY.md` in your project root
|
||||
- Shows progress indicators during generation and saving
|
||||
- Integrates with the Welcome Back feature for seamless session resumption
|
||||
- **Note:** This command requires an active conversation with at least 2 messages to generate a meaningful summary.
|
||||
|
||||
- **`/clear`**
|
||||
- **Description:** Clear the terminal screen, including the visible session history and scrollback within the CLI. The underlying session data (for history recall) might be preserved depending on the exact implementation, but the visual display is cleared.
|
||||
@@ -127,8 +137,18 @@ Slash commands provide meta-level control over the CLI itself.
|
||||
- **`/privacy`**
|
||||
- **Description:** Display the Privacy Notice and allow users to select whether they consent to the collection of their data for service improvement purposes.
|
||||
|
||||
- **`/quit-confirm`**
|
||||
- **Description:** Show a confirmation dialog before exiting Qwen Code, allowing you to choose how to handle your current session.
|
||||
- **Usage:** `/quit-confirm`
|
||||
- **Features:**
|
||||
- **Quit immediately:** Exit without saving anything (equivalent to `/quit`)
|
||||
- **Generate summary and quit:** Create a project summary using `/chat summary` before exiting
|
||||
- **Save conversation and quit:** Save the current conversation with an auto-generated tag before exiting
|
||||
- **Keyboard shortcut:** Press **Ctrl+C** twice to trigger the quit confirmation dialog
|
||||
- **Note:** This command is automatically triggered when you press Ctrl+C once, providing a safety mechanism to prevent accidental exits.
|
||||
|
||||
- **`/quit`** (or **`/exit`**)
|
||||
- **Description:** Exit Qwen Code.
|
||||
- **Description:** Exit Qwen Code immediately without any confirmation dialog.
|
||||
|
||||
- **`/vim`**
|
||||
- **Description:** Toggle vim mode on or off. When vim mode is enabled, the input area supports vim-style navigation and editing commands in both NORMAL and INSERT modes.
|
||||
|
||||
@@ -607,3 +607,11 @@ You can opt out of usage statistics collection at any time by setting the `usage
|
||||
```
|
||||
|
||||
Note: When usage statistics are enabled, events are sent to an Alibaba Cloud RUM collection endpoint.
|
||||
|
||||
- **`enableWelcomeBack`** (boolean):
|
||||
- **Description:** Show welcome back dialog when returning to a project with conversation history.
|
||||
- **Default:** `true`
|
||||
- **Category:** UI
|
||||
- **Requires Restart:** No
|
||||
- **Example:** `"enableWelcomeBack": false`
|
||||
- **Details:** When enabled, Qwen Code will automatically detect if you're returning to a project with a previously generated project summary (`.qwen/PROJECT_SUMMARY.md`) and show a dialog allowing you to continue your previous conversation or start fresh. This feature integrates with the `/chat summary` command and quit confirmation dialog. See the [Welcome Back documentation](./welcome-back.md) for more details.
|
||||
|
||||
@@ -10,6 +10,7 @@ Within Qwen Code, `packages/cli` is the frontend for users to send and receive p
|
||||
- **[Token Caching](./token-caching.md):** Optimize API costs through token caching.
|
||||
- **[Themes](./themes.md)**: A guide to customizing the CLI's appearance with different themes.
|
||||
- **[Tutorials](tutorials.md)**: A tutorial showing how to use Qwen Code to automate a development task.
|
||||
- **[Welcome Back](./welcome-back.md)**: Learn about the Welcome Back feature that helps you resume work seamlessly across sessions.
|
||||
|
||||
## Non-interactive mode
|
||||
|
||||
|
||||
197
docs/cli/welcome-back.md
Normal file
197
docs/cli/welcome-back.md
Normal file
@@ -0,0 +1,197 @@
|
||||
# Welcome Back Feature
|
||||
|
||||
The Welcome Back feature helps you seamlessly resume your work by automatically detecting when you return to a project with existing conversation history and offering to continue from where you left off.
|
||||
|
||||
## Overview
|
||||
|
||||
When you start Qwen Code in a project directory that contains a previously generated project summary (`.qwen/PROJECT_SUMMARY.md`), the Welcome Back dialog will automatically appear, giving you the option to either start fresh or continue your previous conversation.
|
||||
|
||||
## How It Works
|
||||
|
||||
### Automatic Detection
|
||||
|
||||
The Welcome Back feature automatically detects:
|
||||
|
||||
- **Project Summary File:** Looks for `.qwen/PROJECT_SUMMARY.md` in your current project directory
|
||||
- **Conversation History:** Checks if there's meaningful conversation history to resume
|
||||
- **Settings:** Respects your `enableWelcomeBack` setting (enabled by default)
|
||||
|
||||
### Welcome Back Dialog
|
||||
|
||||
When a project summary is found, you'll see a dialog with:
|
||||
|
||||
- **Last Updated Time:** Shows when the summary was last generated
|
||||
- **Overall Goal:** Displays the main objective from your previous session
|
||||
- **Current Plan:** Shows task progress with status indicators:
|
||||
- `[DONE]` - Completed tasks
|
||||
- `[IN PROGRESS]` - Currently working on
|
||||
- `[TODO]` - Planned tasks
|
||||
- **Task Statistics:** Summary of total tasks, completed, in progress, and pending
|
||||
|
||||
### Options
|
||||
|
||||
You have two choices when the Welcome Back dialog appears:
|
||||
|
||||
1. **Start new chat session**
|
||||
- Closes the dialog and begins a fresh conversation
|
||||
- No previous context is loaded
|
||||
|
||||
2. **Continue previous conversation**
|
||||
- Automatically fills the input with: `@.qwen/PROJECT_SUMMARY.md, Based on our previous conversation, Let's continue?`
|
||||
- Loads the project summary as context for the AI
|
||||
- Allows you to seamlessly pick up where you left off
|
||||
|
||||
## Configuration
|
||||
|
||||
### Enable/Disable Welcome Back
|
||||
|
||||
You can control the Welcome Back feature through settings:
|
||||
|
||||
**Via Settings Dialog:**
|
||||
|
||||
1. Run `/settings` in Qwen Code
|
||||
2. Find "Enable Welcome Back" in the UI category
|
||||
3. Toggle the setting on/off
|
||||
|
||||
**Via Settings File:**
|
||||
Add to your `.qwen/settings.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"enableWelcomeBack": true
|
||||
}
|
||||
```
|
||||
|
||||
**Settings Locations:**
|
||||
|
||||
- **User settings:** `~/.qwen/settings.json` (affects all projects)
|
||||
- **Project settings:** `.qwen/settings.json` (project-specific)
|
||||
|
||||
### Keyboard Shortcuts
|
||||
|
||||
- **Escape:** Close the Welcome Back dialog (defaults to "Start new chat session")
|
||||
|
||||
## Integration with Other Features
|
||||
|
||||
### Project Summary Generation
|
||||
|
||||
The Welcome Back feature works seamlessly with the `/chat summary` command:
|
||||
|
||||
1. **Generate Summary:** Use `/chat summary` to create a project summary
|
||||
2. **Automatic Detection:** Next time you start Qwen Code in this project, Welcome Back will detect the summary
|
||||
3. **Resume Work:** Choose to continue and the summary will be loaded as context
|
||||
|
||||
### Quit Confirmation
|
||||
|
||||
When exiting with `/quit-confirm` and choosing "Generate summary and quit":
|
||||
|
||||
1. A project summary is automatically created
|
||||
2. Next session will trigger the Welcome Back dialog
|
||||
3. You can seamlessly continue your work
|
||||
|
||||
## File Structure
|
||||
|
||||
The Welcome Back feature creates and uses:
|
||||
|
||||
```
|
||||
your-project/
|
||||
├── .qwen/
|
||||
│ └── PROJECT_SUMMARY.md # Generated project summary
|
||||
└── .qwen/
|
||||
└── settings.json # Optional project settings
|
||||
```
|
||||
|
||||
### PROJECT_SUMMARY.md Format
|
||||
|
||||
The generated summary follows this structure:
|
||||
|
||||
```markdown
|
||||
# Project Summary
|
||||
|
||||
## Overall Goal
|
||||
|
||||
<!-- Single, concise sentence describing the high-level objective -->
|
||||
|
||||
## Key Knowledge
|
||||
|
||||
<!-- Crucial facts, conventions, and constraints -->
|
||||
<!-- Includes: technology choices, architecture decisions, user preferences -->
|
||||
|
||||
## Recent Actions
|
||||
|
||||
<!-- Summary of significant recent work and outcomes -->
|
||||
<!-- Includes: accomplishments, discoveries, recent changes -->
|
||||
|
||||
## Current Plan
|
||||
|
||||
<!-- The current development roadmap and next steps -->
|
||||
<!-- Uses status markers: [DONE], [IN PROGRESS], [TODO] -->
|
||||
|
||||
---
|
||||
|
||||
## Summary Metadata
|
||||
|
||||
**Update time**: 2025-01-10T15:30:00.000Z
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
### When to Use Project Summaries
|
||||
|
||||
- **Long Development Sessions:** Generate summaries for complex, multi-day projects
|
||||
- **Team Collaboration:** Share project summaries with team members
|
||||
- **Context Switching:** Use when working on multiple projects
|
||||
- **Documentation:** Keep a record of important decisions and progress
|
||||
|
||||
### Summary Generation Tips
|
||||
|
||||
- **Regular Updates:** Run `/chat summary` periodically during long sessions
|
||||
- **Before Major Changes:** Generate summaries before significant refactoring
|
||||
- **End of Sessions:** Use "Generate summary and quit" when finishing work
|
||||
- **Milestone Completion:** Create summaries at project milestones
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Welcome Back Not Appearing
|
||||
|
||||
1. **Check Settings:** Ensure `enableWelcomeBack` is set to `true`
|
||||
2. **Verify Summary File:** Confirm `.qwen/PROJECT_SUMMARY.md` exists
|
||||
3. **File Permissions:** Ensure Qwen Code can read the summary file
|
||||
4. **Project Directory:** Make sure you're in the correct project directory
|
||||
|
||||
### Summary Not Loading
|
||||
|
||||
1. **File Format:** Verify the summary file is valid markdown
|
||||
2. **File Size:** Check if the file is too large or corrupted
|
||||
3. **Permissions:** Ensure read permissions on the summary file
|
||||
|
||||
### Disable Welcome Back
|
||||
|
||||
If you want to disable the feature:
|
||||
|
||||
```json
|
||||
{
|
||||
"enableWelcomeBack": false
|
||||
}
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Typical Workflow
|
||||
|
||||
1. **Start Working:** Begin a new project or feature
|
||||
2. **Generate Summary:** After significant progress, run `/chat summary`
|
||||
3. **End Session:** Use Ctrl+C and choose "Generate summary and quit"
|
||||
4. **Return Later:** Next time you start Qwen Code in this project
|
||||
5. **Welcome Back:** Dialog appears with your previous context
|
||||
6. **Continue:** Choose "Continue previous conversation" to resume
|
||||
|
||||
### Team Collaboration
|
||||
|
||||
1. **Developer A:** Works on feature, generates summary
|
||||
2. **Developer B:** Starts Qwen Code in same project
|
||||
3. **Welcome Back:** Sees Developer A's progress and context
|
||||
4. **Continue:** Can pick up where Developer A left off
|
||||
|
||||
This makes the Welcome Back feature particularly valuable for team environments where multiple developers might work on the same project.
|
||||
|
||||
@@ -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