fix(web): simplify builder conversation events

This commit is contained in:
twwu committed 2026-09-04 14:40:50 +08:00
1 parent 4893c5e621
commit efa7528275
3 files changed
+77 -40

No files matched your search

@@ -442,6 +442,70 @@ describe('DifyBuilderConversation test data form', () => {
expect(screen.getByText('The plan is ready.')).toBeInTheDocument()
})
it('hides challenge, change set, and checkpoint cards from the committed conversation', () => {
render(
<DifyBuilderConversation
busy={false}
activeInteraction={null}
changesExpanded
interrupted={false}
items={[
{
seq: 0,
at_version: 2,
kind: 'challenge',
payload: {
title: 'High-impact rules',
body: 'Review these rules before applying.',
tone: 'warning',
},
},
{
seq: 1,
at_version: 2,
kind: 'change_set',
payload: {
count: 1,
changes: ['Update answer configuration'],
scope: 'configuration',
full_diff_open: true,
},
},
{
seq: 2,
at_version: 2,
kind: 'checkpoint',
payload: {
checkpoint_id: 'checkpoint-1',
label: 'Pre-edit checkpoint',
created_at: '2026-09-04T00:00:00Z',
},
},
{
seq: 3,
at_version: 2,
kind: 'assistant_turn',
payload: {
turn_id: 'turn-1',
stage_id: 'edit.impact_analysis',
execution: { status: 'completed', activities: [] },
reply_text: 'The change is ready for review.',
cards: ['challenge', 'change_set', 'checkpoint'],
},
},
]}
onActionPayloadChange={vi.fn()}
/>,
)
expect(screen.getByText('The change is ready for review.')).toBeInTheDocument()
expect(screen.queryByText('High-impact rules')).not.toBeInTheDocument()
expect(screen.queryByText('Review these rules before applying.')).not.toBeInTheDocument()
expect(screen.queryByText('configuration')).not.toBeInTheDocument()
expect(screen.queryByText('Update answer configuration')).not.toBeInTheDocument()
expect(screen.queryByText('Pre-edit checkpoint')).not.toBeInTheDocument()
})
it('does not render a Thinking section for execution progress alone', () => {
const store = createStore()
store.set(difyBuilderExecutionProgressAtom, {
@@ -479,7 +543,7 @@ describe('DifyBuilderConversation test data form', () => {
expect(screen.queryByText(/Thinking|Thought/)).not.toBeInTheDocument()
})
it('preserves the execution disclosure state while snapshots update', async () => {
it('keeps execution details collapsed by default and preserves user disclosure while snapshots update', async () => {
const user = userEvent.setup()
const store = createStore()
store.set(difyBuilderExecutionProgressAtom, {
@@ -516,9 +580,10 @@ describe('DifyBuilderConversation test data form', () => {
const progressDetails = screen.getByRole('group', { name: 'Run the workflow' })
const progressToggle = progressDetails.querySelector('summary')
expect(progressToggle).not.toBeNull()
expect(progressDetails).toHaveAttribute('open')
await user.click(progressToggle!)
expect(progressDetails).not.toHaveAttribute('open')
expect(screen.getByRole('status')).toHaveTextContent('Run the workflow')
await user.click(progressToggle!)
expect(progressDetails).toHaveAttribute('open')
act(() => {
store.set(difyBuilderExecutionProgressAtom, {
@@ -548,7 +613,7 @@ describe('DifyBuilderConversation test data form', () => {
})
expect(screen.getByRole('group', { name: 'Generate answer' })).toBe(progressDetails)
expect(progressDetails).not.toHaveAttribute('open')
expect(progressDetails).toHaveAttribute('open')
})
it('renders failed test results with the destructive card tone', () => {
@@ -22,7 +22,6 @@ export const ConversationCard = memo(
item,
busy,
interactive,
changesExpanded,
invalidated,
onActionPayloadChange,
onActionValidityChange,
@@ -37,6 +36,9 @@ export const ConversationCard = memo(
}) => {
const { t } = useTranslation()
if (item.kind === 'challenge' || item.kind === 'change_set' || item.kind === 'checkpoint')
return null
if (item.kind === 'user' || item.kind === 'decision') {
return (
<div className="flex justify-end">
@@ -141,40 +143,15 @@ export const ConversationCard = memo(
)
}
if (item.kind === 'challenge' || item.kind === 'error') {
if (item.kind === 'error') {
return (
<DifyBuilderCardShell
invalidated={invalidated}
tone={item.kind === 'error' ? 'error' : 'warning'}
>
<DifyBuilderCardShell invalidated={invalidated} tone="error">
<div className="system-xs-semibold text-text-primary">{item.payload.title}</div>
<div className="mt-1 system-xs-regular text-text-secondary">{item.payload.body}</div>
</DifyBuilderCardShell>
)
}
if (item.kind === 'change_set') {
return (
<DifyBuilderCardShell invalidated={invalidated}>
<div className="flex items-center justify-between">
<span className="system-xs-semibold text-text-primary">
{item.payload.scope || t(($) => $['difyBuilder.changes'], { ns: 'workflow' })}
</span>
<span className="bg-components-badge-gray-bg rounded-md px-1.5 py-0.5 system-2xs-medium text-text-tertiary">
{item.payload.count}
</span>
</div>
{(changesExpanded || item.payload.full_diff_open) && (
<ul className="mt-2 list-disc space-y-1 pl-4 system-xs-regular text-text-secondary">
{item.payload.changes.map((change) => (
<li key={change}>{change}</li>
))}
</ul>
)}
</DifyBuilderCardShell>
)
}
if (item.kind === 'test_result') {
return (
<DifyBuilderCardShell
@@ -227,13 +204,8 @@ export const ConversationCard = memo(
)
}
if (item.kind === 'checkpoint' || item.kind === 'publish' || item.kind === 'build_learning') {
const label =
item.kind === 'checkpoint'
? item.payload.label
: item.kind === 'publish'
? item.payload.version
: item.payload.state
if (item.kind === 'publish' || item.kind === 'build_learning') {
const label = item.kind === 'publish' ? item.payload.version : item.payload.state
return (
<DifyBuilderCardShell
invalidated={invalidated}
@@ -33,7 +33,7 @@ const ActivityRow = ({ activity }: { activity: ExecutionActivity }) => (
)
export const ExecutionProgress = ({ execution }: { execution?: ExecutionProgressData | null }) => {
const [open, setOpen] = useState(execution?.status === 'running' || execution?.status === 'error')
const [open, setOpen] = useState(false)
const activities = execution?.activities ?? []
if (!execution || activities.length === 0) return null