feat(core): 脚本 agent 体感打磨 — skill松绑/对白去重/模型自写收尾/品牌遮罩/删除提速

- skill:旁白/对白每镜交给模型按内容判断(去掉「默认旁白·对白按门槛」);visual 加厚撑满15秒
- 脚本 agent:输出协议加收尾交付语 + _closing_summary → summary 事件(替写死的「已生成」)
- 前端:有对白的镜不再重复显旁白;summary 当 AI 气泡;进度时间轴 @keyframes 嵌套失效→移顶层(动画真跑起来)
- 生成遮罩改品牌生成卡(icon-box转圈+标题+动态点+橙扫光条);AI全生确定后不再闪三菜单
- 删除分镜:不再误显改写罩子(拆 rewriteShot);放开「至少保留一个分镜」可删空;删除提速(后端 bulk_update + 前端 liteRefresh)
- 去掉脚本助手标题旁冗余的模型名

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
seaislee1209
2026-06-18 14:54:33 +08:00
co-authored by Claude Opus 4.8
parent 9fce7e8fff
commit a71be19500
7 changed files with 127 additions and 36 deletions
+7 -6
View File
@@ -369,7 +369,7 @@ export function App() {
// 用 ref 而非 loading state,避免闭包拿到旧值;同步置位,任何同一 tick 的二次点击都拦得住。
const actionInFlightRef = useRef(false);
async function action<T>(work: () => Promise<T>, successText: string): Promise<T | null> {
async function action<T>(work: () => Promise<T>, successText: string, opts?: { liteRefresh?: boolean }): Promise<T | null> {
if (actionInFlightRef.current) {
setNotice({ type: "error", text: "操作进行中,请稍候…" });
return null;
@@ -383,7 +383,8 @@ export function App() {
if (successText) setNotice({ type: "success", text: successText });
// 后台刷新,不阻塞操作返回:全量 loadData 会分页拉全部 assets 很重,await 它会让
// 「项目已创建/确认脚本」后白等很久(行29/37)。改为后台 hydrate,操作立即返回。
void loadData();
// liteRefresh(改/删/加分镜等只动脚本、不动商品/资产的轻操作):跳过全量 loadData,只刷项目详情 → 快很多。
if (!opts?.liteRefresh) void loadData();
void refreshProjectDetail();
return result;
} catch (error) {
@@ -803,10 +804,10 @@ export function App() {
unreadCount={unreadCount}
avatarChar={avatarChar}
logout={logout} onAdoptScript={(scriptId) => action(() => api.adoptScript(pipelineProject.id, scriptId), "脚本已采用")}
onUpdateShot={(payload) => action(() => api.updateScriptSegment(pipelineProject.id, payload), "分镜已更新")}
onAddShot={(afterSegmentId, content) => action(() => api.addScriptSegment(pipelineProject.id, { after_segment_id: afterSegmentId, ...content }), "分镜已添加")}
onDeleteShot={(segmentId) => action(() => api.deleteScriptSegment(pipelineProject.id, { segment_id: segmentId }), "分镜已删除")}
onRerunShot={(segmentId, instruction) => action(() => api.rerunScriptSegment(pipelineProject.id, { segment_id: segmentId, instruction }), "分镜已重跑")}
onUpdateShot={(payload) => action(() => api.updateScriptSegment(pipelineProject.id, payload), "分镜已更新", { liteRefresh: true })}
onAddShot={(afterSegmentId, content) => action(() => api.addScriptSegment(pipelineProject.id, { after_segment_id: afterSegmentId, ...content }), "分镜已添加", { liteRefresh: true })}
onDeleteShot={(segmentId) => action(() => api.deleteScriptSegment(pipelineProject.id, { segment_id: segmentId }), "分镜已删除", { liteRefresh: true })}
onRerunShot={(segmentId, instruction) => action(() => api.rerunScriptSegment(pipelineProject.id, { segment_id: segmentId, instruction }), "分镜已重跑", { liteRefresh: true })}
onSaveProjectMeta={(meta) =>
// metadata 是整体替换:合并现有 project.metadata 后再 PATCH,别把别的 key(wizard 等)冲掉
action(() => api.updateProject(pipelineProject.id, { metadata: { ...(pipelineProject.metadata ?? {}), ...meta } }), "已保存")
+31 -5
View File
@@ -146,7 +146,27 @@
.chat-attach-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.shot-list { display: flex; flex-direction: column; }
.shots-body { padding: 12px 16px; flex: 1; overflow-y: auto; max-height: 540px; display: flex; flex-direction: column; gap: 0; }
.shots-body { padding: 12px 16px; flex: 1; overflow-y: auto; max-height: 540px; display: flex; flex-direction: column; gap: 0; position: relative; }
/* 行: 生成时左侧脚本区罩子(整体)/ 单镜罩子 + 转圈 */
.script-gen-veil { position: absolute; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--background-base) 86%, transparent); }
/* 方案 B · 品牌生成卡:icon-box 转圈 + 标题 + 动态点 + 橙色扫光进度条 */
.script-gen-veil .sgv-card { display: flex; align-items: center; gap: 12px; padding: 14px 18px; min-width: 252px; background: var(--surface); border: 1px solid var(--border-faint); border-radius: var(--r-md); box-shadow: var(--shadow-floating); }
.script-gen-veil .sgv-ico { width: 32px; height: 32px; flex: 0 0 32px; display: grid; place-items: center; background: var(--heat-12); border-radius: var(--r-sm); }
.script-gen-veil .sgv-ico .spinner { width: 18px; height: 18px; border: 2.5px solid var(--heat-20); border-top-color: var(--heat); border-radius: 50%; animation: assetSpin .7s linear infinite; }
.script-gen-veil .sgv-body { flex: 1; display: flex; flex-direction: column; gap: 9px; }
.script-gen-veil .sgv-title { font-size: 13px; font-weight: 500; color: var(--ink); display: inline-flex; align-items: center; gap: 4px; }
.script-gen-veil .sgv-dots { display: inline-flex; gap: 3px; align-items: center; }
.script-gen-veil .sgv-dots i { width: 3px; height: 3px; border-radius: 50%; background: var(--heat); animation: sgvBlink 1.2s infinite; }
.script-gen-veil .sgv-dots i:nth-child(2) { animation-delay: .2s; }
.script-gen-veil .sgv-dots i:nth-child(3) { animation-delay: .4s; }
.script-gen-veil .sgv-bar { position: relative; height: 4px; border-radius: 999px; background: var(--heat-12); overflow: hidden; }
.script-gen-veil .sgv-bar::after { content: ""; position: absolute; top: 0; bottom: 0; width: 42%; border-radius: 999px; background: var(--heat); animation: sgvBar 1.15s ease-in-out infinite; }
.shot-gen-veil { position: absolute; inset: 0; z-index: 4; display: flex; gap: 8px; align-items: center; justify-content: center; background: color-mix(in srgb, var(--background-base) 80%, transparent); border-radius: var(--r-sm); }
.shot-gen-veil .mono { font-size: 12px; color: var(--ink-3); letter-spacing: .04em; }
.script-gen-veil .spinner, .shot-gen-veil .spinner { width: 26px; height: 26px; border: 2.5px solid var(--heat-20); border-top-color: var(--heat); border-radius: 50%; animation: assetSpin .7s linear infinite; flex: 0 0 auto; }
.shot-gen-veil .spinner { width: 20px; height: 20px; }
.chat-send-btn .spinner.spinner-on-accent { width: 14px; height: 14px; border: 2px solid color-mix(in srgb, currentColor 40%, transparent); border-top-color: currentColor; border-radius: 50%; animation: assetSpin .7s linear infinite; }
.shot-list > .pane-h { flex-wrap: wrap; row-gap: 8px; }
.shot-headline { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
@@ -167,7 +187,7 @@
.shots-empty .empty-hint { font-size: 12px; color: var(--black-alpha-56); line-height: 1.55; max-width: 280px; font-family: var(--font-mono); letter-spacing: .02em; }
/* 镜头脚本卡(真实脚本镜头列表) */
.shot-card { display: flex; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--border-faint); }
.shot-card { display: flex; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--border-faint); position: relative; }
.shot-card:last-child { border-bottom: 0; }
.shot-card .shot-n { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 6px; background: var(--heat-12); color: var(--heat); font-family: var(--font-mono); font-size: 12px; font-weight: 600; display: grid; place-items: center; }
.shot-card .shot-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
@@ -553,9 +573,6 @@
.progress-timeline .pt-caret:hover { color: var(--ink-2); }
.progress-timeline .pt-caret.open { transform: rotate(90deg); }
.progress-timeline .pt-think { margin-top: 6px; font-size: 12px; line-height: 1.6; color: var(--ink-3); white-space: pre-wrap; word-break: break-word; max-height: 168px; overflow-y: auto; border-left: 1px solid var(--border-faint); padding-left: 8px; }
@keyframes ptRowIn { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
@keyframes pt-pulse { 0%, 100% { box-shadow: 0 0 0 2px var(--heat-12); } 50% { box-shadow: 0 0 0 5px transparent; } }
@keyframes pt-sweep { from { background-position: 140% 0; } to { background-position: -40% 0; } }
/* ── 行32 · 长文本折叠 ── */
.clamp-lines { display: -webkit-box; -webkit-line-clamp: var(--clamp-lines, 10); -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; word-break: break-word; }
@@ -690,6 +707,15 @@
/* 顶层 @keyframes:嵌套进 .pipeline-page 块内不会注册,动画不执行(product-detail 同坑) */
@keyframes edXfadeFlash { from { opacity: 0.72; } to { opacity: 0; } }
/* 行33 · 进度时间轴(顶层才注册:行入场 / 当前点脉冲 / 状态字光扫) */
@keyframes ptRowIn { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
@keyframes pt-pulse { 0%, 100% { box-shadow: 0 0 0 2px var(--heat-12); } 50% { box-shadow: 0 0 0 5px transparent; } }
@keyframes pt-sweep { from { background-position: 140% 0; } to { background-position: -40% 0; } }
/* 方案 B · 生成卡(顶层才注册:动态点闪烁 / 橙色扫光进度条) */
@keyframes sgvBlink { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@keyframes sgvBar { 0% { left: -42%; } 100% { left: 100%; } }
/* ── 流程步骤4 · 演员库覆盖层(portal 到 body,顶层选择器才生效)── */
/* 资产卡/演员库工作台的提示词输入框:顶层定义,页面内(资产卡)与 portal 弹窗(添加人物工作台)都生效 */
.asset-prompt-edit { width: 100%; margin-top: 8px; font-family: var(--font-mono); font-size: 12px; line-height: 1.55; letter-spacing: .01em; color: var(--black-alpha-72); background: var(--background-base); border: 1px solid var(--border-faint); border-radius: var(--r-sm); padding: 8px 10px; outline: none; resize: vertical; min-height: 56px; transition: border-color var(--t-base), background var(--t-base), box-shadow var(--t-base); }
+54 -19
View File
@@ -489,7 +489,7 @@ export function PipelinePage(props: {
}) {
const {
project, loading, navigate, user, team, products, projects, assets, billing, notice, unreadCount, avatarChar, logout,
scriptModelName, textModels, onAdoptScript, onUpdateShot, onAddShot, onDeleteShot, onRerunShot, onSaveProjectMeta, onAdoptVideoVersion, onGenerateVoiceover,
textModels, onAdoptScript, onUpdateShot, onAddShot, onDeleteShot, onRerunShot, onSaveProjectMeta, onAdoptVideoVersion, onGenerateVoiceover,
onGenerateBaseAsset, onAdoptBaseAsset, onAttachBaseAsset, onGenerateActor, onUploadActor, onGenerateTriview, onRenameActor, onGenerateStoryboard, onSkipStoryboard,
onSubmitVideo, onSubmitAllVideos, onPollVideosQuiet, exportResult, onRefreshExport, onRefreshProject,
onUploadVideoSegment, onUploadBgm, onSaveTimeline, onSubmitExport
@@ -889,14 +889,20 @@ export function PipelinePage(props: {
const [armedDelete, setArmedDelete] = useState<string | null>(null);
// 行35 · 单条分镜重跑 / 删除的即时反馈:正在处理的 shot id(按钮转「处理中」并禁用)
const [busyShot, setBusyShot] = useState<string | null>(null);
// 整体生成中:给整个镜头脚本区盖罩子转圈
const [scriptBusy, setScriptBusy] = useState(false);
// 单镜「改写中」:只在重跑/改稿那一镜盖罩子。与 busyShot 区分——删除也占 busyShot,但删除不该显「改写」罩子
const [rewriteShot, setRewriteShot] = useState<string | null>(null);
// 行35 · 单条分镜重跑:调后端 rerun-script-segment 只重写该镜(instruction 带本镜要点微调),给即时反馈
async function rerunShot(shotId: string, _index: number, hint: string) {
if (busyShot) return;
setBusyShot(shotId);
setRewriteShot(shotId); // 重跑 = 改写 → 那一镜盖「改写中」罩子
try {
await onRerunShot?.(shotId, hint || undefined);
} finally {
setBusyShot(null);
setRewriteShot(null);
}
}
// 单条分镜删除:立即反馈(置 busy)再落库
@@ -933,8 +939,12 @@ export function PipelinePage(props: {
// 指定镜号 = 精准改一镜,强制走 revise(后端读全脚本上下文、只动那一镜)
const agentMode = targetIndex != null ? "revise" : (mode ?? mapSourceToMode(source ?? chatMode));
const baseVersionId = agentMode === "revise" ? currentScript?.id : undefined;
// 生成时给左侧上罩子:指定镜号 → 只盖那一镜(busyShot);否则 → 盖整个脚本区(scriptBusy)
const targetShotId = targetIndex != null ? (shots[targetIndex]?.id ?? null) : null;
if (targetShotId) { setBusyShot(targetShotId); setRewriteShot(targetShotId); } else setScriptBusy(true);
let ok = false;
let receivedEvent = false;
let summaryText = "";
try {
await api.agentScriptStream(
project.id,
@@ -979,6 +989,9 @@ export function PipelinePage(props: {
const steps = (m.steps ?? []).map((s) => (s.id === "generate" ? { ...s, think: false } : s));
return { ...m, stream: (m.stream ?? "") + piece, steps };
}));
} else if (evt.type === "summary" && typeof evt.text === "string") {
// 模型自己写的收尾交付语 → 当 AI 回复气泡(替掉写死的「已生成」)
summaryText = evt.text;
} else if (evt.type === "saved") {
ok = true;
} else if (evt.type === "error") {
@@ -997,26 +1010,30 @@ export function PipelinePage(props: {
// 流中途断了(后端已通过 finally 释放预扣额度):不重试,提示用户
pushMsg("ai", "生成中断了,请重试。");
}
} finally {
if (targetShotId) { setBusyShot(null); setRewriteShot(null); } else setScriptBusy(false);
}
setChatMsgs((list) => list.map((m) => (m.id === progressId ? { ...m, done: true } : m)));
if (ok) {
await onRefreshProject();
pushMsg("ai", "镜头脚本已生成,左侧已刷新。可继续输入修改意见(会基于当前脚本改稿),或点「确认脚本」进入下一步。");
// 模型写了收尾就用它(真 agent 感);没写则兜底默认句
pushMsg("ai", summaryText || "镜头脚本已生成,左侧已刷新。可继续输入修改意见,或点「确认脚本」进入下一步。");
}
}
// 行28/行30 · 确认设定后真正发起生成:把所选「风格 / 人物」并进提示词(后端从 prompt 推断)
async function runScriptWithSetup() {
const styleLabel = WIZ_STYLE_LABEL[setupStyle] || setupStyle;
const personaLabel = WIZ_PERSONA_LABEL[setupPersona] || setupPersona;
setSetupOpen(false);
// 行28 · 持久化所选风格/人物到 metadata.wizard(合并现有 wizard,不冲掉 duration/selling_point_ids);
// 顶部「风格/人物」brief pill 读 metadata.wizard,刷新后即显已确认值
// 先 await 落库再发起生成:action 有 in-flight 互斥锁,并发会被「操作进行中」挡掉
// 一句话主题没填:不关卡、不存档,提示补主题(否则空主题也走下去 → 关卡空窗期闪回三个菜单)
if (setupSource === "theme" && !chatText.trim()) { focusThemeMode(); return; }
// 行28 · 持久化所选风格/人物到 metadata.wizard(合并现有 wizard,不冲掉 duration/selling_point_ids)
// 关键修复:先 await 落库(此时设定卡仍开着、确定按钮 disabled),存完再「关卡 + 发消息」同一帧切换,
// 不再出现「卡已关但消息未发」的空窗 → 不闪回三个菜单。
await onSaveProjectMeta?.({ wizard: { ...(project.metadata?.wizard ?? {}), script_style: setupStyle, persona: setupPersona } });
setSetupOpen(false);
const sourceLabel = SOURCE_LABEL[setupSource] || "AI 全生";
if (setupSource === "theme") {
const theme = chatText.trim();
if (!theme) { focusThemeMode(); return; }
setChatText("");
await runScriptGeneration(`一句话主题:${theme}。风格:${styleLabel},目标人群:${personaLabel}。生成镜头脚本,突出商品卖点,适合短视频投放`, `一句话主题:${theme} · ${styleLabel} · ${personaLabel}`, "theme");
return;
@@ -2130,6 +2147,17 @@ export function PipelinePage(props: {
<button className="btn btn-ghost btn-sm" type="button" id="chat-regen-btn" disabled={loading} onClick={() => void runScriptGeneration("整体重新生成 · 突出商品卖点,节奏紧凑,适合短视频投放", "整体重写")}> </button>
</div>
<div className="shots-body" id="shots-body">
{scriptBusy ? (
<div className="script-gen-veil" aria-hidden="true">
<div className="sgv-card">
<span className="sgv-ico"><span className="spinner"></span></span>
<div className="sgv-body">
<div className="sgv-title"><span className="sgv-dots"><i></i><i></i><i></i></span></div>
<div className="sgv-bar"></div>
</div>
</div>
</div>
) : null}
{shots.length ? (() => {
let cum = 0;
return shots.map((shot, index) => {
@@ -2142,6 +2170,9 @@ export function PipelinePage(props: {
return (
<Fragment key={shot.id}>
<div className="shot-card">
{rewriteShot === shot.id ? (
<div className="shot-gen-veil" aria-hidden="true"><span className="spinner"></span><span className="mono">// 改这一镜…</span></div>
) : null}
<div className="shot-n">{index + 1}</div>
<div className="shot-main">
<div className="shot-meta-row">
@@ -2153,7 +2184,7 @@ export function PipelinePage(props: {
className={`icon-mini-btn${armedDelete === shot.id ? " armed" : ""}`}
type="button"
title={armedDelete === shot.id ? "再点一次确认删除" : "删除本场"}
disabled={loading || shots.length <= 1 || busyShot === shot.id}
disabled={loading || busyShot === shot.id}
onClick={() => {
if (armedDelete === shot.id) {
void deleteShot(shot.id);
@@ -2164,14 +2195,17 @@ export function PipelinePage(props: {
>{armedDelete === shot.id ? "确认删除?" : "×"}</button>
</div>
</div>
<div className="shot-row">
<span className="shot-k"></span>
<EditableShotField
value={narration}
placeholder="(旁白)点击编辑"
onCommit={(text) => { void onUpdateShot({ segment_id: shot.id, narration: text }); }}
/>
</div>
{/* 这一镜有对白时,旁白=对白拼接(同一句),只显对白、不再重复显旁白 */}
{!(shot.dialogue && shot.dialogue.length > 0) ? (
<div className="shot-row">
<span className="shot-k"></span>
<EditableShotField
value={narration}
placeholder="(旁白)点击编辑"
onCommit={(text) => { void onUpdateShot({ segment_id: shot.id, narration: text }); }}
/>
</div>
) : null}
<div className="shot-row">
<span className="shot-k"></span>
<EditableShotField
@@ -2234,7 +2268,6 @@ export function PipelinePage(props: {
<div className="pane-h">
<div className="ai-avatar">AI</div>
<strong></strong>
<span className="muted-2 mono" style={{ fontSize: "12px" }}>· {scriptModelName}</span>
<span className="spacer"></span>
<button className="btn btn-ghost btn-sm" type="button" id="chat-clear-btn" disabled={!chatText && chatAttachments.length === 0 && chatMsgs.length === 0} onClick={clearChat}></button>
</div>
@@ -2352,8 +2385,10 @@ export function PipelinePage(props: {
</div>
) : null}
<span className="spacer"></span>
<button className="chat-send-btn" id="chat-send-btn" type="button" title="发送" aria-label="发送" disabled={loading || (!setupOpen && !chatText.trim() && pendingTagEdits.length === 0)} onClick={submitChat}>
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round"><path d="M5 12h14M13 6l6 6-6 6" /></svg>
<button className="chat-send-btn" id="chat-send-btn" type="button" title="发送" aria-label="发送" disabled={loading || scriptBusy || !!rewriteShot || (!setupOpen && !chatText.trim() && pendingTagEdits.length === 0)} onClick={submitChat}>
{scriptBusy || rewriteShot
? <span className="spinner spinner-on-accent" aria-hidden="true"></span>
: <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round"><path d="M5 12h14M13 6l6 6-6 6" /></svg>}
</button>
</div>
</div>