diff --git a/docs/cli/commands.md b/docs/cli/commands.md index aa056a43..09ea3e8d 100644 --- a/docs/cli/commands.md +++ b/docs/cli/commands.md @@ -93,6 +93,16 @@ Slash commands provide meta-level control over the CLI itself. - **Usage:** `/restore [tool_call_id]` - **Note:** Only available if the CLI is invoked with the `--checkpointing` option or configured via [settings](./configuration.md). See [Checkpointing documentation](../checkpointing.md) for more details. +- **`/resume`** + - **Description:** Resume a previous conversation session. Opens a session picker dialog to browse and select from saved sessions. + - **Usage:** `/resume` + - **Features:** + - Browse all saved sessions for the current project + - Filter sessions by git branch with the **B** key + - Sessions show first prompt, message count, and timestamp + - Navigate with arrow keys or **j/k**, select with **Enter** + - **Note:** For command-line session resumption, see `--resume` and `--continue` flags. For more details, see [Session Resume](../features/session-resume.md). + - **`/settings`** - **Description:** Open the settings editor to view and modify Qwen Code settings. - **Details:** This command provides a user-friendly interface for changing settings that control the behavior and appearance of Qwen Code. It is equivalent to manually editing the `.qwen/settings.json` file, but with validation and guidance to prevent errors. diff --git a/docs/features/session-resume.md b/docs/features/session-resume.md new file mode 100644 index 00000000..00984f30 --- /dev/null +++ b/docs/features/session-resume.md @@ -0,0 +1,74 @@ +# Session Resume + +Qwen Code automatically saves your conversation history, allowing you to resume previous sessions at any time. + +## Overview + +Sessions are saved automatically as you work. You can resume them either from the command line when starting Qwen Code, or from within an active session using the `/resume` command. + +## How Sessions Are Stored + +Sessions are stored as JSONL files (one JSON record per line) at: + +``` +~/.qwen/tmp//chats/.jsonl +``` + +Each session captures: + +- User messages and assistant responses +- Tool calls and their results +- Metadata: timestamps, git branch, working directory, model used + +## Resuming Sessions + +### From the Command Line + +**Resume most recent session:** + +```bash +qwen --continue +``` + +**Show session picker:** + +```bash +qwen --resume +``` + +**Resume specific session by ID:** + +```bash +qwen --resume +``` + +### From Within the App + +Use the `/resume` slash command to open a session picker dialog: + +``` +/resume +``` + +### Session Picker Controls + +- **Arrow keys** or **j/k**: Navigate between sessions +- **Enter**: Select and resume the highlighted session +- **B**: Toggle branch filter (show only sessions from current git branch) +- **Escape**: Cancel and return to current session + +## Session List Display + +Each session shows: + +- First prompt text (truncated if long) +- Number of messages +- Last modified timestamp +- Git branch name (if available) + +Sessions are sorted by last modified time, with most recent first. + +## Related Features + +- [Welcome Back](./welcome-back.md) - Automatic session context restoration +- [/summary command](../cli/commands.md) - Generate project summaries for future reference diff --git a/packages/cli/src/gemini.tsx b/packages/cli/src/gemini.tsx index 18f191bc..ee327c2b 100644 --- a/packages/cli/src/gemini.tsx +++ b/packages/cli/src/gemini.tsx @@ -58,7 +58,7 @@ import { getUserStartupWarnings } from './utils/userStartupWarnings.js'; import { getCliVersion } from './utils/version.js'; import { computeWindowTitle } from './utils/windowTitle.js'; import { validateNonInteractiveAuth } from './validateNonInterActiveAuth.js'; -import { showResumeSessionPicker } from './ui/components/ResumeSessionPicker.js'; +import { showResumeSessionPicker } from './ui/components/StandaloneSessionPicker.js'; export function validateDnsResolutionOrder( order: string | undefined, diff --git a/packages/cli/src/ui/components/ResumeSessionPicker.test.tsx b/packages/cli/src/ui/components/StandaloneSessionPicker.test.tsx similarity index 99% rename from packages/cli/src/ui/components/ResumeSessionPicker.test.tsx rename to packages/cli/src/ui/components/StandaloneSessionPicker.test.tsx index bd63c3ef..c6841f2f 100644 --- a/packages/cli/src/ui/components/ResumeSessionPicker.test.tsx +++ b/packages/cli/src/ui/components/StandaloneSessionPicker.test.tsx @@ -6,7 +6,7 @@ import { render } from 'ink-testing-library'; import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; -import { SessionPicker } from './ResumeSessionPicker.js'; +import { SessionPicker } from './StandaloneSessionPicker.js'; import type { SessionListItem, ListSessionsResult, diff --git a/packages/cli/src/ui/components/ResumeSessionPicker.tsx b/packages/cli/src/ui/components/StandaloneSessionPicker.tsx similarity index 98% rename from packages/cli/src/ui/components/ResumeSessionPicker.tsx rename to packages/cli/src/ui/components/StandaloneSessionPicker.tsx index 3a10c883..b519710e 100644 --- a/packages/cli/src/ui/components/ResumeSessionPicker.tsx +++ b/packages/cli/src/ui/components/StandaloneSessionPicker.tsx @@ -8,7 +8,7 @@ import { useState, useEffect } from 'react'; import { render, Box, Text, useApp } from 'ink'; import { SessionService, getGitBranch } from '@qwen-code/qwen-code-core'; import { theme } from '../semantic-colors.js'; -import { useSessionPicker } from '../hooks/useSessionPicker.js'; +import { useSessionPicker } from '../hooks/useStandaloneSessionPicker.js'; import { SessionListItemView } from './SessionListItem.js'; // Exported for testing diff --git a/packages/cli/src/ui/hooks/useSessionPicker.ts b/packages/cli/src/ui/hooks/useStandaloneSessionPicker.ts similarity index 100% rename from packages/cli/src/ui/hooks/useSessionPicker.ts rename to packages/cli/src/ui/hooks/useStandaloneSessionPicker.ts