Skip to content

Self-improving AI Employees for everyone

fix(chat): say the employee is still answering when a second message is refused

trohitg006f2857959f
diff --git a/client/src/components/ui/ConsolePanel.tsx b/client/src/components/ui/ConsolePanel.tsx
index a0184987..3a2e2ed1 100644
--- a/client/src/components/ui/ConsolePanel.tsx
+++ b/client/src/components/ui/ConsolePanel.tsx
@@ -290,6 +290,8 @@ const ConsolePanel: React.FC<ConsolePanelProps> = ({
} catch (error) {
// Nothing listens while the workflow is stopped, so the server saved nothing.
if (error instanceof Error && error.message === 'not_running') toast.error('Start this workflow to chat with it.');
+ // One answer at a time per conversation; the text stays in the box.
+ else if (error instanceof Error && error.message === 'run_in_progress') toast.info('The workflow is still answering your last message.');
else console.error('Failed to send chat message:', error);
} finally {
setIsSending(false);
diff --git a/client/src/features/home/__tests__/talk.test.tsx b/client/src/features/home/__tests__/talk.test.tsx
index 36be91e7..026c3a34 100644
--- a/client/src/features/home/__tests__/talk.test.tsx
+++ b/client/src/features/home/__tests__/talk.test.tsx
@@ -203,6 +203,20 @@ describe('sending', () => {
expect(screen.queryByText('Working…')).not.toBeInTheDocument();
});
+ it('keeps a message the employee cannot take yet, saying they are still working', async () => {
+ server.send = { success: false, error: 'run_in_progress' };
+ renderTalk(employee());
+ const box = await screen.findByRole('textbox', { name: 'Message Maya' });
+ fireEvent.change(box, { target: { value: 'And Sunday?' } });
+ fireEvent.click(screen.getByRole('button', { name: 'Send' }));
+
+ await waitFor(() =>
+ expect(pillToast).toHaveBeenCalledWith('Maya is still working on your last message. Send this once they answer.', { tone: 'info' }),
+ );
+ expect(screen.getByRole('log', { name: 'Conversation with Maya' })).not.toHaveTextContent('And Sunday?');
+ expect(box).toHaveValue('And Sunday?');
+ });
+
it('lets one message wait while the employee is paused', async () => {
server.send = { success: true, delivery: 'queued' };
const paused = employee({}, 'paused');
diff --git a/client/src/features/home/employee/EmployeeTalk.tsx b/client/src/features/home/employee/EmployeeTalk.tsx
index ac198bd2..c4f931c5 100644
--- a/client/src/features/home/employee/EmployeeTalk.tsx
+++ b/client/src/features/home/employee/EmployeeTalk.tsx
@@ -212,6 +212,12 @@ function Conversation({ employee, control, drafts }: { employee: EmployeeSummary
cancel();
setDraft((current) => current || text);
if (error.message === 'not_running') invalidateEmployees(queryClient);
+ if (error.message === 'run_in_progress') {
+ // One answer at a time: the server refuses a second message while
+ // the employee is still working on the last one.
+ pillToast(`${name} is still working on your last message. Send this once they answer.`, { tone: 'info' });
+ return;
+ }
pillToast(error.message === 'not_running' ? `${name} isn’t running. Start them first.` : 'Your message didn’t send. Try again.', {
tone: 'error',
});