fix(vscode): always show chat view in the Activity Bar sidebar#5757
Conversation
On VS Code >=1.106 the version-gated `when` clauses hid the primary Activity Bar container in favor of a secondary-sidebar container, so the Qwen Code view flashed and disappeared from the left bar. Drop the secondary-sidebar container and context key and always register the chat view in the Activity Bar, which VS Code lets users move to the secondary sidebar natively.
There was a problem hiding this comment.
Pull request overview
Ensures the Qwen Code VS Code extension’s chat view is always contributed to the Activity Bar (primary sidebar) across supported VS Code versions by removing the secondary-sidebar contribution and the runtime context-key gating that caused the icon to “flash and disappear” on newer VS Code builds.
Changes:
- Removed secondary-sidebar view/container contributions, the
supportsSecondarySidebarcontext key, and version detection. - Simplified chat view registration and
focusChatto target the single sidebar view id. - Updated unit tests to reflect the single contributed chat view and added a manifest test to ensure no
whengating remains.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/vscode-ide-companion/src/webview/providers/WebViewProvider.ts | Updates comments related to view hosting after removing secondary-sidebar behavior. |
| packages/vscode-ide-companion/src/webview/providers/ChatWebviewViewProvider.ts | Updates class doc to align with the new single-sidebar contribution. |
| packages/vscode-ide-companion/src/webview/providers/chatViewRegistration.ts | Removes version/context-key logic and registers only the sidebar chat view provider. |
| packages/vscode-ide-companion/src/webview/providers/chatViewRegistration.test.ts | Updates tests to assert only one webview view provider registration occurs. |
| packages/vscode-ide-companion/src/package.test.ts | Adds a test asserting the Activity Bar container/view aren’t gated by runtime when clauses. |
| packages/vscode-ide-companion/src/extension.ts | Removes use of the previous supportsSecondarySidebar return value when wiring commands. |
| packages/vscode-ide-companion/src/extension.test.ts | Updates activation test expectations to only register the sidebar view provider. |
| packages/vscode-ide-companion/src/constants/viewIds.ts | Removes the secondary chat view id constant and updates comments accordingly. |
| packages/vscode-ide-companion/src/commands/index.ts | Simplifies focusChat to always focus the sidebar chat view id; updates docs. |
| packages/vscode-ide-companion/src/commands/index.test.ts | Updates focusChat test to validate focusing the single sidebar chat view. |
| packages/vscode-ide-companion/package.json | Removes secondary view/container contributions and related activation event; leaves Activity Bar entry always visible. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /** | ||
| * Whether this provider is hosted inside a WebviewView (sidebar / secondary bar). | ||
| * Whether this provider is hosted inside the Activity Bar sidebar. | ||
| * When true, "New Session" resets the conversation in-place instead of opening | ||
| * a new editor tab. | ||
| */ |
|
|
||
| /** | ||
| * WebviewView host for placing the chat UI in sidebar / panel / secondary sidebar. | ||
| * WebviewView host for placing the chat UI in the Activity Bar sidebar. |
| * `openChat` and `newConversation` always open an editor tab, while | ||
| * `focusChat` focuses the secondary sidebar (preferred) or primary sidebar. | ||
| * `focusChat` focuses the Activity Bar chat view. | ||
| * |
|
Thanks for the PR! Template looks good ✓ On direction: this is a clear bug fix for #4488 — the chat view icon flashing and disappearing on VS Code 1.106+ is a real user-facing regression. The root cause (async context key causing the On approach: this is a pure simplification — net removal of 118 lines. The dual-sidebar architecture was the source of the race condition, and collapsing to a single Activity Bar view eliminates it at the root rather than patching around it. Users who want the secondary sidebar can still drag the view there natively. Scope is tight — every changed file serves the stated goal, no drive-by refactors or scope creep. Moving on to code review. 🔍 中文说明感谢贡献! 模板完整 ✓ 方向:明确修复 #4488 —— VS Code 1.106+ 上聊天视图图标闪现后消失是一个真实的用户可见回归。根因(异步 context key 导致 方案:纯简化 —— 净删除 118 行。双侧边栏架构本身就是竞态条件的来源,回退为单一活动栏视图从根源消除问题,而非打补丁绕过。需要副侧边栏的用户仍可原生拖动视图过去。范围紧凑 —— 每个改动文件都服务于目标,无顺手重构或范围蔓延。 进入代码审查 🔍 — Qwen Code · qwen3.7-max |
Code ReviewThe diff is clean and well-structured. Every file change serves the single goal of removing the secondary sidebar architecture:
No correctness issues, no security concerns, no AGENTS.md violations found. This is exactly the minimal change needed. Unit TestsRan the four affected test suites with the PR code applied: 20/20 pass — matches the PR's claim. Real-Scenario TestingThis PR modifies the VS Code extension's view registration — specifically where the chat view icon appears in the IDE's Activity Bar. This is a GUI-only change that requires a running VS Code instance to verify visually. It cannot be meaningfully tested via tmux/CLI because:
A reviewer on a real VS Code 1.120 instance should confirm the icon stays visible. 中文说明代码审查Diff 干净且结构清晰,每个文件改动都服务于移除副侧边栏架构这一单一目标:
无正确性问题、无安全隐患、无 AGENTS.md 违规。这正是所需的最小改动。 单元测试使用 PR 代码运行四个受影响的测试套件:20/20 通过,与 PR 声明一致。 真实场景测试本 PR 修改的是 VS Code 扩展的视图注册 —— 即聊天视图图标在 IDE 活动栏中的显示位置。这是纯 GUI 变更,需要运行 VS Code 实例才能可视化验证。无法通过 tmux/CLI 进行有效测试,因为:
建议在真实 VS Code 1.120 实例上确认图标保持可见。 — Qwen Code · qwen3.7-max |
|
This is a textbook bug fix: well-diagnosed root cause, minimal scope, net code reduction. The async context key race condition is eliminated at the source rather than patched around — removing the dual-sidebar architecture entirely and letting VS Code's native drag-to-reposition handle the secondary sidebar use case. The implementation matches what I'd propose independently: strip the All 20 unit tests pass. The only gap is live visual confirmation on VS Code 1.106+ — the PR author is transparent about this, and the fix is low-risk enough that it shouldn't block merge (easy to revert if something unexpected surfaces). Approving. ✅ 中文说明这是一个教科书式的 bug 修复:根因诊断准确、范围最小化、净代码减少。异步 context key 竞态条件从源头消除,而非打补丁绕过 —— 完全移除双侧边栏架构,把副侧边栏用例交给 VS Code 原生的拖动定位功能。 实现与我独立构想一致:去掉 20 个单元测试全部通过。唯一的缺口是 VS Code 1.106+ 上的实时视觉确认 —— PR 作者对此透明说明,且该修复风险足够低,不应阻止合并(如有意外可轻松回退)。 批准 ✅ — Qwen Code · qwen3.7-max |
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
LGTM, looks ready to ship. ✅
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
No review findings. Downgraded from Approve to Comment: CI still running.
— qwen3.7-max via Qwen Code /review
✅ Maintainer local verification — build, package, unit + mutation tests, regression scanVerified PR #5757 by building the real extension and packaging the actual Verdict: safe to merge. Root cause is correctly diagnosed, the fix is mechanically sound at the manifest level (the only thing VS Code reads to decide icon visibility), build/typecheck/lint/unit-tests are green, and a mutation test proves the new tests genuinely guard the change.
1. Root cause confirmed — async context key +
|
| contribution | location | when |
|---|---|---|
container qwen-code-sidebar |
Activity Bar | !qwen-code:supportsSecondarySidebar |
container qwen-code-secondary |
secondary sidebar | qwen-code:supportsSecondarySidebar |
view qwen-code.chatView.sidebar |
Activity Bar | !qwen-code:supportsSecondarySidebar |
view qwen-code.chatView.secondary |
secondary sidebar | qwen-code:supportsSecondarySidebar |
Flash sequence on VS Code ≥ 1.106:
- activate → key still unset →
!unset= true → Activity Bar icon shown - async
setContextresolves → key =true→!true= false → Activity Bar icon hidden → "flashes and disappears" (qwen code插件(v0.16.0)在vscode左侧栏不显示 #4488) - On older VS Code (e.g. 1.95.3)
detectSecondarySidebarSupportreturnsfalse→ key =false→!false= true → icon stays — exactly matching the report that the old version "still works".
2. The fix — verified against the shipped manifest inside the real .vsix
$ npx vsce package --no-dependencies → Packaged: pr5757-qwen.vsix (15 files, 7.13 MB) [exit 0]
$ unzip -p pr5757-qwen.vsix extension/package.json
viewsContainers keys : ['activitybar'] # secondary container GONE
activitybar container: qwen-code-sidebar when=None
view : qwen-code.chatView.sidebar when=None
onView activationEvents: ['onView:qwen-code.chatView.sidebar']
No when clause anywhere → per VS Code's contribution contract the view is always contributed → the icon can no longer be gated off by a context key. The flash mechanism is removed at the root, for all engine versions (engines.vscode: ^1.85.0), replacing the brittle runtime version-detection with a static, unconditional contribution.
3. Build / typecheck / lint / package — all green
| step | command | result |
|---|---|---|
| typecheck | tsc --noEmit |
✅ exit 0 |
| lint | eslint src |
✅ exit 0 (15 pre-existing curly warnings, 0 errors, none in PR-touched logic) |
| bundle | node esbuild.js |
✅ exit 0 (dist/extension.cjs, dist/webview.js) |
| package | vsce package --no-dependencies |
✅ exit 0 (7.13 MB .vsix) |
4. Unit tests — 20/20 across the 4 touched suites
$ npx vitest run commands/index extension package chatViewRegistration
Test Files 4 passed (4)
Tests 20 passed (20)
5. Mutation test — the new tests are non-vacuous
Reverted only the 5 source files to base (ac1e47377), kept the PR's test files, re-ran the suites. Exactly one guard per suite fails, and every unrelated test stays green (targeted, not a blanket break):
| suite | guard test | result with base source |
|---|---|---|
| chatViewRegistration | registers the sidebar host with retained webview context |
❌ FAIL (base registers 2 providers) |
| package | keeps the Activity Bar chat entry visible without runtime context |
❌ FAIL (base manifest still has when) |
| commands/index | focusChat focuses the Activity Bar chat view |
❌ FAIL (base focuses the secondary view) |
| extension | should register the webview view provider for the sidebar position |
❌ FAIL (base registers 2) |
Tests 4 failed | 16 passed (20) # base source → guards fail
→ restore PR source → 20 passed (20) # green again
6. Regression scan — no dangling references
Grepped the whole repo (excluding node_modules/dist) for every removed symbol — zero matches: CHAT_VIEW_ID_SECONDARY, supportsSecondarySidebar, detectSecondarySidebarSupport, chatView.secondary, qwen-code-secondary, secondarySidebar. The two WebViewProvider.ts / ChatWebviewViewProvider.ts changes are comment-only (no functional diff).
Risk notes (low)
- Users who had the chat pinned in the secondary sidebar via the old contribution will see it back in the Activity Bar; VS Code safely ignores stale layout state for the now-missing
chatView.secondaryview, and it remains drag-able to the secondary sidebar (native). - The removed auto-placement was itself the broken path (qwen code插件(v0.16.0)在vscode左侧栏不显示 #4488); trading it for an unconditional Activity Bar entry is a net improvement.
中文版(完整对应)
✅ 维护者本地验证 —— 构建、打包、单测 + 变异测试、回归扫描
我在 PR head(c04e9d2fb)的独立 worktree 里**构建了真实扩展并打出真实 .vsix**来验证 #5757,而不仅是看 diff。先结论,后证据。
结论:可以安全合并。 根因诊断正确;修复在 manifest 层面机制可靠(VS Code 正是读这份 manifest 决定图标是否显示);构建/类型检查/lint/单测全绿;变异测试证明新增测试确实守护了本次改动。
环境:macOS、Node 22.22.2,在
pull/5757/head的git worktree内全新npm ci。CI 三平台已全绿,本报告是独立的本地交叉核验。"闪现"这一视觉现象由作者在 Extension Development Host 的截图佐证 —— 我的沙箱无 VS Code GUI,因此我的检查以确定性方式覆盖机制(manifest + 源码 + 测试)。
1. 根因确认 —— 异步 context key + 被 when 门控的活动栏容器
origin/main 上活动栏容器被一个异步、fire-and-forget 设置的 context key 门控:
// chatViewRegistration.ts(base)—— 未 await
void vscode.commands.executeCommand('setContext', 'qwen-code:supportsSecondarySidebar', supportsSecondarySidebar);base manifest 贡献项:
| 贡献项 | 位置 | when |
|---|---|---|
容器 qwen-code-sidebar |
活动栏 | !qwen-code:supportsSecondarySidebar |
容器 qwen-code-secondary |
副侧边栏 | qwen-code:supportsSecondarySidebar |
视图 qwen-code.chatView.sidebar |
活动栏 | !qwen-code:supportsSecondarySidebar |
视图 qwen-code.chatView.secondary |
副侧边栏 | qwen-code:supportsSecondarySidebar |
VS Code ≥ 1.106 上的闪现时序:
- 激活 → key 仍未设置 →
!未设置= true → 活动栏图标显示 - 异步
setContext完成 → key =true→!true= false → 活动栏图标隐藏 → "闪一下又消失"(qwen code插件(v0.16.0)在vscode左侧栏不显示 #4488) - 老版本(如 1.95.3)
detectSecondarySidebarSupport返回false→ key =false→!false= true → 图标常驻 —— 正好对应"老版本仍正常"的报告。
2. 修复 —— 对真实 .vsix 内发布的 manifest 核验
$ npx vsce package --no-dependencies → 打包:pr5757-qwen.vsix(15 个文件,7.13 MB)[exit 0]
$ unzip -p pr5757-qwen.vsix extension/package.json
viewsContainers 键 : ['activitybar'] # 副侧边栏容器已移除
活动栏容器 : qwen-code-sidebar when=None
视图 : qwen-code.chatView.sidebar when=None
onView 激活事件 : ['onView:qwen-code.chatView.sidebar']
任何地方都没有 when 子句 → 按 VS Code 贡献契约,该视图无条件贡献 → 图标再也不会被 context key 门控掉。闪现机制在根上被移除,且对所有引擎版本(engines.vscode: ^1.85.0)生效,用静态无条件贡献替代了脆弱的运行时版本检测。
3. 构建 / 类型检查 / lint / 打包 —— 全绿
| 步骤 | 命令 | 结果 |
|---|---|---|
| 类型检查 | tsc --noEmit |
✅ exit 0 |
| lint | eslint src |
✅ exit 0(15 个既有 curly 告警,0 error,均不在本 PR 改动逻辑内) |
| 打包 bundle | node esbuild.js |
✅ exit 0(dist/extension.cjs、dist/webview.js) |
| 打 vsix | vsce package --no-dependencies |
✅ exit 0(7.13 MB .vsix) |
4. 单元测试 —— 4 个改动套件 20/20
$ npx vitest run commands/index extension package chatViewRegistration
Test Files 4 passed (4)
Tests 20 passed (20)
5. 变异测试 —— 新测试非空过
只把 5 个源文件回退到 base(ac1e47377),保留 PR 的测试文件,重跑套件。每个套件恰好挂掉一条 guard,其余无关测试全绿(精准命中、非全盘破坏):
| 套件 | guard 测试 | base 源码下结果 |
|---|---|---|
| chatViewRegistration | registers the sidebar host with retained webview context |
❌ FAIL(base 注册 2 个 provider) |
| package | keeps the Activity Bar chat entry visible without runtime context |
❌ FAIL(base manifest 仍有 when) |
| commands/index | focusChat focuses the Activity Bar chat view |
❌ FAIL(base 默认聚焦 secondary 视图) |
| extension | should register the webview view provider for the sidebar position |
❌ FAIL(base 注册 2 个) |
Tests 4 failed | 16 passed (20) # base 源码 → guard 失败
→ 恢复 PR 源码 → 20 passed (20) # 重新全绿
6. 回归扫描 —— 无悬挂引用
在全仓(排除 node_modules/dist)grep 所有被移除符号 —— 零匹配:CHAT_VIEW_ID_SECONDARY、supportsSecondarySidebar、detectSecondarySidebarSupport、chatView.secondary、qwen-code-secondary、secondarySidebar。WebViewProvider.ts / ChatWebviewViewProvider.ts 两处改动纯注释(无功能 diff)。
风险评估(低)
- 此前通过旧贡献把聊天固定在副侧边栏的用户会看到它回到活动栏;VS Code 会安全忽略已不存在的
chatView.secondary视图的旧布局状态,且仍可原生拖回副侧边栏。 - 被移除的自动放置本身就是出问题的路径(qwen code插件(v0.16.0)在vscode左侧栏不显示 #4488);用无条件活动栏入口替换它是净收益。
What this PR does
The Qwen Code chat view is now always contributed to the left Activity Bar on every supported VS Code version. The previously added secondary-sidebar placement — together with the runtime version detection and the context key that switched between the two locations — has been removed. Users who prefer the chat in the secondary sidebar can still drag it there, which VS Code supports natively.
Why it's needed
On VS Code 1.106 and newer, the Activity Bar view container was gated behind a
whenclause tied to a "supports secondary sidebar" context key, and the chat was revealed only in the secondary sidebar instead. Because that context key is set asynchronously after activation, the Activity Bar entry appeared for a moment and then vanished — matching the report in #4488, where the icon "flashes and disappears" on VS Code 1.120 while still working on the older 1.95.3. Collapsing back to a single Activity Bar view restores the icon for all versions.Reviewer Test Plan
How to verify
Automated (run locally):
npx tsc --noEmit— passesnpx vitest runon the touched suites (commands / extension / package / chatViewRegistration) — 20/20 passEvidence (Before & After)
Before: on VS Code >=1.106 the Activity Bar icon flashed and then disappeared (#4488).
After: verified in the Extension Development Host on VS Code 1.122.1 — the Qwen Code icon stays in the left Activity Bar and the chat view opens in the primary sidebar.
Tested on
Environment (optional)
Extension Development Host (F5) on macOS, VS Code 1.122.1. Unit tests via vitest in
packages/vscode-ide-companion.Risk & Scope
chatView.secondaryview is simply no longer contributed; VS Code ignores stale layout state for a missing view.Linked Issues
Closes #4488
中文说明
这个 PR 做了什么
Qwen Code 聊天视图现在在所有受支持的 VS Code 版本上都固定贡献到左侧活动栏(Activity Bar)。此前新增的副侧边栏(secondary sidebar)放置方式,连同用于在两个位置之间切换的运行时版本检测和 context key,一并移除。偏好把聊天放到副侧边栏的用户仍可手动拖动 —— 这是 VS Code 原生支持的。
为什么需要
在 VS Code 1.106 及更高版本上,活动栏视图容器被一个绑定到「是否支持副侧边栏」context key 的
when子句门控,聊天只显示在副侧边栏里。由于该 context key 在激活后异步设置,活动栏入口会先出现一下、随后消失 —— 正对应 #4488 的现象:在 VS Code 1.120 上图标「闪一下又没了」,而在较老的 1.95.3 上正常。回退为单一活动栏视图,可在所有版本上恢复该图标。验证方式
已在 VS Code 1.122.1 的 Extension Development Host 实测:图标常驻活动栏、点击后聊天视图在主侧边栏打开(见上方截图)。自动化(本地已跑):
npx tsc --noEmit通过;改动涉及的 4 个测试套件npx vitest run20/20 通过。风险与范围
chatView.secondary视图不再贡献;VS Code 会忽略缺失视图的旧布局状态。