root commited on
Commit
d57bf8a
·
1 Parent(s): d92239a

批注/批改、总评、AI 写作约定

Browse files
fanqie/mount.js CHANGED
@@ -55,6 +55,13 @@ module.exports = function mountFanqie(app, passwordOk, express) {
55
  app.get('/fanqie/api/projects/:projectId/checks/:versionId', projectRoute(req => projects.getCheck(req.params.projectId, req.params.versionId)))
56
  app.put('/fanqie/api/projects/:projectId/checks/:versionId', projectRoute(req => projects.saveCheck(req.params.projectId, req.params.versionId, req.body || {})))
57
  app.get('/fanqie/api/projects/:projectId/context', projectRoute(req => projects.getContext(req.params.projectId, req.query.chapter_id)))
 
 
 
 
 
 
 
58
  app.get('/fanqie/api/projects/:projectId/requests', projectRoute(req => projects.listRequests(req.params.projectId)))
59
  app.post('/fanqie/api/projects/:projectId/requests', projectRoute(req => projects.createRequest(req.params.projectId, req.body || {}), 201))
60
 
 
55
  app.get('/fanqie/api/projects/:projectId/checks/:versionId', projectRoute(req => projects.getCheck(req.params.projectId, req.params.versionId)))
56
  app.put('/fanqie/api/projects/:projectId/checks/:versionId', projectRoute(req => projects.saveCheck(req.params.projectId, req.params.versionId, req.body || {})))
57
  app.get('/fanqie/api/projects/:projectId/context', projectRoute(req => projects.getContext(req.params.projectId, req.query.chapter_id)))
58
+ app.get('/fanqie/api/projects/:projectId/notes', projectRoute(req => projects.listProjectNotes(req.params.projectId, req.query.status)))
59
+ app.get('/fanqie/api/projects/:projectId/chapters/:chapterId/notes', projectRoute(req => projects.getNotes(req.params.projectId, req.params.chapterId)))
60
+ app.post('/fanqie/api/projects/:projectId/chapters/:chapterId/notes', projectRoute(req => projects.createNote(req.params.projectId, req.params.chapterId, req.body || {}), 201))
61
+ app.patch('/fanqie/api/projects/:projectId/chapters/:chapterId/notes/:noteId', projectRoute(req => projects.updateNote(req.params.projectId, req.params.chapterId, req.params.noteId, req.body || {})))
62
+ app.delete('/fanqie/api/projects/:projectId/chapters/:chapterId/notes/:noteId', projectRoute(req => projects.deleteNote(req.params.projectId, req.params.chapterId, req.params.noteId)))
63
+ app.post('/fanqie/api/projects/:projectId/chapters/:chapterId/reviews', projectRoute(req => projects.saveReview(req.params.projectId, req.params.chapterId, req.body || {}), 201))
64
+ app.patch('/fanqie/api/projects/:projectId/requests/:requestId', projectRoute(req => projects.updateRequest(req.params.projectId, req.params.requestId, req.body || {})))
65
  app.get('/fanqie/api/projects/:projectId/requests', projectRoute(req => projects.listRequests(req.params.projectId)))
66
  app.post('/fanqie/api/projects/:projectId/requests', projectRoute(req => projects.createRequest(req.params.projectId, req.body || {}), 201))
67
 
fanqie/projects.js CHANGED
@@ -136,6 +136,9 @@ function emptyBible() {
136
  open_questions: [],
137
  style_rules: [],
138
  safety_rules: [],
 
 
 
139
  source_material_uids: [],
140
  updated_at: now()
141
  }
@@ -412,6 +415,7 @@ async function deleteProject(projectId) {
412
  await remove(projectKey(projectId, `checks/${version.version_id}.json`))
413
  }
414
  await remove(projectKey(projectId, `chapters/${cid}/versions/index.json`))
 
415
  await remove(projectKey(projectId, `chapters/${cid}/chapter.json`))
416
  }
417
  const requestIndex = await readJson(projectKey(projectId, 'requests/index.json'), { requests: [] })
@@ -465,7 +469,7 @@ async function getContext(projectId, chapterId) {
465
 
466
  async function createRequest(projectId, body) {
467
  await getProjectOrThrow(projectId)
468
- const request = { request_id: id('request'), project_id: projectId, type: String(body?.type || 'writing'), instruction: String(body?.instruction || '').slice(0, 10000), chapter_id: body?.chapter_id || null, status: 'pending', created_at: now(), updated_at: now() }
469
  if (!request.instruction.trim()) throw new HttpError(400, '写作指令不能为空')
470
  await writeJson(projectKey(projectId, `requests/${request.request_id}.json`), request)
471
  const index = await readJson(projectKey(projectId, 'requests/index.json'), { requests: [] })
@@ -477,9 +481,95 @@ async function listRequests(projectId) {
477
  return readJson(projectKey(projectId, 'requests/index.json'), { requests: [] })
478
  }
479
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
480
  module.exports = {
481
  listProjects, createProject, getProject, updateProject, deleteProject, saveBible, saveOutline, saveMaterials,
482
  listChapters, createChapter, getChapter: getChapterOrThrow, updateChapter,
483
  listVersions, getVersion, saveVersion, rollback, saveCheck, getCheck, basicCheck, getContext,
484
- createRequest, listRequests, HttpError
 
485
  }
 
136
  open_questions: [],
137
  style_rules: [],
138
  safety_rules: [],
139
+ ai_rules: [],
140
+ glossary: [],
141
+ self_check: [],
142
  source_material_uids: [],
143
  updated_at: now()
144
  }
 
415
  await remove(projectKey(projectId, `checks/${version.version_id}.json`))
416
  }
417
  await remove(projectKey(projectId, `chapters/${cid}/versions/index.json`))
418
+ await remove(projectKey(projectId, `chapters/${cid}/notes.json`))
419
  await remove(projectKey(projectId, `chapters/${cid}/chapter.json`))
420
  }
421
  const requestIndex = await readJson(projectKey(projectId, 'requests/index.json'), { requests: [] })
 
469
 
470
  async function createRequest(projectId, body) {
471
  await getProjectOrThrow(projectId)
472
+ const request = { request_id: id('request'), project_id: projectId, type: String(body?.type || 'writing'), instruction: String(body?.instruction || '').slice(0, 120000), chapter_id: body?.chapter_id || null, status: 'pending', created_at: now(), updated_at: now() }
473
  if (!request.instruction.trim()) throw new HttpError(400, '写作指令不能为空')
474
  await writeJson(projectKey(projectId, `requests/${request.request_id}.json`), request)
475
  const index = await readJson(projectKey(projectId, 'requests/index.json'), { requests: [] })
 
481
  return readJson(projectKey(projectId, 'requests/index.json'), { requests: [] })
482
  }
483
 
484
+ /* ---------- 批注与批改 ---------- */
485
+ const NOTE_TYPES = ['logic', 'setting', 'character', 'pace', 'prose', 'dialog', 'cut', 'add', 'praise', 'other']
486
+ const NOTE_STATUS = ['open', 'fixed', 'closed', 'wontfix']
487
+ function notesKey(projectId, chapterId) { return projectKey(projectId, `chapters/${chapterId}/notes.json`) }
488
+ function cleanNote(body, base = {}) {
489
+ const n = { ...base }
490
+ if (body.quote !== undefined) n.quote = String(body.quote || '').slice(0, 2000)
491
+ if (body.start !== undefined) n.start = Math.max(0, Math.floor(Number(body.start) || 0))
492
+ if (body.end !== undefined) n.end = Math.max(0, Math.floor(Number(body.end) || 0))
493
+ if (body.type !== undefined) n.type = NOTE_TYPES.includes(body.type) ? body.type : 'other'
494
+ if (body.severity !== undefined) n.severity = ['must', 'should', 'maybe'].includes(body.severity) ? body.severity : 'should'
495
+ if (body.comment !== undefined) n.comment = String(body.comment || '').slice(0, 4000)
496
+ if (body.suggestion !== undefined) n.suggestion = String(body.suggestion || '').slice(0, 4000)
497
+ if (body.reply !== undefined) n.reply = String(body.reply || '').slice(0, 4000)
498
+ if (body.status !== undefined) n.status = NOTE_STATUS.includes(body.status) ? body.status : 'open'
499
+ if (body.version_id !== undefined) n.version_id = body.version_id ? String(body.version_id) : null
500
+ if (body.created_by !== undefined) n.created_by = String(body.created_by || 'author').slice(0, 40)
501
+ return n
502
+ }
503
+ async function getNotes(projectId, chapterId) {
504
+ await getChapterOrThrow(projectId, chapterId)
505
+ const d = await readJson(notesKey(projectId, chapterId), { notes: [], reviews: [] })
506
+ return { notes: d.notes || [], reviews: d.reviews || [], updated_at: d.updated_at || null }
507
+ }
508
+ async function mutateNotes(projectId, chapterId, fn) {
509
+ return withLock(`notes:${cleanId(chapterId, 'chapter_id')}`, async () => {
510
+ const d = await getNotes(projectId, chapterId)
511
+ const out = await fn(d)
512
+ await writeJson(notesKey(projectId, chapterId), { notes: d.notes, reviews: d.reviews, updated_at: now() })
513
+ return out
514
+ })
515
+ }
516
+ async function createNote(projectId, chapterId, body) {
517
+ const note = cleanNote({ type: 'other', severity: 'should', status: 'open', created_by: 'author', ...(body || {}) }, { note_id: id('note'), chapter_id: chapterId, created_at: now() })
518
+ if (!note.comment?.trim() && !note.suggestion?.trim()) throw new HttpError(400, '批注内容不能为空')
519
+ note.updated_at = note.created_at
520
+ return mutateNotes(projectId, chapterId, d => { d.notes.push(note); return note })
521
+ }
522
+ async function updateNote(projectId, chapterId, noteId, body) {
523
+ return mutateNotes(projectId, chapterId, d => {
524
+ const i = d.notes.findIndex(x => x.note_id === noteId)
525
+ if (i < 0) throw new HttpError(404, '批注不存在')
526
+ d.notes[i] = { ...cleanNote(body || {}, d.notes[i]), updated_at: now() }
527
+ return d.notes[i]
528
+ })
529
+ }
530
+ async function deleteNote(projectId, chapterId, noteId) {
531
+ return mutateNotes(projectId, chapterId, d => {
532
+ const before = d.notes.length
533
+ d.notes = d.notes.filter(x => x.note_id !== noteId)
534
+ if (d.notes.length === before) throw new HttpError(404, '批注不存在')
535
+ return { ok: true }
536
+ })
537
+ }
538
+ async function saveReview(projectId, chapterId, body) {
539
+ const scores = {}
540
+ for (const [k, v] of Object.entries(body?.scores || {})) { const n = Number(v); if (n >= 0 && n <= 5) scores[String(k).slice(0, 40)] = n }
541
+ const review = { review_id: id('review'), chapter_id: chapterId, version_id: body?.version_id || null, scores, summary: String(body?.summary || '').slice(0, 6000), verdict: ['pass', 'revise', 'rewrite'].includes(body?.verdict) ? body.verdict : 'revise', created_by: String(body?.created_by || 'author').slice(0, 40), created_at: now() }
542
+ return mutateNotes(projectId, chapterId, d => { d.reviews = [review, ...d.reviews].slice(0, 50); return review })
543
+ }
544
+ async function listProjectNotes(projectId, status) {
545
+ const chapters = await listChapters(projectId)
546
+ const out = []
547
+ for (const c of chapters) {
548
+ const d = await readJson(notesKey(projectId, c.chapter_id), { notes: [], reviews: [] })
549
+ const notes = (d.notes || []).filter(n => !status || n.status === status)
550
+ if (notes.length || (d.reviews || []).length) out.push({ chapter_id: c.chapter_id, number: c.number, title: c.title, current_version_id: c.current_version_id, notes, review: (d.reviews || [])[0] || null })
551
+ }
552
+ return { chapters: out }
553
+ }
554
+ async function updateRequest(projectId, requestId, body) {
555
+ await getProjectOrThrow(projectId)
556
+ const rid = cleanId(requestId, 'request_id')
557
+ const index = await readJson(projectKey(projectId, 'requests/index.json'), { requests: [] })
558
+ const i = (index.requests || []).findIndex(x => x.request_id === rid)
559
+ if (i < 0) throw new HttpError(404, '请求不存在')
560
+ const next = { ...index.requests[i], updated_at: now() }
561
+ if (body?.status) next.status = ['pending', 'running', 'done', 'failed'].includes(body.status) ? body.status : next.status
562
+ if (body?.result !== undefined) next.result = String(body.result || '').slice(0, 10000)
563
+ index.requests[i] = next
564
+ await writeJson(projectKey(projectId, `requests/${rid}.json`), next)
565
+ await writeJson(projectKey(projectId, 'requests/index.json'), { ...index, updated_at: now() })
566
+ return next
567
+ }
568
+
569
  module.exports = {
570
  listProjects, createProject, getProject, updateProject, deleteProject, saveBible, saveOutline, saveMaterials,
571
  listChapters, createChapter, getChapter: getChapterOrThrow, updateChapter,
572
  listVersions, getVersion, saveVersion, rollback, saveCheck, getCheck, basicCheck, getContext,
573
+ createRequest, listRequests, updateRequest, HttpError,
574
+ getNotes, createNote, updateNote, deleteNote, saveReview, listProjectNotes
575
  }
public/assets/{index-DyAFvcZ9.css → index-D4f5QahI.css} RENAMED
The diff for this file is too large to render. See raw diff
 
public/assets/{index-FUYCcNCM.js → index-KJo-99XS.js} RENAMED
The diff for this file is too large to render. See raw diff
 
public/index.html CHANGED
@@ -8,8 +8,8 @@
8
  <title>小说写作台</title>
9
  <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='12' fill='%23b8432f'/%3E%3Ctext x='32' y='44' font-size='34' text-anchor='middle' fill='%23fff' font-family='serif'%3E%E6%96%87%3C/text%3E%3C/svg%3E" />
10
  <script>try{var t=localStorage.getItem('xs_theme');if(t==='night')document.documentElement.dataset.theme='night'}catch(e){}</script>
11
- <script type="module" crossorigin src="/assets/index-FUYCcNCM.js"></script>
12
- <link rel="stylesheet" crossorigin href="/assets/index-DyAFvcZ9.css">
13
  </head>
14
  <body>
15
  <div id="root"></div>
 
8
  <title>小说写作台</title>
9
  <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='12' fill='%23b8432f'/%3E%3Ctext x='32' y='44' font-size='34' text-anchor='middle' fill='%23fff' font-family='serif'%3E%E6%96%87%3C/text%3E%3C/svg%3E" />
10
  <script>try{var t=localStorage.getItem('xs_theme');if(t==='night')document.documentElement.dataset.theme='night'}catch(e){}</script>
11
+ <script type="module" crossorigin src="/assets/index-KJo-99XS.js"></script>
12
+ <link rel="stylesheet" crossorigin href="/assets/index-D4f5QahI.css">
13
  </head>
14
  <body>
15
  <div id="root"></div>
ui-src/.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ node_modules/
2
+ dist/
ui-src/src/api.ts CHANGED
@@ -141,6 +141,7 @@ export interface Bible {
141
  story_core: string; main_plot: string; ending_direction: string; reader_expectation: string
142
  characters: any[]; relationships: any[]; timeline: any[]; settings: any[]; foreshadowing: any[]
143
  open_questions: any[]; style_rules: any[]; safety_rules: any[]; source_material_uids: any[]
 
144
  updated_at?: string; [k: string]: any
145
  }
146
  export interface Outline { three_act: any[]; volumes: any[]; chapters: any[]; updated_at?: string; [k: string]: any }
@@ -180,7 +181,18 @@ export const projectsApi = {
180
  context: (id: string, cid?: string) => get<any>(`${P}/${id}/context${qs({ chapter_id: cid })}`),
181
  requests: (id: string) => get<{ requests: any[] }>(`${P}/${id}/requests`),
182
  createRequest: (id: string, body: { type: string; instruction: string; chapter_id?: string | null }) => post<any>(`${P}/${id}/requests`, body),
183
- }
 
 
 
 
 
 
 
 
 
 
 
184
 
185
  const M = '/fanqie/api/materials'
186
  export const materialsApi = {
 
141
  story_core: string; main_plot: string; ending_direction: string; reader_expectation: string
142
  characters: any[]; relationships: any[]; timeline: any[]; settings: any[]; foreshadowing: any[]
143
  open_questions: any[]; style_rules: any[]; safety_rules: any[]; source_material_uids: any[]
144
+ ai_rules?: any[]; glossary?: any[]; self_check?: any[]
145
  updated_at?: string; [k: string]: any
146
  }
147
  export interface Outline { three_act: any[]; volumes: any[]; chapters: any[]; updated_at?: string; [k: string]: any }
 
181
  context: (id: string, cid?: string) => get<any>(`${P}/${id}/context${qs({ chapter_id: cid })}`),
182
  requests: (id: string) => get<{ requests: any[] }>(`${P}/${id}/requests`),
183
  createRequest: (id: string, body: { type: string; instruction: string; chapter_id?: string | null }) => post<any>(`${P}/${id}/requests`, body),
184
+ notes: (id: string, cid: string) => get<{ notes: Note[]; reviews: Review[] }>(`${P}/${id}/chapters/${cid}/notes`),
185
+ createNote: (id: string, cid: string, body: Partial<Note>) => post<Note>(`${P}/${id}/chapters/${cid}/notes`, body),
186
+ updateNote: (id: string, cid: string, nid: string, body: Partial<Note>) => patch<Note>(`${P}/${id}/chapters/${cid}/notes/${nid}`, body),
187
+ deleteNote: (id: string, cid: string, nid: string) => del(`${P}/${id}/chapters/${cid}/notes/${nid}`),
188
+ saveReview: (id: string, cid: string, body: Partial<Review>) => post<Review>(`${P}/${id}/chapters/${cid}/reviews`, body),
189
+ }
190
+ export interface Note {
191
+ note_id: string; chapter_id: string; version_id?: string | null; quote: string; start: number; end: number
192
+ type: string; severity: 'must' | 'should' | 'maybe'; comment: string; suggestion?: string; reply?: string
193
+ status: 'open' | 'fixed' | 'closed' | 'wontfix'; created_by: string; created_at: string; updated_at?: string
194
+ }
195
+ export interface Review { review_id: string; version_id?: string | null; scores: Record<string, number>; summary: string; verdict: 'pass' | 'revise' | 'rewrite'; created_by: string; created_at: string }
196
 
197
  const M = '/fanqie/api/materials'
198
  export const materialsApi = {
ui-src/src/rooms/Bible.tsx CHANGED
@@ -33,7 +33,7 @@ function SaveBar({ dirty, busy, onSave, onReset, updated }: { dirty: boolean; bu
33
  }
34
 
35
  /* ================= 作品圣经 ================= */
36
- type BTab = 'core' | 'people' | 'world' | 'threads' | 'rules'
37
  export function BibleView({ ctx }: { ctx: BookCtx }) {
38
  const { bundle, setBundle } = ctx
39
  const toast = useToast()
@@ -71,6 +71,7 @@ export function BibleView({ ctx }: { ctx: BookCtx }) {
71
  { id: 'world', label: '世界与时间线', count: len('settings') + len('timeline') || undefined },
72
  { id: 'threads', label: '伏笔与悬念', count: len('foreshadowing') + len('open_questions') || undefined },
73
  { id: 'rules', label: '文风与红线', count: len('style_rules') + len('safety_rules') || undefined },
 
74
  ]} />
75
  <div className="doc-body">
76
  {tab === 'core' && (
@@ -129,6 +130,26 @@ export function BibleView({ ctx }: { ctx: BookCtx }) {
129
  <SmartList items={b.safety_rules} onChange={v => set('safety_rules', v)} addLabel="添加红线" placeholder="例如:主角所有恋爱对象都是成年人。" />
130
  </section>
131
  </>}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  </div>
133
  <SaveBar dirty={dirty} busy={busy} onSave={save} onReset={() => setB({ ...bundle.bible })} updated={bundle.bible.updated_at} />
134
  </div>
 
33
  }
34
 
35
  /* ================= 作品圣经 ================= */
36
+ type BTab = 'core' | 'people' | 'world' | 'threads' | 'rules' | 'ai'
37
  export function BibleView({ ctx }: { ctx: BookCtx }) {
38
  const { bundle, setBundle } = ctx
39
  const toast = useToast()
 
71
  { id: 'world', label: '世界与时间线', count: len('settings') + len('timeline') || undefined },
72
  { id: 'threads', label: '伏笔与悬念', count: len('foreshadowing') + len('open_questions') || undefined },
73
  { id: 'rules', label: '文风与红线', count: len('style_rules') + len('safety_rules') || undefined },
74
+ { id: 'ai', label: 'AI 写作约定', count: len('ai_rules') + len('glossary') + len('self_check') || undefined },
75
  ]} />
76
  <div className="doc-body">
77
  {tab === 'core' && (
 
130
  <SmartList items={b.safety_rules} onChange={v => set('safety_rules', v)} addLabel="添加红线" placeholder="例如:主角所有恋爱对象都是成年人。" />
131
  </section>
132
  </>}
133
+ {tab === 'ai' && <>
134
+ <div className="callout"><Wand2 size={16} /><span>这一页是给 AI 的「合同」。每次复制提示词、提交修改请求时都会放在最前面,AI 必须照做;写完还要按「交稿前自检」逐条核对。</span></div>
135
+ <section className="sheet">
136
+ <h2 className="sheet-title">写作铁律</h2>
137
+ <p className="sheet-note">AI 绝对不能违反的规定:世界观硬规则、不能写的东西、不能改的事实。每条一句话。</p>
138
+ <SmartList items={b.ai_rules || []} onChange={v => set('ai_rules', v)} addLabel="添加铁律" placeholder="例如:全书不出现手腕倒计时数字,余寿只能用鉴龄报告的区间表达。" />
139
+ </section>
140
+ <section className="sheet">
141
+ <h2 className="sheet-title">术语表</h2>
142
+ <p className="sheet-note">统一叫法,防止 AI 前后用词不一致。</p>
143
+ <ListEditor items={b.glossary || []} onChange={v => set('glossary', v)} titleKey="term" addLabel="添加术语" empty="例如:采髓 —— 从骨髓里采集干细胞储备;禁用「抽寿命」。"
144
+ newItem={() => ({ term: '', means: '', avoid: '' })}
145
+ fields={[{ key: 'term', label: '术语' }, { key: 'means', label: '意思', long: true }, { key: 'avoid', label: '禁止的说法' }]} />
146
+ </section>
147
+ <section className="sheet">
148
+ <h2 className="sheet-title">交稿前自检</h2>
149
+ <p className="sheet-note">AI 交稿前必须逐条回答「是 / 否」,有「否」就先改再交。</p>
150
+ <SmartList items={b.self_check || []} onChange={v => set('self_check', v)} addLabel="添加检查项" placeholder="例如:本章出现的每一笔寿命交易,钱数和岁数都对得上吗?" />
151
+ </section>
152
+ </>}
153
  </div>
154
  <SaveBar dirty={dirty} busy={busy} onSave={save} onReset={() => setB({ ...bundle.bible })} updated={bundle.bible.updated_at} />
155
  </div>
ui-src/src/rooms/Editor.tsx CHANGED
@@ -2,8 +2,9 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
2
  import { aiPromptBlock } from '../handbook'
3
  import {
4
  Save, Maximize2, Minimize2, PanelRightClose, PanelRightOpen, History, ClipboardCheck, BookmarkPlus, Sparkles, FileCog,
5
- Type, AlignLeft, RotateCcw, Eye, GitCompare, Copy, Search, Send, X, Check, AlertTriangle, Undo2,
6
  } from 'lucide-react'
 
7
  import { Chapter, Material, materialsApi, projectsApi, Version, VersionMeta } from '../api'
8
  import { cnNum, copyText, countWords, cx, diffParagraphs, fmtAgo, fmtDate, go, CHAPTER_STATUS, GENRE, KIND, VERSION_KIND, useLocal, useDebounced, useAsync } from '../lib'
9
  import { AutoText, Empty, ErrorNote, Field, ListEditor, Loading, Modal, Spinner, Tabs, useConfirm, useToast, Segmented } from '../ui'
@@ -11,7 +12,7 @@ import type { BookCtx } from './Book'
11
  import { toRef } from './Bible'
12
  import { feedApi } from './RankInspire'
13
 
14
- type Tab = 'chapter' | 'versions' | 'check' | 'refs' | 'ai'
15
  const draftKey = (cid: string) => `xs_draft_${cid}`
16
  type Draft = { text: string; base: string | null; at: string }
17
  const readDraft = (cid: string): Draft | null => { try { return JSON.parse(localStorage.getItem(draftKey(cid)) || 'null') } catch { return null } }
@@ -38,6 +39,19 @@ export default function ChapterEditor({ ctx, chapter }: { ctx: BookCtx; chapter:
38
  const [title, setTitle] = useState(chapter.title)
39
  const startWords = useRef<number | null>(null)
40
  const taRef = useRef<HTMLTextAreaElement>(null)
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
  /* 载入章节和当前版本 */
43
  const load = useCallback(async () => {
@@ -190,6 +204,9 @@ export default function ChapterEditor({ ctx, chapter }: { ctx: BookCtx; chapter:
190
  </div>
191
  <div className="eb-right">
192
  <span className="eb-count" title="去掉空白后的字数">{words.toLocaleString()} 字{session !== 0 && <em className={session > 0 ? 'up' : 'down'}>{session > 0 ? '+' : ''}{session}</em>}</span>
 
 
 
193
  <LayoutMenu fontSize={fontSize} setFontSize={setFontSize} pageWidth={pageWidth} setPageWidth={setPageWidth} onIndent={indentAll} />
194
  <button className="icon-btn" onClick={() => setFocus(!focus)} title={focus ? '退出专注(Esc)' : '专注写作(Ctrl+Shift+F)'}>{focus ? <Minimize2 size={17} /> : <Maximize2 size={17} />}</button>
195
  {!focus && <button className="icon-btn" onClick={() => setInspector(!inspector)} title={inspector ? '收起侧栏' : '展开侧栏'}>{inspector ? <PanelRightClose size={17} /> : <PanelRightOpen size={17} />}</button>}
@@ -214,8 +231,12 @@ export default function ChapterEditor({ ctx, chapter }: { ctx: BookCtx; chapter:
214
  <input className="paper-title" value={title} onChange={e => setTitle(e.target.value)} onBlur={commitTitle}
215
  onKeyDown={e => { if (e.key === 'Enter') { e.preventDefault(); taRef.current?.focus() } }} placeholder="章节标题" aria-label="章节标题" />
216
  {detail.goal && !focus && <div className="paper-goal"><span>本章目标</span>{detail.goal}</div>}
 
 
 
 
217
  <textarea ref={taRef} className="paper-text" value={text} onChange={e => setText(e.target.value)} spellCheck={false}
218
- placeholder={'从这里开始写。\n\n稿纸会自动暂存在本机;写到满意时,按 Ctrl+S 或点「存为版本」保存到云端。'} />
219
  <div className="paper-end">{words > 0 ? `— 本章 ${words.toLocaleString()} 字 —` : ''}</div>
220
  </article>
221
  </div>
@@ -224,6 +245,7 @@ export default function ChapterEditor({ ctx, chapter }: { ctx: BookCtx; chapter:
224
  <aside className="inspector">
225
  <Tabs<Tab> value={tab} onChange={setTab} className="inspector-tabs" items={[
226
  { id: 'chapter', label: <><FileCog size={14} />本章</> },
 
227
  { id: 'versions', label: <><History size={14} />版本</>, count: versions.length || undefined },
228
  { id: 'check', label: <><ClipboardCheck size={14} />检查</> },
229
  { id: 'refs', label: <><BookmarkPlus size={14} />素材</> },
@@ -231,6 +253,8 @@ export default function ChapterEditor({ ctx, chapter }: { ctx: BookCtx; chapter:
231
  ]} />
232
  <div className="inspector-body">
233
  {tab === 'chapter' && <ChapterMeta ctx={ctx} detail={detail} onSaved={c => { setDetail(d => d ? { ...d, ...c } : d); updateChapterInBundle(c); setTitle(c.title) }} />}
 
 
234
  {tab === 'versions' && <VersionsPanel pid={pid} cid={cid} versions={versions} current={detail.current_version_id} editorText={text} onLoad={loadIntoEditor} />}
235
  {tab === 'check' && <CheckPanel pid={pid} cid={cid} currentVersion={detail.current_version_id} text={text} dirty={dirty} />}
236
  {tab === 'refs' && <RefsPanel ctx={ctx} />}
@@ -651,7 +675,8 @@ function RequestsBox({ pid, cid }: { pid: string; cid: string }) {
651
  {list === null ? <Spinner size={13} /> : list.slice(0, 8).map(r => (
652
  <div key={r.request_id} className="req">
653
  <div className="req-head"><span className="tag">{T[r.type] || r.type}</span><span className={cx('req-st', r.status)}>{S[r.status] || r.status}</span><span className="muted">{fmtAgo(r.created_at)}</span></div>
654
- <div className="req-text">{r.instruction}</div>
 
655
  </div>
656
  ))}
657
  </div>
@@ -671,6 +696,8 @@ export function buildPrompt(bundle: any, ch: Chapter, text: string, task: string
671
  const prev = bundle.chapters.filter((c: Chapter) => c.number < ch.number).sort((a: Chapter, z: Chapter) => z.number - a.number)[0]
672
  const out: string[] = [aiPromptBlock(), '']
673
  out.push(`你是一名熟悉番茄小说平台的网文作者助手。请用简体中文完成任务。`)
 
 
674
  out.push(`\n【作品】《${p.title}》${p.genre ? `|题材:${p.genre}` : ''}${p.pov ? `|视角:${p.pov}` : ''}${p.style ? `|文风:${p.style}` : ''}`)
675
  if (p.premise) out.push(`一句话梗概:${p.premise}`)
676
  const core = [['核心冲突', b.story_core], ['主线', b.main_plot], ['结局方向', b.ending_direction], ['读者期待', b.reader_expectation]].filter(([, v]) => v)
@@ -699,5 +726,7 @@ export function buildPrompt(bundle: any, ch: Chapter, text: string, task: string
699
  if (task === 'review') out.push(`\n【本章正文】\n${body}\n\n【任务】对照作品圣经做连续性审读,逐条列出:人设前后不一致、时间线矛盾、人物知道了不该知道的事、伏笔遗漏、逻辑漏洞。每条注明原文位置和修改建议。`)
700
  if (task === 'next') out.push(`\n【本章结尾】\n……${body.slice(-1200)}\n\n【任务】为第${ch.number + 1}章写章纲:本章目标、3 个场景(每个场景写清冲突和结果)、章末钩子。`)
701
  if (extra.trim()) out.push(`\n【补充要求】${extra.trim()}`)
 
 
702
  return out.join('\n')
703
  }
 
2
  import { aiPromptBlock } from '../handbook'
3
  import {
4
  Save, Maximize2, Minimize2, PanelRightClose, PanelRightOpen, History, ClipboardCheck, BookmarkPlus, Sparkles, FileCog,
5
+ Type, AlignLeft, RotateCcw, Eye, GitCompare, Copy, Search, Send, X, Check, AlertTriangle, Undo2, Highlighter,
6
  } from 'lucide-react'
7
+ import { aiContractBlock, locateNotes, NotesPanel, ReviewText, selfCheckBlock, useNotes } from './Review'
8
  import { Chapter, Material, materialsApi, projectsApi, Version, VersionMeta } from '../api'
9
  import { cnNum, copyText, countWords, cx, diffParagraphs, fmtAgo, fmtDate, go, CHAPTER_STATUS, GENRE, KIND, VERSION_KIND, useLocal, useDebounced, useAsync } from '../lib'
10
  import { AutoText, Empty, ErrorNote, Field, ListEditor, Loading, Modal, Spinner, Tabs, useConfirm, useToast, Segmented } from '../ui'
 
12
  import { toRef } from './Bible'
13
  import { feedApi } from './RankInspire'
14
 
15
+ type Tab = 'chapter' | 'notes' | 'versions' | 'check' | 'refs' | 'ai'
16
  const draftKey = (cid: string) => `xs_draft_${cid}`
17
  type Draft = { text: string; base: string | null; at: string }
18
  const readDraft = (cid: string): Draft | null => { try { return JSON.parse(localStorage.getItem(draftKey(cid)) || 'null') } catch { return null } }
 
39
  const [title, setTitle] = useState(chapter.title)
40
  const startWords = useRef<number | null>(null)
41
  const taRef = useRef<HTMLTextAreaElement>(null)
42
+ const nb = useNotes(pid, cid)
43
+ const [reviewMode, setReviewMode] = useLocal('xs_review_mode', false)
44
+ const [activeNote, setActiveNote] = useState('')
45
+ const located = useMemo(() => locateNotes(text, nb.notes || []), [text, nb.notes])
46
+ const openNotes = located.filter(n => n.status === 'open').length
47
+ const pickNote = (id: string) => { setActiveNote(''); setTimeout(() => setActiveNote(id), 0); setInspector(true); setTab('notes') }
48
+ const createNote = async (f: any) => {
49
+ try {
50
+ const n = await projectsApi.createNote(pid, cid, { ...f, version_id: detail?.current_version_id || null, created_by: 'author' })
51
+ nb.setNotes(l => [...l, n]); setActiveNote(n.note_id); setInspector(true); setTab('notes')
52
+ toast('批注已保存', 'ok'); return true
53
+ } catch (e: any) { toast(e.message, 'err'); return false }
54
+ }
55
 
56
  /* 载入章节和当前版本 */
57
  const load = useCallback(async () => {
 
204
  </div>
205
  <div className="eb-right">
206
  <span className="eb-count" title="去掉空白后的字数">{words.toLocaleString()} 字{session !== 0 && <em className={session > 0 ? 'up' : 'down'}>{session > 0 ? '+' : ''}{session}</em>}</span>
207
+ <button className={cx('btn small', reviewMode ? 'primary' : 'ghost', 'review-toggle')} onClick={() => setReviewMode(!reviewMode)} title="批阅模式:选中句子加批注">
208
+ <Highlighter size={14} />{reviewMode ? '退出批阅' : '批阅'}{openNotes > 0 && <em className="badge">{openNotes}</em>}
209
+ </button>
210
  <LayoutMenu fontSize={fontSize} setFontSize={setFontSize} pageWidth={pageWidth} setPageWidth={setPageWidth} onIndent={indentAll} />
211
  <button className="icon-btn" onClick={() => setFocus(!focus)} title={focus ? '退出专注(Esc)' : '专注写作(Ctrl+Shift+F)'}>{focus ? <Minimize2 size={17} /> : <Maximize2 size={17} />}</button>
212
  {!focus && <button className="icon-btn" onClick={() => setInspector(!inspector)} title={inspector ? '收起侧栏' : '展开侧栏'}>{inspector ? <PanelRightClose size={17} /> : <PanelRightOpen size={17} />}</button>}
 
231
  <input className="paper-title" value={title} onChange={e => setTitle(e.target.value)} onBlur={commitTitle}
232
  onKeyDown={e => { if (e.key === 'Enter') { e.preventDefault(); taRef.current?.focus() } }} placeholder="章节标题" aria-label="章节标题" />
233
  {detail.goal && !focus && <div className="paper-goal"><span>本章目标</span>{detail.goal}</div>}
234
+ {reviewMode ? <>
235
+ <div className="review-tip"><Highlighter size={14} />批阅中:正文只读,选中任意句子即可批注;点黄色标记查看批注。<button className="link-btn" onClick={() => setReviewMode(false)}>回到编辑</button></div>
236
+ <ReviewText text={text} notes={located} active={activeNote} onPick={pickNote} onCreate={createNote} />
237
+ </> : (
238
  <textarea ref={taRef} className="paper-text" value={text} onChange={e => setText(e.target.value)} spellCheck={false}
239
+ placeholder={'从这里开始写。\n\n稿纸会自动暂存在本机;写到满意时,按 Ctrl+S 或点「存为版本」保存到云端。'} />)}
240
  <div className="paper-end">{words > 0 ? `— 本章 ${words.toLocaleString()} 字 —` : ''}</div>
241
  </article>
242
  </div>
 
245
  <aside className="inspector">
246
  <Tabs<Tab> value={tab} onChange={setTab} className="inspector-tabs" items={[
247
  { id: 'chapter', label: <><FileCog size={14} />本章</> },
248
+ { id: 'notes', label: <><Highlighter size={14} />批注</>, count: openNotes || undefined },
249
  { id: 'versions', label: <><History size={14} />版本</>, count: versions.length || undefined },
250
  { id: 'check', label: <><ClipboardCheck size={14} />检查</> },
251
  { id: 'refs', label: <><BookmarkPlus size={14} />素材</> },
 
253
  ]} />
254
  <div className="inspector-body">
255
  {tab === 'chapter' && <ChapterMeta ctx={ctx} detail={detail} onSaved={c => { setDetail(d => d ? { ...d, ...c } : d); updateChapterInBundle(c); setTitle(c.title) }} />}
256
+ {tab === 'notes' && <NotesPanel bundle={bundle} detail={detail} text={text} notes={nb.notes} setNotes={nb.setNotes} reviews={nb.reviews} setReviews={nb.setReviews}
257
+ active={activeNote} setActive={id => { setActiveNote(''); setTimeout(() => setActiveNote(id), 0) }} reviewMode={reviewMode} setReviewMode={setReviewMode} />}
258
  {tab === 'versions' && <VersionsPanel pid={pid} cid={cid} versions={versions} current={detail.current_version_id} editorText={text} onLoad={loadIntoEditor} />}
259
  {tab === 'check' && <CheckPanel pid={pid} cid={cid} currentVersion={detail.current_version_id} text={text} dirty={dirty} />}
260
  {tab === 'refs' && <RefsPanel ctx={ctx} />}
 
675
  {list === null ? <Spinner size={13} /> : list.slice(0, 8).map(r => (
676
  <div key={r.request_id} className="req">
677
  <div className="req-head"><span className="tag">{T[r.type] || r.type}</span><span className={cx('req-st', r.status)}>{S[r.status] || r.status}</span><span className="muted">{fmtAgo(r.created_at)}</span></div>
678
+ <div className="req-text">{r.instruction.length > 160 ? r.instruction.slice(0, 160) + '…' : r.instruction}</div>
679
+ {r.result && <div className="note-reply"><span>AI 回复</span>{String(r.result).slice(0, 600)}</div>}
680
  </div>
681
  ))}
682
  </div>
 
696
  const prev = bundle.chapters.filter((c: Chapter) => c.number < ch.number).sort((a: Chapter, z: Chapter) => z.number - a.number)[0]
697
  const out: string[] = [aiPromptBlock(), '']
698
  out.push(`你是一名熟悉番茄小说平台的网文作者助手。请用简体中文完成任务。`)
699
+ const contract = aiContractBlock(b)
700
+ if (contract) out.push(`\n${contract}`)
701
  out.push(`\n【作品】《${p.title}》${p.genre ? `|题材:${p.genre}` : ''}${p.pov ? `|视角:${p.pov}` : ''}${p.style ? `|文风:${p.style}` : ''}`)
702
  if (p.premise) out.push(`一句话梗概:${p.premise}`)
703
  const core = [['核心冲突', b.story_core], ['主线', b.main_plot], ['结局方向', b.ending_direction], ['读者期待', b.reader_expectation]].filter(([, v]) => v)
 
726
  if (task === 'review') out.push(`\n【本章正文】\n${body}\n\n【任务】对照作品圣经做连续性审读,逐条列出:人设前后不一致、时间线矛盾、人物知道了不该知道的事、伏笔遗漏、逻辑漏洞。每条注明原文位置和修改建议。`)
727
  if (task === 'next') out.push(`\n【本章结尾】\n……${body.slice(-1200)}\n\n【任务】为第${ch.number + 1}章写章纲:本章目标、3 个场景(每个场景写清冲突和结果)、章末钩子。`)
728
  if (extra.trim()) out.push(`\n【补充要求】${extra.trim()}`)
729
+ const sc = selfCheckBlock(b)
730
+ if (sc && task !== 'next') out.push(`\n${sc}`)
731
  return out.join('\n')
732
  }
ui-src/src/rooms/Review.tsx ADDED
@@ -0,0 +1,337 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useEffect, useMemo, useRef, useState } from 'react'
2
+ import { Check, Copy, MessageSquarePlus, Pencil, Send, Trash2, RotateCcw, Highlighter, X } from 'lucide-react'
3
+ import { Chapter, Note, projectsApi, Review } from '../api'
4
+ import { cnNum, copyText, cx, fmtAgo } from '../lib'
5
+ import { AutoText, Empty, Segmented, useConfirm, useToast } from '../ui'
6
+
7
+ /* ---------- 常量 ---------- */
8
+ export const NOTE_TYPE: Record<string, string> = {
9
+ logic: '逻辑漏洞', setting: '设定冲突', character: '人设不对', pace: '节奏', prose: '文笔', dialog: '对白',
10
+ cut: '该删', add: '该补', praise: '写得好', other: '其他',
11
+ }
12
+ export const SEVERITY: Record<string, string> = { must: '必须改', should: '建议改', maybe: '可改可不改' }
13
+ const STATUS: Record<string, string> = { open: '待修改', fixed: '已修改', closed: '已关闭', wontfix: '不改了' }
14
+ const SCORE_DIMS: [string, string][] = [
15
+ ['logic', '逻辑自洽'], ['setting', '设定一致'], ['character', '人物立得住'], ['pace', '节奏'], ['hook', '爽点与钩子'], ['prose', '文笔'],
16
+ ]
17
+ const VERDICT: Record<string, string> = { pass: '通过', revise: '小修', rewrite: '重写' }
18
+
19
+ /* ---------- 定位批注在正文里的位置 ---------- */
20
+ export type Located = Note & { at: number; to: number; lost: boolean }
21
+ export function locateNotes(text: string, notes: Note[]): Located[] {
22
+ return notes.map(n => {
23
+ if (!n.quote) return { ...n, at: -1, to: -1, lost: false }
24
+ if (text.slice(n.start, n.end) === n.quote) return { ...n, at: n.start, to: n.end, lost: false }
25
+ let best = -1, dist = Infinity, i = text.indexOf(n.quote)
26
+ while (i >= 0) { const d = Math.abs(i - (n.start || 0)); if (d < dist) { dist = d; best = i } i = text.indexOf(n.quote, i + 1) }
27
+ return best >= 0 ? { ...n, at: best, to: best + n.quote.length, lost: false } : { ...n, at: -1, to: -1, lost: true }
28
+ })
29
+ }
30
+
31
+ /* ---------- 批阅模式:只读正文 + 高亮 + 选中加批注 ---------- */
32
+ export function ReviewText({ text, notes, active, onPick, onCreate }: {
33
+ text: string; notes: Located[]; active: string; onPick: (id: string) => void
34
+ onCreate: (n: { quote: string; start: number; end: number; type: string; severity: string; comment: string; suggestion: string }) => Promise<boolean>
35
+ }) {
36
+ const ref = useRef<HTMLDivElement>(null)
37
+ const [sel, setSel] = useState<{ start: number; end: number; quote: string; top: number; left: number } | null>(null)
38
+ const segs = useMemo(() => {
39
+ const marks = notes.filter(n => n.at >= 0 && n.status === 'open' || n.at >= 0 && n.note_id === active).sort((a, b) => a.at - b.at)
40
+ const out: { t: string; n?: Located }[] = []
41
+ let pos = 0
42
+ for (const n of marks) {
43
+ if (n.at < pos) continue
44
+ if (n.at > pos) out.push({ t: text.slice(pos, n.at) })
45
+ out.push({ t: text.slice(n.at, n.to), n })
46
+ pos = n.to
47
+ }
48
+ if (pos < text.length) out.push({ t: text.slice(pos) })
49
+ return out
50
+ }, [text, notes, active])
51
+
52
+ useEffect(() => {
53
+ if (!active || !ref.current) return
54
+ const el = ref.current.querySelector(`[data-nid="${active}"]`) as HTMLElement | null
55
+ if (el) { el.scrollIntoView({ block: 'center', behavior: 'smooth' }); el.classList.remove('flash'); void el.offsetWidth; el.classList.add('flash') }
56
+ }, [active])
57
+
58
+ const onUp = () => {
59
+ const s = window.getSelection()
60
+ const box = ref.current
61
+ if (!s || s.isCollapsed || !box || !box.contains(s.anchorNode) || !box.contains(s.focusNode)) return
62
+ const r = s.getRangeAt(0)
63
+ const pre = document.createRange()
64
+ pre.selectNodeContents(box); pre.setEnd(r.startContainer, r.startOffset)
65
+ const start = pre.toString().length
66
+ const quote = r.toString()
67
+ if (!quote.trim()) return
68
+ const rect = r.getBoundingClientRect(), host = box.getBoundingClientRect()
69
+ setSel({ start, end: start + quote.length, quote, top: rect.bottom - host.top + 8, left: Math.max(0, Math.min(rect.left - host.left, host.width - 340)) })
70
+ }
71
+
72
+ return (
73
+ <div className="review-wrap">
74
+ <div ref={ref} className="review-text" onMouseUp={onUp}>
75
+ {segs.map((s, i) => s.n
76
+ ? <mark key={i} data-nid={s.n.note_id} className={cx('nm', `sev-${s.n.severity}`, s.n.type === 'praise' && 'praise', s.n.note_id === active && 'on', s.n.status !== 'open' && 'done')}
77
+ onClick={e => { e.stopPropagation(); onPick(s.n!.note_id) }} title={s.n.comment}>{s.t}</mark>
78
+ : <React.Fragment key={i}>{s.t}</React.Fragment>)}
79
+ {!text && <span className="muted">稿纸还是空的。</span>}
80
+ </div>
81
+ {sel && <NoteForm style={{ top: sel.top, left: sel.left }} quote={sel.quote} onClose={() => { setSel(null); window.getSelection()?.removeAllRanges() }}
82
+ onSave={async f => { const ok = await onCreate({ ...f, quote: sel.quote, start: sel.start, end: sel.end }); if (ok) { setSel(null); window.getSelection()?.removeAllRanges() } return ok }} />}
83
+ </div>
84
+ )
85
+ }
86
+
87
+ function NoteForm({ quote, onSave, onClose, style, init }: {
88
+ quote?: string; onSave: (f: { type: string; severity: string; comment: string; suggestion: string }) => Promise<boolean>; onClose: () => void
89
+ style?: React.CSSProperties; init?: Partial<Note>
90
+ }) {
91
+ const [type, setType] = useState(init?.type || 'logic')
92
+ const [severity, setSeverity] = useState<string>(init?.severity || 'should')
93
+ const [comment, setComment] = useState(init?.comment || '')
94
+ const [suggestion, setSuggestion] = useState(init?.suggestion || '')
95
+ const [busy, setBusy] = useState(false)
96
+ const save = async () => { setBusy(true); try { await onSave({ type, severity, comment, suggestion }) } finally { setBusy(false) } }
97
+ return (
98
+ <div className={cx('note-form', style && 'floating')} style={style} onMouseUp={e => e.stopPropagation()}>
99
+ <div className="nf-head"><b>{init ? '修改批注' : '添加批注'}</b><button className="icon-btn sm" onClick={onClose} aria-label="关闭"><X size={14} /></button></div>
100
+ {quote && <div className="nf-quote">「{quote.length > 80 ? quote.slice(0, 80) + '…' : quote}」</div>}
101
+ <div className="chip-row">
102
+ {Object.entries(NOTE_TYPE).map(([k, v]) => <button key={k} className={cx('chip', type === k && 'on', k === 'praise' && 'good')} onClick={() => setType(k)}>{v}</button>)}
103
+ </div>
104
+ {type !== 'praise' && <Segmented value={severity} onChange={setSeverity} items={Object.entries(SEVERITY).map(([id, label]) => ({ id, label }))} />}
105
+ <AutoText value={comment} onChange={setComment} minRows={2} placeholder={type === 'praise' ? '好在哪里?(AI 会保留这种写法)' : '哪里不对?例如:父亲刚卖完寿命不可能还能下地干活,贫血会很重。'} />
106
+ {type !== 'praise' && <AutoText value={suggestion} onChange={setSuggestion} minRows={1} placeholder="想怎么改?(可不填,例如:改成他扶着墙走两步就喘。)" />}
107
+ <div className="pop-actions">
108
+ <span className="muted small-note">选中文字即可批注</span>
109
+ <button className="btn primary small" disabled={busy || (!comment.trim() && !suggestion.trim())} onClick={save}>{busy ? '保存中…' : '保存批注'}</button>
110
+ </div>
111
+ </div>
112
+ )
113
+ }
114
+
115
+ /* ---------- 侧栏:批注列表 + 总评 + 修改提示词 ---------- */
116
+ export function NotesPanel({ bundle, detail, text, notes, setNotes, reviews, setReviews, active, setActive, reviewMode, setReviewMode }: {
117
+ bundle: any; detail: Chapter; text: string; notes: Note[] | null; setNotes: (f: (n: Note[]) => Note[]) => void
118
+ reviews: Review[]; setReviews: (f: (r: Review[]) => Review[]) => void
119
+ active: string; setActive: (id: string) => void; reviewMode: boolean; setReviewMode: (v: boolean) => void
120
+ }) {
121
+ const toast = useToast()
122
+ const confirm = useConfirm()
123
+ const pid = bundle.project.project_id, cid = detail.chapter_id
124
+ const [filter, setFilter] = useState<'open' | 'all'>('open')
125
+ const [editing, setEditing] = useState('')
126
+ const [adding, setAdding] = useState(false)
127
+ const [showPrompt, setShowPrompt] = useState(false)
128
+ const [sending, setSending] = useState(false)
129
+ const located = useMemo(() => locateNotes(text, notes || []), [text, notes])
130
+ const sorted = useMemo(() => [...located].sort((a, b) => (a.at < 0 ? 1e9 : a.at) - (b.at < 0 ? 1e9 : b.at)), [located])
131
+ const shown = sorted.filter(n => filter === 'all' || n.status === 'open')
132
+ const open = located.filter(n => n.status === 'open')
133
+ const prompt = useMemo(() => buildRevisePrompt(bundle, detail, text, open, reviews[0]), [bundle, detail, text, open, reviews])
134
+
135
+ const patch = async (n: Note, body: Partial<Note>) => {
136
+ try { const r = await projectsApi.updateNote(pid, cid, n.note_id, body); setNotes(l => l.map(x => x.note_id === n.note_id ? r : x)); return true }
137
+ catch (e: any) { toast(e.message, 'err'); return false }
138
+ }
139
+ const remove = async (n: Note) => {
140
+ if (!(await confirm({ title: '删除这条批注?', ok: '删除', danger: true }))) return
141
+ try { await projectsApi.deleteNote(pid, cid, n.note_id); setNotes(l => l.filter(x => x.note_id !== n.note_id)) } catch (e: any) { toast(e.message, 'err') }
142
+ }
143
+ const addGeneral = async (f: any) => {
144
+ try { const r = await projectsApi.createNote(pid, cid, { ...f, quote: '', start: 0, end: 0, version_id: detail.current_version_id, created_by: 'author' } as any); setNotes(l => [...l, r]); setAdding(false); toast('已记下整章批注', 'ok'); return true }
145
+ catch (e: any) { toast(e.message, 'err'); return false }
146
+ }
147
+ const sendToAi = async () => {
148
+ if (!open.length) return toast('没有待修改的批注', 'err')
149
+ setSending(true)
150
+ try {
151
+ await projectsApi.createRequest(pid, { type: 'revise', chapter_id: cid, instruction: prompt })
152
+ toast('已交给 AI 修改:告诉我「处理修改请求」即可', 'ok')
153
+ } catch (e: any) { toast(e.message, 'err') } finally { setSending(false) }
154
+ }
155
+
156
+ return (
157
+ <div className="panel-stack">
158
+ <div className="callout tight"><Highlighter size={15} /><span>点上方「批阅」进入批阅模式,<b>选中正文里的句子</b>就能加批注。批注写完后在下面「交给 AI 修改」,AI 会逐条改并回复。</span></div>
159
+ <div className="row between">
160
+ <button className={cx('btn small', reviewMode ? 'primary' : 'ghost')} onClick={() => setReviewMode(!reviewMode)}><Highlighter size={14} />{reviewMode ? '退出批阅' : '进入批阅'}</button>
161
+ <button className="btn small ghost" onClick={() => setAdding(a => !a)}><MessageSquarePlus size={14} />整章批注</button>
162
+ </div>
163
+ {adding && <NoteForm onSave={addGeneral} onClose={() => setAdding(false)} />}
164
+
165
+ <div className="row between">
166
+ <b className="panel-h">批注 <span className="muted">{open.length} 条待改 / 共 {located.length}</span></b>
167
+ <Segmented value={filter} onChange={setFilter} items={[{ id: 'open', label: '待改' }, { id: 'all', label: '全部' }]} />
168
+ </div>
169
+ {notes === null ? <div className="muted small-note">读取中…</div> : shown.length === 0 ? (
170
+ <Empty icon={<Highlighter size={20} />} title={filter === 'open' ? '没有待修改的批注' : '还没有批注'}>{filter === 'open' && located.length ? '全部处理完了。' : '进入批阅模式,选中句子写下哪里不对。'}</Empty>
171
+ ) : (
172
+ <ul className="note-list">
173
+ {shown.map((n, i) => (
174
+ <li key={n.note_id} className={cx('note', `sev-${n.severity}`, n.type === 'praise' && 'praise', n.note_id === active && 'on', n.status !== 'open' && 'done')}>
175
+ <div className="note-head">
176
+ <span className="note-no">#{i + 1}</span>
177
+ <span className="tag">{NOTE_TYPE[n.type] || n.type}</span>
178
+ {n.type !== 'praise' && <span className={cx('sev', n.severity)}>{SEVERITY[n.severity]}</span>}
179
+ <span className={cx('note-st', n.status)}>{STATUS[n.status]}</span>
180
+ <span className="muted">{n.created_by === 'ai' ? 'AI · ' : ''}{fmtAgo(n.created_at)}</span>
181
+ </div>
182
+ {n.quote ? (
183
+ <button className="note-quote" onClick={() => { setActive(n.note_id); if (!reviewMode) setReviewMode(true) }} title="在正文里定位">
184
+ 「{n.quote.length > 60 ? n.quote.slice(0, 60) + '…' : n.quote}」{n.lost && <em>原句已改动,找不到了</em>}
185
+ </button>
186
+ ) : <div className="note-quote general">整章</div>}
187
+ {editing === n.note_id ? (
188
+ <NoteForm init={n} onClose={() => setEditing('')} onSave={async f => { const ok = await patch(n, f as any); if (ok) setEditing(''); return ok }} />
189
+ ) : <>
190
+ {n.comment && <div className="note-body">{n.comment}</div>}
191
+ {n.suggestion && <div className="note-sug"><span>建议</span>{n.suggestion}</div>}
192
+ {n.reply && <div className="note-reply"><span>AI 回复</span>{n.reply}</div>}
193
+ <div className="note-actions">
194
+ {n.status === 'open'
195
+ ? <><button className="link-btn" onClick={() => patch(n, { status: 'fixed' })}><Check size={13} />已改好</button>
196
+ <button className="link-btn muted" onClick={() => patch(n, { status: 'wontfix' })}>不改了</button></>
197
+ : <button className="link-btn" onClick={() => patch(n, { status: 'open' })}><RotateCcw size={13} />重新打开</button>}
198
+ <button className="link-btn muted" onClick={() => setEditing(n.note_id)}><Pencil size={13} />编辑</button>
199
+ <button className="link-btn danger" onClick={() => remove(n)}><Trash2 size={13} /></button>
200
+ </div>
201
+ </>}
202
+ </li>
203
+ ))}
204
+ </ul>
205
+ )}
206
+
207
+ <div className="divider" />
208
+ <ReviewForm pid={pid} cid={cid} versionId={detail.current_version_id} reviews={reviews} onSaved={r => setReviews(l => [r, ...l])} />
209
+
210
+ <div className="divider" />
211
+ <b className="panel-h">交给 AI 修改</b>
212
+ <div className="muted small-note">把正文、{open.length} 条待改批注、总评和「AI 写作约定」打包成修改指令。AI 只改批注到的地方,并逐条写修改说明。</div>
213
+ <div className="row gap">
214
+ <button className="btn primary small" onClick={sendToAi} disabled={sending || !open.length}><Send size={14} />{sending ? '提交中…' : '交给 AI 修改'}</button>
215
+ <button className="btn ghost small" onClick={async () => { await copyText(prompt); toast('修改提示词已复制', 'ok') }} disabled={!open.length}><Copy size={14} />复制提示词</button>
216
+ <button className="link-btn" onClick={() => setShowPrompt(s => !s)}>{showPrompt ? '收起' : '预览'}</button>
217
+ </div>
218
+ {showPrompt && <div className="prompt-box"><div className="prompt-head"><b>修改提示词</b><span className="muted">{prompt.length} 字符</span></div><pre>{prompt}</pre></div>}
219
+ </div>
220
+ )
221
+ }
222
+
223
+ function ReviewForm({ pid, cid, versionId, reviews, onSaved }: { pid: string; cid: string; versionId: string | null; reviews: Review[]; onSaved: (r: Review) => void }) {
224
+ const toast = useToast()
225
+ const last = reviews[0]
226
+ const [scores, setScores] = useState<Record<string, number>>({})
227
+ const [verdict, setVerdict] = useState<string>('revise')
228
+ const [summary, setSummary] = useState('')
229
+ const [busy, setBusy] = useState(false)
230
+ const avg = (s: Record<string, number>) => { const v = Object.values(s || {}).filter(x => typeof x === 'number'); return v.length ? (v.reduce((a, b) => a + b, 0) / v.length).toFixed(1) : '—' }
231
+ const save = async () => {
232
+ if (!Object.keys(scores).length && !summary.trim()) return toast('打个分或写一句总评', 'err')
233
+ setBusy(true)
234
+ try { const r = await projectsApi.saveReview(pid, cid, { scores, verdict: verdict as any, summary, version_id: versionId, created_by: 'author' }); onSaved(r); setScores({}); setSummary(''); toast('总评已保存', 'ok') }
235
+ catch (e: any) { toast(e.message, 'err') } finally { setBusy(false) }
236
+ }
237
+ return (
238
+ <div className="panel-stack">
239
+ <b className="panel-h">本章总评 {last && <span className="muted">上次 {avg(last.scores)} 分 · {VERDICT[last.verdict]} · {fmtAgo(last.created_at)}</span>}</b>
240
+ <div className="score-grid">
241
+ {SCORE_DIMS.map(([k, label]) => (
242
+ <div key={k} className="score-row">
243
+ <span>{label}</span>
244
+ <span className="score-pick">
245
+ {[1, 2, 3, 4, 5].map(v => <button key={v} className={cx((scores[k] || 0) >= v && 'on')} onClick={() => setScores(s => ({ ...s, [k]: s[k] === v ? v - 1 : v }))} aria-label={`${v} 分`} />)}
246
+ </span>
247
+ <em>{scores[k] ?? (last?.scores?.[k] != null ? <span className="muted">上次 {last.scores[k]}</span> : '')}</em>
248
+ </div>
249
+ ))}
250
+ </div>
251
+ <Segmented value={verdict} onChange={setVerdict} items={Object.entries(VERDICT).map(([id, label]) => ({ id, label }))} />
252
+ <AutoText value={summary} onChange={setSummary} minRows={2} placeholder="整体感觉如何?最大的问题是什么?例如:开头太慢,第 3 场的设定解释太多。" />
253
+ <button className="btn small ghost block" onClick={save} disabled={busy}>{busy ? '保存中…' : '保存总评'}</button>
254
+ {reviews.length > 0 && (
255
+ <details className="review-history">
256
+ <summary>历次总评({reviews.length})</summary>
257
+ {reviews.slice(0, 10).map(r => (
258
+ <div key={r.review_id} className="rh-item">
259
+ <div><b>{avg(r.scores)} 分</b> · {VERDICT[r.verdict]} · {r.created_by === 'ai' ? 'AI 自评' : '我'} · {fmtAgo(r.created_at)}</div>
260
+ <div className="muted">{SCORE_DIMS.filter(([k]) => r.scores?.[k] != null).map(([k, l]) => `${l} ${r.scores[k]}`).join(' / ')}</div>
261
+ {r.summary && <div>{r.summary}</div>}
262
+ </div>
263
+ ))}
264
+ </details>
265
+ )}
266
+ </div>
267
+ )
268
+ }
269
+
270
+ /* ---------- 提示词片段 ---------- */
271
+ const bullets = (arr: any[], fmt: (x: any) => string = x => String(x)) => (Array.isArray(arr) ? arr : []).map(x => typeof x === 'string' ? x : fmt(x)).filter(s => s && s.trim()).map((s, i) => `${i + 1}. ${s}`).join('\n')
272
+
273
+ export function aiContractBlock(b: any) {
274
+ const out: string[] = []
275
+ const rules = bullets(b.ai_rules || [])
276
+ if (rules) out.push(`【AI 写作约定(必须遵守,违反任何一条都算不合格)】\n${rules}`)
277
+ const gl = (b.glossary || []).filter((g: any) => g?.term).map((g: any) => `- ${g.term}:${g.means || ''}${g.avoid ? `(禁止写成:${g.avoid})` : ''}`).join('\n')
278
+ if (gl) out.push(`【术语表(统一用词)】\n${gl}`)
279
+ const safe = bullets(b.safety_rules || [])
280
+ if (safe) out.push(`【安全红线】\n${safe}`)
281
+ return out.join('\n\n')
282
+ }
283
+ export function selfCheckBlock(b: any) {
284
+ const sc = bullets(b.self_check || [])
285
+ return sc ? `【交稿前自检】输出正文前,逐条在心里核对以下问题;有任何一条答「否」,先改再交。正文之后另起一行写「自检:全部通过」或列出仍有疑问的条目。\n${sc}` : ''
286
+ }
287
+
288
+ export function buildRevisePrompt(bundle: any, ch: Chapter, text: string, notes: Located[], review?: Review) {
289
+ const p = bundle.project, b = bundle.bible || {}
290
+ const out: string[] = []
291
+ out.push(`你是《${p.title}》的执笔 AI。作者批改了第${cnNum(ch.number)}章,请按批注修改。`)
292
+ const contract = aiContractBlock(b)
293
+ if (contract) out.push('\n' + contract)
294
+ const style = bullets(b.style_rules || [])
295
+ if (style) out.push(`\n【文风规则】\n${style}`)
296
+ out.push(`\n【本章】第${ch.number}章 ${ch.title || ''}${ch.goal ? `\n本章目标:${ch.goal}` : ''}`)
297
+ if (review && (review.summary || Object.keys(review.scores || {}).length)) {
298
+ const sc = SCORE_DIMS.filter(([k]) => review.scores?.[k] != null).map(([k, l]) => `${l}${review.scores[k]}/5`).join(',')
299
+ out.push(`\n【作者总评】${VERDICT[review.verdict] || ''}${sc ? `|${sc}` : ''}${review.summary ? `\n${review.summary}` : ''}`)
300
+ }
301
+ const keep = notes.filter(n => n.type === 'praise')
302
+ const fix = notes.filter(n => n.type !== 'praise')
303
+ out.push(`\n【批注(共 ${fix.length} 条,按正文顺序)】`)
304
+ fix.forEach((n, i) => {
305
+ out.push(`N${i + 1}[${n.note_id}]${NOTE_TYPE[n.type] || n.type}|${SEVERITY[n.severity] || ''}`)
306
+ out.push(n.quote ? ` 原文:「${n.quote}」${n.lost ? '(此句已不在当前正文中,按意思找到对应位置)' : ''}` : ' 范围:整章')
307
+ if (n.comment) out.push(` 问题:${n.comment}`)
308
+ if (n.suggestion) out.push(` 建议:${n.suggestion}`)
309
+ })
310
+ if (keep.length) out.push(`\n【作者点赞的地方(必须保留,可作为风格参考)】\n${keep.map(n => `- 「${n.quote || '整章'}」${n.comment ? `:${n.comment}` : ''}`).join('\n')}`)
311
+ out.push(`\n【当前正文】\n${text.trim()}`)
312
+ out.push(`\n【修改规则】
313
+ 1. 只改批注涉及的句子和为了衔接必须连带调整的上下文;没被批注的段落一字不动。
314
+ 2. 「必须改」逐条落实;「建议改」尽量落实,确实不改要说明理由;「可改可不改」自行判断。
315
+ 3. 修改不得违反上面的 AI 写作约定、术语表和人物设定;不能为了改一处引入新的设定冲突。
316
+ 4. 字数变化控制在 ±15% 以内,除非批注要求补写或删减。`)
317
+ const sc = selfCheckBlock(b)
318
+ if (sc) out.push('\n' + sc)
319
+ out.push(`\n【输出格式】
320
+ 先输出修改后的完整正文;
321
+ 然后输出一行「---修改说明---」,按 N1、N2… 逐条写:改了什么、改后的句子是什么;没改的写明理由。`)
322
+ return out.join('\n')
323
+ }
324
+
325
+ export function useNotes(pid: string, cid: string) {
326
+ const [notes, setNotes] = useState<Note[] | null>(null)
327
+ const [reviews, setReviews] = useState<Review[]>([])
328
+ const reload = async () => {
329
+ try { const r = await projectsApi.notes(pid, cid); setNotes(r.notes || []); setReviews(r.reviews || []) } catch { setNotes([]) }
330
+ }
331
+ useEffect(() => { setNotes(null); setReviews([]); reload() }, [pid, cid])
332
+ return {
333
+ notes, reviews, reload,
334
+ setNotes: (f: (n: Note[]) => Note[]) => setNotes(n => f(n || [])),
335
+ setReviews: (f: (r: Review[]) => Review[]) => setReviews(r => f(r)),
336
+ }
337
+ }
ui-src/src/styles.css CHANGED
@@ -1239,3 +1239,63 @@ select.input { appearance: none; padding-right: 28px; background-image: linear-g
1239
  .insp-pick select { width: 100%; }
1240
  .rk-feed-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px 18px; }
1241
  .rk-feed-opts .input { width: 100%; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1239
  .insp-pick select { width: 100%; }
1240
  .rk-feed-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px 18px; }
1241
  .rk-feed-opts .input { width: 100%; }
1242
+
1243
+ /* ---------- 批阅 / 批注 ---------- */
1244
+ .review-toggle { position: relative; }
1245
+ .review-toggle .badge { font-style: normal; font-size: 11px; min-width: 17px; height: 17px; line-height: 17px; padding: 0 4px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); text-align: center; margin-left: 2px; }
1246
+ .review-tip { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); background: var(--warn-soft); border-radius: var(--r-s); padding: 8px 12px; margin: 6px 0 16px; font-family: var(--sans); }
1247
+ .review-wrap { position: relative; }
1248
+ .review-text { white-space: pre-wrap; word-break: break-word; font-family: var(--serif); font-size: var(--fs, 19px); line-height: 2.05; letter-spacing: .02em; color: var(--ink); min-height: 50vh; cursor: text; padding-top: 6px; }
1249
+ .review-text::selection, .review-text *::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }
1250
+ mark.nm { color: inherit; background: color-mix(in srgb, var(--warn) 26%, transparent); border-bottom: 2px solid var(--warn); border-radius: 2px; cursor: pointer; padding: 0 1px; transition: background .2s; }
1251
+ mark.nm.sev-must { background: color-mix(in srgb, var(--err) 18%, transparent); border-bottom-color: var(--err); }
1252
+ mark.nm.sev-maybe { background: color-mix(in srgb, var(--blue) 14%, transparent); border-bottom: 2px dashed var(--blue); }
1253
+ mark.nm.praise { background: color-mix(in srgb, var(--ok) 18%, transparent); border-bottom-color: var(--ok); }
1254
+ mark.nm.done { background: transparent; border-bottom-style: dotted; }
1255
+ mark.nm.on { outline: 2px solid var(--accent); outline-offset: 1px; }
1256
+ mark.nm.flash { animation: nmflash 1.2s ease-out; }
1257
+ @keyframes nmflash { 0%, 40% { background: color-mix(in srgb, var(--accent) 45%, transparent); } }
1258
+ .note-form { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--raised); font-family: var(--sans); font-size: 13px; }
1259
+ .note-form.floating { position: absolute; z-index: 40; width: 340px; max-width: 92vw; box-shadow: var(--shadow-l); animation: pop .15s ease-out; }
1260
+ .nf-head { display: flex; align-items: center; justify-content: space-between; }
1261
+ .nf-quote { color: var(--ink-2); background: var(--bg-2); border-radius: var(--r-s); padding: 6px 8px; font-family: var(--serif); line-height: 1.6; }
1262
+ .chip-row { display: flex; flex-wrap: wrap; gap: 5px; }
1263
+ .chip-row .chip { padding: 3px 9px; font-size: 12px; }
1264
+ .chip.good.on { background: var(--ok); border-color: var(--ok); }
1265
+ .callout.tight { padding: 9px 11px; font-size: 12.5px; margin-bottom: 0; align-items: flex-start; line-height: 1.6; }
1266
+ .note-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
1267
+ .note { border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: var(--r-s); padding: 10px 11px; background: var(--surface); display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
1268
+ .note.sev-must { border-left-color: var(--err); }
1269
+ .note.sev-maybe { border-left-color: var(--blue); }
1270
+ .note.praise { border-left-color: var(--ok); }
1271
+ .note.on { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent); }
1272
+ .note.done { opacity: .62; }
1273
+ .note-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; }
1274
+ .note-no { font-family: var(--mono); color: var(--ink-3); }
1275
+ .sev { font-size: 11px; padding: 1px 6px; border-radius: 9px; background: var(--warn-soft); color: var(--warn); }
1276
+ .sev.must { background: var(--err-soft); color: var(--err); }
1277
+ .sev.maybe { background: var(--blue-soft); color: var(--blue); }
1278
+ .note-st { font-size: 11px; color: var(--ink-3); }
1279
+ .note-st.fixed { color: var(--ok); }
1280
+ .note-st.open { color: var(--accent); }
1281
+ .note-head .muted { margin-left: auto; }
1282
+ .note-quote { text-align: left; background: var(--bg-2); border: 0; border-radius: 5px; padding: 5px 8px; font-family: var(--serif); color: var(--ink-2); line-height: 1.6; cursor: pointer; font-size: 13px; }
1283
+ .note-quote:hover { background: var(--accent-soft); }
1284
+ .note-quote.general { cursor: default; font-family: var(--sans); font-size: 12px; color: var(--ink-3); }
1285
+ .note-quote em { display: block; font-style: normal; font-size: 11px; color: var(--err); font-family: var(--sans); }
1286
+ .note-body { color: var(--ink); line-height: 1.65; white-space: pre-wrap; }
1287
+ .note-sug, .note-reply { line-height: 1.6; white-space: pre-wrap; color: var(--ink-2); }
1288
+ .note-sug span, .note-reply span { display: inline-block; font-size: 11px; padding: 0 6px; margin-right: 6px; border-radius: 4px; background: var(--blue-soft); color: var(--blue); }
1289
+ .note-reply span { background: var(--ok-soft); color: var(--ok); }
1290
+ .note-reply { background: color-mix(in srgb, var(--ok-soft) 50%, transparent); border-radius: 5px; padding: 5px 8px; font-size: 12.5px; }
1291
+ .note-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
1292
+ .link-btn.danger { color: var(--err); margin-left: auto; }
1293
+ .score-grid { display: flex; flex-direction: column; gap: 6px; }
1294
+ .score-row { display: grid; grid-template-columns: 84px 1fr 56px; align-items: center; font-size: 13px; gap: 8px; }
1295
+ .score-row em { font-style: normal; font-size: 12px; text-align: right; color: var(--ink-2); }
1296
+ .score-pick { display: inline-flex; gap: 4px; }
1297
+ .score-pick button { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line-2); background: transparent; cursor: pointer; padding: 0; }
1298
+ .score-pick button.on { background: var(--accent); border-color: var(--accent); }
1299
+ .review-history { font-size: 12.5px; color: var(--ink-2); }
1300
+ .review-history summary { cursor: pointer; color: var(--ink-3); }
1301
+ .rh-item { border-top: 1px dashed var(--line); padding: 7px 0; display: flex; flex-direction: column; gap: 3px; line-height: 1.55; }