Commit graph

718 commits

Author SHA1 Message Date
克竟
24a28d5fb0 refactor(status-line): redesign JSON input schema and add context fields
Restructure the status line stdin JSON for clarity and accuracy:
- Rename model.id → model.display_name, cwd → workspace.current_dir
- Replace raw context_window size/count with used_percentage,
  remaining_percentage, current_usage, context_window_size, and
  total_input_tokens/total_output_tokens
- Add version field from cfg.getCliVersion()
- Add git.branch, metrics.models, metrics.files
- Remove upstream-only fields: tokens.tool (never populated),
  session (start_time/elapsed_time not live-updating),
  streaming_state, approval_mode, terminal, metrics.tools
- Rename tokens.candidates → tokens.completion (Qwen API convention)
- Fix template string escaping in builtin-agents to avoid
  templateString() placeholder collision

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 17:52:07 +08:00
Shaojin Wen
1e8bc031cc
feat(core): adaptive output token escalation (8K default + 64K retry) (#2898)
* feat(core): adaptive output token escalation (8K default + 64K retry)

99% of model responses are under 5K tokens, but we previously reserved
32K for every request. This wastes GPU slot capacity by ~4x.

Now the default output limit is 8K. When a response hits this cap
(stop_reason=max_tokens), it automatically retries once at 64K — only
the ~1% of requests that actually need more tokens pay the cost.

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

* docs: add design doc and user doc for adaptive output token escalation

- Add design doc covering problem, architecture, token limit
  determination, escalation mechanism, and design decisions
- Document QWEN_CODE_MAX_OUTPUT_TOKENS env var in settings.md
- Add max_tokens adaptive behavior explanation in model config section

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 17:30:39 +08:00
tanzhenxin
3c23952ef7
Merge pull request #2897 from QwenLM/feat/thinking-cross-turn-retention-idle-cleanup
feat(core): thinking block cross-turn retention with idle cleanup
2026-04-08 15:26:53 +08:00
wenshao
6a55a9aeea feat(config): make thinking idle threshold configurable and lower default to 5min
Align with observed provider prompt-cache TTL (~5 min). Add
`context.gapThresholdMinutes` setting so users can tune the threshold
for providers with different cache TTLs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 14:21:06 +08:00
wenshao
1d4c17b1ce fix: rename /plan execute to /plan exit
Rename the subcommand to accurately reflect its behavior (exits plan
mode and restores previous approval mode, does not trigger execution).
Update source, tests, i18n keys (6 locales), and docs.
2026-04-08 10:21:00 +08:00
wenshao
7902806e63 docs: add ui.statusLine entry to settings reference
Add the missing ui.statusLine setting to the settings.md reference
table with a link to the status-line feature documentation.
2026-04-08 05:09:56 +08:00
wenshao
820191d99d docs: add zero-findings PR tip to follow-up table
User doc and PR description now include the "PR review, zero findings
→ post comments → approve PR" row in the follow-up actions table.
Also fixed PR description: "Step 4" → "Step 9" for post comments.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 15:33:03 +08:00
wenshao
a9038a1769 fix(review): 5 issues — CI security, incremental+comment, doc accuracy
1. CI config auto-discovery: read from base branch for PR reviews
   (PR branch is untrusted, malicious PR could inject commands)
2. Incremental early-exit: don't block --comment on unchanged PR —
   allow posting comments from previous review findings
3. Doc: review summary not always posted (Comment verdict skips it)
4. Doc: cross-repo reviews skip report persistence
5. Doc: clarify "Agents 1-4 findings verified" (not all — reverse
   audit findings skip verification)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 14:40:16 +08:00
wenshao
c826c24f6e fix(review): skip Agent 5 in cross-repo mode, update token counts
Cross-repo lightweight mode has no local codebase — Agent 5 (build/test)
is pointless. Now launches 4 agents instead of 5 in cross-repo mode.

Updated token count tables in SKILL.md, user doc, and DESIGN.md:
same-repo = 7 LLM calls, cross-repo = 6.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 09:24:59 +08:00
wenshao
8f723575bd docs: add CI config auto-discovery to user doc and design doc
- User doc: added "Other" row to language table + explanation that
  CI config is read for unrecognized projects
- DESIGN.md: added "Why auto-discover from CI config" decision
  section + added .qwen/review-tools.md to rejected alternatives

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 07:47:07 +08:00
wenshao
cbf2aa06ac feat(review): add Java and C/C++ support for deterministic analysis
Step 3 now supports:
- Java: mvn compile, checkstyle, spotbugs, pmd (Maven);
  gradle compileJava, checkstyleMain (Gradle)
- C/C++: clang-tidy (when compile_commands.json available)

Agent 5 build/test precedence now includes Maven and Gradle
before Makefile to avoid duplicate builds.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 07:19:56 +08:00
wenshao
720796e699 fix(review): safe branch cleanup + cross-repo agent count
- git branch -D: add 2>/dev/null || true to both cleanup sites
  (Step 1 stale cleanup + Step 11) to prevent abort if ref missing
- Cross-repo doc: clarify Agents 1-4 only (Agent 5 build/test
  requires local codebase, not available in cross-repo mode)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 05:02:13 +08:00
wenshao
559f2efd42 fix(review): fix cross-repo mode and add documentation
SKILL.md:
- Step 9 must use owner/repo from URL (not gh repo view) for cross-repo
- Step 2 (project rules) skipped in cross-repo mode (no local files)

User doc: add Cross-repo PR Review section with same-repo vs cross-repo
capability comparison table.

DESIGN.md: add "Why cross-repo uses lightweight mode" section explaining
CLI tools are inherently repo-local and our approach is best available.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 04:18:55 +08:00
wenshao
01c105b5e7 refactor(review): renumber steps from sub-steps to sequential 1-11
Replace confusing sub-step numbering (1, 1.1, 1.5, 2, 2.5, 2.6, 3,
3.5, 4, 4.5, 5) with clean sequential numbering (1-11).

Mapping: 1→1, 1.1→2, 1.5→3, 2→4, 2.5→5, 2.6→6, 3→7, 3.5→8,
4→9, 4.5→10, 5→11

Updated all cross-references in SKILL.md, user docs, and PR description.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 04:12:45 +08:00
wenshao
09c95c44c8 fix(review): address 5 Copilot comments
- Add error handling for git fetch and gh pr view failures in Step 1
- Skip worktree cleanup on autofix commit/push failure (preserve
  uncommitted fixes for manual recovery)
- Fix Agent 5 counting: it's 1 of the 5 LLM agents (not a separate
  zero-cost stage). Remove misleading "zero LLM" annotation and
  duplicate row from token efficiency table.
- Reverse audit skip-verification already implemented (comment #53
  was stale)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 03:42:20 +08:00
wenshao
6d7afafe3c perf(review): skip verification for reverse audit findings
Reverse audit agent already has full context (all confirmed findings +
entire diff), so its findings don't need a second opinion. This brings
the actual LLM call count to 7 (5 review + 1 verify + 1 reverse),
matching the documented claim.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 03:38:49 +08:00
wenshao
d6b9b35350 fix(review): handle interrupted review cleanup
If a previous review was interrupted (Ctrl+C, crash), stale worktree
and local ref would block the next review. Now Step 1 checks for and
cleans up stale .qwen/tmp/review-pr-<N> worktree and qwen-review/pr-<N>
ref before creating new ones.

Step 5 also cleans up the local ref alongside the worktree.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 03:35:00 +08:00
wenshao
6b28920a07 docs: fix autofix section redundancy and add pre-fix verdict note
- Remove duplicate worktree commit+push bullet (lines 107 vs 109)
- Add note that PR submission uses pre-fix verdict since remote
  isn't updated until autofix push completes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 03:31:48 +08:00
wenshao
ce47f64ae6 docs: replace Mermaid with plain-text pipeline diagram
Mermaid only renders on GitHub; shows as raw code on Nextra,
Docusaurus, VS Code preview, and offline viewing. Plain-text
ASCII diagram is universally compatible and includes LLM call
cost annotations on each stage.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 03:30:34 +08:00
wenshao
1db1dec517 docs: replace step list with Mermaid flowchart in How It Works
Visual pipeline diagram showing:
- Sequential flow from scope detection to cleanup
- 5 parallel agents subgraph
- Decision branches for autofix and PR comments
- Zero-LLM-cost stages marked
- GitHub renders Mermaid natively

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 03:29:20 +08:00
wenshao
295e907d25 fix(review): address 4 Copilot comments on worktree and verification
- Step 4.5: use absolute paths for reports/cache in worktree mode
  (relative paths would land in worktree and be deleted)
- Step 1: fetch into qwen-review/pr-<N> ref to avoid clobbering
  existing local branches
- Step 2.6: reverse audit findings use batch verification (not
  one-per-finding), consistent with Step 2.5
- Doc: clarify reverse audit findings are also batch-verified

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 03:25:24 +08:00
wenshao
9b9bccd27d docs: update user doc with token efficiency, fix follow-up table
- Add Token Efficiency section showing fixed 7 LLM calls breakdown
- Fix follow-up table: "fix these issues" is local-only (worktree
  cleaned up after PR review)
- Update PR description with worktree, batch verification, cross-model
  review, PR comment dedup, and expanded test plan

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 03:22:54 +08:00
wenshao
e65e5bd353 perf(review): replace N verification agents with single batch verification
Previously, each finding got its own independent verification agent
(N findings = N LLM calls). Now a single verification agent receives
all findings at once and verifies them in one pass.

Token cost: 6+N variable calls → 7 fixed calls (5 review + 1 verify + 1 reverse audit)
Quality: minimal impact — batch verification has fuller cross-finding context

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 03:19:23 +08:00
wenshao
08a797cf76 fix(review): address 4 Copilot comments
- Add model attribution to no-findings LGTM path
- Handle empty string from getModel() with .trim() || 'unknown'
- Add tests for {{model}} with args and empty model ID
- Fix doc contradiction: PR autofix pushes automatically from worktree

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 03:13:23 +08:00
wenshao
a5cc2c38cb fix(review): fix 5 worktree issues found in audit
1. Remove gh pr checkout --detach (modifies working tree, defeats
   worktree purpose). Use git fetch only.
2. Add dependency installation step (npm ci etc.) in worktree —
   without it, all TS/JS linting/building fails.
3. Cache and reports written to main project dir, not worktree
   (would be deleted in Step 5).
4. "fix these issues" tip only for local reviews — worktree is
   cleaned up after PR review, so interactive fixing not possible.
5. Autofix push uses explicit remote branch name from Step 1.
6. Move incremental check before dependency install to avoid
   wasting time when no new changes.
7. Fix Step 3 reference: "from Steps 2.5 and 2.6" (includes
   reverse audit findings).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 03:11:16 +08:00
wenshao
dd2de17de5 feat(review): use ephemeral worktree for PR reviews
Replace the stash + checkout + restore flow with an isolated git
worktree for PR reviews. This eliminates:
- Stash orphan risks (multiple early exit paths)
- Wrong-branch risks (Step 5 restore failures)
- Build cache pollution (worktree has its own state)
- All stash-related error handling complexity

New flow:
- Step 1: git worktree add .qwen/tmp/review-pr-<number>
- All agents operate in the worktree directory
- Autofix commits and pushes from the worktree
- Step 5: git worktree remove (--force for dirty worktrees)

User's working tree is never modified during PR reviews.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 03:07:14 +08:00
wenshao
5effbb696f feat(review): read existing PR comments to avoid duplicate feedback
For PR reviews, fetch existing inline and general comments via gh api
before launching agents. A summary of already-discussed issues is
passed to agents so they don't re-report problems that humans or other
tools have already flagged.

Added to Exclusion Criteria: "Issues already discussed in existing
PR comments."

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 01:07:35 +08:00
wenshao
ba8a3a741f fix(review): fix section numbering, nav entry, and step hierarchy
- commands.md: renumber 1.6→1.7→1.8→1.9 after inserting 1.5 Built-in Skills
- SKILL.md: promote Reverse audit from ### to ## Step 2.6 for consistent
  step hierarchy
- _meta.ts: add code-review to Features navigation sidebar

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 01:04:21 +08:00
wenshao
757bd9865a feat(review): model-aware incremental cache for cross-model review
The incremental review cache now stores modelId alongside commitSha.
When the same PR is re-reviewed with a different model:
- Cache detects model change → runs full review (not skipped)
- Informs user: "Previous review used X. Running full review with Y
  for a second opinion."

Same SHA + same model still skips as before.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 01:01:52 +08:00
wenshao
50d25733d7 feat(review): add reverse audit step to find coverage gaps
Add Step 2.6: after all findings are verified and aggregated, a single
reverse audit agent reviews the diff with full knowledge of what was
already found, specifically looking for important issues that all
previous agents missed.

- Only reports Critical/Suggestion level gaps (not Nice to have)
- Findings go through the same verification as other agents
- Single agent call — minimal cost overhead
- If nothing is found, initial review had strong coverage

This formalizes the "multi-round undirected audit" pattern that proved
effective during the development of this PR (14 rounds, 40+ issues).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 00:56:08 +08:00
wenshao
95a62da039 docs: fix review doc accuracy and remove non-existent /simplify
code-review.md:
- Add PR URL support to Quick Start
- Add "no changes" behavior note
- Fix copilot-instructions.md precedence (prefer .github/, not both)
- Fix "automatically gitignored" → user must ensure .gitignore coverage
- Clarify reports directory is project-relative
- Add "What's NOT Flagged" section (exclusion criteria)

commands.md:
- Replace non-existent /simplify with actual bundled skills
  (/loop, /qc-helper)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 00:50:26 +08:00
wenshao
ac179b0e02 docs: add /review user documentation
Add comprehensive user documentation for the /review command covering:
- Quick start examples for all modes (local, PR, file, --comment)
- Pipeline overview with all steps explained
- Review agents table (5 agents + their focus areas)
- Deterministic analysis (supported languages and tools)
- Severity levels and PR comment filtering rules
- Autofix workflow
- PR inline comments (what gets posted vs terminal-only)
- Follow-up actions (fix/post comments/commit)
- Project review rules (.qwen/review-rules.md etc.)
- Incremental review and caching
- Review report persistence
- Cross-file impact analysis
- Design philosophy

Also add /review and /simplify to the commands reference page
under a new "Built-in Skills" section with link to full docs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 00:47:31 +08:00
wenshao
f8071186a9 docs: use sh -c in troubleshooting test command
Inline shell snippets need sh -c to execute via pipe, matching how
child_process.exec() runs the configured command.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 19:22:25 +08:00
wenshao
f67c9c5d78 fix: clarify footer comment and add Windows shell note to docs
- Footer comment now accurately states only the "? for shortcuts"
  hint is suppressed, not all left-section items
- Docs now note that Windows uses cmd.exe by default and suggest
  wrapping commands with bash -c or using a bash script

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 19:10:52 +08:00
wenshao
3aa246a829 docs: quote $input in inline command examples
Use echo "$input" instead of echo $input for proper shell variable
quoting, consistent with the script file example.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 18:54:06 +08:00
wenshao
2e089cce71 fix(docs): fix mode count and update plan example in approval-mode docs
- Fix "three distinct permission modes" → "four" (Plan was always listed)
- Update refactor example to use /plan command instead of /approval-mode
- Fix grammar in example description

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 18:51:22 +08:00
wenshao
5b9c94b436 docs: fix jsonc trailing commas that break settings parser
The settings parser uses stripJsonComments + JSON.parse, which does
not support trailing commas. Changed the config example from jsonc
to json and removed trailing commas so users can copy-paste safely.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 18:48:25 +08:00
wenshao
813d863e7c docs: guard division by zero in script example
Add size > 0 check before computing context percentage to prevent
division by zero when context_window_size is unavailable.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 18:46:15 +08:00
wenshao
12e1ef4594 docs: add prerequisites, hot-reload note, fix troubleshooting test JSON
- Add jq prerequisite section
- Clarify that settings changes take effect without restart
- Provide complete JSON in troubleshooting test command
- Move script filename out of code block to avoid shebang confusion

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 18:41:41 +08:00
wenshao
b1af941713 docs: add status line user documentation
Covers configuration, JSON stdin fields, examples (model+tokens,
git branch, script file), behavior details, and troubleshooting.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 18:35:46 +08:00
wenshao
ee8fcc9230 docs: add /plan command usage to approval mode documentation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 18:28:27 +08:00
wenshao
09ccc1b896 fix(docs): add /plan <task> usage example to commands table
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 07:11:25 +08:00
wenshao
63c4bd0b05 fix(docs): align /plan description wording with i18n keys
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 07:06:31 +08:00
wenshao
135699dd5a feat(cli): implement /plan command for plan mode
- Add /plan command to switch to plan mode or execute the current plan
- Update BuiltinCommandLoader to include planCommand
- Allow planCommand in non-interactive environments
- Add corresponding unit tests
- Update i18n locales to include new translations
- Document /plan command in features/commands.md
2026-04-06 06:31:04 +08:00
Shaojin Wen
3bce84d5da
feat(cli, webui): add follow-up suggestions feature (#2525)
Some checks failed
E2E Tests / E2E Test (Linux) - sandbox:docker (push) Has been cancelled
E2E Tests / E2E Test (Linux) - sandbox:none (push) Has been cancelled
Qwen Code CI / Lint (push) Has been cancelled
Qwen Code CI / CodeQL (push) Has been cancelled
E2E Tests / E2E Test - macOS (push) Has been cancelled
Qwen Code CI / Test (push) Has been cancelled
Qwen Code CI / Test-1 (push) Has been cancelled
Qwen Code CI / Test-2 (push) Has been cancelled
Qwen Code CI / Test-3 (push) Has been cancelled
Qwen Code CI / Test-4 (push) Has been cancelled
Qwen Code CI / Test-5 (push) Has been cancelled
Qwen Code CI / Test-6 (push) Has been cancelled
Qwen Code CI / Test-7 (push) Has been cancelled
Qwen Code CI / Test-8 (push) Has been cancelled
Qwen Code CI / Post Coverage Comment (push) Has been cancelled
* feat(cli, webui): add follow-up suggestions feature

Implement context-aware follow-up suggestions that appear after task
completion, suggesting relevant next actions like "commit this", "run
tests", etc.

- Add `followup/` module with types, generator, and rule-based provider
- Export follow-up types and functions from core index
- 8 default suggestion rules covering common workflows

- Add `useFollowupSuggestionsCLI` hook for Ink/React
- Integrate suggestion generation in AppContainer when streaming completes
- Add Tab key to accept, arrow keys to cycle through suggestions
- Display suggestions as ghost text in input prompt

- Add `useFollowupSuggestions` hook for React
- Update InputForm to display suggestions as placeholder
- Add CSS styling for suggestion appearance with counter
- Add keyboard handlers (Tab, arrow keys)

- After streaming completes with tool calls, suggestions appear
- Tab accepts the current suggestion
- Left/Right arrows cycle through multiple suggestions
- Typing or pasting dismisses the suggestion

- Shell command rules (tests, git, npm install) don't work yet due to
  history not storing tool arguments
- VSCode extension integration pending
- Web UI needs parent app integration for suggestion generation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: resolve merge conflicts and build errors

- Rebased on upstream main (5d02260c8)
- Fixed JSX structure in InputPrompt.tsx
- Changed `return;` to `return true;` in follow-up handlers
- Added @agentclientprotocol/sdk to core package dependencies
- Restored correct BaseTextInput usage (self-closing, no children)
- Follow-up suggestions now shown via placeholder prop only

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: remove @agentclientprotocol/sdk from core package.json

The types are imported in fileSystemService.ts but the package
should not be a runtime dependency of core. It's provided by
the CLI package which depends on core. This was causing
package-lock.json sync issues on Node.js 24.x CI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: restore alphabetical order of dependencies in core/package.json

* fix: restore package-lock.json from upstream to fix Node 24.x CI

* fix: resolve acpConnection test failure and ESLint warning

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* style: apply prettier formatting after merge

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(followup): address review issues in follow-up suggestions

- Export followupState.ts from core index (was dead code)
- Refactor CLI and WebUI hooks to use shared followupReducers (eliminate duplication)
- Move side effects out of setState updaters via queueMicrotask
- Fix AppContainer useEffect dependency on unstable historyManager.history reference
- Reorder matchesRule to check pattern before condition (cheaper first)
- Make RuleBasedProvider collect from all matching rules with dedup and limit
- Add missing resetGenerator export for testing
- Add explicit implements SuggestionProvider to RuleBasedProvider
- Fix unstable followup object in useEffect dependency arrays
- Merge duplicate imports to fix eslint import/no-duplicates warnings
- Standardize copyright year to 2025
- Add test files for followupState, ruleBasedProvider, suggestionGenerator

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

* fix(followup): address review feedback from PR #2525

- Fix acceptingRef race: set lock synchronously before queueMicrotask
- Derive hasError/wasCancelled from actual tool call statuses
- Incorporate rule priority into suggestion priority calculation
- Clear suggestions immediately when setSuggestions([]) is called
- Add !completion.showSuggestions guard to Tab handler
- Fix onAcceptFollowup type from (string) => void to () => void
- Fix ToolCallInfo.name doc examples to match display names
- Scope CSS counter ::after to data-has-suggestion + empty conditions
- Reset regex lastIndex before test() for g/y flag safety
- Stabilize hook return with useMemo + onAcceptRef pattern
- Add @qwen-code/qwen-code-core as webui external + peerDependency

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

* fix(followup): address second round of review feedback

- Scope CSS max-width to match counter condition (not count=1)
- Only dismiss followup on printable character input, not navigation keys
- Restrict tool_group scan to most recent contiguous block (current turn)

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

* fix(followup): clear suggestions on new turn, add search guards

- Clear followupSuggestions when streaming starts (Idle → Responding)
  to prevent stale suggestions from previous turns
- Add !reverseSearchActive && !commandSearchActive guards to Tab handler
  to avoid keybinding conflicts with search modes

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

* fix(followup): address third round of review feedback

- Fix string pattern asymmetry: only match tool names when matchMessage=false
- Collect tool_groups from last user message boundary, not contiguous tail
- Flatten to individual tool calls before slicing to cap at 10 actual calls

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

* fix(followup): fix arrow cycling guard and align rule conditions with patterns

- Remove unreliable textContent check for arrow cycling in WebUI InputForm;
  rely on inputText state which already accounts for zero-width spaces
- Add 'error' to fix/bug rule condition to match its regex pattern
- Add 'clean up' to refactor rule condition to match its regex pattern

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

* fix(followup): reset acceptingRef in clear() to prevent deadlock

If clear() is called during accept debounce window, acceptingRef
could remain stuck true permanently. Now reset in clear().

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

* fix(followup): cancel pending timeout in dismiss() and accept()

Prevents stale suggestion timeout from re-showing suggestions
after user dismisses or accepts during the 300ms delay window.

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

* fix(followup): reset lastIndex in removeRules() for g/y flag safety

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

* fix(vscode-ide-companion): mark @qwen-code/qwen-code-core as external in webview esbuild

The webui package now declares @qwen-code/qwen-code-core as external in its
vite build config. Without this change, the vscode-ide-companion webview
esbuild (platform: 'browser') would try to bundle core's Node.js-only
dependencies (undici, @grpc/grpc-js, fs, stream, etc.), causing 562 build
errors during `npm ci`.

* fix: restore node_modules/@google/gemini-cli-test-utils workspace link in lockfile

The top-level workspace symlink entry was accidentally removed by a local
npm install in commit 004baaeb, which replaced it with a nested
packages/cli/node_modules/ entry. npm ci requires the top-level link entry
to be present in the lockfile, otherwise it fails with:
  "Missing: @google/gemini-cli-test-utils@0.13.0 from lock file"

Also syncs @qwen-code/qwen-code-core peerDependency into the lockfile
to match the updated packages/webui/package.json.

* refactor(followup): extract controller and improve rule matching

- Extract createFollowupController for unified state management across CLI and WebUI
- Refactor rule-based provider to match via assistant message keywords instead of tool arguments
- Add enableFollowupSuggestions user setting in UI category
- Decouple WebUI from @qwen-code/qwen-code-core by copying browser-safe state logic
- Add followupHistory.ts for extracting suggestion context from CLI history
- Add comprehensive tests for controller and rule matching scenarios
- Use --app-primary CSS variable for consistency

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* refactor(webui): import followup state from core package

- Remove followupState.ts from webui (moved to core)
- Import FollowupSuggestion, FollowupState types from core
- Add @qwen-code/qwen-code-core as peerDependency
- Add core to vite external list
- Update test to include id field in HistoryItem

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* refactor(followup): simplify generator, revert unrelated changes

- Collapse FollowupSuggestionsGenerator class into a single
  generateFollowupSuggestions() function (152 → 26 lines)
- Inline extractSuggestionContext into followupHistory.ts
- Remove unused RuleBasedProvider.addRule/removeRules methods
- Revert unrelated acpConnection.test.ts refactor
- Fix followupHistory.test.ts HistoryItem missing id field
- Reduce test verbosity (162 → 36 lines for generator tests)

* fix(followup): fix accept() deadlock and restore UMD globals mapping

- Wrap queueMicrotask callback in try/catch/finally to prevent accepting
  lock from being permanently held when onAccept throws
- Restore '@qwen-code/qwen-code-core': 'QwenCodeCore' in webui
  vite.config.ts globals (regression from d0f38a5f)
- Add test case verifying accept() recovers after callback exception

* fix(followup): log accept callback errors instead of swallowing them

Replace empty catch {} with console.error to ensure onAccept errors
remain visible for debugging while still preventing deadlock via finally.
Update test to verify error is logged.

* refactor(webui): move followup hook to separate subpath entry

Move useFollowupSuggestions from the root entry to a dedicated
'@qwen-code/webui/followup' subpath so that consumers who only need
UI components are not forced to install @qwen-code/qwen-code-core.

- Add src/followup.ts as separate Vite lib entry
- Remove followup exports from src/index.ts
- Add ./followup exports map in package.json
- Mark @qwen-code/qwen-code-core as optional peerDependency
- Switch build from single-entry UMD to multi-entry ESM/CJS

* fix(webui): restore UMD build and isolate core from root type boundary

- Restore UMD output for root entry (used by CDN demos, export-html, etc.)
- Build followup subpath via separate vite.config.followup.ts to avoid
  Vite's multi-entry + UMD limitation
- Replace FollowupState import in InputForm.tsx with a local structural
  type (InputFormFollowupState) so root .d.ts no longer references
  @qwen-code/qwen-code-core
- Root entry (JS + UMD + .d.ts) is now fully free of core dependency;
  core is only required by '@qwen-code/webui/followup' subpath

* refactor(followup): replace rule-based suggestions with LLM-based prompt suggestion

Replace the hardcoded rule-based follow-up suggestion engine with an LLM-based
prompt suggestion system, aligned with Claude Code's NES (Next-step Suggestion)
architecture.

Core changes:
- Replace ruleBasedProvider with generatePromptSuggestion using BaseLlmClient.generateJson()
- Port Claude Code's SUGGESTION_PROMPT and 14 filter rules (shouldFilterSuggestion)
- Simplify state from multi-suggestion array to single string (FollowupState)
- Add framework-agnostic controller with Object.freeze'd initial state

Guard conditions (9 checks):
- Settings toggle, non-interactive/SDK mode, plan mode
- Permission/confirmation/loop-detection dialogs, elicitation requests
- API error response detection, conversation history limit (slice -40)

UI interaction (CLI + WebUI):
- Tab: fill suggestion into input
- Enter: accept and submit
- Right Arrow: fill without submitting
- Typing/paste: dismiss suggestion
- Autocomplete conflict prevention

Telemetry (PromptSuggestionEvent):
- outcome (accepted/ignored/suppressed), accept_method (tab/enter/right)
- time_to_accept_ms, time_to_ignore_ms, time_to_first_keystroke_ms
- suggestion_length, similarity, was_focused_when_shown, prompt_id
- Per-rule suppression logging with reason strings

Deleted files:
- ruleBasedProvider.ts/test, followupHistory.ts/test, types.ts (dead FollowupSuggestion type)

13 rounds of adversarial audit, 17 issues found and fixed.

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

* fix(followup): address qwen3.6-plus-preview review findings

P0: Fix API error detection — check pendingGeminiHistoryItems for error
items (API errors go to pending items, not historyManager.history).

P1: Don't log abort as 'error' in telemetry — aborts are normal user
behavior (user started typing), not errors.

P3: Early return in dismiss() when state already cleared, avoiding
redundant applyState call after accept().

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

* fix(settings): update suggestion feature description to match current behavior

Remove outdated "arrow keys to cycle" text — the feature now uses
Tab/Right Arrow to accept and Enter to accept+submit (no cycling).

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

* fix(followup): fix WebUI Enter submitting empty text + defend onOutcome

P0/P1: WebUI Enter handler now passes suggestion text explicitly via
onSubmit(e, followupSuggestion) instead of relying on React setState
(which is async and would leave inputText as "" in the closure).

P3: Wrap onOutcome callbacks in try/catch in both accept() and dismiss()
so telemetry errors cannot block state transitions.

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

* fix(followup): allow setSuggestion(null) when disabled + fix dts clobber

- setSuggestion(null) now always clears state/timers even when disabled,
  preventing stale suggestions from lingering after feature toggle.
- Set insertTypesEntry: false in followup vite config to prevent
  overwriting the main build's index.d.ts.

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

* fix(webui): thread explicitText through submit chain for Enter accept

handleSubmit and handleSubmitWithScroll now accept an optional
explicitText parameter. When provided (e.g., from prompt suggestion
Enter accept), it is used instead of the closure-captured inputText,
fixing the React setState race where onSubmit reads stale empty text.

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

* fix(followup): address Copilot review — 4 fixes

- Enter accept: use buffer.text.length === 0 instead of !trim() to
  prevent whitespace-only input from triggering suggestion accept
- Move ref tracking from render body to useEffect to avoid
  render-time side effects in StrictMode/concurrent rendering
- Align PromptSuggestionEvent event.name to 'qwen-code.prompt_suggestion'
  matching the EVENT_PROMPT_SUGGESTION constant used by the logger
- Fix onOutcome JSDoc: remove mention of 'suppressed' (handled separately)

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

* fix(followup): address Copilot review — curated history, type compat, peer version

- Use curated history (getChat().getHistory(true)) to avoid invalid
  entries causing API 400 errors in suggestion generation
- Use method signature for onSubmit in InputFormProps to maintain
  bivariant compatibility with existing consumers under strictFunctionTypes
- Tighten @qwen-code/qwen-code-core peer dependency to >=0.13.1

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

* feat(followup): add prompt cache sharing + speculation engine

Phase 1 — Forked Query (cache sharing):
- CacheSafeParams: snapshot of generationConfig (systemInstruction + tools)
  + curated history + model + version, saved after each successful main turn
- createForkedChat: isolated GeminiChat sharing the same cache prefix for
  DashScope cache_control hit
- runForkedQuery: single-turn request via forked chat with JSON schema support
- suggestionGenerator: uses forked query when CacheSafeParams available,
  falls back to BaseLlmClient.generateJson otherwise
- GeminiChat.getGenerationConfig(): new getter for cache param snapshots
- Feature flag: enableCacheSharing (default: false)

Phase 2 — Speculation (predictive execution):
- OverlayFs: copy-on-write filesystem for speculation file isolation
  (/tmp/qwen-speculation/{pid}/{id}/), handles new files + existing files
- speculationToolGate: tool boundary enforcement using AST-based shell
  checker (not deprecated regex), write tools gated by ApprovalMode
  (only auto-edit/yolo allow overlay writes)
- speculation.ts: startSpeculation (on suggestion display), acceptSpeculation
  (on Tab/Enter — copies overlay to real FS, injects history via addHistory),
  abortSpeculation (on user input/new turn — cleanup overlay)
- Custom execution loop: toolRegistry.getTool → tool.build → invocation.execute
  (bypasses CoreToolScheduler — permission handled by toolGate)
- ensureToolResultPairing: strips unpaired functionCalls at boundary
- Boundary-aware tool result preservation: keeps executed tool results
  even when boundary truncates remaining calls
- Feature flag: enableSpeculation (default: false)

Telemetry:
- SpeculationEvent: outcome, turns_used, files_written, tool_use_count,
  duration_ms, boundary_type, had_pipelined_suggestion
- logSpeculation logger function

Security:
- Write tools only allowed in auto-edit/yolo mode during speculation
- Shell commands gated by isShellCommandReadOnlyAST (AST parser)
- Unknown/MCP tools always hit boundary (safe default)
- All structuredClone for cache param isolation

4 rounds of adversarial audit, 20+ issues found and fixed.

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

* fix(followup): address Copilot review — curated history, type compat, peer version

- Move web_fetch/web_search from SAFE_READ_ONLY to BOUNDARY tools
  (they require user confirmation for network requests)
- Add overlay read path resolution for read tools (resolveReadPaths)
  so speculative reads see overlay-written files
- Wire enableCacheSharing setting into generatePromptSuggestion
- Fix esbuild comment to not hardcode webui version

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

* fix(speculation): use index-based tracking for boundary tool pairing

Track executed function calls by order (first N matching
functionResponses.length) instead of by name. Fixes incorrect
pairing when model emits multiple calls with the same tool name.

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

* fix(speculation): handle undefined functionCall.name + wrap rewritePathArgs

- Skip functionCall parts with missing name instead of non-null assertion
- Wrap rewritePathArgs in try/catch — treat path rewrite failure as boundary

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

* feat(followup): pipelined suggestion, UI rendering, dismiss abort

- Pipelined suggestion: after speculation completes, generate next
  suggestion using augmented context. Promoted on accept.
- UI rendering: completed speculation results rendered via historyManager.
- Dismiss abort: typing/pasting calls dismissPromptSuggestion → clears
  promptSuggestion → useEffect aborts running speculation immediately.

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

* fix(followup): clear cache on reset, truncate history, fix test + comment

- Clear CacheSafeParams on startChat/resetChat to prevent cross-session leakage
- Truncate history to 40 entries before deep clone in saveCacheSafeParams
  to reduce CPU/memory overhead on long sessions
- Update stale comment about speculation dismiss lifecycle
- Add onAccept assertion to accept test with proper microtask flush

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

* docs(design): add prompt suggestion design documentation

- prompt-suggestion-design.md: architecture, generation, filtering, state
  management, keyboard interaction, telemetry, feature flags
- speculation-design.md: copy-on-write overlay, tool gate security, boundary
  handling, pipelined suggestion, forked query cache sharing
- prompt-suggestion-implementation.md: implementation status, test coverage,
  audit history, Claude Code alignment tracking

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

* fix(overlay): align catch comment with silent behavior

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

* fix(followup): wire augmented context into pipelined suggestion + guard Tab/Right

- Pipelined suggestion now includes the accepted suggestion text and
  speculated model response as context for the next prediction
- Tab/ArrowRight handlers only preventDefault when onAcceptFollowup
  is provided, preventing key interception without a wired callback

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

* fix(speculation): filter thought parts + add filePath to path keys

- Skip thought/reasoning parts from model responses to prevent leaking
  internal reasoning into speculated history
- Add 'filePath' to path rewrite key list for LSP and other tools that
  use camelCase argument names

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

* fix(overlay): resolve relative paths against realCwd not process.cwd

Relative tool paths are now resolved against the overlay's realCwd
before computing the relative path, preventing incorrect outside-cwd
detection when process.cwd() differs from config.getCwd().

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

* docs(design): fix 4 doc-code inconsistencies

- Guard conditions: clarify 13 code checks vs 11 table categories,
  separate feature flags from guard block, add streaming transition
- Filter rules: 14 → 12 (actual count in code and table)
- BOUNDARY_TOOLS: add todo_write + exit_plan_mode to doc table
- SpeculationEvent: 8 → 7 fields (matching code)

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

* fix(followup): turns_used metric + reuse SUGGESTION_PROMPT + reduce clones

- turns_used: count only model messages (not all Content entries)
  to accurately reflect LLM round-trips instead of inflated 3x count
- Pipelined suggestion: reuse exported SUGGESTION_PROMPT from
  suggestionGenerator instead of a degraded local copy, ensuring
  consistent quality (EXAMPLES, NEVER SUGGEST rules included)
- createForkedChat: replace redundant structuredClone with shallow
  copies since params are already deep-cloned snapshots

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

* feat(followup): speculation UI tool rendering + speculationModel setting

- Speculation UI: render tool calls as tool_group HistoryItems with
  structured name/description/result instead of plain text only
- speculationModel setting: allows using a cheaper/faster model for
  speculation and pipelined suggestion. Leave empty to use main model.
  Passed through startSpeculation → runSpeculativeLoop → pipelined.

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

* docs(design): sync docs with latest code changes

- Add speculationModel setting to feature flags table
- Document tool_group UI rendering in speculation accept flow
- Fix createForkedChat: deep clone → shallow copy (already cloned snapshots)
- Document pipelined suggestion SUGGESTION_PROMPT reuse
- Add Model Override and UI Rendering sections to speculation-design
- Update line counts to match actual file sizes

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

* test(followup): add unit tests for overlayFs, toolGate, forkedQuery

overlayFs (15 tests): COW write, read resolution, apply, cleanup, path traversal
speculationToolGate (24 tests): tool categories, approval mode gating, shell AST, path rewrite
forkedQuery (6 tests): cache params save/get/clear, deep clone, version detection

Total: 27 → 173 tests

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

* test(followup): P0-P2 test coverage for speculation + controller + toolGate

speculation.test.ts (7 tests):
- ensureToolResultPairing: empty, no calls, paired, unpaired text+call,
  unpaired call-only, user-ending, empty parts

followupState.test.ts (+8 tests = 15 total):
- onOutcome: accepted/tab, ignored/dismiss, error caught, no-op when cleared
- clear(): resets accepting lock allowing re-accept
- double accept blocked by debounce
- setSuggestion replaces pending timer

speculationToolGate.test.ts (+3 tests = 27 total):
- resolveReadPaths: overlay path after write, unchanged when not written
- rewritePathArgs: path key coverage

Total: 173 → 190 tests

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

* test(followup): smoke tests + P0-P2 coverage gaps

smoke.test.ts (21 tests): E2E verification across modules
- Filter against realistic LLM outputs (9 good + 7 bad + reason check)
- OverlayFs full round-trip (write → read → apply → verify)
- ToolGate → OverlayFs integration (write redirect → read resolve)
- CacheSafeParams lifecycle (save → mutate → isolation → clear)
- ensureToolResultPairing orphaned functionCalls

followupState.test.ts (+8 tests):
- onOutcome: accepted/tab, ignored/dismiss, error caught, no-op cleared
- clear(): resets accepting lock
- double accept debounce
- setSuggestion replaces pending timer

speculationToolGate.test.ts (+3 tests):
- resolveReadPaths through overlay after write
- path key coverage for rewritePathArgs

Export ensureToolResultPairing for testing.

Total: 190 → 211 tests

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

* fix(followup): dismiss aborts suggestion, boundary skip inject, parentSignal check

- dismissPromptSuggestion now also aborts suggestionAbortRef to prevent
  race between dismiss and in-flight startSpeculation
- Boundary speculation: skip acceptSpeculation (which injects history),
  fall through to normal addMessage to avoid duplicate user turns
- startSpeculation: check parentSignal.aborted upfront before starting
- Speculation rendering: use index-based loop instead of indexOf O(n²)

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

* docs(design): fix speculation accept diagram — boundary skips inject

The architecture diagram now shows the branching logic: completed
speculations go through acceptSpeculation (inject + render), while
boundary speculations are discarded and the query is submitted fresh
via addMessage.

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

* feat(followup): enable cache sharing by default

enableCacheSharing now defaults to true. This is a pure cost
optimization with no behavioral change — suggestion generation
uses the forked query path (sharing the main conversation's
prompt cache prefix) when CacheSafeParams are available.

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

* fix(followup): aborted parent skips loop, acceptSpeculation try/finally, doc sync

- startSpeculation: return aborted state immediately when parentSignal
  is already aborted, without creating overlay or starting loop
- acceptSpeculation: wrap in try/finally to guarantee overlay cleanup
  even if applyToReal or addHistory throws
- Doc: enableCacheSharing default false → true (matches code)
- Doc: update test count table (7 → 15 followupState, add 6 new files)

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

* fix(followup): remove debug logs, add function calling fallback for non-FC models

- Remove all followup-debug process.stderr.write logs
- Add direct text fallback in generateViaBaseLlm when generateJson
  returns {} (model doesn't support function calling, e.g., glm-5.1)
- Add CJK text support in filter: skip whitespace-based word count
  for Chinese/Japanese/Korean text, use character count instead

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

* feat(followup): add suggestionModel setting for faster suggestion generation

New setting `suggestionModel` allows using a smaller/faster model
(e.g., qwen-turbo) for prompt suggestion generation instead of the
main conversation model. Reduces suggestion latency significantly.

Passed through: settings → AppContainer → generatePromptSuggestion
→ generateViaForkedQuery / generateViaBaseLlm (both paths).

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

* feat(followup): suggestionModel setting, /stats tracking, /about display

- suggestionModel: new setting to use a faster model for suggestion
  generation (e.g., qwen3.5-flash instead of main model glm-5.1)
- /stats: suggestion API calls now report usage to UiTelemetryService
  so token consumption appears in /stats model breakdown
- /about: shows Suggestion Model field (configured or main model)

Also:
- Function calling fallback for non-FC models (direct text generation)
- CJK text support in word count filter (character-based for Chinese)

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

* i18n: add Suggestion Model translations for /about display

en: Suggestion Model | zh: 建议模型 | ja: 提案モデル
de: Vorschlagsmodell | pt: Modelo de Sugestão | ru: Модель предложений

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

* fix(followup): always use generateContent for suggestion (not generateJson)

generateJson doesn't expose usageMetadata, so /stats can't track
suggestion model tokens. Switch to direct generateContent which
always returns usage data. Also simplifies the code by removing
the function-calling + fallback dual path.

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

* fix(followup): fix /stats tracking — use ApiResponseEvent constructor

Use ApiResponseEvent class constructor with proper response_id and
override event.name to match UiEvent type for UiTelemetryService
switch statement. This ensures suggestion model token usage appears
in /stats model output.

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

* i18n: fix Chinese translation for Suggestion Model

"建议模型" → "提示建议模型" to avoid ambiguity.

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

* refactor(followup): merge suggestionModel + speculationModel into fastModel

Single unified setting for all background tasks: suggestion generation,
speculation, pipelined suggestions, and future background tasks.

Users only need to understand one concept: main model for conversation,
fast model for background tasks.

- Remove: suggestionModel, speculationModel
- Add: fastModel (ui.fastModel in settings.json)
- Update /about display: "Fast Model" with i18n translations
- Update all 6 locale files (en/zh/ja/de/pt/ru)

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

* refactor(settings): move fastModel to top-level (parallel to model)

fastModel is an independent model concept, not a property of the
main model. Move from model.fastModel to top-level settings.fastModel.

Config: { "fastModel": "qwen3.5-flash", "model": { "name": "glm-5.1" } }

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

* fix(followup): report usage in both forkedQuery and baseLlm paths

The forkedQuery path (used when enableCacheSharing=true) was not
reporting token usage to UiTelemetryService, so /stats model didn't
show the fast model. Now both paths report usage.

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

* feat(cli): add /model --fast command to set fast model

Usage:
  /model --fast qwen3.5-flash  — set fast model
  /model --fast                — show current fast model
  /model                      — open model selection dialog (unchanged)

Saves to user settings (SettingScope.User).

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

* docs(design): update to fastModel (replace suggestionModel/speculationModel)

- prompt-suggestion-design.md: speculationModel → fastModel (top-level)
- speculation-design.md: Model Override → Fast Model, update description
- prompt-suggestion-implementation.md: update settings description

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

* feat(cli): /model --fast opens model selection dialog for fast model

When called without a model name, /model --fast now opens the same
model selection dialog used by /model, but selecting a model saves
it as fastModel instead of switching the main model.

- useModelCommand: add isFastModelMode state
- ModelDialog: intercept selection in fast model mode, save to fastModel
- DialogManager: pass isFastModelMode prop to ModelDialog
- types.ts: add 'fast-model' dialog type

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

* fix(followup): pass resolved model (not undefined) to runForkedQuery

model: modelOverride → model: model (which has the fallback applied)

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

* fix(cli): /model --fast defaults to current fast model in dialog

When opening the model selection dialog via /model --fast, the
currently configured fastModel is pre-selected instead of the
main model.

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

* feat(cli): add --fast tab completion for /model command

/model <Tab> now shows --fast as a completion option with description.

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

* fix(schema): regenerate settings.schema.json with new followup settings

Adds enableCacheSharing, enableSpeculation, and fastModel to the
generated JSON schema so CI validation passes.

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

* fix(test): update tests for new Fast Model field in system info

Add "Fast Model" to expected labels in systemInfoFields and bugCommand
tests to match the new field added to /about and bug report output.

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

* ci: trigger PR synchronize event

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

* fix: address Copilot review comments (batch 4)

- modelCommand: use getPersistScopeForModelSelection for fastModel,
  return meaningful info message instead of empty content
- ModelDialog: handle $runtime|authType|modelId format in fast-model mode
- forkedQuery: return structuredClone from getCacheSafeParams
- client: fix stale comment about history truncation order
- speculation: detect abort in .then() handler, set 'aborted' status
  and cleanup overlay to prevent leaks
- docs: update test count table

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

* docs(users): add followup suggestions user manual

- New feature page: followup-suggestions.md covering usage, keybindings,
  fast model configuration, settings, and quality filters
- commands.md: add /model --fast command reference
- settings.md: add enableFollowupSuggestions, enableCacheSharing,
  enableSpeculation, and fastModel settings documentation
- _meta.ts: register new page in navigation

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

* docs(users): audit fixes for followup suggestions documentation

- followup-suggestions.md: add 300ms delay, WebUI support, plan mode
  guard, non-interactive guard, slash commands as single-word, meta/error
  filters, character limit
- settings.md: move fastModel next to model section, add /model --fast
  cross-reference and link to feature page
- overview.md: add followup suggestions to feature list
- i18n: add missing translations for 'Set fast model for background
  tasks' and 'Fast model updated.' in all 6 locales

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

* fix: address Copilot review comments (batch 5)

- modelCommand: remove duplicate info message (keep addItem only)
- followup-suggestions.md: clarify WebUI requires host app wiring
- speculation-design.md: fix abort telemetry description
- i18n: add missing translations for fast model strings

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

* fix(cli): remove duplicate message in /model --fast command

Use return message instead of addItem + empty return to avoid
blank INFO line in history. Also handle missing settings service.

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

* fix(i18n): remove unused 'Fast model updated.' translations

The /model --fast command now returns the model name directly
instead of using this string. Remove dead translations.

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

* fix(followup): disable thinking mode for suggestion and speculation

Forked queries inherit the main conversation's generationConfig which
may have thinkingConfig enabled. This wastes tokens and adds latency
for background tasks that don't need reasoning. Explicitly set
thinkingConfig.includeThoughts=false in both paths:
- createForkedChat (covers forked query + speculation)
- generateViaBaseLlm (non-cache-sharing fallback)

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

* docs: document thinking mode auto-disable for background tasks

- User docs: note that thinking is auto-disabled for suggestions/speculation
- Design docs: detail thinkingConfig override in both forked query and
  BaseLlm paths, explain why cache hits are unaffected

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

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: jinjing.zzj <jinjing.zzj@alibaba-inc.com>
Co-authored-by: yiliang114 <1204183885@qq.com>
2026-04-03 20:07:23 +08:00
Shaojin Wen
e855229453
Merge pull request #2776 from QwenLM/feat/enhance-btw-command
feat(cli): enhance /btw side question with improved prompt and Ctrl+C/D cancel
2026-04-03 19:17:12 +08:00
tanzhenxin
0c1635c26c docs(channels): consolidate design docs into single file
- Fix broken references to non-existent files
- Replace "What's Next" with detailed "Future Work" roadmap
- Remove redundant implementation, roadmap, and testing guide files
- User docs already cover these topics in docs/users/features/channels/

This consolidates the channels design documentation into a single
authoritative design doc, reducing duplication and maintenance burden.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-04-02 11:17:37 +08:00
tanzhenxin
b2f04418fa
Merge pull request #2628 from QwenLM/feat/channels-telegram
feat(channels): add extensible Channels platform with plugin system and Telegram/WeChat/DingTalk channels
2026-04-01 16:19:08 +08:00
tanzhenxin
76d64c9464
Merge pull request #2731 from QwenLM/feat/in-session-cron-loops
feat(cron): add in-session loop scheduling with cron tools
2026-04-01 16:18:46 +08:00
tanzhenxin
2eb2f4e319
Merge pull request #2719 from QwenLM/feat/npm-extension-installation
feat(extension): Add npm registry support for extension installation
2026-04-01 16:18:17 +08:00