Files
Agent-System/web/src/lib/commentPolicy.ts
T
weichenandCursor d5ce81228c feat(web): keep viewer comments read-only
Hide add-comment affordances and reject submit for viewer; keep
author/reviewer/approver comment roles unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-13 17:08:35 +00:00

16 lines
630 B
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.
import type { UserRole } from '../types/docgov';
export type CommentAuthorRole = 'reviewer' | 'approver';
/** viewer 只能读批注,不能打开新增入口或提交。 */
export function canAddBlockComment(role: UserRole | string): boolean {
return role === 'author' || role === 'reviewer' || role === 'approver';
}
/** author 的批注按既有语义记为 reviewer;viewer 不得被 cast。 */
export function resolveCommentAuthorRole(role: UserRole | string): CommentAuthorRole | null {
if (role === 'approver') return 'approver';
if (role === 'reviewer' || role === 'author') return 'reviewer';
return null;
}