Skip to content

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

fix(conversations): handle empty conversation list edge case

Steven Enamakel2a8765e24f5e
diff --git a/app/src/features/conversations/Conversations.tsx b/app/src/features/conversations/Conversations.tsx
index aea0410d2b..74fbab9a68 100644
--- a/app/src/features/conversations/Conversations.tsx
+++ b/app/src/features/conversations/Conversations.tsx
@@ -1435,6 +1435,36 @@ const Conversations = ({
});
}, [selectedThreadId, streamingAssistantByThread, dispatch]);
+ handleStopGenerationRef.current = handleStopGeneration;
+
+ // Register this surface as the owner of the selected thread's write path, so
+ // assistant-ui's runtime (`useOpenHumanExternalStore`) forwards `onNew` /
+ // `onCancel` here instead of reimplementing ~200 lines of send orchestration.
+ //
+ // `send` deliberately routes through `handleComposerSend` — the SAME function
+ // the composer's Send button and plain Enter use — so the streaming-vs-idle
+ // decision (queued follow-up vs. a fresh turn) is made in exactly one place.
+ // Re-deriving it here would be the drift `chatSurfaceHandlers` exists to
+ // prevent, and `handleSendMessage` already runs `evaluateComposerSend`
+ // internally for the block/allow half of that decision.
+ //
+ // `reload` is intentionally left undefined: there is no regenerate-last-turn
+ // path in this surface (`ai_regenerate` re-runs a failed ARTIFACT, not a
+ // chat turn), and an `onReload` that silently does nothing is worse than an
+ // absent one — the runtime can then correctly report the capability as off.
+ useEffect(() => {
+ if (!selectedThreadId) return;
+ debug('[chat] registering assistant-ui chat surface thread=%s', selectedThreadId);
+ return registerChatSurface(selectedThreadId, {
+ send: async (text: string) => {
+ await handleComposerSendRef.current?.(text);
+ },
+ cancel: async () => {
+ handleStopGenerationRef.current?.();
+ },
+ });
+ }, [selectedThreadId]);
+
const transcribeAndSendAudio = async (mimeType: string) => {
setIsRecording(false);
mediaRecorderRef.current = null;