Files
superwork/vscode/src/panel/issueOwnership.ts
T
cruldra 9167b86708 ✨ feat(vscode): 看板默认显示团队工单,同事的卡只读并贴头像
看板范围默认从「只看我的」改为「团队全部」,同事移交或推进的工单不用
手动切开关就能看见。同事的卡片按 Gitea 归属(assignee 优先,无 assignee
退回创建者)判定为只读:禁止拖列、开会话、实施、合并分支、删 worktree、
删改工单,卡片右上角贴归属人头像,详情面板属性表整体消毒并显示只读徽章。
看 PR 改动、勾已查看、生成文件摘要属于本机审查动作,照常放行。

扩展侧在消息分发前统一拦截需要归属人身份的消息,兜住前端快照过期或工单
刚被重新指派的竞态;webhook 单卡上板时同步归属,避免增量卡漏进门禁。
头像由扩展侧带 token 抓回转 data URI 下发,绕开 webview CSP 对外链图片
的限制,按 URL 进程内缓存。

Claude-Session: https://claude.ai/code/session_01KSgcQwf1mWrb8qeTKFvJbV
2026-09-10 15:30:02 +08:00

32 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 看板工单归属判定:范围切到「团队全部」后同事的工单也会上板,这类卡片
* 只读——能看详情、spec/plan、PR 改动,不能改列、开会话、合并或删除。
*
* 口径与 webhook/eventOwnership 一致:有 assignee 时指派即真相;无 assignee
* 的存量工单退回创建者。身份未知(token 解析失败)时一律按「我的」放行,
* 宁可不锁也不能把自己的板锁死。
*/
export interface IssueOwnershipFacts {
/** Gitea 工单创建者 login;YouTrack 工单没有该字段。 */
poster?: string
/** Gitea assignee login 列表;空/缺省表示未指派。 */
assignees?: string[]
}
/** 该工单是否归当前登录者所有(可写)。 */
export function isIssueMine(facts: IssueOwnershipFacts, me: string | undefined): boolean {
if (me === undefined)
return true
const assignees = facts.assignees ?? []
if (assignees.length > 0)
return assignees.includes(me)
// 无 assignee:创建者说了算;poster 缺省(非 Gitea 来源)不参与判定。
return facts.poster === undefined || facts.poster === me
}
/** 卡片头像取谁:assignee 优先(责任人),否则创建者。都没有则 undefined。 */
export function issueOwnerLogin(facts: IssueOwnershipFacts): string | undefined {
return (facts.assignees ?? [])[0] ?? facts.poster
}