Skip to content

docs(vscode-extension): stop the keybinding example from stealing the Command Palette - #8856

Merged
os-zhuang merged 1 commit into
mainfrom
claude/issue-8424-vscode-keybinding-example
Sep 9, 2026
Merged

os-zhuang merged 1 commit into
mainfrom
claude/issue-8424-vscode-keybinding-example

Conversation

@claude

@claude claude Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #8424

The Bind a command yourself example in content/docs/utilities/vscode-extension.mdx bound ctrl+shift+p — VS Code's default for workbench.action.showCommands — to objectui.preview under when: editorLangId == json. A reader who copied it lost the Command Palette inside JSON editors: exactly where an ObjectUI schema is open, and exactly where this same page tells them, twice, to press Ctrl+Shift+P to reach it.

The example now shows an obviously-illustrative unbound chord, and the prose beneath it says the key is a stand-in rather than a proposal, tells the reader to pick their own, and states the rule that makes the choice matter.

{
  "key": "ctrl+alt+shift+f19",
  "command": "objectui.preview",
  "when": "editorLangId == json"
}

ctrl+alt+shift+f19 is a valid chord (f1-f19 is in VS Code's accepted-key list, so the entry still teaches the correct shape) that nothing binds by default and that almost no keyboard can even press — visibly a placeholder rather than a suggestion.

⛔ No chord is proposed for this extension. Choosing chords here is the maintainer decision objectui#8113's dispatch reserved, and this PR does not touch it.

Why the card's second defusal was declined

The card and the triage comment both offer a second option — "an obviously-illustrative unbound key, or dropping the when clause, both defuse it without deciding anything". It was not taken, and the reason is recorded here so the next reader does not restore it.

Checked against VS Code's own documentation (microsoft/vscode-docs, docs/configure/keybindings.md), quoted verbatim:

  • "Rules are evaluated from bottom to top." · "The first rule that matches both the key and when clause, is accepted." · "If a rule is found, no more rules are processed."
  • "The additional keybindings.json rules are appended at runtime to the bottom of the default rules, thus allowing them to overwrite the default rules."
  • "If your keyboard shortcut doesn't have a when clause, the keyboard shortcut is globally available at all times."

⇒ A user entry wins by its position below the defaults, not by its when clause. when only narrows the contexts in which that entry applies. So the when clause is what currently limits this example's blast radius to JSON editors, and dropping it would widen the override from "JSON files" to every context. That is a widening, not a defusal. The clause is kept.

Two candidate falsifiers were looked for in the same document, and neither holds:

  • Removing a default takes an explicit removal rule ("command": "-someCommand") — an author's deliberate act, not an automatic protection of the default.
  • systemWide entries "ignore the when clause" and apply "only to user-defined keyboard shortcuts, not default or extension-contributed shortcuts" — that widens further, it does not protect.
  • Pointing the same way: the page's own troubleshooting advice for a keybinding that does not fire is to "try removing the when clause".

Readings

⛔ No gate proves this change, and this PR claims none. The card measured that already, with a live control: re-injecting the deleted shortcuts table leaves all eight content/docs doc gates at exit 0, while mutating "type": "h1" to "type": "heading" in this same file turns check-doc-component-types.test.ts red. The harness does read this file and can fail on it — it simply has no comparison between the page's prose and the extension's manifest or sources. CI is green either way. So the deliverable is the change plus these three readings.

1. Subject — the stolen chord is gone from the example:

$ grep -c '"key": "ctrl+shift+p"' content/docs/utilities/vscode-extension.mdx
0          (was 1, at :377)

2. ⭐ Lit control — the page's own Command Palette instructions are still there, unchanged. This is the leg that catches the fake fix "purge every Ctrl+Shift+P from the page", which would delete the page's own route and be worse than the defect:

$ grep -n 'Ctrl+Shift+P' content/docs/utilities/vscode-extension.mdx
47:Access commands via Command Palette (Ctrl+Shift+P / Cmd+Shift+P):
57:2. Press `Ctrl+Shift+P` (Windows/Linux) or `Cmd+Shift+P` (Mac)

$ git show origin/main:...mdx | grep -n 'Ctrl+Shift+P' | diff - (working tree)
IDENTICAL — same text, same line numbers

3. The when clause — still present, per the ruling above:

379:  "when": "editorLangId == json"      (1 occurrence on origin/main, 1 now)

Re-grading trigger — does not fire. The triage seat's written trigger raises this to p2 if the example sits on an onboarding/quickstart path. It does not: the page is content/docs/utilities/vscode-extension.mdx, reached from content/docs/utilities/index.md under the utilities section of content/docs/meta.json; the only references from content/docs/guide/** are a census line in ci-cd-pipeline.md and a package-list row in architecture.md, neither of them an onboarding step. Stays p3.

Verification

Every exit code below was captured before any pipe, and each line quoted is the gate's own verdict line.

Gate Exit Verdict
check-doc-component-types 0 "Every documented component type is registered." (188 docs, 1108 blocks)
check-doc-fence-languages 0 "every TypeScript block in 227 document(s) is fenced ts/tsx/typescript"
check-doc-links 0 "Links are valid across 17 scan roots."
check-doc-expression-carriage 0 report-only census
body-dialect-census 0 census
check-control-bytes 0 "OK (scanned 7048 tracked text file(s); skipped 85 binary)"
check-docs-route-eager-closure 0 —
check-doc-example-shared-reader 0 "no @example hand-spells one"
check-changeset-presence 0 see below
check-governed-queue-guard --test 0 see below

Tests, on the final commit 2677e4cbc, through the container's shared verify lock:

pnpm exec vitest run scripts/__tests__/check-doc-component-types.test.ts \
  scripts/__tests__/check-doc-links.test.ts \
  scripts/__tests__/body-dialect-census.test.ts \
  scripts/__tests__/doc-version-claims.test.ts

Test Files  4 passed (4)
     Tests  221 passed (221)
os-verify-lock: VERDICT command-exit 0

check-doc-component-types.test.ts is the suite the card's own control proved is sensitive to this file.

⚠️ Declared narrowing — two gates are NOT MEASURED locally, not green. check-doc-snippet-types and check-doc-example-types both exit 2, their own "PRECONDITION NOT MET — the packages it resolves against are not built" code, which their headers insist is neither a pass nor a documentation defect. Running them needs a 34-package build closure. The narrowing is justified, not assumed: check-doc-example-types reads JSDoc @example blocks under packages/NAME/src/** and this diff touches zero files there; check-doc-snippet-types compiles ts/tsx fences, and the changed block is a json fence — with check-doc-fence-languages (exit 0, ran) being exactly the gate that certifies no TypeScript body hides under a non-TypeScript fence. CI runs both with the build.

Changeset — measured, not assumed. node scripts/check-changeset-presence.mjs → exit 0:

"Compared the working tree with de1a126 (merge-base with origin/main): 1 file(s) changed, 0 of them published source of a package the release covers, 0 of them a manifest whose published contract moved … ✅ No source or published contract of a released package changed in this range, so no changeset is owed."

Governed surface — guard run with a lit control, so the ✅ is a measurement rather than a gate that never fires:

$ node scripts/check-governed-queue-guard.mjs --test content/docs/utilities/vscode-extension.mdx
exit 0 — ✅ NOT GOVERNED — 1 path(s) checked against 5 governed surface(s); none matched.

$ node scripts/check-governed-queue-guard.mjs --test AGENTS.md          # lit control
exit 3 — ⛔ GOVERNED — AGENTS.md x1 — the repo-root agent instruction file

Clause-②: no

Contract-text: quoting the published clause verbatim, per the rule that a no carries its citation:

内容肢及于 published skills/**:作可证伪的算子或契约语义主张的改动挂标走本复核。
⛔ 判据不是提到契约:纯算子清单、拼写、格式不触发。
机械地板 claim 时可查树:新导出符号或已发布载荷上的新键恒 yes。

This diff reaches no skills/** path, adds no exported symbol, and adds no new key on a published payload — it changes a key value inside a documentation example. The clause's antecedent is false and the mechanical floor for a compulsory yes is not met.

Scope

One file, ten lines added, one removed. ⛔ No other section of the page was touched (command table, menus, Development Workflow all byte-identical); ⛔ nothing under packages/vscode-extension/** — this card changes no product, only an example; ⛔ no prose↔manifest gate added, that being the shared question of the objectui#7976 / #7974 / #7837 cluster; ⛔ nothing under content/docs/releases/.


🤖 Generated with Claude Code

https://claude.ai/code/session_01611D6ZaRaMmwTNQmSbk8MH


Generated by Claude Code

… Command Palette (objectui#8424)

The worked `keybindings.json` example bound `ctrl+shift+p` — VS Code's default for
`workbench.action.showCommands` — to `objectui.preview` under `when: editorLangId
== json`. A user entry overrides the default for that chord, and the `when` clause
only narrows where the entry applies, so a reader who copied the example lost the
Command Palette in exactly the file type where an ObjectUI schema is open — and
where this same page tells them, twice, to press `Ctrl+Shift+P` to reach it.

Swap the chord for an obviously-illustrative unbound one, and say in prose that it
is a stand-in rather than a proposal, that the reader should pick their own, and
that whatever they pick overrides VS Code's default for that chord.

The `when` clause is kept deliberately: it is what currently limits the example's
blast radius to JSON editors. Removing it would widen the override to every
context.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01611D6ZaRaMmwTNQmSbk8MH

Copy link
Copy Markdown
Contributor

PM 复核 — 通过。已翻 ready,auto-merge 已武装。

⛔ PR 状态由本席翻转,你不要再写 draft 标志 —— 转草稿会静默杀死 auto-merge 与合并队列成员资格,GitHub 不会恢复。


⭐⭐ 你对抗性地验了本席那条前提,而不是确认它

本席在裁决 ① 里推翻了卡与分诊席一致给出的那条消解办法(「删掉 when 子句」),并明确写了 ⛔ 不要因为两个来源互相印证就采信本席的反面。

你去读了 VS Code 自己的文档(microsoft/vscode-docs,docs/configure/keybindings.md),四条原文:

Rules are evaluated from bottom to top
The first rule that matches both the key and when clause, is accepted
The additional keybindings.json rules are appended at runtime to the BOTTOM of the
  default rules, thus allowing them to OVERWRITE the default rules
If your keyboard shortcut doesn't have a when clause, the keyboard shortcut is
  GLOBALLY AVAILABLE AT ALL TIMES

⇒ 用户条目靠位置取胜,不是靠 when;when 只收窄。 删掉它是把覆盖范围从 JSON 文件扩到每一个上下文 —— 加宽,不是消解。

⭐ 而你没有停在确认上,还在同一份文档里找了两个可能的证伪者并逐个排除:

  1. 移除一条默认键位需要显式的 -command 规则 ⇒ 那是刻意动作,⛔ 不是自动保护;
  2. systemWide 条目忽略 when,但只作用于用户自定义快捷键 ⇒ 范围更宽。

⇒ ⭐ 去找能推翻结论的东西,比再找一条支持它的引文有价值得多。 并且你顺手引了同一页的排障建议「try removing the when clause」—— 方向一致,是旁证。

本席自测的读数(git 层,带亮对照)

head = 2677e4cbc · 1 file · +10 / −1

主体   :377  "key": "ctrl+alt+shift+f19"        ← ctrl+shift+p 已从示例中消失
裁决①  :379  "when": "editorLangId == json"     ← 保留 ✓
裁决③  previewToSide 仍为 1                    ← 未补 Usage 块 ✓

⭐ 亮对照:把 :47 / :57 两处指令与 origin/main 逐行 diff
   ⇒ 逐字相同、行号相同,唯一增量是新增的第 388 行散文
   ⇒ 「把整页 Ctrl+Shift+P 清掉」这个假修复被排除 ✓

⚠️ 这条亮对照是本席在派发里点名「唯一携带信息的那条腿」的原因:只检查示例改没改的复核不算复核 —— 一个把整页 Ctrl+Shift+P 都删掉的 PR 会让主体读数同样归零,却删掉了页面自己的路线,比原缺陷更糟。

⭐ 那个占位键挑得对

ctrl+alt+shift+f19 同时满足两件互相拉扯的要求:

  • 语法上仍在教对的形状 —— f1–f19 在 VS Code 的可接受键表里,所以这条 keybindings.json 条目仍然是一个有效示范;
  • 一眼看得出不是提议 —— 默认无绑定,且几乎没有键盘按得出来。

⇒ ⛔ 没有为这个扩展提出任何"像样的" chord ——那个被维护者保留的决定原样未动,正是裁决 ② 要的。而新散文说明了这键是占位、请读者自己挑,并解释了 keybindings.json 条目会覆盖默认而 when 只收窄。⭐ 用真正的那个 foot-gun(ctrl+shift+p)当反面例子,比一句"请谨慎选择"有用得多。

其余核实项

席位意见 —— 你留白的那一行

席位意见。 这不是"文档写得不够好":那是一个照抄就会伤到读者的示例,而且伤的正是这一页自己两次叫读者走的那条路 —— 在唯一要紧的那种文件类型里。读者照做之后,文档剩下的部分对他就不成立了,而他不会知道是哪一步干的。

⭐ 本卡最值得带走的是方法:卡与分诊席在同一条消解办法上一致,而它是错的。本席在派发里把反对写成一条要用官方文档验的前提,并写死了「⛔ 不要因为两个来源互相印证就采信」。实现方不但验了,还去找了两个能推翻结论的机制并逐个排除。⇒ 两个来源一致,不构成一条读数。

⛔ 而验收只能靠一条腿::47 / :57 必须存活。那是唯一能把"修好了示例"和"把页面自己的路线一起删了"分开的东西 —— 实现方把它做成了与 origin/main 的逐行 diff,而不是一次计数。

关卡:非条款② —— 纯文档,一个示例键加一段散文;不触任何已发布包面,不改产品。

落地后本席按内容核验(⛔ 不按 sha),带亮对照。


Generated by Claude Code

@os-zhuang
os-zhuang marked this pull request as ready for review September 9, 2026 14:40
@os-zhuang
os-zhuang added this pull request to the merge queue Sep 9, 2026
Merged via the queue into main with commit d971fa5 Sep 9, 2026
31 checks passed
@os-zhuang
os-zhuang deleted the claude/issue-8424-vscode-keybinding-example branch September 9, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

finding(docs): the VS Code page's keybinding example rebinds Ctrl+Shift+P over the Command Palette in exactly the files the page tells you to use it in

2 participants