Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@ export const FilesetFileBlockingInput: FC<FilesetFileBlockingInputBaseProps> = (
control,
handleSubmit,
setError,
watch,
formState: { errors },
} = useForm<FilesetFileFormData>({
defaultValues: { datasetFile: null },
resolver: zodResolver(schema),
disabled: isSubmitting,
});
const acceptedFileTypes = getAcceptedFileTypes(input, defaultAcceptedFileTypes);
const datasetFile = watch('datasetFile');

const submit = handleSubmit((data) => {
const parsed =
Expand All @@ -98,6 +100,7 @@ export const FilesetFileBlockingInput: FC<FilesetFileBlockingInputBaseProps> = (
request={request}
secondaryActions={secondaryActions}
secondaryActionLabel={secondaryActionLabel}
submitDisabled={!datasetFile}
submitLabel={submitLabel}
>
<Stack className="max-h-[45vh] overflow-y-auto pr-density-sm">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe('AgentDecisionInput', () => {
);
});

it('shows a send button for the text choice and submits the entered text', async () => {
it('shows a send button that is disabled while a text choice awaits input', async () => {
const user = userEvent.setup();
const onSubmit = vi.fn();

Expand All @@ -129,13 +129,13 @@ describe('AgentDecisionInput', () => {
/>
);

expect(screen.queryByRole('button', { name: /Send alternative instruction/i })).toBeNull();
const sendButton = screen.getByRole('button', { name: /Send/i });
expect(sendButton).not.toBeDisabled();

await user.click(
screen.getByRole('option', { name: /3\.\s+Tell the Agent what to do differently/i })
);

const sendButton = screen.getByRole('button', { name: /Send alternative instruction/i });
expect(sendButton).toBeDisabled();

await user.type(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,19 +367,17 @@ export const AgentDecisionInput = ({
<Text kind="label/regular/sm">{skipLabel}</Text>
</Button>
) : null}
{selectedChoiceInput ? (
<Button
aria-label="Send alternative instruction"
type="button"
color="brand"
size="small"
disabled={isSubmitting || !trimmedChoiceInputValue}
className={subduedButtonFocusClassName}
onClick={() => void submitSelectedChoice()}
>
<Send size={16} />
</Button>
) : null}
<Button
aria-label="Send"
type="button"
color="brand"
size="small"
disabled={isSubmitting || (!!selectedChoiceInput && !trimmedChoiceInputValue)}
className={subduedButtonFocusClassName}
onClick={() => void submitSelectedChoice()}
>
<Send size={16} />
</Button>
</Flex>
</Flex>
</Flex>
Expand Down