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

@@ -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">