From c1bea9047eebf668585ca058abb26c57e61184c4 Mon Sep 17 00:00:00 2001 From: Menghuan1918 Date: Sun, 11 Oct 2026 22:39:18 +0800 Subject: [PATCH] =?UTF-8?q?fix(skill):=20board-sync=20=E6=B8=85=E6=8E=89?= =?UTF-8?q?=E5=A4=B1=E6=95=88=E7=9A=84=E7=BB=A7=E6=89=BF=E4=BC=98=E5=85=88?= =?UTF-8?q?=E7=BA=A7=EF=BC=88PR=20=E7=9A=84=E4=BC=98=E5=85=88=E7=BA=A7?= =?UTF-8?q?=E6=9D=A5=E6=BA=90=E5=85=B3=E9=97=AD=E5=90=8E=E7=95=99=E7=A9=BA?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 首次在 2026-10-11 的分诊里跑全量同步时,verify() 报了 23 条 mismatched,全部是 PR 的 优先级:脚本只在「有新值」时写字段,而 PR 的优先级是从它引用的仍开着的 issue 继承的——那批 issue 一关闭,期望值变成「留空」,旧值却留在板上,于是脚本自己算出的 期望与看板永远对不上。 - 期望值为空时改为清空字段:value:{singleSelectOptionId:null}(value:null 被 schema 拒,ProjectV2FieldValue! 非空)。 - gh-gotchas.md 记下这条坑。 --- .agents/skills/issue-triage/references/gh-gotchas.md | 1 + .agents/skills/issue-triage/scripts/board-sync.mjs | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.agents/skills/issue-triage/references/gh-gotchas.md b/.agents/skills/issue-triage/references/gh-gotchas.md index 076c97fd..a91dc946 100644 --- a/.agents/skills/issue-triage/references/gh-gotchas.md +++ b/.agents/skills/issue-triage/references/gh-gotchas.md @@ -16,6 +16,7 @@ ## 字段与选项 - **`updateProjectV2Field(singleSelectOptions: [...])` 是整体替换**:被替换掉的选项 id 失效、`Status` 值会掉;想改选项就把**全部**目标选项一次列全(name/color/description 三个字段都是必填),改完**重新给条目写一遍值**。 +- **清空某个单选字段的值:传 `value:{singleSelectOptionId:null}`**,不要传 `value:null`——`UpdateProjectV2ItemFieldValueInput.value` 的类型是 `ProjectV2FieldValue!`(非空),传 null 会被 schema 拒(`argumentLiteralsIncompatible`)。`board-sync.mjs` 依赖这条来清掉「继承来源已关闭」的 PR 优先级:只在有新值时才写的实现会让 `verify()` 永远报 `mismatched`(2026-10-11 实测 23 条)。 - option id 会随替换变化 → 脚本每次运行都按**名字**重新解析 id,不要硬编码。 - `ProjectV2SingleSelectFieldOptionInput` 三个字段全 `NON_NULL`:`name` / `color`(枚举 `GRAY BLUE GREEN YELLOW ORANGE RED PINK PURPLE`)/ `description`(可空串)。 diff --git a/.agents/skills/issue-triage/scripts/board-sync.mjs b/.agents/skills/issue-triage/scripts/board-sync.mjs index 36d0ac96..fa1e8f0f 100644 --- a/.agents/skills/issue-triage/scripts/board-sync.mjs +++ b/.agents/skills/issue-triage/scripts/board-sync.mjs @@ -174,7 +174,13 @@ for (const [key, want] of desired) { } const wantValues = { '优先级': want.prio, '批次': want.batch, 'Status': want.status }; for (const [name, value] of Object.entries(wantValues)) { - if (!value || item.current[name] === value) continue; + if ((item.current[name] ?? undefined) === (value ?? undefined)) continue; + // A value that is no longer desired must be CLEARED, not left behind: a PR + // inherits its priority from the issues it cites, so when the last of those + // issues closes the inherited value has to go (otherwise verify() fails on + // exactly this mismatch). `value: null` is rejected — ProjectV2FieldValue! + // is non-null; the null option id is what clears a single-select. + if (!value) { mutations.push({ itemId: item.id, fieldId: fieldId[name], clear: true }); continue; } const oid = optionId[`${name}:${value}`]; if (!oid) { console.log(`! ${key} no option ${name}:${value}`); continue; } mutations.push({ itemId: item.id, fieldId: fieldId[name], optionId: oid }); @@ -182,7 +188,7 @@ for (const [key, want] of desired) { } for (let i = 0; i < mutations.length; i += 16) { const chunk = mutations.slice(i, i + 16); - gql('mutation{' + chunk.map((m, k) => `m${k}:updateProjectV2ItemFieldValue(input:{projectId:"${PROJECT}",itemId:"${m.itemId}",fieldId:"${m.fieldId}",value:{singleSelectOptionId:"${m.optionId}"}}){projectV2Item{id}}`).join(' ') + '}'); + gql('mutation{' + chunk.map((m, k) => `m${k}:updateProjectV2ItemFieldValue(input:{projectId:"${PROJECT}",itemId:"${m.itemId}",fieldId:"${m.fieldId}",value:${m.clear ? '{singleSelectOptionId:null}' : `{singleSelectOptionId:"${m.optionId}"}`}}){projectV2Item{id}}`).join(' ') + '}'); } console.log(`items: ${items.size} on board | field writes: ${mutations.length}`); verify();