fix(web): label unfinished template documents as preview

Template bodies were read-only, but the status chip said 编制中 and the lock banner said the document was already controlled.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
weichen
2026-09-21 06:26:05 +00:00
co-authored by Cursor
parent 70ceb03652
commit bdd4b970d4
3 changed files with 21 additions and 0 deletions
+4
View File
@@ -165,6 +165,10 @@ export const BlockRenderer: React.FC<BlockRendererProps> = ({
<div style={{ marginTop: '8px', padding: '6px 10px', background: 'var(--amber-50)', borderRadius: 'var(--r-sm)', fontSize: '11.5px', color: 'var(--amber-600)', display: 'flex', alignItems: 'center', gap: '6px' }}>
<span>⏳ 本文档正由【{ast.editLease?.holderType === 'squad' ? '项目助手' : '其他用户'}】编辑/生成中,正文与批注暂不可操作。</span>
</div>
) : ast.lifecycleState === 'template' ? (
<div style={{ marginTop: '8px', padding: '6px 10px', background: '#E0F2FE', borderRadius: 'var(--r-sm)', fontSize: '11.5px', color: '#0369A1', display: 'flex', alignItems: 'center', gap: '6px' }}>
<span>任务未完成,正文仍为模板预览。完成编写任务后,编制人才能编辑正文。</span>
</div>
) : ast.lifecycleState !== 'drafting' ? (
<div style={{ marginTop: '8px', padding: '6px 10px', background: 'var(--amber-50)', borderRadius: 'var(--r-sm)', fontSize: '11.5px', color: 'var(--amber-600)', display: 'flex', alignItems: 'center', gap: '6px' }}>
<span>🔒 本文档当前处于【{ast.lifecycleState === 'reviewing' ? '审核中' : ast.lifecycleState === 'approving' ? '批准中' : '已生效受控'}】锁定状态,正文只读,禁止篡改。可通过鼠标右键或右侧浮标添加批注。</span>
@@ -300,6 +300,8 @@ export const DocGovActionBar: React.FC<DocGovActionBarProps> = ({
? 'var(--amber-50)'
: ast.lifecycleState === 'approving'
? '#F3E8FF'
: ast.lifecycleState === 'template'
? '#E0F2FE'
: 'var(--brand-50)',
color:
ast.lifecycleState === 'approved'
@@ -308,6 +310,8 @@ export const DocGovActionBar: React.FC<DocGovActionBarProps> = ({
? 'var(--amber-600)'
: ast.lifecycleState === 'approving'
? '#9333EA'
: ast.lifecycleState === 'template'
? '#0369A1'
: 'var(--brand-600)',
}}
>
@@ -317,6 +321,8 @@ export const DocGovActionBar: React.FC<DocGovActionBarProps> = ({
? '审核中'
: ast.lifecycleState === 'approving'
? '批准中'
: ast.lifecycleState === 'template'
? '模板预览'
: '编制中'}
</span>
{ast.dutyPolicy === 'author_only' && (
+11
View File
@@ -0,0 +1,11 @@
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import test from 'node:test';
test('template documents are labeled as preview, not 编制中 or 已生效受控', () => {
const bar = readFileSync(new URL('../components/doc/DocGovActionBar.tsx', import.meta.url), 'utf8');
const blocks = readFileSync(new URL('../components/doc/BlockRenderer.tsx', import.meta.url), 'utf8');
assert.equal(bar.includes("ast.lifecycleState === 'template'\n ? '模板预览'"), true);
assert.equal(blocks.includes('任务未完成,正文仍为模板预览。完成编写任务后,编制人才能编辑正文。'), true);
assert.equal(blocks.includes("lifecycleState === 'template'"), true);
});