qwen-code/docs/users/features/tips.md
Shaojin Wen b3bc42931e
feat: add contextual tips system with post-response context awareness (#2904)
* feat: add contextual tips system with post-response context awareness

Add a context-aware tips system that proactively shows helpful tips based
on session state. Post-response tips warn when context usage exceeds 80%
or 95%, suggesting /compress. Startup tips rotate across sessions via LRU
scheduling with cross-session persistence (~/.qwen/tip_history.json).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: use value import for runtime values in useContextualTips

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: address PR review feedback

- Use lastSessionTimestamp instead of totalShown for cross-session LRU
- Move getTipHistory singleton from Tips.tsx to services/tips/index.ts
- Defer TipHistory.load() when hideTips is true (no side effects)
- Use os.tmpdir() in tests for cross-platform portability
- Add proper translations for de/ja/pt/ru locale files
- Accept TipHistory | null in useContextualTips

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: address Copilot review feedback

- Validate tips field type in TipHistory.load() to handle corrupted JSON
- Split approval-mode tip into platform-specific variants using ctx.platform
- Add afterEach cleanup for temp files in all test suites
- Guard useContextualTips against null tipHistory

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: import shared DEFAULT_TOKEN_LIMIT, harden tipHistory, set file permissions

- Import DEFAULT_TOKEN_LIMIT from @qwen-code/qwen-code-core instead of
  hardcoding 1_048_576 in tipRegistry.ts and useContextualTips.ts
- Add normalizeEntry() to defensively handle corrupted tip history entries
- Write tip_history.json with mode 0o600 for privacy on multi-user systems

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: remove unused compressionThreshold from TipContext

compressionThreshold was defined in TipContext but never used by any tip's
isRelevant check. Remove it to avoid misleading consumers into thinking
tips respect the user's compression settings.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: sanitize sessionCount and getLastShown against corrupted tip history

- Validate sessionCount is finite and non-negative in TipHistory.load()
- Use normalizeEntry() in getLastShown() for corrupted lastSessionTimestamp

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* docs: add contextual tips user documentation

Add docs/users/features/tips.md covering startup tips, post-response
context warnings, tip history persistence, and the hideTips setting.
Update settings.md description and register the new page in _meta.ts.

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 17:40:27 +08:00

54 lines
2.2 KiB
Markdown

# Contextual Tips
Qwen Code includes a contextual tips system that helps you discover features and stay aware of session state.
## Startup Tips
Each time you launch Qwen Code, a tip is shown in the header area. Tips are selected by priority first, then rotated across sessions using LRU (least-recently-used) scheduling among tips of the same priority, so you see a different tip each time.
New users see onboarding-focused tips during their first sessions:
| Sessions | Example tips |
| -------- | ---------------------------------------------------- |
| < 5 | Slash commands (`/`), Tab autocomplete |
| < 10 | `QWEN.md` project context, `--continue` / `--resume` |
| < 15 | Shell commands with `!` prefix |
After that, tips rotate through general features like `/compress`, `/approval-mode`, `/insight`, `/btw`, and more.
## Post-Response Tips
During a conversation, Qwen Code monitors your context window usage and shows tips when action may be needed:
| Context usage | Condition | Tip |
| ------------- | ------------------------------ | ------------------------------------------------- |
| 50-80% | After a few prompts in session | Suggests `/compress` to free up context |
| 80-95% | | Warns context is getting full |
| >= 95% | — | Urgent: run `/compress` now or `/new` to continue |
Post-response tips have per-tip cooldowns to avoid being repetitive.
## Tip History
Tip display history is persisted at `~/.qwen/tip_history.json`. This file tracks:
- Session count (used for new-user tip selection)
- Which tips have been shown and when (used for LRU rotation and cooldown)
You can safely delete this file to reset tip history.
## Disabling Tips
To hide all tips (both startup and post-response), set `ui.hideTips` to `true` in `~/.qwen/settings.json`:
```json
{
"ui": {
"hideTips": true
}
}
```
You can also toggle this in the settings dialog via the `/settings` command.
Tips are also automatically hidden when screen reader mode is enabled.