Commit graph

7186 commits

Author SHA1 Message Date
克竟
23ead5a1e3 fix(web-shell): address scheduled task review feedback 2026-07-11 13:56:46 +08:00
qwen-code-dev-bot
8fdc5a234a merge: resolve conflicts with origin/main for scheduled task prompt references 2026-07-11 04:36:25 +00:00
chinesepowered
e1a82864a4
fix(mobile-mcp): strip bounds with negative coordinates from ui dump (#6624)
* fix(mobile-mcp): strip bounds with negative coordinates from ui dump

The bounds-stripping regex added in #6568 (`\[[0-9,]+\]`) does not match negative coordinates, but UIAutomator reports negative bounds for elements scrolled partially off-screen (e.g. `bounds="[-5,-20][100,50]"`). Those attributes survived the strip, partially defeating the token-reduction goal.

Extract the strip into a tested `stripUiBounds()` helper and widen the pattern to allow a leading `-` on each value. The vendored file keeps its existing tab/double-quote style.

* test(mobile-mcp): assert malformed bounds-like strings pass through unchanged

Adds a negative test covering extra-coordinate, decimal, and non-numeric
bounds-like strings, locking in that stripUiBounds only removes well-formed
integer `[x,y][x,y]` pairs. Requested in PR review.

---------

Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>
2026-07-11 04:21:20 +00:00
yuanyuanAli
98f046872e
feat(web-shell): add mobile welcome composer slots (#6584)
Some checks are pending
E2E Tests / E2E Test - macOS (push) Waiting to run
E2E Tests / web-shell Browser Regression (push) Waiting to run
E2E Tests / E2E Test (Linux) - sandbox:docker (push) Waiting to run
E2E Tests / E2E Test (Linux) - sandbox:none (push) Waiting to run
SDK Python / Classify PR (push) Waiting to run
SDK Python / SDK Python (3.10) (push) Blocked by required conditions
SDK Python / SDK Python (3.11) (push) Blocked by required conditions
SDK Python / SDK Python (3.12) (push) Blocked by required conditions
* feat(web-shell): add mobile welcome composer slots

* refactor(web-shell): deduplicate MessageList JSX and remove dead CSS reference

- Extract ~80 lines of duplicated MessageList rendering into shared variables with conditional props and wrapper
- Remove dead chatPaneWithWelcomeMiddle className reference (CSS class never defined)
- Document mobileWelcomeFooterMiddle dependency on renderWelcomeFooter in JSDoc

* fix(web-shell): stabilize MessageList tree position and conditional customFooter wrapper

- Use stable outer wrapper div for IIFE to prevent MessageList unmount/remount when showMobileWelcomeFooterMiddle toggles
- Only wrap CustomFooter in styles.customFooter div when hasMobileComposerBottom is true, avoiding DOM depth change for non-mobile consumers

* fix(release): raise package size budget to 85 MiB (#6688)

* fix(interactive): configure Docker sandbox networking for protocol tag retry test (#6684) (#6689)

The protocol-tags-interactive.test.ts started the fake OpenAI server
on 127.0.0.1 without Docker-aware host options, making it unreachable
from inside the Docker sandbox container. The CLI running in the
container tried to connect to 127.0.0.1 which resolved to the
container's own loopback, not the host where the test server listens.

Bind the fake server to 0.0.0.0 and advertise host.docker.internal
as the base URL host when QWEN_SANDBOX is docker or podman, matching
the established pattern in tool-control.test.ts. Also set NO_PROXY to
include host.docker.internal so the CLI does not route sandbox model
requests through an HTTP proxy.

Co-authored-by: qwen-autofix[bot] <qwen-autofix[bot]@users.noreply.github.com>

* fix(core): keep YOLO mode when the model calls enter_plan_mode (#6630)

* fix(core): keep YOLO mode when the model calls enter_plan_mode

A model-initiated enter_plan_mode call from YOLO silently switched the
session into the read-only Plan mode, surprising users who explicitly
chose YOLO for low-friction execution and then blocking the reads/writes
they expected to proceed. Genuine user-driven plan-mode entries
(Shift+Tab, /plan) call setApprovalMode directly and never route through
this tool, so guarding the tool only affects the model deciding to plan
on its own. From YOLO the tool now keeps the current mode and returns a
message telling the model to continue planning without switching.

Fixes #5970

* fix(core): gate the YOLO plan-mode guard on an explicit user request

Addresses review feedback on #6630.

The previous guard suppressed every enter_plan_mode invocation while the
session was in YOLO mode. That fixes the unsolicited switch reported in
#5970, but it also blocks the legitimate path: the tool description tells
the model to call this tool only after the user explicitly asks, and
/plan is interactive-only (supportedModes: ['interactive']) with no
Shift+Tab equivalent. In a headless or ACP YOLO session the tool is the
only door into plan mode, so a blanket guard made an explicit user
request unreachable.

Add an optional userRequested flag to the tool schema and only no-op when
the entry is NOT user-requested. A user-requested entry still goes through
setApprovalMode(PLAN, { enteredByModel: true }) so the Plan Approval Gate
on exit continues to run for AUTO/YOLO sessions (#5574).

* fix(core): address review suggestions on the YOLO plan-mode guard

- Log via debugLogger.info when the guard suppresses a model-initiated
  entry, so a "I asked for plan mode and nothing happened" report is
  diagnosable by grepping ENTER_PLAN_MODE (the other early-return paths
  already log).
- Strengthen the userRequested:false test to assert on the returned
  llmContent/returnDisplay, matching the unsolicited-entry sibling test.
- Add a defensive test pinning that userRequested is inert outside
  YOLO: DEFAULT with the flag set enters plan mode normally.

---------

Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>

* feat(cli): forward ask_user_question answers from SDK can_use_tool (#6655)

* feat(cli): forward ask_user_question answers from SDK can_use_tool

SDK-hosted agents could receive ask_user_question calls through the
can_use_tool callback and approve them, but the user's answers never
reached the tool: the CLI called onConfirm(ProceedOnce) with no payload,
so the tool read an empty answers map and the model never got the
decisions.

Route updatedInput.answers from the SDK's allow response into the tool
confirmation payload so the collected answers reach the tool. Reuses the
existing updatedInput channel — no new SDK API or types. Document the
pattern in the TypeScript and Python SDK READMEs.

* fix(cli): forward ask_user_question answers on teammate approval path

Address review feedback on #6655:

- handleTeammateApproval now mirrors the leader path and promotes the
  user's answers from updatedInput into the confirmation payload, so
  ask_user_question calls approved through a teammate no longer drop the
  user's choices (wenshao).
- Extract a shared buildAllowConfirmationPayload helper used by both the
  leader and teammate paths, and only promote `answers` for
  ask_user_question so a same-named field on any other tool's input can't
  leak into the payload.
- Add tests for the teammate path and the defensive guards (array
  updatedInput, array/null/empty answers, foreign answers field).

* test(web-shell): stub Range client-rect methods to fix flaky CI

CodeMirror's async measure pass (scheduled via requestAnimationFrame)
calls getClientRects()/getBoundingClientRect() on a text Range. jsdom
implements these on Element but not on Range, so the call throws
"textRange(...).getClientRects is not a function" from a rAF callback
after the test completed. Vitest surfaces it as an unhandled error and
fails the whole run with exit code 1 even though every assertion passed
(seen intermittently in useComposerCore.dom.test.tsx).

Polyfill both methods on Range.prototype in the shared test setup,
mirroring the existing ResizeObserver/scrollIntoView stubs.

* refactor(cli): use ToolNames constant and broaden permission tests

Address review suggestions on #6655:

- buildAllowConfirmationPayload now gates answers-promotion on the
  ToolNames.ASK_USER_QUESTION constant instead of a bare string literal,
  so a future rename of the tool name is a compile-time break rather than
  a silent regression.
- Add an it.each case for a non-object primitive updatedInput (string) to
  cover the `typeof updatedInput !== 'object'` guard branch.
- Assert the leader path overrides toolCall.request.args with the host's
  sanitized updatedInput before confirming.
- Add a teammate-path test for an allow response with no updatedInput,
  asserting respond is called with (ProceedOnce, undefined).

---------

Co-authored-by: qwen-code-dev-bot <qwen-code-dev-bot@users.noreply.github.com>

* fix(cli): localize approval mode UI labels (#6592)

* fix(cli): localize approval mode UI labels

* fix(cli): address approval mode i18n review

* fix(cli): stabilize approval mode i18n key

* test(cli): cover approval mode i18n follow-up

* test(cli): cover localized auto indicator

* test(cli): address approval i18n suggestions

---------

Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>

* feat(dingtalk): mention response senders (#6679)

* docs: design DingTalk at-sender replies

* docs: plan DingTalk at-sender replies

* feat(channels): preserve session for response delivery

* feat(dingtalk): optionally mention response sender

* docs(dingtalk): explain response mentions

* fix(dingtalk): retain queued mention targets

* fix(dingtalk): bound mention target lifecycle

* fix(dingtalk): clear synthetic command mention target

* fix(dingtalk): clear buffered targets on session death

* debug(dingtalk): log mention delivery result

* fix(dingtalk): render response mentions

* fix(dingtalk): send visible response mentions

* feat(dingtalk): use text replies for mentions

* fix(dingtalk): preserve mentioned text replies

* feat(web-shell): add artifact right panel (#6591)

* feat(web-shell): add artifact right panel

* fix(web-shell): address artifact panel review feedback

* fix(web-shell): handle artifact panel review edge cases

* fix(web-shell): tighten scheduled task parsing

* fix(web-shell): address artifact panel review followups

* fix(web-shell): guard large file diff stats

* fix(web-shell): address review panel suggestions

* test(webui): stabilize heartbeat prompt cleanup test

* fix(web-shell): address artifact review refresh issues

* test(web-shell): stabilize ChatPane artifact hook mock

* fix(web-shell): clear stale session artifacts while loading

* fix(web-shell): preserve artifact tabs during refresh

* fix(web-shell): address artifact review followups

* fix(web-shell): respect workspace cwd for artifact outputs

* fix(web-shell): scope artifact panel actions to pane

* fix(web-shell): resolve split pane merge conflict

* fix(web-shell): clear stale artifact panel state

* fix(web-shell): preserve leading turn outputs

* fix(web-shell): tighten turn output selectors

* fix(web-shell): harden artifact preview sanitizer

* fix(web-shell): address artifact panel review regressions

* fix(web-shell): reconcile split pane artifact snapshots

* fix(web-shell): clear pane artifacts on session switch

* fix(web-shell): clear stale right panel snapshots

* fix(web-shell): repair scheduled task hint string

---------

Co-authored-by: ytahdn <ytahdn@gmail.com>
Co-authored-by: qwen-code-dev-bot <qwen-code-dev-bot@users.noreply.github.com>

* feat(cli): workspace-qualified ACP transport (daemon multi-workspace phase 4) (#6621)

* docs(design): add daemon multi-workspace phase 4 (workspace-qualified ACP) design

* feat(cli): add workspace-qualified ACP transport (issue #6378 phase 4)

Per-runtime ACP dispatcher at /workspaces/:workspace/acp (HTTP + WS) dispatched by URL path from the single upgrade listener; per-runtime device-flow + reverse client-MCP; owner-index via bridge lifecycle; untrusted/unknown rejected; legacy /acp unchanged; advertise workspace_qualified_acp for multi-workspace.

* fix(cli): keep per-runtime device-flow registry out of serve fast-path bundle

Phase 4 secondary-runtime device-flow statically imported createDeviceFlowRegistry into run-qwen-serve, pulling glob/@iarna/toml into the serve fast-path bundle and failing the closure check. Import it dynamically at the creation site; the check now passes and behavior is unchanged.

* refactor(cli): drop per-runtime device-flow for secondary workspaces

Follow-up to the fast-path fix: instead of dynamically importing createDeviceFlowRegistry for secondary runtimes, drop the per-runtime device-flow wiring entirely. Secondary ACP device-flow falls back to the dispatcher default, keeping the serve fast-path bundle closure clean without the dynamic-import indirection. WorkspaceRuntime.deviceFlowRegistry stays optional for a future per-runtime hook.

* fix(cli): share daemon-global device-flow across ACP mounts; harden WS path parsing

Secondary ACP mounts share the daemon-global device-flow registry (single instance per daemon) instead of a per-runtime one; the event sink fans out to every trusted runtime bridge so secondary ACP clients receive their own flow events, fixing the reviewer #6621 Critical and the CI test failure. Drops WorkspaceRuntime.deviceFlowRegistry. WS upgrade path is parsed from the raw request-target instead of new URL().pathname, rejecting %2e%2e / backslash / dot-segment traversal.

* refactor(cli): gate CDP claim on primary mount; return plural ACP POST promise

Add a primary flag to RuntimeAcpMount so a secondary workspace's ACP connection cannot claim the CDP tunnel -- the claim is gated on activeMount.primary, matching the primary-only chrome-devtools MCP wiring. The plural /workspaces/:workspace/acp POST handler returns the dispatch promise instead of voiding it.

* refactor(cli): centralize ACP-HTTP enablement in resolveAcpHttpEnabled

Add resolveAcpHttpEnabled() as the single interpretation of the QWEN_SERVE_ACP_HTTP opt-out, replacing four independent env checks across mount, voice-WS advertisement, and CDP-MCP gating. Advertise workspace_qualified_acp only when the ACP HTTP surface is enabled AND multi-workspace sessions are active, so it is not announced when ACP HTTP is disabled.

* feat(cli): ACP dispose 503 gate + aggregate connection snapshot across mounts

After dispose() the shared ACP HTTP handlers (legacy /acp + workspace-qualified) return 503 server_disposed instead of racing torn-down registries during the shutdown drain. Add AcpHttpHandle.getSnapshot() aggregating connection and wsStream counts across the primary mount and every trusted secondary runtime, and switch the metrics sampler to it so daemon metrics report all workspaces' ACP connections rather than only the primary's.

* test(cli): cover ACP dispose 503, aggregate snapshot, and raw dot-segment WS reject

* docs(design): record Phase 4 ACP systematic rework (8-axis hardening)

Correct the Summary (the device-flow registry stays daemon-global and shared, not per-runtime) and add a section documenting the final architecture: runtime mount factory, routing/trust isolation, raw request-target WS parsing, daemon-global device-flow with event-sink fan-out, primary-only CDP, disposed 503 gate, aggregate getSnapshot, and resolveAcpHttpEnabled-gated capability advertisement.

* fix(cli): align /daemon/status ACP counts with the aggregate mount snapshot

Code review found a drift: the metrics sampler switched to the aggregate AcpHttpHandle.getSnapshot() (all mounts) while /daemon/status still read the primary-only registry snapshot, so the two observability surfaces diverged under multi-workspace. Extend AcpHttpSnapshot to aggregate all transport counters (connection/session/sse/ws streams + pending client requests) and feed the /daemon/status transport summary from it; per-connection diagnostics and the connection cap stay primary-scoped. Also refresh the device-flow-registry doc comment to the daemon-global shared model.

* test(cli): regression-test device-flow on a trusted secondary workspace

Locks in the reviewer Critical fix: a trusted secondary workspace's ACP now shares the daemon-global device-flow registry, so device_flow/start reaches provider resolution (an unsupported-provider error here) instead of erroring 'Device flow not configured'. Wires a shared DeviceFlowRegistry into the test harness and drives initialize + device_flow/start over the secondary WebSocket.

* docs(design): mark the superseded per-runtime device-flow section

Address PR #6621 review: the pre-rework 'Per-runtime device-flow registry' section contradicted Systematic rework axis 4 (daemon-global shared registry + fan-out). Flag it as superseded design-history so readers don't build the wrong mental model.

* refactor(cli): mount ACP only for trusted secondary workspaces

Address PR #6621 review suggestions: (1) skip creating a dispatcher/registry/remember-lane for untrusted non-primary workspaces (they are 403-rejected before any mount lookup), so they no longer appear as always-zero entries in the aggregate getSnapshot(); (2) test that a secondary workspace cannot claim the process-wide CDP tunnel (primary-only guard); (3) test that a WS upgrade to an unknown selector is rejected 400.

* test(cli): cover device-flow event fan-out across bridges

Address PR #6621 review: the resolveEventBridges fan-out (the reviewer Critical fix's core delivery path) had zero test coverage. Add unit tests that a device-flow event reaches every resolved bridge, that one bridge throwing does not block the others (best-effort), and that it falls back to the single bridge when no resolver is provided.

* fix(cli): report ACP connection pressure across all mounts

Address PR #6621 review: the connection_capacity_high warning read the primary mount's snapshot only, so a saturated secondary workspace was invisible. Compute the busiest mount from the aggregate snapshot (per-mount cap is uniform, opts.maxConnections) so any mount nearing capacity triggers the warning.

* test(cli): allow acp-http-enabled.ts in the serve process.env guard

Fix CI failure on PR #6621: the serve process.env guard flagged the new acp-http-enabled.ts as a direct process.env reader. It is the QWEN_SERVE_ACP_HTTP interpreter extracted from index.ts and serve-features.ts (both already allow-listed); QWEN_SERVE_ACP_HTTP is a daemon-level process-global toggle, so the file inherits their allow-list entry.

* docs: harden workspace-qualified ACP design

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

* docs: plan workspace-qualified ACP hardening

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

* fix(cli): align workspace-qualified ACP routing

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

* fix(cli): harden qualified ACP request errors

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

* test(cli): cover unmarked URIError fallback

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

* fix(cli): make ACP disposal terminal

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

* fix(cli): aggregate ACP connection diagnostics

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

* chore: remove review process artifact

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

* fix(cli): address workspace ACP review feedback

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

* fix(cli): finish ACP review follow-ups

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

---------

Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>
Co-authored-by: qwen-code-dev-bot <qwen-code-dev-bot@users.noreply.github.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

---------

Co-authored-by: qwen-code-dev-bot <qwen-code-dev-bot@users.noreply.github.com>
Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>
Co-authored-by: qqqys <qys177@gmail.com>
Co-authored-by: qwen-code-dev-bot <qwen-code-dev@service.alibaba.com>
Co-authored-by: qwen-autofix[bot] <qwen-autofix[bot]@users.noreply.github.com>
Co-authored-by: nas <156536069+Nas01010101@users.noreply.github.com>
Co-authored-by: Tianyuan <2720711917@qq.com>
Co-authored-by: han <2992336417@qq.com>
Co-authored-by: ytahdn <1294726970@qq.com>
Co-authored-by: ytahdn <ytahdn@gmail.com>
Co-authored-by: jinye <djy1989418@126.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-07-11 01:33:32 +00:00
易良
9163f3b61d
fix(cli): run periodic memory-pressure check in interactive UI to prevent OOM on quit (#6682)
The memory pressure monitor's performCheck() was only invoked after a tool
call completed, so a long interactive session with no tool calls never
triggered compact_history / cache eviction / GC. The heap could grow toward
the V8 limit and hard-OOM during the React unmount on quit (the 'Reached
heap limit Allocation failed' crash seen after /quit or Ctrl+C).

Add a 30s unref'd interval in startInteractiveUI that calls performCheck(),
cleared on cleanup. The quit/cleanup path also runs a final performCheck()
right before instance.unmount() so a near-limit heap is not pushed over the
edge by React reconciliation during unmount.

References: #5147, #4149, #4254.

Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>
2026-07-11 01:25:33 +00:00
chinesepowered
61ea72b3a6
fix(vscode-companion): don't override cursorPosition=0 to text.length (#2971)
A cursor genuinely at position 0 was being rewritten to text.length in two places in useCompletionTrigger, so @// trigger detection scanned text after the cursor:

- the container-node path used `offset || text.length`, so a valid offset of 0 fell through to text.length

- the effectiveCursorPosition computation forced `cursorPosition === 0` to text.length

Both paths now preserve a legitimate 0 while keeping the Math.min clamp that guards against the DOM offset exceeding the zero-width-space-stripped text length.

Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>
2026-07-11 01:18:39 +00:00
qwen-code-dev-bot
bcf5b7bfdd
fix(release): raise prepared package size limit to 96 MB (#6687) (#6691)
The assertPreparedPackageSize check introduced after v0.19.8 set an
80 MB ceiling, but the current package is 80.58 MB — 597 KB over —
causing the Docker sandbox build to fail during the v0.19.9 release.
Bump to 96 MB to accommodate normal growth with ample headroom.

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-07-11 01:01:59 +00:00
qwen-code-dev-bot
2db71f8b6b
fix(interactive): configure Docker sandbox networking for protocol tag retry test (#6690) (#6692)
The protocol-tags-interactive.test.ts started the fake OpenAI server
on 127.0.0.1 without Docker-aware host options, making it unreachable
from inside the Docker sandbox container. The CLI running in the
container tried to connect to 127.0.0.1 which resolved to the
container's own loopback, not the host where the test server listens.

Bind the fake server to 0.0.0.0 and advertise host.docker.internal
as the base URL host when QWEN_SANDBOX is docker or podman, matching
the established pattern in tool-control.test.ts. Also set NO_PROXY to
include host.docker.internal so the CLI does not route sandbox model
requests through an HTTP proxy.

Co-authored-by: qwen-autofix[bot] <qwen-autofix[bot]@users.noreply.github.com>
2026-07-11 01:01:50 +00:00
qqqys
2428741166
fix(channels): suppress nested subagent output (#6696) 2026-07-11 01:00:53 +00:00
chinesepowered
4aed60a362
docs(core): fix inaccurate token-limit comment and two comment typos (#6698) 2026-07-11 01:00:26 +00:00
Shaojin Wen
909f0fe744
docs(agents): add a bounded self-audit step to the pre-done workflow (#6685)
* docs(agents): add a bounded self-audit step to the pre-done workflow

Add a self-audit step to the general workflow: read the outgoing diff in
open-ended passes, then verify each change and each green test relied on
as evidence, presuming them wrong. Stop after two consecutive clean
passes or five passes total; a fix re-runs build/typecheck/tests and
resets the clean-pass count; effort scales with the diff. The build step
now also runs unit tests for changed files, review-triage fixes route
back through build and audit, and the feat-dev and bugfix skills point
to the new step at their review phases.

* docs(agents): close audit-bypass gaps from review

Address review findings on the self-audit step: a terminal pass can no
longer fix-and-exit (every fix requires a further pass over the updated
diff, a non-converged fifth pass is reported instead of declared done,
and the trivial-change shortcut now requires a clean pass), the outgoing
diff explicitly includes new untracked files, audit fixes in the skill
workflows re-run their verification phases before the audit resumes,
iteration rules re-run the self-audit after review fixes, and the phase
headings, frontmatter, and inline gists now reflect the embedded
self-audit.
2026-07-11 00:38:02 +00:00
qwen-code-ci-bot
40ed6b21d7
chore(release): v0.19.9 (#6693)
* chore(release): v0.19.9

* docs(changelog): sync for v0.19.9

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-07-11 00:35:15 +00:00
jinye
ff514476de
feat(cli): workspace-qualified ACP transport (daemon multi-workspace phase 4) (#6621)
* docs(design): add daemon multi-workspace phase 4 (workspace-qualified ACP) design

* feat(cli): add workspace-qualified ACP transport (issue #6378 phase 4)

Per-runtime ACP dispatcher at /workspaces/:workspace/acp (HTTP + WS) dispatched by URL path from the single upgrade listener; per-runtime device-flow + reverse client-MCP; owner-index via bridge lifecycle; untrusted/unknown rejected; legacy /acp unchanged; advertise workspace_qualified_acp for multi-workspace.

* fix(cli): keep per-runtime device-flow registry out of serve fast-path bundle

Phase 4 secondary-runtime device-flow statically imported createDeviceFlowRegistry into run-qwen-serve, pulling glob/@iarna/toml into the serve fast-path bundle and failing the closure check. Import it dynamically at the creation site; the check now passes and behavior is unchanged.

* refactor(cli): drop per-runtime device-flow for secondary workspaces

Follow-up to the fast-path fix: instead of dynamically importing createDeviceFlowRegistry for secondary runtimes, drop the per-runtime device-flow wiring entirely. Secondary ACP device-flow falls back to the dispatcher default, keeping the serve fast-path bundle closure clean without the dynamic-import indirection. WorkspaceRuntime.deviceFlowRegistry stays optional for a future per-runtime hook.

* fix(cli): share daemon-global device-flow across ACP mounts; harden WS path parsing

Secondary ACP mounts share the daemon-global device-flow registry (single instance per daemon) instead of a per-runtime one; the event sink fans out to every trusted runtime bridge so secondary ACP clients receive their own flow events, fixing the reviewer #6621 Critical and the CI test failure. Drops WorkspaceRuntime.deviceFlowRegistry. WS upgrade path is parsed from the raw request-target instead of new URL().pathname, rejecting %2e%2e / backslash / dot-segment traversal.

* refactor(cli): gate CDP claim on primary mount; return plural ACP POST promise

Add a primary flag to RuntimeAcpMount so a secondary workspace's ACP connection cannot claim the CDP tunnel -- the claim is gated on activeMount.primary, matching the primary-only chrome-devtools MCP wiring. The plural /workspaces/:workspace/acp POST handler returns the dispatch promise instead of voiding it.

* refactor(cli): centralize ACP-HTTP enablement in resolveAcpHttpEnabled

Add resolveAcpHttpEnabled() as the single interpretation of the QWEN_SERVE_ACP_HTTP opt-out, replacing four independent env checks across mount, voice-WS advertisement, and CDP-MCP gating. Advertise workspace_qualified_acp only when the ACP HTTP surface is enabled AND multi-workspace sessions are active, so it is not announced when ACP HTTP is disabled.

* feat(cli): ACP dispose 503 gate + aggregate connection snapshot across mounts

After dispose() the shared ACP HTTP handlers (legacy /acp + workspace-qualified) return 503 server_disposed instead of racing torn-down registries during the shutdown drain. Add AcpHttpHandle.getSnapshot() aggregating connection and wsStream counts across the primary mount and every trusted secondary runtime, and switch the metrics sampler to it so daemon metrics report all workspaces' ACP connections rather than only the primary's.

* test(cli): cover ACP dispose 503, aggregate snapshot, and raw dot-segment WS reject

* docs(design): record Phase 4 ACP systematic rework (8-axis hardening)

Correct the Summary (the device-flow registry stays daemon-global and shared, not per-runtime) and add a section documenting the final architecture: runtime mount factory, routing/trust isolation, raw request-target WS parsing, daemon-global device-flow with event-sink fan-out, primary-only CDP, disposed 503 gate, aggregate getSnapshot, and resolveAcpHttpEnabled-gated capability advertisement.

* fix(cli): align /daemon/status ACP counts with the aggregate mount snapshot

Code review found a drift: the metrics sampler switched to the aggregate AcpHttpHandle.getSnapshot() (all mounts) while /daemon/status still read the primary-only registry snapshot, so the two observability surfaces diverged under multi-workspace. Extend AcpHttpSnapshot to aggregate all transport counters (connection/session/sse/ws streams + pending client requests) and feed the /daemon/status transport summary from it; per-connection diagnostics and the connection cap stay primary-scoped. Also refresh the device-flow-registry doc comment to the daemon-global shared model.

* test(cli): regression-test device-flow on a trusted secondary workspace

Locks in the reviewer Critical fix: a trusted secondary workspace's ACP now shares the daemon-global device-flow registry, so device_flow/start reaches provider resolution (an unsupported-provider error here) instead of erroring 'Device flow not configured'. Wires a shared DeviceFlowRegistry into the test harness and drives initialize + device_flow/start over the secondary WebSocket.

* docs(design): mark the superseded per-runtime device-flow section

Address PR #6621 review: the pre-rework 'Per-runtime device-flow registry' section contradicted Systematic rework axis 4 (daemon-global shared registry + fan-out). Flag it as superseded design-history so readers don't build the wrong mental model.

* refactor(cli): mount ACP only for trusted secondary workspaces

Address PR #6621 review suggestions: (1) skip creating a dispatcher/registry/remember-lane for untrusted non-primary workspaces (they are 403-rejected before any mount lookup), so they no longer appear as always-zero entries in the aggregate getSnapshot(); (2) test that a secondary workspace cannot claim the process-wide CDP tunnel (primary-only guard); (3) test that a WS upgrade to an unknown selector is rejected 400.

* test(cli): cover device-flow event fan-out across bridges

Address PR #6621 review: the resolveEventBridges fan-out (the reviewer Critical fix's core delivery path) had zero test coverage. Add unit tests that a device-flow event reaches every resolved bridge, that one bridge throwing does not block the others (best-effort), and that it falls back to the single bridge when no resolver is provided.

* fix(cli): report ACP connection pressure across all mounts

Address PR #6621 review: the connection_capacity_high warning read the primary mount's snapshot only, so a saturated secondary workspace was invisible. Compute the busiest mount from the aggregate snapshot (per-mount cap is uniform, opts.maxConnections) so any mount nearing capacity triggers the warning.

* test(cli): allow acp-http-enabled.ts in the serve process.env guard

Fix CI failure on PR #6621: the serve process.env guard flagged the new acp-http-enabled.ts as a direct process.env reader. It is the QWEN_SERVE_ACP_HTTP interpreter extracted from index.ts and serve-features.ts (both already allow-listed); QWEN_SERVE_ACP_HTTP is a daemon-level process-global toggle, so the file inherits their allow-list entry.

* docs: harden workspace-qualified ACP design

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

* docs: plan workspace-qualified ACP hardening

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

* fix(cli): align workspace-qualified ACP routing

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

* fix(cli): harden qualified ACP request errors

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

* test(cli): cover unmarked URIError fallback

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

* fix(cli): make ACP disposal terminal

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

* fix(cli): aggregate ACP connection diagnostics

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

* chore: remove review process artifact

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

* fix(cli): address workspace ACP review feedback

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

* fix(cli): finish ACP review follow-ups

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

---------

Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>
Co-authored-by: qwen-code-dev-bot <qwen-code-dev-bot@users.noreply.github.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-07-11 00:24:01 +00:00
ytahdn
0ef3a76bda
feat(web-shell): add artifact right panel (#6591)
* feat(web-shell): add artifact right panel

* fix(web-shell): address artifact panel review feedback

* fix(web-shell): handle artifact panel review edge cases

* fix(web-shell): tighten scheduled task parsing

* fix(web-shell): address artifact panel review followups

* fix(web-shell): guard large file diff stats

* fix(web-shell): address review panel suggestions

* test(webui): stabilize heartbeat prompt cleanup test

* fix(web-shell): address artifact review refresh issues

* test(web-shell): stabilize ChatPane artifact hook mock

* fix(web-shell): clear stale session artifacts while loading

* fix(web-shell): preserve artifact tabs during refresh

* fix(web-shell): address artifact review followups

* fix(web-shell): respect workspace cwd for artifact outputs

* fix(web-shell): scope artifact panel actions to pane

* fix(web-shell): resolve split pane merge conflict

* fix(web-shell): clear stale artifact panel state

* fix(web-shell): preserve leading turn outputs

* fix(web-shell): tighten turn output selectors

* fix(web-shell): harden artifact preview sanitizer

* fix(web-shell): address artifact panel review regressions

* fix(web-shell): reconcile split pane artifact snapshots

* fix(web-shell): clear pane artifacts on session switch

* fix(web-shell): clear stale right panel snapshots

* fix(web-shell): repair scheduled task hint string

---------

Co-authored-by: ytahdn <ytahdn@gmail.com>
Co-authored-by: qwen-code-dev-bot <qwen-code-dev-bot@users.noreply.github.com>
2026-07-11 00:13:49 +00:00
qqqys
25f491d3ac
feat(dingtalk): mention response senders (#6679)
* docs: design DingTalk at-sender replies

* docs: plan DingTalk at-sender replies

* feat(channels): preserve session for response delivery

* feat(dingtalk): optionally mention response sender

* docs(dingtalk): explain response mentions

* fix(dingtalk): retain queued mention targets

* fix(dingtalk): bound mention target lifecycle

* fix(dingtalk): clear synthetic command mention target

* fix(dingtalk): clear buffered targets on session death

* debug(dingtalk): log mention delivery result

* fix(dingtalk): render response mentions

* fix(dingtalk): send visible response mentions

* feat(dingtalk): use text replies for mentions

* fix(dingtalk): preserve mentioned text replies
2026-07-11 00:08:13 +00:00
han
a130ce430e
fix(cli): localize approval mode UI labels (#6592)
* fix(cli): localize approval mode UI labels

* fix(cli): address approval mode i18n review

* fix(cli): stabilize approval mode i18n key

* test(cli): cover approval mode i18n follow-up

* test(cli): cover localized auto indicator

* test(cli): address approval i18n suggestions

---------

Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>
2026-07-11 00:07:03 +00:00
Tianyuan
075c3f03e5
feat(cli): forward ask_user_question answers from SDK can_use_tool (#6655)
* feat(cli): forward ask_user_question answers from SDK can_use_tool

SDK-hosted agents could receive ask_user_question calls through the
can_use_tool callback and approve them, but the user's answers never
reached the tool: the CLI called onConfirm(ProceedOnce) with no payload,
so the tool read an empty answers map and the model never got the
decisions.

Route updatedInput.answers from the SDK's allow response into the tool
confirmation payload so the collected answers reach the tool. Reuses the
existing updatedInput channel — no new SDK API or types. Document the
pattern in the TypeScript and Python SDK READMEs.

* fix(cli): forward ask_user_question answers on teammate approval path

Address review feedback on #6655:

- handleTeammateApproval now mirrors the leader path and promotes the
  user's answers from updatedInput into the confirmation payload, so
  ask_user_question calls approved through a teammate no longer drop the
  user's choices (wenshao).
- Extract a shared buildAllowConfirmationPayload helper used by both the
  leader and teammate paths, and only promote `answers` for
  ask_user_question so a same-named field on any other tool's input can't
  leak into the payload.
- Add tests for the teammate path and the defensive guards (array
  updatedInput, array/null/empty answers, foreign answers field).

* test(web-shell): stub Range client-rect methods to fix flaky CI

CodeMirror's async measure pass (scheduled via requestAnimationFrame)
calls getClientRects()/getBoundingClientRect() on a text Range. jsdom
implements these on Element but not on Range, so the call throws
"textRange(...).getClientRects is not a function" from a rAF callback
after the test completed. Vitest surfaces it as an unhandled error and
fails the whole run with exit code 1 even though every assertion passed
(seen intermittently in useComposerCore.dom.test.tsx).

Polyfill both methods on Range.prototype in the shared test setup,
mirroring the existing ResizeObserver/scrollIntoView stubs.

* refactor(cli): use ToolNames constant and broaden permission tests

Address review suggestions on #6655:

- buildAllowConfirmationPayload now gates answers-promotion on the
  ToolNames.ASK_USER_QUESTION constant instead of a bare string literal,
  so a future rename of the tool name is a compile-time break rather than
  a silent regression.
- Add an it.each case for a non-object primitive updatedInput (string) to
  cover the `typeof updatedInput !== 'object'` guard branch.
- Assert the leader path overrides toolCall.request.args with the host's
  sanitized updatedInput before confirming.
- Add a teammate-path test for an allow response with no updatedInput,
  asserting respond is called with (ProceedOnce, undefined).

---------

Co-authored-by: qwen-code-dev-bot <qwen-code-dev-bot@users.noreply.github.com>
2026-07-10 23:53:46 +00:00
nas
417fef2130
fix(core): keep YOLO mode when the model calls enter_plan_mode (#6630)
* fix(core): keep YOLO mode when the model calls enter_plan_mode

A model-initiated enter_plan_mode call from YOLO silently switched the
session into the read-only Plan mode, surprising users who explicitly
chose YOLO for low-friction execution and then blocking the reads/writes
they expected to proceed. Genuine user-driven plan-mode entries
(Shift+Tab, /plan) call setApprovalMode directly and never route through
this tool, so guarding the tool only affects the model deciding to plan
on its own. From YOLO the tool now keeps the current mode and returns a
message telling the model to continue planning without switching.

Fixes #5970

* fix(core): gate the YOLO plan-mode guard on an explicit user request

Addresses review feedback on #6630.

The previous guard suppressed every enter_plan_mode invocation while the
session was in YOLO mode. That fixes the unsolicited switch reported in
#5970, but it also blocks the legitimate path: the tool description tells
the model to call this tool only after the user explicitly asks, and
/plan is interactive-only (supportedModes: ['interactive']) with no
Shift+Tab equivalent. In a headless or ACP YOLO session the tool is the
only door into plan mode, so a blanket guard made an explicit user
request unreachable.

Add an optional userRequested flag to the tool schema and only no-op when
the entry is NOT user-requested. A user-requested entry still goes through
setApprovalMode(PLAN, { enteredByModel: true }) so the Plan Approval Gate
on exit continues to run for AUTO/YOLO sessions (#5574).

* fix(core): address review suggestions on the YOLO plan-mode guard

- Log via debugLogger.info when the guard suppresses a model-initiated
  entry, so a "I asked for plan mode and nothing happened" report is
  diagnosable by grepping ENTER_PLAN_MODE (the other early-return paths
  already log).
- Strengthen the userRequested:false test to assert on the returned
  llmContent/returnDisplay, matching the unsolicited-entry sibling test.
- Add a defensive test pinning that userRequested is inert outside
  YOLO: DEFAULT with the flag set enters plan mode normally.

---------

Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>
2026-07-10 23:50:57 +00:00
qwen-code-dev-bot
b2601c8613
fix(interactive): configure Docker sandbox networking for protocol tag retry test (#6684) (#6689)
The protocol-tags-interactive.test.ts started the fake OpenAI server
on 127.0.0.1 without Docker-aware host options, making it unreachable
from inside the Docker sandbox container. The CLI running in the
container tried to connect to 127.0.0.1 which resolved to the
container's own loopback, not the host where the test server listens.

Bind the fake server to 0.0.0.0 and advertise host.docker.internal
as the base URL host when QWEN_SANDBOX is docker or podman, matching
the established pattern in tool-control.test.ts. Also set NO_PROXY to
include host.docker.internal so the CLI does not route sandbox model
requests through an HTTP proxy.

Co-authored-by: qwen-autofix[bot] <qwen-autofix[bot]@users.noreply.github.com>
2026-07-10 19:06:55 +00:00
qqqys
ebd83f1d2d
fix(release): raise package size budget to 85 MiB (#6688) 2026-07-10 18:24:39 +00:00
Shaojin Wen
65393d0377
feat(daemon): record & query sub-session parentSessionId; drop isolated scheduled-task mode (#6676)
Some checks are pending
E2E Tests / web-shell Browser Regression (push) Waiting to run
E2E Tests / E2E Test (Linux) - sandbox:docker (push) Waiting to run
E2E Tests / E2E Test (Linux) - sandbox:none (push) Waiting to run
E2E Tests / E2E Test - macOS (push) Waiting to run
* feat(daemon): record sub-session parentSessionId; drop isolated scheduled-task mode

Two changes bundled from this session (recovered after an external
merge-test harness force-reset the worktree):

1. Remove the scheduled-task "isolated" run mode and its precondition
   machinery. All tasks now run in their bound session (shared). The
   create_sub_session tool is retained so users can request isolation
   from a prompt. Drops runMode/condition/withheld across the persistence
   type, scheduler, Session dispatch, REST route, Web Shell UI, i18n, and
   the daemon/SDK contract, with tests updated.

2. Add an immutable parentSessionId to sub-sessions created via
   create_sub_session, wired end to end: BridgeSpawnRequest -> SessionEntry
   -> session summary, persisted into the child transcript (new
   parent_session record + qwen/control/session/parent ext-method) and
   rehydrated by listSessions on daemon restart, surfaced on
   BridgeSessionSummary / DaemonSessionSummary.

* test(daemon): cover sub-session parentSessionId end to end

- chatRecordingService: recordParentSession writes a parent_session record
- sessionService: listSessions reads parentSessionId back from the transcript,
  including the head-window fallback past the 64KB tail
- bridge: spawnOrAttach threads parentSessionId to the session summary and
  dispatches the sessionParent ext-method (and not when there is no parent)
- create-sub-session launcher: passes callerSessionId as parentSessionId

* feat(daemon): add parentSessionId filter to the session list API

GET /workspace/:id/sessions accepts a `parentSessionId` query param that
returns only the sessions spawned by that parent (via create_sub_session).
The default path gathers the whole workspace (persisted + live) and filters
before paginating, so a page is never short of matches; results are sorted
newest-activity-first with an opaque activity cursor. Rejected (400) when
combined with view=organized. Threaded through the SDK
(DaemonSessionListPageOptions.parentSessionId / listWorkspaceSessions).

* test(daemon): cover the parentSessionId session-list filter

Response-builder cases: filters to a parent's children, empty when none,
paginates the filtered set completely (no dupes/gaps). Route cases: the
query param filters GET /workspace/:id/sessions, 400s with view=organized
(invalid_parent_session_filter) and on an empty value
(invalid_parent_session_id).

* fix(daemon): address review — fail closed on removed scheduled-task fields; scope & persist parentSessionId

Review follow-ups on the isolated-removal + parentSessionId work:

- scheduled-tasks REST: reject a POST/PATCH that still carries `runMode` or
  `condition` (400 unsupported_field) instead of silently ignoring them, so a
  stale SDK / cached Web Shell fails closed rather than getting a plain
  unconditional task in place of the guarded one it asked for.
- cron scheduler: a legacy on-disk task that still carries a `condition`
  precondition is skipped (left on disk), not run inline unconditionally —
  a removed safety gate must not silently become "always run". One-time
  operator breadcrumb points at remediation.
- bridge: await + verify the sessionParent persistence instead of
  fire-and-forget, so a dropped transcript write is surfaced loudly rather
  than silently degrading the parent link to live-only after a restart. The
  child is not rolled back on failure.
- session list: the ?parentSessionId= page cursor now binds its
  parentSessionId + archiveState and rejects a cursor replayed against a
  different parent / archive scope, matching the organized cursor contract.

Tests added for all four.

* fix(daemon): address review round 2 — legacy tasks fail closed on all paths; surface parentSessionId persistence outcome

- cron: remove obsolete callback-level "guarded task" tests (headless +
  interactive) — the guard moved to the scheduler load (fail-closed), so
  those callbacks never receive a guarded job. Fixes the CI failures.
- scheduled-tasks REST: a legacy on-disk task that still carries a
  `condition` is now failed closed on EVERY path, not just the scheduler
  tick — GET reports it `enabled:false` with no `nextRunAt`, and POST /run
  rejects it (409 task_legacy_unsupported). Shared `taskHasLegacyCondition`
  helper (exported from core) is the single source of truth.
- bridge: the sub-session parent-lineage write is now timeout-bounded
  (withTimeout, like the other init round-trips) and retried, and its
  outcome is surfaced to the caller via BridgeSession.parentSessionPersisted
  (threaded through the launcher → ext-method → spawner → tool) instead of
  only stderr. create_sub_session warns the model when the link is
  live-only. Requires persisted===true for success.

Tests added for all of the above.

* fix(daemon): reject enabling a legacy guarded task via PATCH

Follow-up: toView reports a legacy `condition` task as disabled, so the
only PATCH the Web Shell sends for it is the Enable toggle. Accepting that
(200) then reading back disabled again is an Enable control that can never
succeed with no error. PATCH `{enabled:true}` on such a task now returns
409 task_legacy_unsupported with the recreate remediation. Test added.

* fix(daemon): address review round 3 — warn on legacy isolated tasks; idempotent parent record; perf + dedup

Addressing ytahdn's review:
- cron: a bare `runMode: 'isolated'` task (no precondition) has no safety
  gate, so it still fires — but it now accumulates history in its bound
  session instead of a fresh per-run one. It runs, with a one-time
  operator warning (the condition subset still fails closed). New shared
  `taskHasLegacyRunMode` helper.
- chatRecordingService: `recordParentSession` is now idempotent (skips a
  repeat append for the same immutable lineage) — matters because the
  bridge write is now retried.
- sessionService: read `parentSessionId` from the records already loaded
  for the listing instead of a second per-file open (the record is written
  at creation, within the scan window) — removes the extra I/O on the hot
  listing path.
- session-list: extract the persisted+live merge into one
  `mergeLiveSessionSummary` helper (was duplicated across the default,
  organized and by-parent paths).

Tests: legacy-runMode fires+warns-once, recordParentSession idempotency,
and the acpAgent sessionParent ext-method handler (valid / no-recording /
invalid-params).

* fix(daemon): address deep review — lineage on fork/restore/SDK; durable parent write; legacy tasks fail closed everywhere

GPT-5 review round + a two-pass reverse audit:

- forkSession no longer copies the source's `parent_session` record, so a
  fork is a fresh top-level session, not a phantom child of the original.
- restore/resume now re-seed the persisted `parentSessionId` on the live
  entry (both the REST handler and the ACP-HTTP transport — the audit caught
  the ACP path being missed), so a restored sub-session still reports its
  parent after a daemon restart.
- SDK: the ACP route mapping + `session/list` dispatcher now forward,
  filter, and project `parentSessionId`; `WorkspaceDaemonClient` serializes
  it too — the filter works over every SDK transport, not just the root HTTP
  client.
- recordParentSession is awaited via the strict append path, so
  `persisted: true` never claims a write that silently failed; it stays
  idempotent so a retry can't double-append.
- bridge parent-write is raced against transport close and treats a timeout
  as terminal (not a retry that would overlap an in-flight request), under
  one deadline.
- legacy guarded tasks (removed isolated mode + precondition) now fail closed
  on ALL consumers — cron_list reports them disabled, keepalive won't bind or
  keep their sessions resident — not just the scheduler tick.
- a bare legacy `runMode: 'isolated'` task (no gate) still runs, with a
  one-time behavior-change warning.
- restored `withheld` as a read-only compat field so pre-upgrade withheld
  run-history is marked "skipped", not shown as a successful run.

Tests added/updated across all of the above.

---------

Co-authored-by: qwen-code-dev-bot <qwen-code-dev-bot@users.noreply.github.com>
2026-07-10 17:15:13 +00:00
曹潇缤
998d36068b
feat(qqbot): group message handling and cron-msg-experimental (#6457)
* feat(qqbot): group message handling and cron-msg-experimental

Adds group message handling with keyword triggers, @-mention detection,
cron-msg-experimental support, streaming idle-flush with DeliveryError,
token refresh reconnect fallback, and comprehensive test coverage.

Supersedes PR #6206.

* fix(qqbot): address PR #6457 review threads — cron retry, token guard, lifecycle cleanup

- Fix tokenReconnectId guard: capture _reconnectId after disconnect() so
  reconnectWithRetry fires correctly after 10 token refresh failures.
- Cron flush catch: only delete buffer for RETRY_EXHAUSTED; re-schedule
  flush with 5s delay for transient errors (RATE_LIMITED, FALLBACK_FAILED).
- Log dropped cron buffer when router.getTarget returns null (silent loss).
- sendMessage: throw DeliveryError('RATE_LIMITED') when active messages
  disabled, so callers can detect the policy block instead of treating
  the silent return as success.
- handleGroup: persist chatTypeMap on new group detection to survive
  crashes between group join and next debounced save.
- connect(): remove isReconnecting reset (prevents double reconnect),
  add serverRequestedReconnect=false reset.
- handleGroupDelRobot: clean flushingSessions/pendingStreamDelete/
  flushedSessions when removing streamState entries for deleted group.
- reconnectWithRetry: always increment reconnectAttempts regardless of
  gwCalled flag, so maxReconnectAttempts FATAL guard triggers even
  when fetchToken fails on every attempt.

* fix(qqbot): address PR #6457 review threads — ACTIVE_MSG_DISABLED, GroupGate isMentioned, cron pendingRetry, reconnectId guard, dedup log ordering

- Add ACTIVE_MSG_DISABLED DeliveryErrorCode for admin-policy blocks
- Treat ACTIVE_MSG_DISABLED as permanent in cron/flush handlers
- Set isMentioned=true for non-@-bot messages passing keyword/all policy
  so GroupGate.requireMention doesn't silently drop them
- Add pendingRetry recovery when cron retry timer cancelled by new text
- Add _reconnectId guard in reconnectWithRetry to prevent stale chains
- Reorder handleGroupAll author/bot checks before chatTypeMap persistence
- Schedule idleFlush for residual buffer after RETRY_EXHAUSTED
- Add retryCount check in buffer-exceeds-limit idleFlush path
- Add future-timestamp upper-bound in replyMsgId restore validation
- Move slash/active-msg logs after dedup to prevent duplicate on WS replay
- Update far-future timestamp test to match new validation
- 251 tests pass, tsc clean

* fix(qqbot): address remaining PR #6457 review threads — 20 fixes across lifecycle, cron, routing, validation, and tests

* fix(qqbot): make reconnect/flush/gateway retry limits configurable, revert isMentioned override

- maxReconnectAttempts, maxFlushRetries, maxGwRetries exposed via qqConfig
- 0 or negative value disables the limit (unlimited mode)
- Revert Thread #17: restore isMentioned=isAtBot in handleGroupAll
- Non-@-bot group message routing controlled via GroupGate requireMention
  config (use requireMention: false with keyword/all policy to enable)

* docs(qqbot): add requireMention warning when groupAllPolicy is keyword/all without explicit false

* fix(qqbot): address review — isReconnecting leak, cron retry duplicate, _ready on close, cleanup ordering, plus 13 suggestions

* fix(qqbot): add restoreQQState diagnostic logs, extract finalizeReady, and test coverage for resolveRoute/flushAndTrack/sendIdentify

* fix(qqbot): enforce sessionScope=single when groupAllPolicy is keyword/all

* fix(qqbot): address 12 review suggestions — bufferFlushLength fix, isValidChatId, fence-post, dead code, method extraction, cleanup, tests

* fix(qqbot): cron retry data-loss guards, reconnectAttempts double-increment

* feat(qqbot): implement passive-to-active message fallback chain (md→md active→text active)

* fix(qqbot): address ci-bot review — config clone, finalizeReady in RESUME, remove dead isCrossEventDuplicate, keyword NFC boundary, add logs

* fix(qqbot): safeContent for slash/C2C, orphan cron guard, extractBotOpenId timing, FALLBACK_FAILED as permanent, onSessionDied single-scope guard

* fix(qqbot): finalizeReady TOCTOU guard, cron text drop log, cron buffer identity checks

* fix(qqbot): add missing logs, safeContent slash detection, gate OPENID on allowMention, deduplicate comment, show full senderOpenId

* test(qqbot): add coverage for 7 gaps — flushAndTrack concurrent, cron assertion, persistence rename, ws close state, active guard, re-buffer exhaustion, empty keywords

* fix(qqbot): reconnectAttempts loop placement, permanent error retry loop, cron retry transient guard, connect reset tryResume

* fix(qqbot): cron retry backoff + permanent error discrimination + single-scope cleanup

Fix 4 issues from ci-bot review:

1. handleGroupDelRobot cron cleanup used router.getTarget which is
   broken in single scope (shared session returns last-routed group).
   Switch to streamState-based matching.

2. Innermost cron retry .catch() unconditionally deleted buffer.
   Add DeliveryError code discrimination: only delete for permanent
   errors (RETRY_EXHAUSTED, ACTIVE_MSG_DISABLED, FALLBACK_FAILED).
   For transient, log with toFlush.length + sessionId.

3. Cron retry chain had no upper bound with fixed 5000ms delay.
   Add retryCount?: number to cronBuffer entry type. Increment per
   attempt. Use exponential backoff (5s/10s). Cap at 3 total attempts.

4. FALLBACK_FAILED missing from cron permanent error list (already
   classified as permanent in flushAndTrack). Add to both cron
   permanent-error conditions.

Update tests to match new behavior:
- cron.test.ts: use RATE_LIMITED (still transient) instead of
  FALLBACK_FAILED (now permanent) for retry-path test
- events.test.ts: populate streamState alongside cronBuffer for
  the streamState-based cleanup matching
2026-07-10 16:40:46 +00:00
qwen-code-dev-bot
dde67b8e39
feat(core): add forceGlobalCacheScope for Anthropic proxy providers (#6643)
* feat(core): add forceGlobalCacheScope for Anthropic proxy providers (#6642)

Allow users to opt-in to `scope: 'global'` on Anthropic cache_control
entries even when the base URL is not an Anthropic-native origin. This
enables cross-session prompt caching through proxy providers (e.g.
Routify, OpenRouter) that forward the `prompt-caching-scope-2026-01-05`
beta, significantly improving cache hit rates (from ~20% to ~60-80%)
and reducing input token costs by 3-4x.

Usage: set `forceGlobalCacheScope: true` in the model's generationConfig
within the provider settings.

Changes:
- Add `forceGlobalCacheScope` field to ContentGeneratorConfig
- Update `useGlobalCacheScope()` to check the new field
- Add to MODEL_GENERATION_CONFIG_FIELDS for provider config passthrough
- Wire through handleModelChange hot-update path
- Add 2 tests (opt-in on proxy URL, suppression when caching disabled)

* fix(core): add forceGlobalCacheScope to settings schema and fix stale JSDoc (#6643)

- Add forceGlobalCacheScope entry to settingsSchema.ts and settings.schema.json
  so users get autocomplete and validation for the new field
- Update stale JSDoc comments that still said gate requires Anthropic-native
  baseURL without mentioning the forceGlobalCacheScope opt-in path
- Extend existing handleModelChange hot-update test to cover forceGlobalCacheScope
  round-trip (value and source)

---------

Co-authored-by: qwen-code-dev-bot <269191875+qwen-code-dev-bot@users.noreply.github.com>
Co-authored-by: 易良 <1204183885@qq.com>
Co-authored-by: qwen-code-ci-bot <qwen-code-ci-bot@users.noreply.github.com>
2026-07-10 16:35:50 +00:00
jinye
38384ae7b9
feat(serve): Add cursor-paged transcript replay endpoint (#6525)
* feat(serve): Add cursor-paged transcript replay endpoint

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

* fix(cli): Bound transcript replay indexing

Limit transcript index builds to bounded snapshots and surface oversized transcript errors as 413 responses. Give transcript status calls a dedicated timeout and update the capabilities integration baseline.

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

* fix(core): Validate transcript cursors

Sign transcript cursors so forged snapshot sizes cannot bypass the index cache, and keep hasMore tied to persisted record availability when replay conversion returns a partial page.

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

* fix(core): Lazy-init transcript cursor secret

Avoid generating the transcript cursor HMAC key while importing the core barrel so unrelated tests with narrow crypto mocks can load core without requiring randomBytes. Keep the VS Code companion crypto mock partial so it only replaces the auth-token UUID behavior it asserts on.

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

* fix(serve): Address transcript replay review suggestions

Mark bounded replay truncation frames as having a transcript endpoint, sanitize paged transcript replay conversion errors, and remove the core reader's incomplete pre-encoded cursor field so cursors are only emitted after replay continuation state is merged.

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

* fix(serve): Stabilize transcript replay pagination

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

* fix(core): Avoid quadratic transcript line scanning

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

* fix(core): Mark transcript history gaps

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

* fix(core): Address transcript reader review comments

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

* fix(serve): Address transcript replay review feedback

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

* fix(serve): align transcript cursor preflight errors

Return transcript snapshot conflicts for cursor pagination when the active JSONL can no longer be found during route preflight. Add route-level and integration coverage for full transcript paging, and document the boolean fullTranscriptAvailable SDK contract.

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

* test(cli): Cover paged dangling tool call replay

Add a HistoryReplayer.replayPage regression test that carries a dangling tool call through pendingToolCalls and finalizes it on a later page.

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

* fix(core): Bound transcript index cache bytes

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

* fix: Address transcript replay review follow-ups

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

* fix(cli): Preserve pending tool calls on transcript replay errors

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

* codex: address PR review feedback (#6525)

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

* codex: fix CI failure on PR #6525

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

* fix(serve): warm transcript-replay tools leniently

The read-only transcript-replay Config sets skipSkillManager, but Config.initialize() still runs toolRegistry.warmAll({ strict: true }), which constructs SkillTool whose constructor throws when no SkillManager exists. The throw escaped the replay try/catch and surfaced as JSON-RPC -32603, so GET /session/:id/transcript returned HTTP 500 for every persisted session.

Add a lenientToolWarmup initialize option and set it for the replay Config so tools that cannot construct under the deliberately-skipped subsystems are logged and skipped instead of aborting initialize(). Replay only needs optional tool_call metadata and ToolCallEmitter already falls back to the recorded tool name, so buildable tools keep full title/kind. This supersedes the narrower excludeTools:[Skill] guard, which is removed.

* fix(core): invalidate transcript index cache on in-place rewrites

An in-place transcript rewrite that keeps the inode and byte length (e.g. rsync --inplace or a redaction pass) reused a stale cached index, because makeCacheKey() keyed only on path:dev:ino:size. readSegmentRecords then found each recorded offset parsing to a different uuid and dropped it, so GET /session/:id/transcript answered 200 with an empty events array instead of the documented 409.

Include the file mtime in the index cache key so a fresh read after a same-size rewrite rebuilds the index, and raise SessionTranscriptSnapshotUnavailableError (-> 409) on a uuid mismatch or missing fragment instead of silently returning a short/empty transcript. Also make the qwen-serve docs explicit that at the default --channel-idle-timeout-ms 0 each page rebuilds the index (O(snapshotSize)).

* codex: address PR review feedback (#6525)

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

* qwen: fix CI failure on PR #6525

The Run ESLint step failed on vitest/valid-expect in packages/acp-bridge/src/bridge.test.ts: the getSessionTranscriptPage timeout test stores expect(request).rejects.toBeInstanceOf(BridgeTimeoutError) and awaits it only after advancing the fake timers (a deliberate deferred await so the pending timeout rejection has a handler before it fires). Auto-fixing would add an inline await and deadlock the test, so scope-disable the rule on that assignment with a rationale. lint:ci and the affected test pass.

* qwen: address PR review feedback (#6525)

Withhold nextCursor on a mid-page transcript replay error. When collectHistoryReplayUpdatesPage catches a replayError partway through a page, records after the failed one are dropped and pendingToolCalls reflect partial state; still emitting nextCursor advanced the client past the dropped records and carried corrupted pendingToolCalls forward (phantom in-progress tool calls on later pages). Now nextCursor is withheld whenever replay.replayError is set — the page is already flagged partial + replayError, so the client stops instead of paginating with corrupted cursor state. Update the handler test to assert no cursor is issued on a replay error.

* qwen: address PR review feedback (#6525)

Log when parseTranscriptReplayState drops malformed pending tool calls from a replay cursor. Previously rawPending.filter(isPendingReplayToolCall) silently discarded entries that no longer matched the shape (e.g. a cursor from a newer daemon or corrupted in transit), turning a version-mismatch/corruption into a hard-to-diagnose 'tool never completed' artifact on later pages. Now emit a debug warning with the dropped/total counts; behavior is otherwise unchanged.

* fix(serve): address transcript review feedback

Dispose superseded replay configs, preserve structured resolution errors, sanitize multi-workspace failures, and expand transcript replay coverage across unit and real-daemon integration paths.

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

* qwen: address transcript review feedback (#6525)

- [Critical] Map a missing transcript session to HTTP 404: the child throws a raw resourceNotFound (ENOENT without a cursor) that fell through sendBridgeError to 500. bridge.getSessionTranscriptPage now translates it to SessionNotFoundError, mirroring the load/resume path, with a bridge test.
- Dedup the untrusted-session-owner 403 onto the shared sendUntrustedWorkspaceResponse so the response format/message stay consistent across session routes (route logging + context preserved).
- Add coverage for parseTranscriptReplayState's non-object replay branch (cursor replay=garbage) -> empty pendingToolCalls + default cumulativeUsage.
- Document that cursorHmacKeys are cached for the daemon lifetime (external key rotation requires a restart).

* qwen: adopt transcript review suggestions (#6525)

- Add a handler test that a mid-page replay error preserves already-emitted events (events>=1) alongside partial+replayError and withholds the cursor.
- Add a two-call handler test for the cross-page cumulativeUsage round-trip: page 1 folds the bumped usage into the encoded cursor; page 2 decodes and propagates it into the replay context.
- Log (not silently drop) a superseded structured error in the multi-workspace transcript resolution fallback.

* qwen: clean up transcript test fixtures to fix no-AK CI flake (#6525)

The transcript-paging integration suite wrote ~6 persisted chats/*.jsonl sessions into the daemon's project dir and never removed them. Because vitest runs a file's suites sequentially, those leftover sessions widened a pre-existing race in the later 'PATCH /session/:id/metadata > updates displayName' test (a freshly-created session can exist on disk but not yet appear in the listWorkspaceSessions page), making it fail deterministically in the no-AK smoke run. Add an afterAll to the transcript suite that removes the project chats/ dir, restoring a clean session list for subsequent suites. Verified: full no-AK suite now passes 43/43 across repeated runs.

* qwen: harden transcript reader test timestamps + assert page fields (#6525)

The record() helper derived the ISO timestamp seconds from text.length, producing invalid values (e.g. 00:00:013) once a record's text reached 10+ chars — harmless today only because no test asserted startTime. Replace it with a monotonic base+offset timestamp (always valid, strictly increasing). Also assert the previously-unchecked required SessionTranscriptRecordPage fields (sessionId, filePath, startTime, lastUpdated); the strict-ISO checks on startTime/lastUpdated guard against the timestamp-helper class of bug.

---------

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: qwen-code-dev-bot <qwen-code-dev-bot@users.noreply.github.com>
2026-07-10 16:34:43 +00:00
jinye
2523a36b52
feat(web-shell): workspace management sidebar with dynamic registration (daemon multi-workspace phase 4) (#6625)
* feat(web-shell): add workspace picker for new sessions (issue #6378 phase 4)

Multi-workspace daemons now show a new-session workspace picker in the sidebar (default primary, untrusted disabled); the chosen workspace cwd is sent on POST /session so the session spawns in that workspace. daemon-react-sdk createSession gains an optional per-call workspaceCwd override covering both the detached and active-session paths; omitting it preserves the previous primary behavior.

* feat(web-shell): workspace management with dynamic registration

Replace the new-session workspace picker with a full workspace
management sidebar. Registered workspaces render as a parallel,
collapsible list (folder icon per workspace), each with its own
sessions nested underneath, and a "+" entry registers an existing
directory as a new workspace at runtime with no daemon restart.

Backend: WorkspaceRegistry becomes mutable (add()/onChange()); a new
POST /workspaces route validates the directory (exists, not a
duplicate, not nested) and registers it; run-qwen-serve exposes a
runtime factory that builds a complete workspace runtime (bridge, fs
factory, channel factory, workspace service) on demand. The SDK
DaemonClient and daemon-react-sdk gain addWorkspace().

* fix(web-shell): show newly registered workspace without a reload

Registering a workspace via the sidebar "+" left the list unchanged
until a full page reload. handleAddWorkspace called
workspace.getCapabilities(), which returns a cached promise and only
feeds setCapabilities from the mount effect, so the refresh was a no-op.

Add DaemonWorkspaceProvider.refreshCapabilities(): it bypasses the
promise cache, issues a fresh /capabilities fetch, and pushes the
result into state so consumers re-render. handleAddWorkspace now awaits
it (best-effort, so a refresh failure never masks a successful
registration).

* fix(web-shell): address review feedback for workspace management

- registry: list() returns a frozen snapshot so callers can't mutate the
  internal runtimes array (restores the push()-throws invariant)
- POST /workspaces: reject relative paths on the raw input, canonicalize
  via realpath so symlink aliases can't bypass the duplicate/nesting
  checks, and serialize concurrent registrations to close a TOCTOU race
  that leaked bridge/channel infrastructure
- sidebar: restore a compact single-workspace project header (name,
  search toggle, collapse) so single-workspace users keep those
  affordances and searchOpen/projectExpanded are no longer dead
- daemon session: include the target workspace in the create-session
  failure message
- tests: rework WebShellSidebar tests for the WorkspaceSection UI (add
  the useWorkspace mock, query workspace buttons, cover primary->undefined),
  use the canonical DaemonWorkspaceCapability type, and add a createSession
  workspaceCwd forwarding test

* fix(cli): harden dynamic workspace registration per review

- POST /workspaces: bound cwd by MAX_WORKSPACE_PATH_LENGTH before any
  filesystem work, and return a generic 500 (log the full error to
  stderr) so responses can't leak internal filesystem paths
- createDynamicWorkspaceRuntime: log a stderr warning when a workspace's
  settings can't be read, matching the startup secondary-workspace path

* qwen: address PR review feedback (#6625)

Dynamic workspace reloadDaemonEnv now mirrors the startup secondary path:
after reloadEnvironment() it rebuilds the runtime env via
buildRuntimeEnvironment(), calls wsEnv.replace(), and updates the env
metadata (envFileReadFailed / envFileReadFailures / overlayKeys /
envFilePaths). Without this, .env changes on a dynamically registered
workspace never propagated to that workspace's spawned child processes.

* qwen: address PR review feedback (#6625)

Harden POST /workspaces and the workspace registry per review:
- canonicalize with realpathSync.native (matches startup) so the same
  physical dir on a case-insensitive FS can't register twice
- nesting guard now also checks in-flight registrations, closing a
  concurrent parent/child registration race
- error responses no longer echo resolved/other-workspace paths
- registry add() isolates onChange listener throws so a bad listener
  can't abort a caller after the workspace is already committed

* qwen: address PR review feedback (#6625)

- POST /workspaces: cap total registered workspaces (startup + dynamic)
  to guard against unbounded registration exhausting resources
- createDynamicWorkspaceRuntime: register shutdown-cleanup arrays only
  after the runtime is fully built, so a throw during workspace-service
  construction can't orphan the bridge/channel
- web-shell App: reset selectedWorkspaceCwd after session creation so the
  workspace picker is one-shot (next new chat defaults to primary)

* qwen: address human review suggestions (batch 1)

- WorkspaceSection: add console.warn on session-poll failure (was silent)
- WorkspaceSection: add aria-expanded for screen readers
- AddWorkspaceDialog: associate label/input (htmlFor/id), i18n the
  absolute-path error, accept Windows drive-letter paths
- i18n: remove unused workspaceUntrustedHint key, add addWorkspaceAbsError

* qwen: address human review suggestions (batch 2)

- Remove dead CSS (.workspacePickerSelect, .workspaceItem* classes from
  the old select-based picker, replaced by WorkspaceSection)
- Add title tooltip to single-workspace project name (shows full path)
- WorkspaceSection: sync expanded state on workspace.primary change

* qwen: address human review suggestions (batch 3)

- DaemonWorkspaceProvider: refreshCapabilities now clears error on
  success and sets error+status on failure (was incomplete vs mount)
- Remove unused onChange/WorkspaceRegistryEvent from workspace registry
  per simplicity-first (no consumer exists; defers API surface until
  a real subscriber like SSE push is needed)

* qwen: add workspace-management route test coverage

Tests cover: 501 (no factory), 400 (missing/empty/relative/long/
nonexistent cwd), 409 (duplicate canonical path), 201 (success),
and verifying error messages are generic (no path leak).

* qwen: fix CI build failure — add explicit types in route test

The CLI's tsconfig includes test files in tsc --build, so all
noImplicitAny violations in tests cause build failures. Add explicit
type annotations to mock parameters.

* qwen: add type/title to single-workspace add-button

---------

Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>
2026-07-10 16:30:20 +00:00
jifeng
7328341a71
feat(web-shell): improve markdown table readability (#6626)
* feat(web-shell): improve markdown table readability

* fix(web-shell): address table readability review issues

* fix(web-shell): align row detail values consistently

* fix(web-shell): address table review blockers

* fix(web-shell): refine table readability state

* fix(web-shell): flatten tabs in table TSV copy

---------

Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>
2026-07-10 16:26:20 +00:00
易良
661b70a874
fix(core): retry leaked protocol turns (#6603)
* fix(core): strip leaked protocol summary tags

* refactor(core): remove stale analysis block stripper

* test(cli): add protocol tag leak interactive mock

* docs: add protocol tag tmux evidence report

* test(core): cover tagged retry discard evidence

* test(core): cover protocol tag retry filtering

* test(integration): cover protocol tag filtering after retries

* test(core): trim protocol tag retry coverage

* test(integration): assert exact retry replay

* fix(core): sanitize protocol tags at chat stream boundary

* fix(core): harden protocol stream retry handling

* chore: drop unrelated merge formatting

* test(integration): cover hidden SSE disconnect retry

* test(core): harden sanitizer coverage and add review feedback

Address review suggestions:
- Add edge case tests: single-char chunk splitting, adversarial
  prefixes (<analyze>, <suitor>), whitespace-only flush, reset+reuse,
  nested analysis-inside-summary-inside-analysis
- Add inline comments on bidirectional prefix check in classifyTagStart
  to prevent future maintainers from mistaking one direction for a typo
- Add debug log on first protocol tag suppression in stream processing
  to aid diagnosing 'model response disappeared' incidents

* test(cli): isolate cli entry fallback fixture

* fix(core): harden protocol tag sanitization

* fix(core): preserve literal protocol tag mentions

* test(webui): stabilize heartbeat prompt cleanup test

* fix(core): preserve visible protocol tag literals

* fix(core): align streaming sanitizer with batch on summary-internal analysis

The streaming protocol-tag filter dropped visible text after a literal
`<analysis>` mention inside a visible `<summary>`, e.g.
`<summary>Fix: replace <analysis> tag ...</summary>` streamed as
`Fix: replace ` while the batch sanitizer correctly kept the literal
mention. Distinguishing a paired analysis block (hidden scratchpad) from
an unmatched literal opener needs look-ahead, which a per-char stream
cannot do inline.

Buffer the summary tail once an analysis-shaped token appears inside a
visible summary and resolve it through the same batch stripper, so the
streaming and non-streaming paths always agree.

* fix(core): stop unmatched "<" from breaking streaming tag detection

An unmatched '<' in prose (e.g. "3 < 5" or "if (x<3)") put the streaming
filter into literal-tag scanning that only ended at the next '>' — which
was the '>' of the tag closing the current protocol block. Inside a
summary this leaked the raw `</summary>`; inside an analysis block it
swallowed the visible answer that followed, so a valid response was
discarded and retried instead of surfaced.

Treat every '<' as the start of a fresh tag candidate while scanning
literal text, keeping the streaming and batch sanitizers aligned.

* fix(core): retry leaked protocol turns

* test(integration): isolate protocol retry scenario
2026-07-10 15:56:34 +00:00
Shaojin Wen
51888210aa
feat(review): give every line of a large diff an accountable reviewer (#6612)
* feat(review): give every line of a large diff an accountable reviewer

Review agents were handed the diff *command* and left to run it themselves.
Shell tool output is capped at 30 000 characters and split head-1/5 / tail-4/5,
so on a large changeset every agent received a few hundred lines off the top of
the first file, the tail of the last file, and a truncation marker in place of
everything between. Measured on a 211 000-character diff: 14.4% of the
changeset, the same 14.4% for all ten agents. Nineteen of the twenty defects
maintainers eventually confirmed on that PR lay in the hidden 85.6%. The
ten-way dimension fan-out multiplied redundant reads of the visible sliver
rather than adding coverage, and each review round sampled a different subset
of the bugs depending on which files an agent happened to open on its own.

The diff is now captured to a file and partitioned. `read_file` still caps a
single read at ~25 000 characters, so writing the diff out is necessary but not
sufficient — a whole-file read of that diff returns its first 611 lines. Chunks
are therefore bounded by both a line budget (attention) and a character budget
(what one un-truncated read returns), split on hunk boundaries, and never
through the middle of a function. They tile the diff exactly, which is what
makes the new coverage receipts checkable: past 500 diff lines each chunk gets
one agent that owns it and must account for it, and a chunk with no receipt is
re-reviewed before the run proceeds. "No blockers" can no longer be reported
over code nobody read.

Coverage alone did not close the gap. Chunk agents held every state-machine
defect in that PR inside their assigned territory and reported none of them:
the bugs were not inside any hunk but between new lines sitting two thousand
lines apart, and what the agents lacked was not the lines but the question. A
heavily rewritten file now also gets three whole-file agents that walk a fixed
invariant checklist — mutable fields cleared on every exit path, timers
cancelled on every close without discarding captured data, map inserts matched
by deletes, retry counters incremented at every entry, status returns actually
checked, error codes classified permanent versus transient, config honoured on
every path, early returns that skip a required side effect. The checklist is
split three ways deliberately: one agent asked to run all eight checks over a
2 400-line file runs one of them properly.

Verification is sharded at eight findings per agent, because one verifier
re-reading code for sixty findings degrades on the tail of its list. A verifier
may now downgrade a Critical but never delete one — a rejected Critical is
invisible to every later stage, a downgraded one still reaches a human. The
reverse audit fans out per chunk instead of asking a single context-starved
agent to re-read the whole diff, no longer skips verification, and stops after
two consecutive dry rounds rather than one: on the PR that motivated this, the
review reported "no blockers" twice and the next round surfaced five Criticals,
three of them in code present since the first commit.

* fix(review): keep small-diff reads inside the read_file cap

Step 3A told every agent to read the whole diff in one call. `read_file`
truncates a single call at ~25 000 characters, so a 500-line diff of long lines
would come back short — the same blind spot the chunk plan removes, reintroduced
at a smaller scale. Across the last 39 merged PRs that take the Step 3A path the
largest diff is 23 570 characters, so this never fired in practice, but the
margin is six percent. Step 3A now walks the chunk ranges, which are sized to
fit one un-truncated read: one or two calls at this size.

Derive a file's pre-change line count from the diff instead of measuring it with
a second `git show` per file. `git show <base>:<newpath>` returns nothing for a
renamed file, reporting zero pre-change lines and classifying a wholesale
rewrite as light. The identity holds exactly for creations, deletions, renames
and ordinary edits, and halves the process spawns.

* fix(review): choose the topology from source lines, not diff lines

Diff size is a bad proxy for review risk because test code dominates it. Across
this repo's last 40 merged PRs the median diff is 41% test code and 14 of the 40
are more than half tests; PR #6457, which motivated the territory fan-out, is
itself 58% tests. Gating on raw diff lines therefore carved small production
changes into territories: a change of 173 source lines shipping 489 lines of new
tests went to the chunked topology, where its production code ended up owned by
a single agent, when the dimension fan-out would have read it through eight
lenses. Territory fan-out is worth it when there is a lot of risky code to
divide, not a lot of lines.

The gate is now `srcDiffLines > 500`, with `diffLines > 2400` as a second clause
— a delivery bound rather than a risk one, since past that point chunking uses
fewer agents than the ten-lens topology anyway and reading a diff that large
dilutes all ten. On the 40-PR sample six PRs move back to the dimension fan-out,
for about 5% more agents in total across the sample.

Paths are classified as source, test, or generated, and the per-kind line counts
ship in the fetch report. Chunking is unchanged: the plan still tiles every
line, tests and generated files included. What the gate decides is how many
reviewers there are and what each is asked to do. Heaviness is likewise
restricted to source files — the invariant checklist asks about fields, timers,
collections, and error taxonomies, and a rewritten test file has none of those.

* fix(review): decode C-quoted diff paths as bytes

`git diff` C-quotes any path with a control character or a non-ASCII byte, so a
file named `sub/中文文件.ts` arrives as `"b/sub/\344\270\255..."`. The chunk
planner stripped the backslashes, turning it into `sub/344270255...ts` — a name
that exists nowhere. Every downstream use of the path then failed silently: the
line count came back zero, the file could never be classified as heavy, and the
chunk agent was told it was reviewing a file that does not exist. Reuse core's
`unquoteCStylePath`, which reassembles the octal escapes as UTF-8 bytes, rather
than keeping a second, wrong decoder here.

Coverage was never affected — line ranges stayed correct — but this repo has
non-ASCII paths, so the mislabelling was reachable.

Also correct two places that claimed hunks are never split. They are: a hunk
larger than the chunk target is split at a top-level declaration, because a
brand-new file arrives as one enormous hunk and treating it as atomic would hand
a single agent a 50 000-character territory.

* fix(review): make diff capture and header parsing robust to git config

Four defects, all found in review of this branch.

Diff capture obeyed whatever the user's git config said. With `color.diff=always`
every `diff --git` line arrives wrapped in ANSI escapes, the parser recognises
none of them, and the plan comes back with zero files and zero chunks — the
coverage guarantee silently evaluates to nothing. `diff.mnemonicPrefix` renames
the `a/`/`b/` prefixes to `i/`/`w/` and every path is then wrong; `diff.external`
and textconv filters emit output that is not a unified diff at all. Capture now
pins `--no-ext-diff --no-textconv --no-color --unified=3` and the two prefixes.

The `diff --git` header was split with a greedy regex. Git separates the two
paths with a space and does not quote a path merely for containing one, so
`a/img with space.png b/img with space.png` split into `space.png`. Usually the
`---`/`+++` headers disambiguate, but a binary or mode-only section has neither.
For a non-rename both paths are the same string, so the split point is
arithmetic; a rename states its new path outright in `rename to`.

A chunk boundary could land on a `-` line. Those exist only on the old side, so
the "starts at a top-level declaration" guarantee did not hold for the
post-change file an invariant agent later reads. Split points are now restricted
to lines present on the new side.

An `oversized` chunk — one hunk with no safe interior boundary — can exceed what
a single `read_file` returns. Chunks now carry their character count, and a
chunk agent is told to page when a read reports truncation. A `Covered:` receipt
for a range the agent only half read is worse than no receipt at all.

* fix(review): split past a distant boundary, and stop probing GitHub for anchors

Both defects surfaced running the new review against PR #6591.

A 1431-line React component was emitted as a single 45 675-character chunk —
nearly twice what one `read_file` returns — because the splitter looked for a
safe boundary only inside the 400-line budget window, found none, and gave up on
the entire remainder. Twenty-seven boundaries existed further along; the first
sat 460 lines in. It now reaches past the window for the next one, so a single
distant boundary can no longer collapse a whole file into one chunk. That PR
goes from 15 chunks with one over the read cap to 18 with none.

Step 7 validated comment anchors by trial. GitHub rejects an entire review with
a 422 if any comment's line falls outside every hunk of its file, and the skill
offered no cheap way to check, so a run against a real PR submitted five
throwaway reviews carrying the bodies `Test`, `Test`, `t`, `t`, `t` to discover
which anchors would stick. Those are permanent, public reviews on someone else's
pull request. The fetch report now carries each file's hunks as new-side line
ranges, which turns the check into a lookup, and the skill states plainly that
a review is never submitted to test an anchor.

* fix(review): stop reading hunk payload as metadata, and harden the plan

Eleven defects from review of this branch. The worst two were silent.

A unified diff emits a removed line whose content starts with `-- ` as
`--- ...`, and an added line whose content starts with `++ ` as `+++ ...`. SQL,
Lua and Haskell comments start with `-- `. The parser read those payload lines
as file headers: the path was overwritten by the line's text, and the line
vanished from the add/remove counts. A two-file diff — one SQL file losing a
comment, one text file gaining a `++ ` line — came back with the second file
named `plus line`. Metadata is now only recognised before a file's first hunk.

The tiling invariant — every diff line belongs to exactly one chunk, which is
what makes a missing coverage receipt mean something — was asserted only in
tests. `buildDiffPlan` now checks it and refuses to return a plan with a hole.

The rest: a split point could take a *deleted* blank line as evidence of the
blank line before a declaration, though that blank exists only in the old file;
whole-file invariant agents were pointed at `chunks[].files[]`, which merges
hunks at lines 10 and 900 into one `10-902` span and would have had them report
pre-existing defects as new; pure-deletion hunks were exported as the inclusive
range `[N, N]`, so a right-side comment could be anchored where GitHub has no
line and the 422 would sink the whole review; a deleted file could be marked
heavy and send three agents to read a post-image that does not exist; a chunk
holding a single line longer than one `read_file` can never be fully read by
paging, and must now report itself uncoverable rather than receipt a lie;
capture did not pin rename detection or `--no-relative`; `gitRaw` had no
timeout, so a credential prompt on headless CI would hang forever; a failed
base fetch was swallowed, leaving a stale merge-base and a structurally
complete report describing the wrong diff; and local reviews still captured
with a bare `git diff`, which `color.diff=always` alone renders unparseable.

Adds an integration test that drives the real capture against a real repository
under hostile git config, covering the paths synthetic fixtures cannot: renames
and binaries and mode-only changes with spaces in their names, C-quoted
non-ASCII names, and payload lines that impersonate headers.

* fix(review): pin submodule output, and separate written lines from hunk spans

Four defects from review of this branch.

Diff capture left submodules to user config. `diff.ignoreSubmodules=all` hides a
changed gitlink completely — a silent coverage hole in the file that is now the
review's source of truth — and `diff.submodule=log` replaces the whole
`diff --git` section with prose no parser can read. Both are pinned now, and the
integration test asserts a bumped gitlink survives them.

Whole-file invariant agents were handed `files[].hunks[]` as "the changed
lines". A hunk spans the three context lines git prints either side of every
change: on PR #6457's `QQChannel.ts` those spans cover 1 962 new-side lines of
which only 1 403 were written. The agent would have reported defects in 559
lines that predate the PR. The report now also carries `addedRanges[]` — the
exact lines the change wrote — and the skill gates invariant agents on those,
keeping `hunks[]` for the one thing it is right for, GitHub anchor validation.

`Uncoverable:` was introduced as a chunk agent's answer for a chunk holding a
line longer than one read, but the receipt accounting still demanded a
`Covered:` line from every chunk and relaunched any chunk lacking one — so an
uncoverable chunk would have been retried forever. It is now a first-class
terminal status: accepted by the accounting, carried into Step 6 under "Not
reviewed", and it blocks an Approve verdict. Step 3A, which also walks the
chunk plan, is covered by the same rule.

The integration test built its fixture repository inside the developer's git
environment, so a global `core.hooksPath` or `commit.gpgsign` ran during the
test and `~/.gitconfig` decided what the "clean" baseline was. It now disables
system and global config, hooks and signing, and sets the executable bit through
the index rather than shelling out to `chmod`, which does nothing on Windows.

* feat(review): plan any captured diff, and stop the report outgrowing one read

Seven items from review of this branch. None blocking; two of them were the
skill promising a topology it could not deliver.

Step 3B's chunk agents are "one per entry in `chunks[]`", and only `fetch-pr`
produced a chunk plan. A local-diff review, and a cross-repo review in
lightweight mode, therefore routed into the territory fan-out with no chunk
list, no receipts and no tiling guarantee. `qwen review plan-diff <diff-file>`
now emits the same plan from any captured diff; redirecting `git diff` or
`gh pr diff` to a file already sidesteps the shell's character cap, so all four
review paths share one mechanism. A bare diff has no tree to read a post-image
from, so it gets chunk agents but no invariant agents, and says so by omission.

The fetch report is read with the same `read_file` that truncates at 25 000
characters — and for a seven-file PR it was already 28 056. The tail of
`chunks[]` was being silently lost: the coverage hole this design closes,
reappearing one level up. `addedRanges[]` now ships only on `heavy` files, its
only consumer, which brings that report to 24 992; the skill says to page the
read; and the command prints a note when the report exceeds one read. It stays
pretty-printed on purpose — a compact one-line JSON cannot be paged by line.

The tiling assertion threw inside `fetch-pr` after the worktree existed and
before any report was written, so an unforeseen diff shape killed the review
outright. It now degrades to the documented diff-less report with a loud
warning, keeping both the loudness and the review.

`gitOpt` and `git` had no timeout, and `resolveMergeBase` uses `gitOpt` for a
network fetch — the exact path whose credential prompt the `gitRaw` timeout was
added to survive. All three wrappers now share a deadline and
`GIT_TERMINAL_PROMPT=0`.

Markdown under `docs/` or at the repository root classifies as `docs` and stays
out of `srcDiffLines`, so a translation PR does not trip the territory gate.
Markdown inside a source tree stays `source` — the bundled skill prompts are
behaviour, not prose.

Also: the user docs stated the gate without its `diffLines > 2400` clause, and
`READ_FILE_CHAR_CAP` was exported but never used. It now backs the report-size
warning.

* test(review): unit-test the merge-base and plan-report seams

The last open review thread asked for `resolveMergeBase`, `fileMetrics` and
`gitRaw` to be testable with git mocked out. Three of the four functions it
named have since moved: `classifyHeavy` is a pure function with unit tests,
`fileMetrics` became `buildPlanReport`, which already takes an injected
post-image resolver, and `gitRaw`'s output path is exercised by the real-git
integration test. `resolveMergeBase` was still private and untested.

It now lives behind a three-method `GitProbe` — fetch, refExists, mergeBase —
that `fetch-pr` fills from the real wrappers. Seven tests cover the branches
that matter and that no end-to-end run reaches: the tracking ref preferred over
the local branch, the fall-through when the tracking ref shares no history, and
above all the dangerous one — a failed fetch that still resolves a merge-base
from a stale local ref, which produces a structurally complete report describing
a diff nobody wrote.

`buildPlanReport` gains seven of its own: the injected resolver is asked once
per file and never for a binary, a null resolver means "no tree, decide nothing"
rather than a guess, `addedRanges` ship only where an invariant agent will read
them, and a pure-deletion hunk never reaches the anchorable ranges.

* fix(review): see deletions, survive suppressBlankEmpty, and stop approving unread code

Seven findings from review of the merged head. Three of them were the design
contradicting itself.

`diff.suppressBlankEmpty` prints a blank context line as a physically empty
record rather than a lone space, and there is no command-line flag to override
it — only `-c`. The parser advanced its new-side cursor for space-prefixed
context alone, so every `addedRanges` entry after the first blank line shifted
up by one, and the split-point heuristic stopped recognising blank lines. The
capture now pins the config, and the parser treats an empty hunk-body record as
context regardless, because a diff from `gh pr diff` or a hand-captured file
never passes through that pin.

A whole-file invariant agent was given the post-change file and the ranges the
PR wrote. A deletion appears in neither. Removing a `clearTimeout()`, a
`Map.delete()`, or a retry-counter increment is exactly what the checklist
hunts, and the text it was handed cannot show a line that is no longer there —
telling it to "cite the surrounding hunk" pointed at data it never received.
Heavy files now carry a `diffRange` into the report, and the agent reads its own
slice of the diff, where the `-` lines are.

The receipt accounting demanded exactly one per chunk and said it applied to
Step 3A, where nine dimension agents each walk every chunk: literal execution
yields nine receipts or none. Territory ownership is a Step 3B idea. What both
paths share is the uncoverable rule, and that needs no agent — a chunk is
uncoverable iff its `maxLineChars` exceeds the read cap, which the orchestrator
reads out of the plan before launching anything.

That rule was also never threaded into Step 7, so a green PR with an unread
chunk could receive a public LGTM. Any uncoverable chunk now downgrades APPROVE
to COMMENT and must be named in the body.

Also: the capture recipes redirected into `.qwen/tmp` before anything created
it; a file-path review of an unchanged file produced an empty plan that no agent
could read, and the skill now branches to a full-file read instead; and the docs
classifier called `website/src/App.tsx` prose while calling
`packages/cua-driver/docs/*.md` source — it now matches prose extensions under a
documentation directory at any depth.

* fix(review): tell agents what a severity means before asking for one

The severity definitions lived once, in Step 6 — after every severity had
already been assigned. Step 3's finding format asked each agent for
`Severity: Critical | Suggestion | Nice to have` and never said what the words
meant. The agents that fill that field are separate subagents with separate
priors and no shared definition between them, so each fell back on its own, and
the priors disagree.

Observed on a live review of PR #6635 — a run of the skill as it stands on main,
whose Step 3 and Step 6 text this branch inherits unchanged. One review,
CHANGES_REQUESTED, ten inline comments. Six were Critical, and four of those six
were coverage gaps: "zero test coverage", "no references to `workers`", "no test
exercises this". Two Suggestions in the same review were the identical class.
The verdict is computed from Criticals alone, so that PR was blocked partly on
the strength of findings its own reviewer had, elsewhere, called suggestions.
The two genuine Criticals — a fail-fast that no longer fires before the daemon
reports healthy, and a startup failure path that never closes the HTTP server —
would have blocked it on their own.

The definitions now sit in the finding format that every agent is handed, they
are listed among the things every agent prompt must carry, and Step 6 points
back at them rather than restating them. A missing test is a Suggestion: "this
file has zero references to X" is a coverage statistic, not a defect. Two shapes
stay Critical because something is genuinely wrong — a test asserting the
opposite of the intended behaviour, and a test weakened or deleted in the diff
so new behaviour passes. If a missing test would let a specific incorrect
behaviour ship, report that behaviour and cite the gap as evidence.

* fix(review): walk cross-file edges in both directions

Cross-file impact analysis only ever asked "will the existing callers break?"
Every bullet was about signature compatibility, and the budget rule told agents
in so many words to "skip unchanged-signature modifications". A field added to
an interface changes no signature and breaks no caller, so the analysis was
blind to it by construction.

The failure that exposed this, on PR #6621: the diff added `deviceFlowRegistry?`
to WorkspaceRuntime and passed it into the dispatcher for every secondary ACP
mount, and nothing anywhere assigned it. The reviewing agent saw the
declaration, found no writer, wrote "intentionally deferred to a later
milestone", and filed a Suggestion to fix the JSDoc. The reader was AcpDispatcher
— a file the diff never touched — where `if (!this.deviceFlowRegistry)` turned
`auth/device_flow/start` into an INTERNAL_ERROR and `auth/status` into an empty
list on every non-primary workspace. Workspace-qualified ACP shipped its
authentication dead, and the review called it a documentation nit. A second
reviewer filed the same observation as Critical; the author fixed it with code
and dropped the field.

Reading cannot find this. The declaration, the pass-through, and the read sit in
three different places, and the read is outside the diff, so no agent reaches it
by paging through hunks. Only a grep for the read sites does.

So: for every field, option, or optional parameter the diff adds, grep its read
sites, including outside the diff, and ask what happens when it arrives
undefined. Severity is decided at the read site, not the declaration. And an
agent must not explain an unpopulated field with author intent it cannot
observe — "reserved for future use" is a claim about a person, not about code,
and reaching for one means filling a hole in your own field of view.

* fix(review): pin the diff base, and make the review body checkable

Three defects, all found by reading what live reviews actually posted.

The diff base. Agents were handed a diff command and left to choose a base.
`main..HEAD` and `main...HEAD` differ by one character and by the entire meaning
of the review: a two-dot diff against a main that has moved shows main's later
commits reversed, so main's fixes read as the branch's regressions. A review of
PR #6626 approved the four files the PR actually changed, then warned the author
publicly that their branch carried "typo regressions" in a file the PR never
touched and should be rebased. main had corrected `compatability` to
`compatibility` after the fork point. The branch had done nothing. Capture now
resolves the base once and hands agents a file; they never see a ref name, and a
finding in a file outside the report's `files[]` is not a finding about this PR.

The review body. "A Suggestion never goes in body" is stated twice and was
violated anyway, because a model holding a finding it cannot anchor would rather
say it somewhere than drop it. On PR #6631 an unanchorable Suggestion about
`session.ts:2048` — a line in no hunk — became a second paragraph of the public
review body. So the rule stops being prose: for COMMENT the body is exactly one
of three sentences plus the footer and nothing else, and you read what you are
about to send and confirm it. A Suggestion that will not anchor is deleted; it is
already in the terminal output and the Step 8 report.

The downgrade sentence. On PR #6489 a review with three Suggestions and no
Critical announced it had been "downgraded from Approve" — telling the author the
PR would otherwise have been approved, which was false: a Suggestion-only review
is COMMENT on its own. Decide the event from the findings first, apply the
downgrade flag second, and write the sentence only if it changed the answer.

* fix(review): decide the event by counting, not by weighing

A review of PR #6584 filed three inline Suggestions and submitted APPROVE with
an empty body. GitHub recorded it as an approval. The rule it broke has been in
Step 7 all along --- APPROVE means no Critical *and* no Suggestion --- and so has
the one about the body, which is empty only for REQUEST_CHANGES. Both were
stated twice. Both were ignored.

They are ignored because at submit time the model is reasoning about what it
wants to say, and "these are only suggestions, the PR is fine" is a sentence it
can talk itself into. Nothing in that sentence is a count.

So the event and the body become arithmetic. Count the Criticals, count the
Suggestions, read the row off a three-row table, and only then apply the
downgrade flags --- which can turn APPROVE or REQUEST_CHANGES into COMMENT and
nothing else. Then read back what you are about to send and confirm it matches
the row. A body holding text the table does not authorise is a finding that
failed to anchor; if it is a Suggestion, it gets deleted, not relocated into
public prose that no line of code answers to.

This subsumes the body-only invariant added in the previous commit, which the
same submit-time reasoning had already defeated once, on PR #6631.

* fix(review): stop the plan report outgrowing the read it must fit in

The report tells an agent how to page everything else, so it has to be readable
in one `read_file` — about 25 000 characters. Running the real `fetch-pr`
against PR #6457 produced 25 070.

Two constraints pull against each other. Compact JSON is a single enormous line,
and `read_file` pages at line boundaries, so a report too big for one call could
never be read at all. Indented JSON pages fine but spends four lines on
`{ "start": 812, "end": 815 }`, and a heavily rewritten file contributes hundreds
of them: `QQChannel.ts` alone carries 140 added ranges and 49 hunks.

So indent the structure and inline the leaves. Same JSON, same keys, one range
per line, still pageable — and 28% smaller. The #6457 report goes from 25 070
bytes to 18 042, and the "page it" warning that used to fire on a seven-file PR
now stays quiet.

The earlier attempt at this trimmed `addedRanges` to heavy files only and landed
at 24 992 bytes on the same PR. Eight bytes of headroom was not a fix.

Tests pin the three properties that matter: the collapsed text parses back to an
identical object, no range spans two lines, and a path that literally spells a
range is not mistaken for one — JSON escapes the quotes inside a string value,
and the collapse patterns require unescaped ones.

* fix(review): prune the worktree registration a deleted directory leaves behind

`cleanStale` and `cleanup` both guarded `git worktree remove` behind
`existsSync(path)`, and neither ever pruned. Delete the directory by hand — which
is exactly what reclaiming disk with `rm -rf .qwen/tmp` does — and git keeps the
worktree registered but missing. From then on `/review` on that PR cannot run:

    $ git worktree add .qwen/tmp/review-pr-6457 qwen-review/pr-6457
    fatal: '...' is a missing but already registered worktree;
    use 'add -f' to override, or 'prune' or 'remove' to clear

and the branch delete that `cleanStale` does next fails too, because the phantom
worktree still has that branch checked out. Nothing in the review command surface
ran `git worktree prune`, so nothing ever cleared it.

This surfaced running the real skill: the orchestrator's first `fetch-pr` failed,
it fell back to `qwen review cleanup`, and retried. The leak is not rare — three
abandoned worktrees from May and June were still registered in this checkout,
one per review that died before Step 9.

`releaseWorktree` now does both halves in the order they depend on: remove the
directory if it is there, prune the registration unconditionally (a no-op when
nothing is stale), and only then let the caller delete the branch. Both callers
share it.

The tests drive real git. Deleting a worktree directory by hand and re-adding it
throws "missing but already registered" without the prune, and `branch -D` throws
"used by worktree" — both assertions fail if the prune is removed, which is the
point of writing them.

* fix(review): put the open comments where a truncated read will find them

`read_file` returns the first `truncateToolOutputThreshold` characters — 25 000
by default — sets `isTruncated`, and pages by line. `pr-context` wrote
"## Open inline comments (no replies yet — may still need attention)" last, so
on a PR with a long history it was the first thing lost, and nothing read the
flag that said so.

On PR #5738 that section began at character 27 125 of a 31 220-character file.
The review submitted "Reviewed — no blockers." Five Critical threads were
unresolved; four had in fact been addressed, but the fifth — `clearCiEnv()`
clearing only `CI*` while `writeTerminalTitle` branches on `TMUX`/`STY`/
`ZELLIJ`/`DVTM` — was live, in the diff, and never seen.

Regenerating the context for ten PRs: four lost part or all of the section, and
all four were the PRs with the most review rounds. Small PRs never trip it.

- Emit the open threads before the already-discussed ones. The findings a round
  must answer outrank the ones already settled.
- `pr-context` warns when the file exceeds the threshold, naming any headings
  past the cut, and says so plainly when the loss is inside the last section's
  body instead.
- Step 2 of SKILL.md now tells the agent to read `isTruncated` and page the
  remainder before Step 3.

Reordering buys headroom; it does not create it. A 40 000-character context still
loses its tail, which is what the warning is for.

* fix(review): load this repo's review rules, and re-check open Criticals before approving

Two gaps the dogfood on live PRs surfaced, both invisible from reading the skill.

`load-rules` looks for a `## Code Review` heading in AGENTS.md and QWEN.md.
Neither had one, so it wrote an empty file on every run: every `/review` in this
repo reviewed with zero project rules. Add the section, distilled from the
conventions already scattered through AGENTS.md (ESM, no cross-package relative
imports, kebab-case/PascalCase naming, collocated tests, comments-only-when-why),
plus the two hard lessons below. The section loads from the base branch by design
— a PR cannot inject its own review rules — so it takes effect once merged.

The skill treated a zero-Critical outcome as a fallback rather than a claim. On
one PR it published two Criticals citing code not present at the reviewed commit
(a fabricated blocker on an already-approved PR); on another it submitted C=0
while a live, twice-filed Critical still stood (a dropped blocker). Add a step
before the verdict: for each unresolved Critical on the PR, read the code at the
reviewed commit and record still-stands / fixed-by-this-diff / cannot-tell. The
event follows from the code, not from the finding count or the thread flags —
`isResolved`/`isOutdated` track the anchored line, not whether the bug was fixed.

- AGENTS.md: new `## Code Review` section.
- load-rules.ts: export `extractCodeReviewSection`; load-rules.test.ts covers the
  boundary scan and asserts AGENTS.md's own section extracts non-empty, so
  deleting the heading fails the build.
- SKILL.md: re-verification step ahead of the Verdict.
2026-07-10 15:53:09 +00:00
易良
f06e932260
fix(web-shell): polyfill Range layout APIs in tests (#6677)
* fix(web-shell): polyfill range layout in tests

* test(webui): stabilize heartbeat prompt cleanup
2026-07-10 15:18:48 +00:00
tanzhenxin
fa7fdbca01
fix(core): clamp max_tokens to the context window; retire the output reservation (#6556)
* fix(core): clamp max_tokens to the context window; retire the output reservation

Auto-compaction was firing far too early — a 200K-window session compacted at roughly half the window. The cause was not the compaction engine but that every request manufactured a large max_tokens, which forced a defensive reservation of that output budget out of the window before computing compaction thresholds. The reservation shrank the effective window, pulled the trigger down, and spawned a chain of band-aids.

Size max_tokens to the room actually left in the window instead — the smaller of the model's output ceiling and (window − prompt − margin) — so an oversized request can never exceed the context limit. Once output is guaranteed to fit, the reservation is unnecessary and is removed; compaction gates on the full window again. Raise the default proportional threshold from 0.70 to 0.85, and replace the temporary half-window reservation cap with a flat 64K output ceiling.

This resolves early compaction, the 400 "maximum context length" error on request, the "hard limit: 0" pre-send NOOP for env-configured models, and retires the half-window reservation cap, while keeping max_tokens on the wire for both OpenAI- and Anthropic-shaped providers.

Fixes #5950
Fixes #6384

Claude-Session: https://claude.ai/code/session_014DW2TynKHLjsbRqTBSyQue

* test(cli): update /context threshold expectations for 85% default

The auto-compaction default moved from 70% to 85% and the output
reservation was removed, so computeThresholds(200K) now yields
warn=150K / auto=170K (was 147K / 167K). Update the /context
command tests that hard-coded the old ladder.

* fix(core): apply window clamp to samplingParams users who omit max_tokens

Previously a samplingParams config without a max_tokens key sent no
max_tokens on the wire (OpenAI path), so those users bypassed the
prompt + max_tokens <= window clamp — inconsistent with the Anthropic
path, which always injects the clamped value. Mirror the Anthropic
fallback (reconcile ?? config ?? request) so the clamped maxOutputTokens
is injected when samplingParams omits max_tokens.

Guard the injection: when samplingParams targets a provider-specific
output-budget key (max_completion_tokens for GPT-5/o-series, max_new_tokens),
leave it verbatim — adding max_tokens alongside double-specifies the
budget and those endpoints reject the pair.

* fix(core): clamp provider output-budget keys to the window in samplingParams

A samplingParams config carrying a provider-specific output-budget key
(max_completion_tokens for GPT-5/o-series, max_new_tokens) but no
max_tokens previously passed the key through verbatim, so its value
escaped the prompt + output <= window clamp — e.g. max_completion_tokens:
200000 on a 200K window with a 150K prompt.

Clamp the key's value in place to the remaining window (min with the
request maxOutputTokens) instead of injecting a separate max_tokens:
sending both keys double-specifies the output budget and o-series
rejects the pair. The value only shrinks when the window is tight; when
there is room it passes through unchanged, matching how max_tokens is
already treated.

* fix(core): compact on the window ceiling, not the max of the threshold ladder (#6583)

* fix(core): compact on the window ceiling (min), not the max of the ladder

computeThresholds combined the proportional term (pct*window) and the
absolute term (effectiveWindow - AUTOCOMPACT_BUFFER) with Math.max, which
pushed the auto-compaction trigger toward the top of the window on large
windows — a 1M-token window compacted at ~97%, leaving ~33K headroom.

The absolute term is structurally a ceiling ("compact before the prompt
leaves too little room for the summarization side-query, which needs up
to SUMMARY_RESERVE of output"), so it composes with Math.min, matching
the claude-code reference (services/compact/autoCompact.ts, which uses
Math.min and whose default trigger is the absolute term alone).

  auto = absoluteCeiling > 0 ? min(pct*window, absoluteCeiling) : pct*window
  warn = max(0, auto - WARN_BUFFER)   // WARN_PCT_OFFSET retired
  hard = unchanged

Effect: large windows compact at ~85% (the DEFAULT_PCT ceiling) instead
of ~97%; small/mid windows keep room to run compaction (a 128K window's
summary now provably fits); sub-33K windows are unchanged. A lower
context.autoCompactThreshold now pulls compaction earlier on large
windows, matching the reference's Math.min override semantics.

Updates the threshold unit tests, the settings schema description, and
the user docs to describe the setting as a ceiling on the trigger.

* refactor(core): trim threshold doc comments; name the hard-edge term

Post-review cleanup (no behavior change):
- Collapse the duplicated regime explanation shared between the DEFAULT_PCT
  and computeThresholds doc comments into one canonical block; point the
  constant's doc at computeThresholds.
- Rename rawHard -> hardEdge and note it is the window-edge ceiling, so the
  two roles of the hard tier (window edge vs. auto + HARD_BUFFER) are legible.
- Shorten the context.autoCompactThreshold description in settings.md to the
  concise schema wording (also un-widens the docs table).

* fix(core): clamp provider output-budget keys on every samplingParams exit

A config carrying both max_tokens and a provider-specific output-budget
key (max_completion_tokens / max_new_tokens) took the max_tokens early
return, spreading the provider key onto the wire unclamped — on backends
honoring the larger key, prompt + output could exceed the window.

Collapse the two returns into a single exit that always runs the
provider-key clamp, so no output-budget key escapes the window clamp
regardless of which combination of keys is present.

---------

Co-authored-by: 易良 <1204183885@qq.com>
2026-07-10 14:44:14 +00:00
qqqys
7129cecba2
fix(channels): manage stale DingTalk Stream connections (#6675)
* fix(channels): manage stale DingTalk Stream connections

* fix(channels): harden DingTalk connection lifecycle

---------

Co-authored-by: qwen-code-dev-bot <qwen-code-dev-bot@users.noreply.github.com>
2026-07-10 14:19:59 +00:00
易良
cc556818fe
fix(core): fix tool_use/tool_result pairing for Anthropic-compatible providers (#6651)
* fix(core): preserve pending tool results during compaction

* fix(core): merge consecutive assistant messages in Anthropic converter

Add mergeConsecutiveAssistantMessages and cleanOrphanedToolCalls to the
Anthropic converter, mirroring the same-name functions already present in
the OpenAI converter. When the Gemini history has consecutive model turns
(e.g. from streaming chunk-level recording, max_tokens recovery, or adaptive
thinking splits), processContent emits one Anthropic message per Content.
The Anthropic API requires tool_use blocks to be immediately followed by
tool_result blocks — consecutive assistant messages break this pairing and
cause HTTP 400.

The merge pass combines consecutive assistant messages into one (thinking
blocks first, then non-thinking). The clean pass removes orphaned tool_use
and tool_result blocks. A second merge pass fixes any alternation issues
created by dropped messages.

* test(cli): isolate cli entry fallback fixture

* fix(core): harden Anthropic tool pairing cleanup

* fix(core): preserve tool result order when merging users
2026-07-10 13:50:18 +00:00
qqqys
dcbfc30ec5
fix(channels): cap channel memory recall prompt (#6617)
* fix(channels): cap channel memory recall prompt

* fix(channels): harden memory recall truncation

* fix(channels): count memory prompt limit by code points
2026-07-10 13:09:05 +00:00
qqqys
c84089ec48
fix(dingtalk): preserve markdown tables (#6673) 2026-07-10 13:08:31 +00:00
qqqys
043c22cb4b
feat(channels): support webhook-triggered channel tasks (#6495)
* feat(daemon): add a2a settings and capabilities

* docs(channels): design webhook-triggered tasks

* feat(channels): add webhook task helpers

* fix(channels): bound webhook prompt metadata

* feat(channels): run webhook-triggered tasks

* fix(channels): harden webhook task lifecycle

* fix(channels): require yolo for webhook tasks

* feat(channels): parse webhook configuration

* fix(channels): validate webhook secrets

* feat(channels): forward webhook tasks to channel worker

* fix(channels): require webhook enqueue on supervisors

* fix(channels): handle webhook IPC send failures safely

* feat(serve): accept channel webhook tasks

* fix(serve): stop webhook validation after first error

* fix(webhooks): reject inherited target refs

* docs(channels): document webhook-triggered tasks

* docs(channels): fix webhook task example

* docs(channels): refine webhook task docs

* docs(channels): add webhook task implementation plan

* fix(channels): restore webhook task context and chunks

* fix(serve): classify worker webhook enqueue failures

* fix(channels): address webhook review feedback

* fix(serve): address channel webhook review blockers

* fix(serve): satisfy channel webhook lint

* fix(serve): harden channel webhook admission

* fix(serve): narrow channel webhook source config

* fix(serve): classify webhook session scope failures

* fix(serve): harden webhook payload handling

* fix(serve): authenticate webhook startup cheaply

* fix(serve): keep deferred serve fast path lean

* fix(serve): address deferred webhook review blockers

* fix(channels): propagate webhook approval mode

* fix(channels): harden webhook task admission

* fix(acp): harden approval mode initialization

* fix(channels): harden webhook shutdown and secrets

* fix(channels): harden webhook review blockers

* fix(serve): harden deferred webhook auth

* test(channels): cover webhook target rejection

* fix(channels): preserve webhook thread targets

* fix(channels): address webhook review blockers

* fix(channels): harden webhook review blockers

* test(serve): align deferred webhook secret log assertion

* fix(channels): isolate webhook thread sessions

* fix(channels): harden webhook enqueue failures

* fix(serve): classify disabled channel workers
2026-07-10 12:54:27 +00:00
qqqys
ff156e5955
fix(channels): enable DingTalk stream keepalive (#6668)
* docs: add DingTalk keepalive PR1 design

* docs: plan DingTalk keepalive PR1

* fix(channels): enable DingTalk stream keepalive

* chore: exclude DingTalk keepalive planning docs
2026-07-10 12:43:29 +00:00
Dragon
5fea9e8258
feat(cli): allow long goal conditions (#6665) 2026-07-10 12:13:40 +00:00
yuanyuanAli
01cbddf5b3
feat(web-shell): add collapse/expand toggle to AskUserQuestion panel (#6588)
* feat(web-shell): add collapse/expand toggle to AskUserQuestion panel

The AskUserQuestion panel can block the main content view. This adds a collapse/expand button next to the progress tabs, allowing users to minimize the panel to just the header row when not actively interacting with it. Also adds i18n keys for expand/collapse labels in both English and Chinese.

* fix(web-shell): address PR review feedback for AskUserQuestion collapse

- Remove stale padding-right: 72px on .text (no longer needed after flex layout change)
- Reset collapsed state in useEffect when new questions arrive
- Add aria-expanded attribute to collapse button for accessibility
2026-07-10 12:11:46 +00:00
nas
71bef9bfa9
fix(core): apply cron step to a single starting value (N/step) (#6627)
The 5-field cron parser expanded a stepped single value like `5/15` to just
{5}, silently discarding the step. Standard Vixie-cron semantics treat `N/step`
as `N-max/step` — start at N and skip forward to the field maximum — so
`5/15` in the minute field means 5, 20, 35, 50, and `0/15` means every 15
minutes on the hour.

The parser already accepted the `N/step` syntax (it validates the step, e.g.
`5/2x` is rejected as an invalid step), so the step was parsed but never
applied, making the form a confusing no-op identical to a bare `N`. A user
scheduling a task with a common idiom like `0/15 * * * *` would get one that
fires once an hour instead of four times.

Fix: when a step is present on a single value, set the range end to the field
maximum, matching Vixie/cronie, croniter, and node-cron. Bare single values and
the `*`, `a-b`, and `*/step` forms are unchanged.

Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>
2026-07-10 12:10:20 +00:00
joeytoday
c0aeb7df5d
docs(channels): add setup screenshots to WeCom robot guide (#6648) 2026-07-10 12:10:06 +00:00
nas
32ddd7ae77
docs: document tools.disabled and tools.visible settings (#6641)
Both settings are implemented and wired end to end (settingsSchema.ts,
normalizeDisabledTools.ts, ToolRegistry registration gate) but were
missing from the settings reference, while their deprecated siblings
tools.core / tools.exclude / tools.allowed are documented.

In particular, tools.disabled already answers a recurring user request:
disabling enter_plan_mode entirely so the model can never switch into
plan mode on its own (#5970). Documenting it makes that option
discoverable.
2026-07-10 12:09:57 +00:00
tanzhenxin
7a9ee09f49
fix(core): honor NO_PROXY for model requests (#6640) 2026-07-10 10:41:04 +00:00
ytahdn
8522d43875
feat(daemon): expose session runtime status (#6645)
* feat(daemon): expose session runtime status

* test(daemon): cover pending interaction mirrors

---------

Co-authored-by: 钉萁 <dingqi.jww@alibaba-inc.com>
2026-07-10 10:15:12 +00:00
Nothing Chan
35fadad103
fix(sdk): escalate process abort termination (#6653) 2026-07-10 10:12:10 +00:00
易良
d454d0e744
fix(cli,core): Restore default debug log file output (#6605)
* fix(cli,core): restore default debug log file output

* fix(cli): preserve debug log sandbox opt-out

* test(cli): stabilize flaky UI tests

* fix(cli): scope default debug log to debug mode

* fix(core): scope debug log default to --debug mode per #6600

Revert isDebugLogFileEnabled() guard from `value === undefined` back to
`!value` so the non-debug default stays opt-in as prescribed in #6600.
The --debug scoping in config.ts already sets QWEN_DEBUG_LOG_FILE=1 when
in debug mode, making the global default flip unnecessary.

Also adds a regression test for the opt-out edge case
(QWEN_DEBUG_LOG_FILE='0' + --debug should not overwrite).

* test(cli): remove unused voice keyterms import

* test(cli): isolate cli entry fallback test

* ci: avoid web-shell smoke port collisions

---------

Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>
2026-07-10 09:58:41 +00:00
易良
2b482c0281
fix(triage): require explicit defer comment and prevent hygiene-based defer on re-runs (#6652)
* fix(triage): require explicit defer comment and prevent hygiene-based defer on re-runs

Two issues fixed in Stage 3 Step 2:

1. Defer was silent — when the bot chose "genuinely unsure → defer", it
   updated stage comments but never explicitly said "I'm deferring to
   @maintainer because X". Maintainers had no signal they were needed,
   and users thought the triage hung.

   Fix: defer path now requires posting a comment that states the
   escalation, names the specific uncertainty, and @mentions the
   maintainer.

2. Re-runs deferred on hygiene concerns — when a maintainer manually
   triggered `/triage`, the bot would defer instead of approving because
   of scope mismatch, undocumented changes, or naming issues. These are
   hygiene concerns, not blockers, but the model treated them as reasons
   to defer.

   Fix: re-run path now explicitly states hygiene concerns are not a
   valid reason to defer. Only genuine blocking uncertainty (something
   unresolvable from the diff, tests, and PR description) should defer.

* fix(triage): use maintainer handle variable
2026-07-10 09:55:19 +00:00
顾盼
0d1707a7e9
test(mobile-mcp): update coord-norm tests for removed output normalization (#6664)
Remove tests for deleted functions (pxToNorm, normalizeElementResult,
normalizeScreenSizeResult) and add tests for hasCoordFields.
2026-07-10 09:45:48 +00:00
易良
6002159ab8
Bound glob result collection (#6618)
* fix(core): bound glob result collection

* fix(core): lower glob collection cap

* fix(core): destroy capped glob stream

---------

Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>
2026-07-10 09:41:11 +00:00
易良
3bf2d45403
ci: add suspicious comment attachment guard (#6599)
* ci: add suspicious comment attachment guard

Resolves #6597

* ci: reduce attachment guard false positives

* ci: harden comment attachment guard

* ci: tighten attachment extension matching

* ci: avoid false attachment removal summary

* ci: avoid markdown link attachment false positives

* ci: avoid country-code attachment false positives

* ci: harden attachment URL parsing

* ci: reduce attachment guard false positives

Updates #6597

* ci: harden malformed attachment URLs

Updates #6597

* ci: reduce attachment guard overmatching

Updates #6597

* ci: scan attachment path segments

Updates #6597

* ci: cover review attachment summaries

* ci: harden attachment link detection

* fix: address critical bypass vectors in comment attachment guard

- Remove break in decodeTarget catch block so malformed percent sequences
  (e.g., %ZZ) don't prematurely exit the decode loop, allowing
  double-encoded extensions to be fully detected
- Strip zero-width characters (U+200B-U+200D, U+FEFF, U+00AD, U+2060,
  U+180E) before NFKC normalization to prevent invisible-character
  evasion of extension matching
- Add protocol-relative URL (//) support to linkPattern and
  highRiskTarget, normalizing to https: before parsing
- Add tests for all three bypass vectors (39 total, all passing)

---------

Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>
2026-07-10 09:40:54 +00:00
顾盼
0e91fe5362
fix(mobile-mcp): coord-norm audit fixes for 0.1.3 (#6659)
Some checks are pending
E2E Tests / web-shell Browser Regression (push) Waiting to run
E2E Tests / E2E Test - macOS (push) Waiting to run
E2E Tests / E2E Test (Linux) - sandbox:docker (push) Waiting to run
E2E Tests / E2E Test (Linux) - sandbox:none (push) Waiting to run
* fix(mobile-mcp): fix coord-norm audit issues for 0.1.3

- normalizeScreenSizeResult: return real pixel values instead of 1000x1000
- normalizeElementResult: return real pixel coordinates (query tools
  should not transform output, matching cua-driver 0.7.1)
- ensureScreenSize: throw ActionableError when screen size unknown and
  tool has coordinate params, instead of silently passing through
- swipe distance: fix description to avoid misleading default value
- screenshot: fix annotation to clarify coordinate space vs image size
- server instructions: add normalized coordinate guidance
- mobile_ui_dump: update description to note bounds are stripped

* fix(mobile-mcp): fix tool descriptions that mislead models about coordinate systems

- click/long_press: remove 'use list_elements_on_screen to find
  coordinates' guidance that led models to pass pixel coords directly
  into normalized coordinate params
- list_elements_on_screen: clarify coordinates are in device pixels
- get_screen_size: reword to avoid rewriteDescription replacing
  'in pixels' with 'in normalized coordinates' (returns real pixels)
- take_screenshot: remove guidance to use list_elements for clicking
2026-07-10 09:38:29 +00:00