收口创作代理聊天空态与输入框
将 creation-agent 聊天空态迁移到 PlatformEmptyState 将 creation-agent composer 文本域迁移到 PlatformTextField 补充空态输入框样式和键盘提交语义测试 更新 PlatformUiKit 文档和 Hermes 决策记录
This commit is contained in:
@@ -99,11 +99,58 @@ test('creation agent workspace keeps initial chat progress at zero percent', ()
|
||||
).toContain('rounded-[1.5rem]');
|
||||
expect(documentUploadButton.className).toContain('platform-icon-button');
|
||||
expect(referenceUploadButton.className).toContain('platform-icon-button');
|
||||
const emptyState = screen.getByText('暂无消息');
|
||||
const composer = screen.getByPlaceholderText('输入消息');
|
||||
|
||||
expect(emptyState.className).toContain('platform-empty-state');
|
||||
expect(emptyState.className).toContain('h-full');
|
||||
expect(composer.className).toContain('platform-text-field');
|
||||
expect(composer.className).toContain('min-h-[3rem]');
|
||||
expect(composer.className).toContain('flex-1');
|
||||
expect(
|
||||
(progressbar.firstElementChild as HTMLElement | null)?.style.width,
|
||||
).toBe('0%');
|
||||
});
|
||||
|
||||
test('creation agent workspace keeps composer keyboard submit semantics', () => {
|
||||
ensureScrollApis();
|
||||
|
||||
const onSubmitText = vi.fn();
|
||||
render(
|
||||
<CreationAgentWorkspace
|
||||
session={{
|
||||
sessionId: 'creation-agent-session-1',
|
||||
title: null,
|
||||
currentTurn: 0,
|
||||
progressPercent: 0,
|
||||
anchors: [],
|
||||
messages: [],
|
||||
}}
|
||||
theme={testTheme}
|
||||
loadingText="正在准备"
|
||||
composerPlaceholder="输入消息"
|
||||
primaryActionLabel="生成结果页"
|
||||
onBack={() => {}}
|
||||
onSubmitText={onSubmitText}
|
||||
onPrimaryAction={() => {}}
|
||||
/>,
|
||||
);
|
||||
|
||||
const composer = screen.getByPlaceholderText('输入消息') as HTMLTextAreaElement;
|
||||
|
||||
fireEvent.change(composer, {
|
||||
target: { value: ' 继续推进设定 ' },
|
||||
});
|
||||
fireEvent.keyDown(composer, { key: 'Enter', shiftKey: true });
|
||||
|
||||
expect(onSubmitText).not.toHaveBeenCalled();
|
||||
|
||||
fireEvent.keyDown(composer, { key: 'Enter' });
|
||||
|
||||
expect(onSubmitText).toHaveBeenCalledWith('继续推进设定');
|
||||
expect(composer.value).toBe('');
|
||||
});
|
||||
|
||||
test('creation agent workspace renders operation banner with shared status message', () => {
|
||||
ensureScrollApis();
|
||||
|
||||
|
||||
@@ -9,10 +9,12 @@ import {
|
||||
resolveCreationAgentProgressHint,
|
||||
} from '../../services/creation-agent';
|
||||
import { PlatformActionButton } from '../common/PlatformActionButton';
|
||||
import { PlatformEmptyState } from '../common/PlatformEmptyState';
|
||||
import { PlatformIconButton } from '../common/PlatformIconButton';
|
||||
import { PlatformProgressBar } from '../common/PlatformProgressBar';
|
||||
import { PlatformStatusMessage } from '../common/PlatformStatusMessage';
|
||||
import { PlatformSubpanel } from '../common/PlatformSubpanel';
|
||||
import { PlatformTextField } from '../common/PlatformTextField';
|
||||
import { PlatformUploadPreviewCard } from '../common/PlatformUploadPreviewCard';
|
||||
|
||||
export type CreationAgentAnchorView = {
|
||||
@@ -577,9 +579,14 @@ export function CreationAgentWorkspace({
|
||||
className="min-h-0 flex-1 space-y-3 overflow-y-auto px-4 py-4"
|
||||
>
|
||||
{displayedMessages.length === 0 ? (
|
||||
<div className="flex h-full items-center justify-center text-sm text-[var(--platform-text-soft)]">
|
||||
<PlatformEmptyState
|
||||
surface="subpanel"
|
||||
size="compact"
|
||||
tone="soft"
|
||||
className="flex h-full items-center justify-center text-center"
|
||||
>
|
||||
暂无消息
|
||||
</div>
|
||||
</PlatformEmptyState>
|
||||
) : (
|
||||
displayedMessages.map((message, index) => (
|
||||
<CreationAgentMessageBubble
|
||||
@@ -672,12 +679,15 @@ export function CreationAgentWorkspace({
|
||||
className="h-11 w-11 shrink-0"
|
||||
/>
|
||||
) : null}
|
||||
<textarea
|
||||
<PlatformTextField
|
||||
variant="textarea"
|
||||
value={draftText}
|
||||
disabled={
|
||||
isBusy || isParsingDocumentInput || isReadingReferenceImage
|
||||
}
|
||||
rows={2}
|
||||
size="md"
|
||||
density="compact"
|
||||
onChange={(event) => {
|
||||
setDraftText(event.target.value);
|
||||
setDocumentInputError(null);
|
||||
@@ -689,7 +699,7 @@ export function CreationAgentWorkspace({
|
||||
}
|
||||
}}
|
||||
placeholder={composerPlaceholder}
|
||||
className="min-h-[3rem] flex-1 resize-none bg-transparent px-2 py-2 text-sm text-[var(--platform-text-strong)] outline-none placeholder:text-[var(--platform-text-soft)]"
|
||||
className="min-h-[3rem] min-w-0 flex-1 placeholder:text-[var(--platform-text-soft)]"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
Reference in New Issue
Block a user