@qwen-code/qwen-code 0.15.7-preview.2 → 0.15.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -353,6 +353,9 @@ Use the `/model` command at any time to switch between all configured models.
353
353
 
354
354
  You can also run models locally — no API key or cloud account needed. This is not an authentication method; instead, configure your local model endpoint in `~/.qwen/settings.json` using the `modelProviders` field.
355
355
 
356
+ Set `generationConfig.contextWindowSize` inside the matching provider entry
357
+ and adjust it to the context length configured on your local server.
358
+
356
359
  <details>
357
360
  <summary>Ollama setup</summary>
358
361
 
@@ -368,7 +371,10 @@ You can also run models locally — no API key or cloud account needed. This is
368
371
  "id": "qwen3:32b",
369
372
  "name": "Qwen3 32B (Ollama)",
370
373
  "baseUrl": "http://localhost:11434/v1",
371
- "description": "Qwen3 32B running locally via Ollama"
374
+ "description": "Qwen3 32B running locally via Ollama",
375
+ "generationConfig": {
376
+ "contextWindowSize": 131072
377
+ }
372
378
  }
373
379
  ]
374
380
  },
@@ -400,7 +406,10 @@ You can also run models locally — no API key or cloud account needed. This is
400
406
  "id": "Qwen/Qwen3-32B",
401
407
  "name": "Qwen3 32B (vLLM)",
402
408
  "baseUrl": "http://localhost:8000/v1",
403
- "description": "Qwen3 32B running locally via vLLM"
409
+ "description": "Qwen3 32B running locally via vLLM",
410
+ "generationConfig": {
411
+ "contextWindowSize": 131072
412
+ }
404
413
  }
405
414
  ]
406
415
  },
@@ -417,6 +417,13 @@ The configuration resolution follows a strict layering model with one crucial ru
417
417
  - All fields **not defined** by the provider are set to `undefined` (not inherited from settings)
418
418
  - This ensures provider configurations act as a complete, self-contained "sealed package"
419
419
 
420
+ If a model is listed in `modelProviders`, put all model-specific
421
+ generation settings for that model in the matching provider entry. Top-level
422
+ `model.generationConfig` values, including `contextWindowSize`,
423
+ `modalities`, `customHeaders`, and `extra_body`, are ignored for provider
424
+ models. Configure those fields under
425
+ `modelProviders[authType][].generationConfig` for them to apply.
426
+
420
427
  2. **When NO modelProvider model is selected** (e.g., using `--model` with a raw model ID, or using CLI/env/settings directly):
421
428
  - The resolution falls through to lower layers
422
429
  - Fields are populated from CLI → env → settings → defaults
@@ -116,6 +116,7 @@ Settings are organized into categories. Most settings should be placed within th
116
116
  | `ui.hideFooter` | boolean | Hide the footer from the UI. | `false` |
117
117
  | `ui.showMemoryUsage` | boolean | Display memory usage information in the UI. | `false` |
118
118
  | `ui.showLineNumbers` | boolean | Show line numbers in code blocks in the CLI output. | `true` |
119
+ | `ui.renderMode` | string | Default Markdown display mode. Use `"render"` for rich visual previews or `"raw"` to show source-oriented Markdown by default. Toggle during a session with `Alt/Option+M`; on macOS the terminal must send Option as Meta. See [Markdown Rendering](../features/markdown-rendering). | `"render"` |
119
120
  | `ui.showCitations` | boolean | Show citations for generated text in the chat. | `true` |
120
121
  | `ui.compactMode` | boolean | Hide tool output and thinking for a cleaner view. Toggle with `Ctrl+O` during a session or via the Settings dialog. Tool approval prompts are never hidden, even in compact mode. The setting persists across sessions. | `false` |
121
122
  | `ui.shellOutputMaxLines` | number | Max number of shell output lines shown inline. Set to `0` to disable the cap and show full output. Hidden lines are surfaced via the `+N lines` indicator. Errors, `!`-prefix user-initiated commands, confirming tools, and focused embedded shells always show full output. | `5` |
@@ -199,15 +200,20 @@ To override this behavior, either set `samplingParams.max_tokens` in your settin
199
200
 
200
201
  Overrides the default context window size for the selected model. Qwen Code determines the context window using built-in defaults based on model name matching, with a constant fallback value. Use this setting when a provider's effective context limit differs from Qwen Code's default. This value defines the model's assumed maximum context capacity, not a per-request token limit.
201
202
 
203
+ When the selected model is defined in `modelProviders`, set
204
+ `contextWindowSize` in that provider entry's `generationConfig` instead of the
205
+ top-level `model.generationConfig`. Provider model entries are sealed, so
206
+ top-level generation settings do not fill missing provider fields.
207
+
202
208
  **modalities:**
203
209
 
204
210
  Overrides the auto-detected input modalities for the selected model. Qwen Code automatically detects supported modalities (image, PDF, audio, video) based on model name pattern matching. Use this setting when the auto-detection is incorrect — for example, to enable `pdf` for a model that supports it but isn't recognized. Format: `{ "image": true, "pdf": true, "audio": true, "video": true }`. Omit a key or set it to `false` for unsupported types.
205
211
 
206
212
  **customHeaders:**
207
213
 
208
- Allows you to add custom HTTP headers to all API requests. This is useful for request tracing, monitoring, API gateway routing, or when different models require different headers. If `customHeaders` is defined in `modelProviders[].generationConfig.customHeaders`, it will be used directly; otherwise, headers from `model.generationConfig.customHeaders` will be used. No merging occurs between the two levels.
214
+ Allows you to add custom HTTP headers to all API requests. This is useful for request tracing, monitoring, API gateway routing, or when different models require different headers. For provider models, define `customHeaders` in `modelProviders[].generationConfig.customHeaders`. For runtime models without a matching provider entry, define it in `model.generationConfig.customHeaders`. No merging occurs between the two levels.
209
215
 
210
- The `extra_body` field allows you to add custom parameters to the request body sent to the API. This is useful for provider-specific options that are not covered by the standard configuration fields. **Note: This field is only supported for OpenAI-compatible providers (`openai`, `qwen-oauth`). It is ignored for Anthropic and Gemini providers.** If `extra_body` is defined in `modelProviders[].generationConfig.extra_body`, it will be used directly; otherwise, values from `model.generationConfig.extra_body` will be used.
216
+ The `extra_body` field allows you to add custom parameters to the request body sent to the API. This is useful for provider-specific options that are not covered by the standard configuration fields. **Note: This field is only supported for OpenAI-compatible providers (`openai`, `qwen-oauth`). It is ignored for Anthropic and Gemini providers.** For provider models, define `extra_body` in `modelProviders[].generationConfig.extra_body`. For runtime models without a matching provider entry, define it in `model.generationConfig.extra_body`.
211
217
 
212
218
  **model.openAILoggingDir examples:**
213
219
 
@@ -3,6 +3,7 @@ export default {
3
3
  'code-review': 'Code Review',
4
4
  'followup-suggestions': 'Followup Suggestions',
5
5
  'tool-use-summaries': 'Tool-Use Summaries',
6
+ 'markdown-rendering': 'Markdown Rendering',
6
7
  'sub-agents': 'SubAgents',
7
8
  arena: 'Agent Arena',
8
9
  skills: 'Skills',
@@ -0,0 +1,163 @@
1
+ # Markdown Rendering
2
+
3
+ Qwen Code renders common Markdown structures directly in the TUI so model
4
+ answers are easier to scan without leaving the terminal. The renderer is
5
+ designed to keep the original source reachable, especially for visual blocks
6
+ such as Mermaid diagrams and LaTeX math.
7
+
8
+ ## Render and Raw Modes
9
+
10
+ By default, Markdown is shown in `render` mode. Supported blocks render as
11
+ visual previews where possible:
12
+
13
+ - Mermaid fenced code blocks
14
+ - Markdown tables
15
+ - task lists
16
+ - blockquotes
17
+ - inline and block LaTeX math
18
+ - fenced code blocks with syntax highlighting
19
+
20
+ Press `Alt/Option+M` to toggle the current session between modes. On macOS,
21
+ the terminal must send Option as Meta for this shortcut; otherwise Option+M is
22
+ treated as normal text input.
23
+
24
+ - `render`: show rich terminal previews for supported Markdown.
25
+ - `raw`: show source-oriented Markdown for visual blocks such as Mermaid,
26
+ tables, and LaTeX.
27
+
28
+ To start Qwen Code in raw mode by default, set `ui.renderMode`:
29
+
30
+ ```json
31
+ {
32
+ "ui": {
33
+ "renderMode": "raw"
34
+ }
35
+ }
36
+ ```
37
+
38
+ Accepted values are `"render"` and `"raw"`. The shortcut only changes the
39
+ current session view; it does not rewrite your settings file.
40
+
41
+ ## Mermaid
42
+
43
+ Fenced `mermaid` code blocks render visually in `render` mode. The TUI uses a
44
+ layered strategy:
45
+
46
+ 1. If enabled and supported, Qwen Code asks Mermaid CLI (`mmdc`) to render the
47
+ diagram to a PNG and sends it to the terminal image protocol.
48
+ 2. If terminal images are unavailable but `chafa` is installed, the same PNG can
49
+ be converted to ANSI block graphics.
50
+ 3. Otherwise, Qwen Code falls back to a terminal wireframe or compact text
51
+ preview.
52
+ 4. If a Mermaid diagram type cannot be previewed, Qwen Code shows the original
53
+ fenced source instead of hiding it behind a placeholder.
54
+
55
+ Mermaid image rendering is disabled by default because it requires external
56
+ renderers and terminal image support. Enable it with:
57
+
58
+ ```bash
59
+ QWEN_CODE_MERMAID_IMAGE_RENDERING=1 qwen
60
+ ```
61
+
62
+ Optional environment variables:
63
+
64
+ | Variable | Description |
65
+ | ------------------------------------------- | ----------------------------------------------------------------------------------- |
66
+ | `QWEN_CODE_MERMAID_IMAGE_RENDERING=1` | Enables external Mermaid image rendering. |
67
+ | `QWEN_CODE_DISABLE_MERMAID_IMAGES=1` | Disables Mermaid image rendering even when enabled elsewhere. |
68
+ | `QWEN_CODE_MERMAID_IMAGE_PROTOCOL=kitty` | Forces Kitty protocol output. Useful for terminals such as Kitty and Ghostty. |
69
+ | `QWEN_CODE_MERMAID_IMAGE_PROTOCOL=iterm2` | Requests iTerm2 inline images. Interactive TUI rendering falls back to text/ANSI. |
70
+ | `QWEN_CODE_MERMAID_IMAGE_PROTOCOL=off` | Disables terminal image protocols and allows text or `chafa` fallback. |
71
+ | `QWEN_CODE_MERMAID_MMD_CLI=/path/to/mmdc` | Uses a specific Mermaid CLI executable. |
72
+ | `QWEN_CODE_MERMAID_ALLOW_NPX=1` | Allows Qwen Code to run `npx @mermaid-js/mermaid-cli` when `mmdc` is not installed. |
73
+ | `QWEN_CODE_MERMAID_ALLOW_LOCAL_RENDERERS=1` | Allows project-local renderer binaries under `node_modules/.bin`. |
74
+ | `QWEN_CODE_MERMAID_RENDER_WIDTH=1200` | Overrides the PNG render width. |
75
+ | `QWEN_CODE_MERMAID_RENDER_TIMEOUT_MS=10000` | Overrides the external render timeout, capped at 60000 ms. |
76
+ | `QWEN_CODE_MERMAID_CELL_ASPECT_RATIO=0.5` | Adjusts image row fitting for terminal font cell geometry. |
77
+
78
+ The first image render can be slow, especially when `npx` needs to resolve or
79
+ download Mermaid CLI. During streaming, Qwen Code shows a bounded text preview
80
+ and attempts image rendering only after the model response is complete.
81
+
82
+ ### Mermaid Source Copy
83
+
84
+ Every rendered Mermaid block includes a source hint such as:
85
+
86
+ ```text
87
+ Mermaid flowchart (TD) · source: /copy mermaid 1
88
+ ```
89
+
90
+ Use these commands to copy Mermaid source from the last AI response:
91
+
92
+ | Command | Behavior |
93
+ | ---------------------- | --------------------------------------------- |
94
+ | `/copy mermaid` | Copies the last Mermaid block. |
95
+ | `/copy mermaid 1` | Copies the first Mermaid block. |
96
+ | `/copy code mermaid` | Copies the last fenced `mermaid` code block. |
97
+ | `/copy code mermaid 1` | Copies the first fenced `mermaid` code block. |
98
+
99
+ `/copy code 1` counts all fenced code blocks, not only Mermaid blocks. Use
100
+ `/copy mermaid N` when you want the Mermaid-specific sequence shown in the
101
+ rendered title.
102
+
103
+ ## LaTeX Math
104
+
105
+ Qwen Code supports basic inline and block LaTeX rendering in the terminal:
106
+
107
+ ```markdown
108
+ Inline math: $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$
109
+
110
+ $$
111
+ \sum_{n=1}^{\infty} 1/n^2 = \pi^2/6
112
+ $$
113
+ ```
114
+
115
+ The renderer focuses on common symbols and readable terminal output. It is not
116
+ a full TeX engine; complex layouts such as matrices, aligned equations, and
117
+ large nested expressions may be simplified.
118
+
119
+ Inline `$...$` expressions are intentionally bounded to 1024 characters per
120
+ line so malformed or very large generated Markdown cannot stall terminal
121
+ rendering. Longer formulas remain visible as source text and can still be
122
+ copied from raw mode or the original response.
123
+
124
+ ### LaTeX Source Copy
125
+
126
+ Use these commands to copy LaTeX source from the last AI response:
127
+
128
+ | Command | Behavior |
129
+ | ---------------------- | --------------------------------------- |
130
+ | `/copy latex` | Copies the last block LaTeX expression. |
131
+ | `/copy latex 2` | Copies the second block expression. |
132
+ | `/copy latex inline` | Copies the last inline expression. |
133
+ | `/copy latex inline 2` | Copies the second inline expression. |
134
+ | `/copy inline-latex 2` | Alias for `/copy latex inline 2`. |
135
+
136
+ Inline LaTeX does not show a per-expression copy hint in rendered text to avoid
137
+ making prose noisy. Switch to raw mode with `Alt/Option+M` when you want to
138
+ inspect inline source in place; on macOS this requires Option-as-Meta terminal
139
+ input.
140
+
141
+ ## General Code Copy
142
+
143
+ The `/copy code` command reads fenced code blocks from the last AI Markdown
144
+ response:
145
+
146
+ | Command | Behavior |
147
+ | ----------------------- | ---------------------------------------- |
148
+ | `/copy code` | Copies the last fenced code block. |
149
+ | `/copy code 2` | Copies the second fenced code block. |
150
+ | `/copy code typescript` | Copies the last `typescript` code block. |
151
+ | `/copy code mermaid 1` | Copies the first `mermaid` code block. |
152
+
153
+ ## Current Limits
154
+
155
+ - Mermaid image rendering depends on Mermaid CLI plus terminal image support.
156
+ - Async iTerm2 inline image placement is disabled in the TUI because the
157
+ protocol is cursor-position bound; use Kitty/Ghostty or ANSI fallback for
158
+ interactive image previews.
159
+ - Wireframe Mermaid rendering is a readable terminal preview, not a full
160
+ Mermaid layout engine.
161
+ - Raw mode is global for rendered Markdown blocks; it is not a per-block toggle.
162
+ - LaTeX rendering covers common symbols and expressions, not full TeX layout.
163
+ - Source copy commands operate on the last AI response.
@@ -4,16 +4,17 @@ This document lists the available keyboard shortcuts in Qwen Code.
4
4
 
5
5
  ## General
6
6
 
7
- | Shortcut | Description |
8
- | ------------------------------ | --------------------------------------------------------------------------------------------------------------------- |
9
- | `Esc` | Close dialogs and suggestions. |
10
- | `Ctrl+C` | Cancel the ongoing request and clear the input. Press twice to exit the application. |
11
- | `Ctrl+D` | Exit the application if the input is empty. Press twice to confirm. |
12
- | `Ctrl+L` | Clear the screen. |
13
- | `Ctrl+O` | Toggle compact mode (hide/show tool output and thinking). |
14
- | `Ctrl+S` | Allows long responses to print fully, disabling truncation. Use your terminal's scrollback to view the entire output. |
15
- | `Ctrl+T` | Toggle the display of tool descriptions. |
16
- | `Shift+Tab` (`Tab` on Windows) | Cycle approval modes (`plan` `default` `auto-edit` `yolo`) |
7
+ | Shortcut | Description |
8
+ | ------------------------------ | --------------------------------------------------------------------------------------------------------------------------- |
9
+ | `Esc` | Close dialogs and suggestions. |
10
+ | `Ctrl+C` | Cancel the ongoing request and clear the input. Press twice to exit the application. |
11
+ | `Ctrl+D` | Exit the application if the input is empty. Press twice to confirm. |
12
+ | `Ctrl+L` | Clear the screen. |
13
+ | `Ctrl+O` | Toggle compact mode (hide/show tool output and thinking). |
14
+ | `Ctrl+S` | Allows long responses to print fully, disabling truncation. Use your terminal's scrollback to view the entire output. |
15
+ | `Ctrl+T` | Toggle the display of tool descriptions. |
16
+ | `Alt/Option+M` | Toggle Markdown output between rich rendered previews and raw/source mode. On macOS, the terminal must send Option as Meta. |
17
+ | `Shift+Tab` (`Tab` on Windows) | Cycle approval modes (`plan` → `default` → `auto-edit` → `yolo`) |
17
18
 
18
19
  ## Input Prompt
19
20