fix creation chat initial progress

This commit is contained in:
2026-04-25 14:18:40 +08:00
parent 8ec19e2364
commit 1b2daf4796
3 changed files with 41 additions and 2 deletions

View File

@@ -308,6 +308,7 @@
2. 壳层文件内不再直接包含自动保存防抖实现。
3. 壳层文件内不再直接包含 session -> result profile 编译细节。
4. 壳层文件内不再直接处理 works/library/history/save 的多路请求编排。
5. Agent 聊天工作区进入时必须如实展示后端 session 的 `progressPercent`。新会话后端初始值为 `0` 时,前端数字与进度条填充都必须保持 `0%`;只允许对大于 0 的值使用视觉最小宽度,避免用户误判聊天流程已经推进。
## 5.2 custom world 专属 client 拆分方案

View File

@@ -32,6 +32,37 @@ function ensureScrollApis() {
}
}
test('creation agent workspace keeps initial chat progress at zero percent', () => {
ensureScrollApis();
render(
<CreationAgentWorkspace
session={{
sessionId: 'creation-agent-session-1',
title: null,
currentTurn: 0,
progressPercent: 0,
anchors: [],
messages: [],
}}
theme={testTheme}
loadingText="正在准备"
composerPlaceholder="输入消息"
primaryActionLabel="生成结果页"
onBack={() => {}}
onSubmitText={() => {}}
onPrimaryAction={() => {}}
/>,
);
const progressbar = screen.getByRole('progressbar');
expect(progressbar.getAttribute('aria-valuenow')).toBe('0');
expect((progressbar.firstElementChild as HTMLElement | null)?.style.width).toBe(
'0%',
);
});
test('creation agent workspace filters duplicate recommended replies', () => {
const consoleErrorSpy = vi
.spyOn(console, 'error')

View File

@@ -311,6 +311,7 @@ export function CreationAgentWorkspace({
}
const progress = normalizeCreationAgentProgress(session.progressPercent);
const progressFillWidth = progress <= 0 ? '0%' : `${Math.max(6, progress)}%`;
const hasHeroCopy = Boolean(session.title || session.assistantSummary);
const canShowPrimaryAction = progress >= 100;
const visibleQuickActions = quickActions.filter((action) =>
@@ -414,10 +415,16 @@ export function CreationAgentWorkspace({
{progress}%
</span>
</div>
<div className="h-2 overflow-hidden rounded-full bg-white/12">
<div
className="h-2 overflow-hidden rounded-full bg-white/12"
role="progressbar"
aria-valuemin={0}
aria-valuemax={100}
aria-valuenow={progress}
>
<div
className={`h-full rounded-full transition-all ${theme.accentBgClass}`}
style={{ width: `${Math.max(6, progress)}%` }}
style={{ width: progressFillWidth }}
/>
</div>
<div className="mt-2 text-xs leading-5 text-white/64">