Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion wework/src/components/chat/ChatInput.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2400,7 +2400,36 @@ describe('ChatInput', () => {
expect(screen.getByTestId('pause-goal-button')).toBeInTheDocument()
})

test.each(['blocked', 'usageLimited', 'budgetLimited'] as const)(
test('offers the resume action for a blocked goal', async () => {
const onResumeGoal = vi.fn()

render(
<ChatInput
value=""
onChange={vi.fn()}
onSubmit={vi.fn()}
disabled={false}
variant="desktop"
goal={{
threadId: 'thread-1',
objective: 'Resolve the issue',
status: 'blocked',
tokenBudget: null,
tokensUsed: 0,
timeUsedSeconds: 0,
createdAt: 1780000000000,
updatedAt: 1780000000000,
}}
onResumeGoal={onResumeGoal}
/>
)

await userEvent.click(screen.getByTestId('resume-goal-button'))

expect(onResumeGoal).toHaveBeenCalledTimes(1)
})

test.each(['usageLimited', 'budgetLimited'] as const)(
'does not offer the pause action for a %s goal',
status => {
render(
Expand Down
12 changes: 6 additions & 6 deletions wework/src/components/chat/composer/GoalStatusBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ export function GoalStatusBar({
[goal, timerKey, timerState]
)
const elapsed = formatGoalElapsed(elapsedSeconds)
const paused = goal.status === 'paused'
const canToggle = goal.status === 'active' || paused
const ToggleIcon = paused ? Play : Pause
const toggleLabel = paused
const resumable = goal.status === 'paused' || goal.status === 'blocked'
const canToggle = goal.status === 'active' || resumable
const ToggleIcon = resumable ? Play : Pause
const toggleLabel = resumable
? t('workbench.goal_resume', '继续目标')
: t('workbench.goal_pause', '暂停目标')
const toggleAction = paused ? onResumeGoal : onPauseGoal
const toggleAction = resumable ? onResumeGoal : onPauseGoal

useEffect(() => {
if (goal.status !== 'active') return
Expand Down Expand Up @@ -87,7 +87,7 @@ export function GoalStatusBar({
{canToggle && (
<button
type="button"
data-testid={paused ? 'resume-goal-button' : 'pause-goal-button'}
data-testid={resumable ? 'resume-goal-button' : 'pause-goal-button'}
onClick={toggleAction}
disabled={!toggleAction}
className="flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-text-secondary hover:bg-surface hover:text-text-primary disabled:cursor-not-allowed disabled:opacity-40"
Expand Down
Loading