Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(chat): prevent composer from sending empty messages

Steven Enamakel554c58bc9c3b
diff --git a/app/src/components/chat/ChatComposer.tsx b/app/src/components/chat/ChatComposer.tsx
index 06a30e09f2..4dacb294ca 100644
--- a/app/src/components/chat/ChatComposer.tsx
+++ b/app/src/components/chat/ChatComposer.tsx
@@ -154,14 +154,17 @@ export interface ChatComposerProps {
* host surface passes down as `isSending`. Reading it directly keeps the
* composer renderable by surfaces whose thread is not the runtime's.
*
- * ## Runtime context is required
+ * ## Runtime context
*
* `ComposerPrimitive.*` reads its runtime from React context, so every surface
- * rendering this component must sit under an `AssistantUiRuntimeProvider`
- * scoped to *its own* thread. Two surfaces did not, and inheriting the app-wide
- * runtime (bound to `selectedThreadId`) would have pointed their composer at
- * the home chat's thread; both now mount their own. See the comments at those
- * mount sites in `WorkflowCopilotPanel` and `orchestration/AgentChatPanel`.
+ * rendering this component should sit under a runtime scoped to *its own*
+ * thread. Two did not, and would have inherited the app-wide one bound to
+ * `selectedThreadId` — the home chat's thread; both now mount their own (see
+ * `WorkflowCopilotPanel` and `orchestration/AgentChatPanel`). The default
+ * export wraps this body in `ComposerRuntimeBoundary`, which supplies an inert
+ * runtime when there is none at all; read that file before assuming the
+ * boundary makes the per-surface decision unnecessary — it cannot, because an
+ * inherited runtime and a correct one are indistinguishable from in here.
*/
function ChatComposerBody({
inputValue,
diff --git a/app/src/components/chat/__tests__/ChatComposer.test.tsx b/app/src/components/chat/__tests__/ChatComposer.test.tsx
index 817cc023e4..82a741be68 100644
--- a/app/src/components/chat/__tests__/ChatComposer.test.tsx
+++ b/app/src/components/chat/__tests__/ChatComposer.test.tsx
@@ -238,6 +238,38 @@ describe('ChatComposer', () => {
expect(onSwitchToMicCloud).toHaveBeenCalledTimes(1);
});
+ describe('runtime boundary', () => {
+ it('renders with no assistant-ui runtime in context at all', () => {
+ // The primitives throw on a missing runtime; the boundary supplies an
+ // inert one so a host that mounts none still gets a working composer
+ // rather than a crash. Note the deliberate absence of `wrapper: Runtime`.
+ render(
+ <ChatComposer
+ inputValue="standalone"
+ setInputValue={vi.fn()}
+ onSend={vi.fn().mockResolvedValue(undefined)}
+ textInputRef={createRef<HTMLTextAreaElement | null>()}
+ fileInputRef={createRef<HTMLInputElement | null>()}
+ composerInteractionBlocked={false}
+ isSending={false}
+ attachments={[]}
+ onAttachFiles={vi.fn().mockResolvedValue(undefined)}
+ onRemoveAttachment={vi.fn()}
+ attachError={null}
+ onSwitchToMicCloud={vi.fn()}
+ handleInputKeyDown={vi.fn()}
+ inlineCompletionSuffix=""
+ isComposingTextRef={{ current: false }}
+ maxAttachments={0}
+ allowedMimeTypes={[]}
+ attachmentsEnabled={false}
+ />
+ );
+ expect(screen.getByRole('textbox')).toHaveValue('standalone');
+ expect(screen.getByTestId('send-message-button')).toBeInTheDocument();
+ });
+ });
+
describe('assistant-ui composer text bridge', () => {
it('renders the inputValue prop through the primitive input', () => {
// The primitive is not a controlled React input — it renders the