Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(desktop): issue 反馈附带构建区域——cn 标 CN、dev 标 Dev、global 不标 (#739)
Dashe279b1732047
diff --git a/apps/desktop/src/main/github-issue/__tests__/githubIssueSubmitService.test.ts b/apps/desktop/src/main/github-issue/__tests__/githubIssueSubmitService.test.tsindex a894e67bbe..734ef6eba1 100644--- a/apps/desktop/src/main/github-issue/__tests__/githubIssueSubmitService.test.ts+++ b/apps/desktop/src/main/github-issue/__tests__/githubIssueSubmitService.test.ts@@ -39,6 +39,7 @@ function makeDeps(over: Partial<GithubIssueSubmitServiceDeps> = {}) {postIssue,getAppVersion: () => '0.0.112',getOsInfo: () => ({ platform: 'darwin', arch: 'arm64', osVersion: '25.5.0' }),+ getRegion: () => 'cn',getFallbackLocale: () => 'en',getSubmitterName: () => 'Carol',...over,@@ -76,7 +77,13 @@ describe('submitGithubIssueWithConfirm', () => {expect(confirm).toHaveBeenCalledWith('sess-1',{ title: REQ.title, body: REQ.body, type: 'bug' },- { appVersion: '0.0.112', platform: 'darwin', arch: 'arm64', osVersion: '25.5.0' },+ {+ appVersion: '0.0.112',+ platform: 'darwin',+ arch: 'arm64',+ osVersion: '25.5.0',+ region: 'cn',+ },PLATFORM_IDENTITY,);expect(postIssue).toHaveBeenCalledTimes(1);@@ -87,6 +94,7 @@ describe('submitGithubIssueWithConfirm', () => {expect(posted.appVersion).toBe('0.0.112');expect(posted.userName).toBe('Carol');expect(posted.description).toContain('用户改过的正文');+ expect(posted.description).toContain('**版本区域**: CN');expect(posted.description).toContain('**OS**: darwin arm64 (25.5.0)');expect(posted.description).toContain('**界面语言**: ja');expect(res).toEqual({@@ -98,6 +106,32 @@ describe('submitGithubIssueWithConfirm', () => {});});+ it('env 块只标注非默认区域: cn → CN / dev → Dev,global 省略该行', async () => {+ for (const [region, label] of [+ ['cn', '**版本区域**: CN'],+ ['dev', '**版本区域**: Dev'],+ ] as const) {+ const { deps, confirm, postIssue } = makeDeps({ getRegion: () => region });+ await expect(submitGithubIssueWithConfirm(deps, REQ)).resolves.toMatchObject({ ok: true });+ // 卡片展示的区域必须与最终写进 issue 的是同一个值。+ expect(confirm.mock.calls[0]![2]).toMatchObject({ region });+ expect(postIssue.mock.calls[0]![1]().description).toContain(label);+ }+ });++ it('global 是默认区域: 不写版本区域行,「没有这一行」即国际版', async () => {+ const { deps, confirm, postIssue } = makeDeps({ getRegion: () => 'global' });+ await expect(submitGithubIssueWithConfirm(deps, REQ)).resolves.toMatchObject({ ok: true });+ // 区域本身照常传给卡片(卡片自己决定不渲染),但正文里不能出现这一行。+ expect(confirm.mock.calls[0]![2]).toMatchObject({ region: 'global' });+ const description = postIssue.mock.calls[0]![1]().description!;+ expect(description).not.toContain('版本区域');+ expect(description).not.toContain('global');+ // 其余 env 行不受影响,不能因为省略区域行把 env 块整段搞坏。+ expect(description).toContain('**OS**: darwin arm64 (25.5.0)');+ expect(description).toContain('**界面语言**: zh-CN');+ });+it('身份解析收到当前 session workingDir', async () => {const resolveSubmissionIdentity = vi.fn(async () => PLATFORM_IDENTITY);const { deps } = makeDeps({ resolveSubmissionIdentity });@@ -160,6 +194,7 @@ describe('submitGithubIssueWithConfirm', () => {expect(res).toMatchObject({ ok: true, finalTitle: 't'.repeat(200) });const posted = postIssue.mock.calls[0]![1]();expect(posted.description!.length).toBeLessThanOrEqual(5000);+ expect(posted.description).toContain('**版本区域**: CN');expect(posted.description).toContain('**界面语言**: zh-CN');});diff --git a/apps/desktop/src/main/github-issue/__tests__/issueConfirmBridge.test.ts b/apps/desktop/src/main/github-issue/__tests__/issueConfirmBridge.test.tsindex 41b849aa3f..653cbd2fcb 100644--- a/apps/desktop/src/main/github-issue/__tests__/issueConfirmBridge.test.ts+++ b/apps/desktop/src/main/github-issue/__tests__/issueConfirmBridge.test.ts@@ -9,7 +9,13 @@ import { IssueConfirmBridge } from '../issueConfirmBridge';import { MAKER_PUSH } from '../../maker-ipc/channels';const DRAFT = { title: '标题标题标题', body: '正文'.repeat(20), type: 'bug' as const };-const ENV = { appVersion: '0.0.112', platform: 'darwin', arch: 'arm64', osVersion: '25.5.0' };+const ENV = {+ appVersion: '0.0.112',+ platform: 'darwin',+ arch: 'arm64',+ osVersion: '25.5.0',+ region: 'cn' as const,+};const IDENTITY = { kind: 'github-user', login: 'octocat' } as const;function lastRequestId(broadcast: ReturnType<typeof vi.fn>): string {diff --git a/apps/desktop/src/main/github-issue/githubIssueSubmitService.ts b/apps/desktop/src/main/github-issue/githubIssueSubmitService.tsindex 8cadf7ee47..30f74c2017 100644--- a/apps/desktop/src/main/github-issue/githubIssueSubmitService.ts+++ b/apps/desktop/src/main/github-issue/githubIssueSubmitService.ts@@ -10,6 +10,9 @@* 模块保持 electron-free,全部依赖注入(规则 14),单测直接调 submitGithubIssueWithConfirm。*/+import type { CindyRegion } from '@cindy/maker-shared/brand-identity';++import { ISSUE_REGION_CODE } from '../../shared/issueRegionCode.js';import type {IssueConfirmDecision,IssueDraft,@@ -75,6 +78,8 @@ export interface GithubIssueSubmitServiceDeps {) => Promise<GithubIssuePostResponse>;getAppVersion: () => string;getOsInfo: () => { platform: string; arch: string; osVersion: string };+ /** 本构建的区域身份(构建期烘焙);同版本号的 cn / global 是两个不同的包。 */+ getRegion: () => CindyRegion;/** main 侧 OS locale,仅当 renderer 未回传 uiLanguage 时兜底。 */getFallbackLocale: () => string;/** 当前 Cindy membership 的展示名,仅用于 issue 正文标记提交人。 */@@ -92,6 +97,7 @@ export async function submitGithubIssueWithConfirm(const env: IssueEnvInfo = {appVersion: deps.getAppVersion(),...deps.getOsInfo(),+ region: deps.getRegion(),};let submissionIdentity: IssueSubmissionIdentity;@@ -131,9 +137,12 @@ export async function submitGithubIssueWithConfirm(decision.type !== req.type;const uiLanguage = decision.uiLanguage ?? deps.getFallbackLocale();+ const regionCode = ISSUE_REGION_CODE[env.region];const envBlock = ['','---',+ // global 不写这一行 —— 缺失即默认区域,理由见 ISSUE_REGION_CODE(与确认卡片同源)。+ ...(regionCode ? [`**版本区域**: ${regionCode}`] : []),`**OS**: ${env.platform} ${env.arch} (${env.osVersion})`,`**界面语言**: ${uiLanguage}`,].join('\n');diff --git a/apps/desktop/src/main/github-issue/index.ts b/apps/desktop/src/main/github-issue/index.tsindex 4b43181b38..f7fb252830 100644--- a/apps/desktop/src/main/github-issue/index.ts+++ b/apps/desktop/src/main/github-issue/index.ts@@ -10,6 +10,7 @@ import os from 'node:os';import { app } from 'electron';+import { CURRENT_CINDY_REGION } from '../../shared/brandRegion.js';import { getCurrentMembershipDisplayName } from '../authManager';import { getGhostManager, getGhostPipeDispatcher } from '../cindy-brain';import { isGhostDisabledForWorkdir } from '../cindy-brain/ghostWorkdirPrefs.js';@@ -96,6 +97,7 @@ export async function submitGithubIssueForSession(arch: process.arch,osVersion: os.release(),}),+ getRegion: () => CURRENT_CINDY_REGION,getFallbackLocale: () => app.getLocale(),getSubmitterName: getCurrentMembershipDisplayName,},diff --git a/apps/desktop/src/main/github-issue/issueConfirmBridge.ts b/apps/desktop/src/main/github-issue/issueConfirmBridge.tsindex 3225fbd77d..7ab5b8976b 100644--- a/apps/desktop/src/main/github-issue/issueConfirmBridge.ts+++ b/apps/desktop/src/main/github-issue/issueConfirmBridge.ts@@ -19,6 +19,8 @@import { randomUUID } from 'node:crypto';+import type { CindyRegion } from '@cindy/maker-shared/brand-identity';+import { MAKER_PUSH } from '../maker-ipc/channels';export interface IssueDraft {@@ -33,6 +35,11 @@ export interface IssueEnvInfo {platform: string;arch: string;osVersion: string;+ /**+ * 本构建的区域身份(中国版 / 国际版 / 开发版)。构建期烘焙、运行时不可切换,+ * 但同一个版本号在两区是两个不同的包——反馈里没有它就分不清用户装的是哪一个。+ */+ region: CindyRegion;}/** 确认后真正写入 GitHub 的身份;卡片必须原样展示,避免把平台代提交误认成用户本人。 */diff --git a/apps/desktop/src/renderer/__tests__/issueConfirmPayload.test.ts b/apps/desktop/src/renderer/__tests__/issueConfirmPayload.test.tsindex 6680944595..59c8f0fe2a 100644--- a/apps/desktop/src/renderer/__tests__/issueConfirmPayload.test.ts+++ b/apps/desktop/src/renderer/__tests__/issueConfirmPayload.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from 'vitest';-import { parseIssueSubmissionIdentity } from '@/lib/issueConfirmPayload';+import { parseIssueEnvRegion, parseIssueSubmissionIdentity } from '@/lib/issueConfirmPayload';describe('parseIssueSubmissionIdentity', () => {it('保留 GitHub 用户和平台的实际 login', () => {@@ -20,3 +20,20 @@ describe('parseIssueSubmissionIdentity', () => {expect(parseIssueSubmissionIdentity(null)).toBeNull();});});++describe('parseIssueEnvRegion', () => {+ it('保留三种合法构建区域', () => {+ expect(parseIssueEnvRegion('cn')).toBe('cn');+ expect(parseIssueEnvRegion('global')).toBe('global');+ expect(parseIssueEnvRegion('dev')).toBe('dev');+ });++ it('未知 / 缺失 / 非字符串一律 undefined,不猜区域', () => {+ // 猜错的代价是把中国版用户的反馈标成国际版,宁可不展示。+ expect(parseIssueEnvRegion('CN')).toBeUndefined();+ expect(parseIssueEnvRegion('china')).toBeUndefined();+ expect(parseIssueEnvRegion(undefined)).toBeUndefined();+ expect(parseIssueEnvRegion(null)).toBeUndefined();+ expect(parseIssueEnvRegion(1)).toBeUndefined();+ });+});diff --git a/apps/desktop/src/renderer/__tests__/issueRegionCode.consistency.test.ts b/apps/desktop/src/renderer/__tests__/issueRegionCode.consistency.test.tsnew file mode 100644index 0000000000..c78a99fc05--- /dev/null+++ b/apps/desktop/src/renderer/__tests__/issueRegionCode.consistency.test.ts@@ -0,0 +1,67 @@+/**+ * issue 区域代号的跨侧一致性 —— 确认卡片(走 i18n)与 issue 正文(走+ * ISSUE_REGION_CODE 常量)必须对同一个区域给出同一个代号。+ *+ * 为什么需要专门一测:确认卡片的契约是「展示的就是最终写进 issue 的内容」,但两侧+ * 走的是不同机制(卡片按 DESIGN.md §16.3 要求走 i18n,便于日后改判为可译文案;正文+ * 直接落常量,因为读者是维护者、不跟随界面语言)。机制不同就没有编译期约束——改了+ * 一边的取值、或新增区域只补了一边,typecheck 与各自的单测都不会响,用户确认时看到+ * 的区域却与实际提交的正文不一致。这一测就是补上那道缺失的信号。+ */++import { describe, expect, it } from 'vitest';++import { ISSUE_REGION_CODE, shouldLabelIssueRegion } from '../../shared/issueRegionCode';+import en from '../i18n/locales/en/common.json';+import ja from '../i18n/locales/ja/common.json';+import ko from '../i18n/locales/ko/common.json';+import zhCN from '../i18n/locales/zh-CN/common.json';++const LOCALES: Record<string, { issueAgent: { confirm: Record<string, unknown> } }> = {+ 'zh-CN': zhCN,+ en,+ ja,+ ko,+};++/** region → 卡片 i18n key 后缀(cn → regionCodeCn)。 */+function confirmKeyFor(region: string): string {+ return `regionCode${region.charAt(0).toUpperCase()}${region.slice(1)}`;+}++describe('issue 区域代号:卡片 i18n 与 issue 正文常量一致', () => {+ it('有代号的区域: 四语 i18n 值逐字等于常量,且不被翻译', () => {+ const labeled = Object.entries(ISSUE_REGION_CODE).filter(([, code]) => code !== null);+ // 防塌陷:常量被清空时下面的循环会变成空跑而全绿。+ expect(labeled.length).toBeGreaterThan(0);+ for (const [region, code] of labeled) {+ for (const [locale, bundle] of Object.entries(LOCALES)) {+ expect(+ bundle.issueAgent.confirm[confirmKeyFor(region)],+ `${locale} 的 issueAgent.confirm.${confirmKeyFor(region)} 应为 ${code}(区域代号四语同文、不翻译)`,+ ).toBe(code);+ }+ }+ });++ it('不标注的区域: 四语都不得存在对应 key,避免出现「能显示但正文不写」的半套实现', () => {+ const unlabeled = Object.entries(ISSUE_REGION_CODE).filter(([, code]) => code === null);+ expect(unlabeled.length).toBeGreaterThan(0);+ for (const [region] of unlabeled) {+ for (const [locale, bundle] of Object.entries(LOCALES)) {+ expect(+ bundle.issueAgent.confirm[confirmKeyFor(region)],+ `${locale} 不应有 issueAgent.confirm.${confirmKeyFor(region)}——${region} 按产品规则不标注(DESIGN.md §16.3)`,+ ).toBeUndefined();+ }+ }+ });++ it('global 不标是硬规则(DESIGN.md §16.3 不得回退),缺失 region 同样不标', () => {+ expect(ISSUE_REGION_CODE.global).toBeNull();+ expect(shouldLabelIssueRegion('global')).toBe(false);+ expect(shouldLabelIssueRegion(undefined)).toBe(false);+ expect(shouldLabelIssueRegion('cn')).toBe(true);+ expect(shouldLabelIssueRegion('dev')).toBe(true);+ });+});diff --git a/apps/desktop/src/renderer/features/cc-agent/IssueConfirmCard.tsx b/apps/desktop/src/renderer/features/cc-agent/IssueConfirmCard.tsxindex 9c282c368c..c70666cf3b 100644--- a/apps/desktop/src/renderer/features/cc-agent/IssueConfirmCard.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/IssueConfirmCard.tsx@@ -18,6 +18,7 @@ import { useTranslation } from 'react-i18next';import { cn } from '@/lib/utils';import type { PendingIssueConfirm } from '@/lib/makerChatStore';+import { shouldLabelIssueRegion } from '../../../shared/issueRegionCode';interface IssueConfirmCardProps {pending: PendingIssueConfirm;@@ -49,6 +50,20 @@ export function IssueConfirmCard({ pending, onRespond }: IssueConfirmCardProps)const canSubmit = title.trim().length > 0 && body.trim().length > 0;+ // 构建区域代号,与登录页区域徽标同一套不对称命名(DESIGN.md §16.3):cn → CN、+ // dev → Dev、global 不标。「哪些区域要标」只有 ISSUE_REGION_CODE 一个事实源 ——+ // main 侧 issue 正文用的是同一个常量,卡片承诺展示的就是最终写进 issue 的内容,+ // 两侧各写一份判断迟早漂移。region 缺失(IPC payload 异常)时按不标处理,不猜。+ // 展示文案仍走 i18n(同 login.regionPill.*,便于日后改判为可译文案),所以这里是+ // 「常量决定标不标 + i18n 提供文案」;两者逐区域逐语言的一致性由+ // __tests__/issueRegionCode.consistency.test.ts 断言。key 写成字面量分支而非+ // 动态拼接,保证 pnpm check:i18n 的静态提取能看到全部 key。+ const regionCode = !shouldLabelIssueRegion(pending.env.region)+ ? null+ : pending.env.region === 'cn'+ ? t('issueAgent.confirm.regionCodeCn')+ : t('issueAgent.confirm.regionCodeDev');+const handleSubmit = useCallback(() => {if (!canSubmit) return;onRespond({@@ -156,6 +171,11 @@ export function IssueConfirmCard({ pending, onRespond }: IssueConfirmCardProps)login: pending.submissionIdentity.login,})}</p>+ {regionCode && (+ <p className="mt-1 text-12 leading-tight text-[var(--status-bar-meta)]">+ {t('issueAgent.confirm.regionLine', { region: regionCode })}+ </p>+ )}<p className="mt-1 text-12 leading-tight text-[var(--status-bar-meta)]">{t('issueAgent.confirm.envLine', {appVersion: pending.env.appVersion,diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex 68288b73b2..46133d0b16 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -6380,6 +6380,9 @@"identityGithubUser": "Submitting identity: GitHub user @{{login}} (you)","identityPlatform": "Submitting identity: Cindy platform (GitHub App {{login}})","envLine": "Attached automatically on submit: client {{appVersion}} · {{platform}} {{arch}} · UI language {{uiLanguage}}",+ "regionLine": "Build region: {{region}}",+ "regionCodeCn": "CN",+ "regionCodeDev": "Dev","submit": "Submit","cancel": "Cancel"},diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex 8a7011964a..36dffd777f 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -6370,6 +6370,9 @@"identityGithubUser": "送信者:GitHub ユーザー @{{login}}(本人)","identityPlatform": "送信者:Cindy プラットフォームによる代理送信(GitHub App {{login}})","envLine": "送信時に自動で付加されます:クライアント {{appVersion}} · {{platform}} {{arch}} · 表示言語 {{uiLanguage}}",+ "regionLine": "リージョン:{{region}}",+ "regionCodeCn": "CN",+ "regionCodeDev": "Dev","submit": "送信","cancel": "キャンセル"},diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex 13123a3e8c..7940b9cc2e 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -6370,6 +6370,9 @@"identityGithubUser": "제출 계정: GitHub 사용자 @{{login}}(본인)","identityPlatform": "제출 계정: Cindy 플랫폼 대리 제출(GitHub App {{login}})","envLine": "제출 시 자동으로 첨부됩니다: 클라이언트 {{appVersion}} · {{platform}} {{arch}} · 표시 언어 {{uiLanguage}}",+ "regionLine": "지역: {{region}}",+ "regionCodeCn": "CN",+ "regionCodeDev": "Dev","submit": "제출","cancel": "취소"},diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex 9475932154..dbcea95437 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -6370,6 +6370,9 @@"identityGithubUser": "提交身份:GitHub 用户 @{{login}}(本人)","identityPlatform": "提交身份:Cindy 平台代提交(GitHub App {{login}})","envLine": "提交时将自动附加:客户端 {{appVersion}} · {{platform}} {{arch}} · 界面语言 {{uiLanguage}}",+ "regionLine": "版本区域:{{region}}",+ "regionCodeCn": "CN",+ "regionCodeDev": "Dev","submit": "提交","cancel": "取消"},diff --git a/apps/desktop/src/renderer/lib/issueConfirmPayload.ts b/apps/desktop/src/renderer/lib/issueConfirmPayload.tsindex b859bd5bd8..0e7e55616c 100644--- a/apps/desktop/src/renderer/lib/issueConfirmPayload.ts+++ b/apps/desktop/src/renderer/lib/issueConfirmPayload.ts@@ -1,3 +1,18 @@+import type { CindyRegion } from '@cindy/maker-shared/brand-identity';++/**+ * issue_confirm IPC 里的构建区域。非法或缺失一律返回 undefined —— 确认卡片宁可+ * 不展示区域,也不能把用户的 CN 版说成默认版。+ *+ * 写成字面量比较而非「数组 + includes + as CindyRegion」:narrowing 直接得出+ * `CindyRegion`,不需要类型断言,也就不会在 `CindyRegion` 改动后继续静默通过。+ * 新增区域时的漏改由同族的 `shared/issueRegionCode.ts` 兜住——那里的+ * `Record<CindyRegion, …>` 会编译报错,改它时会一并看到本函数。+ */+export function parseIssueEnvRegion(raw: unknown): CindyRegion | undefined {+ return raw === 'cn' || raw === 'global' || raw === 'dev' ? raw : undefined;+}+/** issue_confirm IPC 中的真实 GitHub 提交身份;renderer 只展示,不参与选择。 */export type IssueSubmissionIdentity ={ kind: 'github-user'; login: string } | { kind: 'platform'; login: string };diff --git a/apps/desktop/src/renderer/lib/makerChatStore.ts b/apps/desktop/src/renderer/lib/makerChatStore.tsindex 0b14957315..15b705956e 100644--- a/apps/desktop/src/renderer/lib/makerChatStore.ts+++ b/apps/desktop/src/renderer/lib/makerChatStore.ts@@ -21,6 +21,7 @@* - User-initiated stopSession (NOT called on session switch anymore)*/+import type { CindyRegion } from '@cindy/maker-shared/brand-identity';import { redactSensitiveText } from '@cindy/maker-shared/error-redaction';import { applyCodexPlanSnapshotOnDone } from '@cindy/maker-shared/message-render';import type { MessageRole, Message, MessageAutomationOrigin } from '@/lib/ccAgent.types';@@ -88,6 +89,7 @@ import { getUserPrompt } from '@/lib/userPromptStore';import { getMakerMemoryEnabled } from '@/lib/memorySettingsStore';import { buildUserMessageAttachmentPayload } from '@/lib/messageAttachmentPayload';import {+ parseIssueEnvRegion,parseIssueSubmissionIdentity,type IssueSubmissionIdentity,} from '@/lib/issueConfirmPayload';@@ -572,8 +574,18 @@ export interface PendingPlanReview {export interface PendingIssueConfirm {requestId: string;draft: { title: string; body: string; type: 'bug' | 'feature' };- /** 只读展示的环境信息(main 会附进 issue body)。 */- env: { appVersion: string; platform: string; arch: string; osVersion: string };+ /**+ * 只读展示的环境信息(main 会附进 issue body)。`region` 是本构建的区域身份+ * (中国版 / 国际版 / 开发版);main 侧 payload 未带时按 undefined 处理,卡片+ * 省略该段而不是猜一个区域。+ */+ env: {+ appVersion: string;+ platform: string;+ arch: string;+ osVersion: string;+ region?: CindyRegion;+ };/** main 已经选定、确认后不会自动切换的实际 GitHub 作者身份。 */submissionIdentity: IssueSubmissionIdentity;}@@ -3798,9 +3810,16 @@ function initGlobalListeners(): void {// ephemeral 卡片(同 permission 语义,无 persistId 不落库),直接写 state,// 不走 handleStreamEvent —— 它不属于 agent 事件流。const draft = request.draft as PendingIssueConfirm['draft'] | undefined;- const env = request.env as PendingIssueConfirm['env'] | undefined;+ // region 必须先 Omit 掉再重建成 unknown:交叉类型做不到这件事+ // (`CindyRegion & unknown` 仍是 `CindyRegion`),那样写会让 TS 以为 IPC 传来的+ // region 已经是合法值,下面的白名单校验看着像在校验、实际没有类型层面的约束。+ const rawEnv = request.env as+ | (Omit<PendingIssueConfirm['env'], 'region'> & { region?: unknown })+ | undefined;const submissionIdentity = parseIssueSubmissionIdentity(request.submissionIdentity);- if (!draft || !env || !submissionIdentity) return;+ if (!draft || !rawEnv || !submissionIdentity) return;+ // region 过一遍白名单:非法值宁可不展示区域,也不能把 CN 版说成默认版。+ const env = { ...rawEnv, region: parseIssueEnvRegion(rawEnv.region) };setState(sessionId, (s) => ({...s,pendingIssueConfirm: {diff --git a/apps/desktop/src/shared/issueRegionCode.ts b/apps/desktop/src/shared/issueRegionCode.tsnew file mode 100644index 0000000000..6637f68d36--- /dev/null+++ b/apps/desktop/src/shared/issueRegionCode.ts@@ -0,0 +1,41 @@+/**+ * issueRegionCode — issue 反馈链路的构建区域代号,main(写进 issue 正文)与+ * renderer(提交确认卡片)共用的**唯一事实源**。+ *+ * 为什么需要这个单点:确认卡片的契约是「展示的就是最终写进 issue 的内容」。+ * 区域标注一旦在两侧各写一份「哪些区域要标」的判断,任一侧被改动就会让用户+ * 确认时看到的区域与实际提交的正文不一致,而这种漂移没有任何编译期信号。+ *+ * 代号与登录页区域徽标同一套不对称命名(DESIGN.md §16.3「区域徽标」):+ * cn → `CN`、dev → `Dev`、**global 不标**(值为 null)。+ *+ * ⚠️ global 故意为 null,两条理由叠在一起:+ * 1. 产品叙事硬规则(DESIGN.md §16.3「给 global 恢复徽标即回退该决策,不得+ * 回退」)——Cindy 默认版本不给自己贴标签自证是全球版,只标为特定法规单独+ * 构建的版本;+ * 2. global 是 DEFAULT_CINDY_REGION,「没有这一行」因此是个有含义的信号,不是+ * 漏附加。新增区域时要么给代号,要么明确复用这条默认语义,别让第二个区域也+ * 落进 null——那样两个区域就又分不清了。+ *+ * 代号本身四语同文、不翻译(术语表 region-code-cn / region-code-dev)。但卡片+ * 上的展示文案仍走 i18n(`issueAgent.confirm.regionCode*`,同 login.regionPill.*+ * 的做法),以便日后改判为「中国大陆版」这类可译文案时不必回改组件——本常量因此+ * 只负责「标不标 + 正文写什么」,不直接当卡片文案用。两者的一致性由+ * `renderer/__tests__/issueRegionCode.consistency.test.ts` 逐区域逐语言断言。+ *+ * Record<CindyRegion, …> 是 exhaustiveness 哨兵:`CindyRegion` 新增取值时本对象+ * 会编译报错,提醒一并决定新区域标不标、补齐四语 key。+ */++import type { CindyRegion } from '@cindy/maker-shared/brand-identity';++export const ISSUE_REGION_CODE: Readonly<Record<CindyRegion, string | null>> = Object.freeze({+ cn: 'CN',+ global: null,+ dev: 'Dev',+});++/** 该区域是否需要在卡片与 issue 正文里标注(global / 未知一律 false)。 */+export function shouldLabelIssueRegion(region: CindyRegion | undefined): boolean {+ return !!region && ISSUE_REGION_CODE[region] !== null;+}diff --git a/i18n/GLOSSARY.md b/i18n/GLOSSARY.mdindex 0f6ce9ed92..59526e5ce7 100644--- a/i18n/GLOSSARY.md+++ b/i18n/GLOSSARY.md@@ -142,13 +142,13 @@ OAuth 2.0 Device Authorization Grant 中由用户在另一设备验证页输入### CN-中国大陆版登录页区域徽标上的标签值(DESIGN.md §16.3)。四语同值、**不翻译**——它是区域代号不是可译文案,所以把 en 原样写进各语言 translations(同 Agent 条目的做法),这让 caseStandardFor 生效、guard 能挡住 cn/Cn 之类的大小写漂移。forbidden 用条件形态(whenEn=CN)补另一半:大小写规则挡不住“被整体译走”,条件形态又能把拦截精确限定在英文源为 CN 的 key 上,不误伤别处正当的“国内”“中国版”表述。列的是最可能的自造说法,不求穷举。status 取 proposed 与 region-badge 一致:产品尚未拍板是否改用可译文案,改判后本条应随之作废而非沿用。+中国大陆版登录页区域徽标上的标签值(DESIGN.md §16.3)。四语同值、**不翻译**——它是区域代号不是可译文案,所以把 en 原样写进各语言 translations(同 Agent 条目的做法),这让 caseStandardFor 生效、guard 能挡住 cn/Cn 之类的大小写漂移。forbidden 用条件形态(whenEn=CN)补另一半:大小写规则挡不住“被整体译走”,条件形态又能把拦截精确限定在英文源为 CN 的 key 上,不误伤别处正当的“国内”“中国版”表述。列的是最可能的自造说法,不求穷举。status 取 proposed 与 region-badge 一致:产品尚未拍板是否改用可译文案,改判后本条应随之作废而非沿用。2026-07-28 起同一代号也用于 submit_github_issue 的提交确认卡片与 issue 正文(`issueAgent.confirm.regionCodeCn`),口径与徽标完全一致:global 不标。已确定禁用:`中国版(仅当英文含 CN)`(zh-CN)、`国内版(仅当英文含 CN)`(zh-CN)、`中国版(仅当英文含 CN)`(ja)、`중국판(仅当英文含 CN)`(ko)### Dev-dev 版登录页区域徽标上的标签值(DESIGN.md §16.3),四语同值、不翻译,理由同 region-code-cn。与 CN 不同的是 dev 还是个普通技术词:豁免的两条文案里“Always on in dev mode.”“dev builds may be authorized…”“dev 模式下始终开启”指的是开发模式而非本区域标签,小写本就正确(四语同 key 一并覆盖)。用 exempt 精确豁免这两条、而不是整条关掉 checkCase,是为了保住徽标值本身的大小写约束——这正是本条存在的意义。+dev 版登录页区域徽标上的标签值(DESIGN.md §16.3),四语同值、不翻译,理由同 region-code-cn。与 CN 不同的是 dev 还是个普通技术词:豁免的两条文案里“Always on in dev mode.”“dev builds may be authorized…”“dev 模式下始终开启”指的是开发模式而非本区域标签,小写本就正确(四语同 key 一并覆盖)。用 exempt 精确豁免这两条、而不是整条关掉 checkCase,是为了保住徽标值本身的大小写约束——这正是本条存在的意义。2026-07-28 起同一代号也用于 submit_github_issue 的提交确认卡片与 issue 正文(`issueAgent.confirm.regionCodeDev`),口径与徽标完全一致:global 不标。已确定禁用:`开发版(仅当英文含 Dev)`(zh-CN)、`開発版(仅当英文含 Dev)`(ja)、`개발판(仅当英文含 Dev)`(ko)diff --git a/i18n/glossary.json b/i18n/glossary.jsonindex 3472a8bc82..1c1f41239b 100644--- a/i18n/glossary.json+++ b/i18n/glossary.json@@ -82,7 +82,7 @@"ja": [{ "text": "中国版", "whenEn": "CN" }],"ko": [{ "text": "중국판", "whenEn": "CN" }]},- "note": "中国大陆版登录页区域徽标上的标签值(DESIGN.md §16.3)。四语同值、**不翻译**——它是区域代号不是可译文案,所以把 en 原样写进各语言 translations(同 Agent 条目的做法),这让 caseStandardFor 生效、guard 能挡住 cn/Cn 之类的大小写漂移。forbidden 用条件形态(whenEn=CN)补另一半:大小写规则挡不住“被整体译走”,条件形态又能把拦截精确限定在英文源为 CN 的 key 上,不误伤别处正当的“国内”“中国版”表述。列的是最可能的自造说法,不求穷举。status 取 proposed 与 region-badge 一致:产品尚未拍板是否改用可译文案,改判后本条应随之作废而非沿用。"+ "note": "中国大陆版登录页区域徽标上的标签值(DESIGN.md §16.3)。四语同值、**不翻译**——它是区域代号不是可译文案,所以把 en 原样写进各语言 translations(同 Agent 条目的做法),这让 caseStandardFor 生效、guard 能挡住 cn/Cn 之类的大小写漂移。forbidden 用条件形态(whenEn=CN)补另一半:大小写规则挡不住“被整体译走”,条件形态又能把拦截精确限定在英文源为 CN 的 key 上,不误伤别处正当的“国内”“中国版”表述。列的是最可能的自造说法,不求穷举。status 取 proposed 与 region-badge 一致:产品尚未拍板是否改用可译文案,改判后本条应随之作废而非沿用。2026-07-28 起同一代号也用于 submit_github_issue 的提交确认卡片与 issue 正文(`issueAgent.confirm.regionCodeCn`),口径与徽标完全一致:global 不标。"},{"id": "region-code-dev",@@ -102,7 +102,7 @@"desktop:settings.about.debugLogDescription","desktop:settings.voiceInput.permissions.inputMonitoring.tooltip"],- "note": "dev 版登录页区域徽标上的标签值(DESIGN.md §16.3),四语同值、不翻译,理由同 region-code-cn。与 CN 不同的是 dev 还是个普通技术词:豁免的两条文案里“Always on in dev mode.”“dev builds may be authorized…”“dev 模式下始终开启”指的是开发模式而非本区域标签,小写本就正确(四语同 key 一并覆盖)。用 exempt 精确豁免这两条、而不是整条关掉 checkCase,是为了保住徽标值本身的大小写约束——这正是本条存在的意义。"+ "note": "dev 版登录页区域徽标上的标签值(DESIGN.md §16.3),四语同值、不翻译,理由同 region-code-cn。与 CN 不同的是 dev 还是个普通技术词:豁免的两条文案里“Always on in dev mode.”“dev builds may be authorized…”“dev 模式下始终开启”指的是开发模式而非本区域标签,小写本就正确(四语同 key 一并覆盖)。用 exempt 精确豁免这两条、而不是整条关掉 checkCase,是为了保住徽标值本身的大小写约束——这正是本条存在的意义。2026-07-28 起同一代号也用于 submit_github_issue 的提交确认卡片与 issue 正文(`issueAgent.confirm.regionCodeDev`),口径与徽标完全一致:global 不标。"},{"id": "agent",diff --git a/packages/lizi-mcps/src/xdt-helper/submit_github_issue.ts b/packages/lizi-mcps/src/xdt-helper/submit_github_issue.tsindex aa4732c153..85b4aea509 100644--- a/packages/lizi-mcps/src/xdt-helper/submit_github_issue.ts+++ b/packages/lizi-mcps/src/xdt-helper/submit_github_issue.ts@@ -5,7 +5,8 @@* - 工具被调用后 host 会在 App 内弹出系统确认卡片,用户可编辑/确认/取消,* 确认是通往提交的唯一路径(handler 在 main 进程挂起等待)。* - host 在确认前确定并展示真实提交身份;确认后失败也不会静默切换身份。- * - 环境信息(客户端版本 / OS / 界面语言)由 host 自动附加,agent 无法也无需填写。+ * - 环境信息(客户端版本 / 版本区域 / OS / 界面语言)由 host 自动附加,agent 无法也+ * 无需填写。版本区域(CN / Dev;默认 global 不标注)是构建期身份,agent 更猜不到。* 本文件只承载工具 schema + 描述(对 LLM 的流程指引)和 host 回调的 payload 整形。*/@@ -67,7 +68,7 @@ const DESCRIPTION = ['2) 本工具被调用后会在 App 内弹出系统确认卡片,用户可以编辑标题/正文并确认或取消;最终提交内容以用户确认的版本为准(返回的 final_title 可能与你传入的不同)。','3) 提交身份由系统确定并显示在确认卡片:已启用 Cindy GitHub 且绑定有效账号时,用该 GitHub 用户本人身份提交(受其 token 仓库权限约束);未绑定或插件不可用时,显示并使用 Cindy 平台代提交。用户身份一旦确认,提交失败不会静默降级成平台身份。','4) errorCode 语义: USER_CANCELLED = 用户主动取消了本次提交,如实告知即可,不要换参数自动重试; CONFIRM_TIMEOUT = 确认卡片超时无人响应(用户可能不在电脑前),告知用户可以再说一声重新发起; AUTH_NOT_READY / NETWORK_ERROR / SERVER_ERROR / HOST_NOT_READY = 提交失败,如实转告原因,不存在任何绕过确认、权限或失败的提交途径。',- '5) 环境信息(客户端版本 / OS / 界面语言)由系统自动附加;GitHub 作者就是确认卡片显示的身份——都无需也无法由你填写。',+ '5) 环境信息(客户端版本 / 版本区域 / OS / 界面语言)由系统自动附加;GitHub 作者就是确认卡片显示的身份——都无需也无法由你填写。版本区域是用户装的哪个区域构建(CN / Dev,默认的 global 构建不标注),构建期烘焙,你猜不到也不要写。',].join('\n');const D_TITLE =@@ -77,7 +78,7 @@ const D_TITLE =const D_BODY ='Markdown 正文。bug 用「## 现象 / ## 复现步骤 / ## 期望行为 / ## 实际行为」结构;' +'feature 用「## 使用场景 / ## 诉求 / ## 建议方案」结构,信息来自与用户的对话。' +- '不要写环境信息(客户端版本 / OS / 界面语言)和提交人——系统会自动附加。';+ '不要写环境信息(客户端版本 / 版本区域 / OS / 界面语言)和提交人——系统会自动附加。';const D_TYPE = 'bug=缺陷, feature=功能建议。决定 GitHub label。';