> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/QwenLM/qwen-code/llms.txt
> Use this file to discover all available pages before exploring further.

# Interactive Mode

> Using the interactive terminal UI for real-time AI coding assistance

## Overview

Qwen Code's interactive mode provides a rich terminal UI for conversing with AI in real-time. When you run `qwen` without arguments, you enter an interactive session where you can chat naturally, issue commands, and see AI actions unfold live.

## Starting Interactive Mode

```bash theme={null}
# Launch interactive UI
qwen

# Start with a prompt and continue interactively
qwen --prompt "Explain this codebase" --continue
```

## Key Features

### Real-Time Streaming

The interactive UI streams responses as they're generated, showing:

* AI thinking and reasoning
* Tool calls being executed
* File edits with syntax highlighting
* Command outputs with proper formatting

### Visual Feedback

<Tabs>
  <Tab title="Tool Execution">
    When AI executes tools, you see:

    * Tool name and arguments
    * Progress indicators for long-running operations
    * Success/failure status with colored indicators
    * Structured output formatting
  </Tab>

  <Tab title="File Operations">
    File edits display:

    * Unified diff view with syntax highlighting
    * Line numbers and context
    * Before/after preview
    * Approval prompts (in default mode)
  </Tab>

  <Tab title="Subagent Activity">
    When delegating to subagents:

    * Nested indentation showing delegation hierarchy
    * Subagent name and task description
    * Independent tool calls from subagents
    * Progress tracking for each agent
  </Tab>
</Tabs>

## Terminal Controls

### Keyboard Shortcuts

| Shortcut    | Action                           |
| ----------- | -------------------------------- |
| `Ctrl+C`    | Cancel current operation         |
| `Ctrl+D`    | Exit session                     |
| `Shift+Tab` | Cycle through approval modes     |
| `Esc`       | Cancel pending slash command     |
| `↑` / `↓`   | Navigate command history         |
| `Tab`       | Auto-complete commands and paths |

### Vim Mode

Enable Vim-style keybindings for input:

```bash theme={null}
/vim
```

In Vim mode:

* `Esc` enters normal mode
* `i`, `a`, `o` enter insert mode
* `h`, `j`, `k`, `l` for navigation
* `w`, `b`, `e` for word movement

## Session Management

### Starting Fresh

```bash theme={null}
# Clear conversation and start new session
/clear

# Alternative commands
/reset
/new
```

<Note>
  `/clear` resets the conversation history and frees up context, but preserves your configuration and settings.
</Note>

### Resuming Sessions

```bash theme={null}
# Open session picker
/resume
```

The resume dialog shows:

* List of recent sessions with timestamps
* Session descriptions (first user message)
* Fuzzy search to filter sessions
* Arrow keys to select, Enter to load

### Exiting Gracefully

```bash theme={null}
# Quit with summary
/quit

# Alternative
/exit
```

On exit, you'll see:

* Total session duration
* Number of turns
* Token usage statistics

## Advanced UI Features

### Debug Mode

Enable detailed logging:

```bash theme={null}
export DEBUG=qwen:*
qwen
```

Debug mode displays:

* API request/response details
* Tool execution traces
* Performance metrics
* Internal state changes

### Stats and Monitoring

```bash theme={null}
# View session statistics
/stats

# Model-specific stats
/stats model

# Tool usage breakdown
/stats tools
```

### Theme Customization

```bash theme={null}
# Open theme selector
/theme
```

Available themes:

* Light
* Dark
* High Contrast
* Solarized
* Custom themes via settings

## Rich Formatting

The interactive UI renders:

<Tabs>
  <Tab title="Markdown">
    * Headers and emphasis
    * Code blocks with syntax highlighting
    * Lists (ordered and unordered)
    * Tables
    * Blockquotes
    * Links (not clickable, but visible)
  </Tab>

  <Tab title="Code">
    * Language-specific syntax highlighting
    * Line numbers
    * Inline code with monospace font
    * Diff highlighting for edits
  </Tab>

  <Tab title="Data Structures">
    * JSON with pretty-printing
    * YAML formatting
    * Tree views for file structures
    * Table rendering for structured data
  </Tab>
</Tabs>

## Context Indicators

The footer displays:

* Current approval mode (plan/default/auto-edit/yolo)
* Token usage (current/limit)
* Active model name
* Session ID
* Working directory

<Info>
  Press `Shift+Tab` to cycle approval modes on-the-fly without opening the settings dialog.
</Info>

## Accessibility

### Screen Reader Support

Enable screen reader mode:

```json theme={null}
// settings.json
{
  "accessibility": {
    "screenReader": true,
    "enableLoadingPhrases": true
  }
}
```

Screen reader mode:

* Announces AI responses
* Reads tool execution status
* Provides audio feedback for state changes
* Simplifies visual output for clarity

### Keyboard Navigation

All features are keyboard-accessible:

* Tab through interactive elements
* Arrow keys for list navigation
* Enter to confirm, Esc to cancel
* No mouse required

## Performance Considerations

### Large Outputs

The UI handles large outputs efficiently:

* Virtual scrolling for long conversations
* Pagination for tool results
* Compression of old context
* Memory-efficient rendering

### Memory Management

```bash theme={null}
# Compress context to free memory
/compress

# Alternative
/summarize
```

Compression:

* Replaces old messages with summaries
* Preserves semantic meaning
* Reduces token usage
* Allows longer sessions

## Troubleshooting

<AccordionGroup>
  <Accordion title="UI is slow or unresponsive">
    Try:

    * Compress context with `/compress`
    * Start a new session with `/clear`
    * Reduce model token limits in settings
    * Disable debug mode if enabled
  </Accordion>

  <Accordion title="Text is garbled or misaligned">
    * Ensure terminal supports UTF-8
    * Resize terminal window
    * Try a different theme with `/theme`
    * Check for font issues
  </Accordion>

  <Accordion title="Colors not displaying correctly">
    * Verify terminal supports 256 colors
    * Try `export TERM=xterm-256color`
    * Use high contrast theme
    * Check terminal emulator settings
  </Accordion>

  <Accordion title="Keyboard shortcuts not working">
    * Check for terminal keybinding conflicts
    * Disable Vim mode if enabled
    * Try alternative shortcuts
    * Verify terminal emulator compatibility
  </Accordion>
</AccordionGroup>

## Best Practices

1. **Use `/clear` periodically** to free up context and maintain performance
2. **Enable Vim mode** if you prefer modal editing
3. **Customize your theme** for optimal readability
4. **Use `/stats` to monitor** token usage and stay within limits
5. **Leverage `/compress`** before hitting context limits
6. **Resume sessions** to continue previous work
7. **Use shortcuts** to speed up common operations

## Next Steps

<CardGroup cols={2}>
  <Card title="Session Commands" icon="terminal" href="/features/commands">
    Learn all available slash commands
  </Card>

  <Card title="Approval Modes" icon="shield" href="/features/approval-modes">
    Control how AI tools are approved
  </Card>

  <Card title="Headless Mode" icon="robot" href="/features/headless-mode">
    Run non-interactively for automation
  </Card>

  <Card title="Subagents" icon="users" href="/features/subagents">
    Delegate tasks to specialized agents
  </Card>
</CardGroup>
