fix(cli): emit deferred stream-json startup warnings - #7174
Conversation
Stream-json defers configuration initialization until its session receives input, but warnings generated during that deferred step were never surfaced to automation clients. Snapshot already-emitted warnings, then write only initialization-time additions to stderr and lock the behavior with a focused regression test. Constraint: Preserve the existing pre-initialization warning output without duplicates Rejected: Route warning state through the Session constructor | unnecessary interface expansion for a local delta Confidence: high Scope-risk: narrow Directive: Keep deferred initialization diagnostics on stderr for stream-json consumers Tested: packages/cli session test; CLI typecheck; ESLint; Prettier check; diff check Not-tested: End-to-end CLI invocation with a filesystem-generated startup warning
|
Thanks for the PR! Template: the body uses Problem: observed bug with a clear reproduction in #7158. Stream-json mode silently drops startup warnings generated during deferred Direction: aligned — startup warnings should reach users regardless of input format. SDK and automation clients consuming stream-json are exactly the audience that can't discover misconfiguration any other way. This matches the existing pattern in Size: 34 additions, 0 deletions across 2 files (production: ~10 lines, test: ~24 lines). Not applicable for core module checks. Approach: minimal and focused. Snapshot pre-init warnings into a Set, emit only the delta after Moving on to code review. 🔍 中文说明感谢贡献! 模板: PR 正文使用了 问题: 已在 #7158 中观测到并提供复现。Stream-json 模式下, 方向: 对齐——无论输入格式如何,启动警告都应触达用户。Stream-json 的消费者(SDK 和自动化客户端)恰恰是最需要发现配置异常的一方。与 规模: 34 行新增,0 行删除,涉及 2 个文件(生产代码约 10 行,测试约 24 行)。不触及核心模块保护规则。 方案: 最小且聚焦。将初始化前的警告快照到 Set 中, 进入代码审查 🔍 — Qwen Code · qwen3.7-max Reviewed at |
Code ReviewIndependent proposal (before reading the diff): snapshot The PR's implementation matches this proposal exactly. In
This is line-for-line consistent with the non-stream-json branch in One minor note: No correctness bugs, security holes, or regressions found. Test covers both legs of the dedup: pre-existing warning NOT re-emitted, new warning IS emitted. Real-Scenario TestingRan stream-json mode end-to-end in tmux. No startup warnings were triggered in this CI environment (no legacy plan files or team-memory config present), so the before/after comparison shows clean stream-json output on both sides. The fix targets a code path that the unit test directly exercises. Before (installed build, v0.19.11)After (PR code via
|
|
Confidence: 5/5 — Clean across every stage; a textbook bugfix. This is what a good external contribution looks like: a real bug with a filed issue (#7158, P2), a minimal fix that mirrors the established pattern in The fix is 10 lines of production code that snapshot pre-init warnings and emit only the delta after The test is well-designed: it sets up pre-existing warnings, mocks Stream-json mode runs cleanly end-to-end in both the installed build and the PR code. Approving. ✅ 中文说明信心度:5/5 — 各阶段均通过;教科书级别的 bugfix。 这是一个优秀外部贡献的典范:真实 bug 已有 P2 issue(#7158),最小化修复与 修复仅 10 行生产代码:在 测试设计良好:预设已有警告,mock Stream-json 模式在安装版本和 PR 代码中均端到端正常运行。 已批准 ✅ — Qwen Code · qwen3.7-max Reviewed at |
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
LGTM, looks ready to ship. ✅
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
No issues found. LGTM! ✅
— qwen3.7-max via Qwen Code /review
doudouOUC
left a comment
There was a problem hiding this comment.
No issues found. LGTM! ✅
— qwen3.7-max via Qwen Code /review
Resolves the ACP bootstrap conflict (keep #7145 profiling wrapper + warning emission), drops the session.ts warnings block superseded by #7174, and guards the ACP getWarnings call against stubbed configs. Claude-Session: https://claude.ai/code/session_01KwsYFzWZ6VLCxVN8MbeFXb
Summary
Fixes #7158.
Testing
npm run test --workspace=packages/cli -- src/nonInteractive/session.test.tsnpm run typecheck --workspace=packages/clinpm run lint --workspace=packages/cli -- src/nonInteractive/session.ts src/nonInteractive/session.test.tsnpm exec prettier -- --check packages/cli/src/nonInteractive/session.ts packages/cli/src/nonInteractive/session.test.tsgit diff --check