Skip to content

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

fix(assistant-ui): handle empty conversation state on initial render

Steven Enamakel848de0a26906
diff --git a/app/src/features/conversations/components/AssistantUiChat.tsx b/app/src/features/conversations/components/AssistantUiChat.tsx
index 3bb8612f49..3f083089e2 100644
--- a/app/src/features/conversations/components/AssistantUiChat.tsx
+++ b/app/src/features/conversations/components/AssistantUiChat.tsx
@@ -22,7 +22,11 @@ import { contextUsageFromTokenUsage, ContextWindowPill } from './composer/Contex
const EMPTY_TOKEN_USAGE = emptySessionTokenUsage();
const selectComposerText = (state: AssistantState) => state.composer.text;
-function ComposerTextBridge({
+/**
+ * Keeps a host-owned draft string and assistant-ui's composer text in step.
+ * Exported for surfaces that mount `Thread` directly (the workflow copilot).
+ */
+export function ComposerTextBridge({
value,
onChange,
}: {
@@ -61,6 +65,7 @@ export function AssistantUiChat({
onModelChange,
composerHeader,
composerFooterExtras,
+ composerReplacement,
inputValue,
onInputValueChange,
onEscape,
@@ -86,6 +91,13 @@ export function AssistantUiChat({
* background-processes button and the thread files chip).
*/
composerFooterExtras?: ReactNode;
+ /**
+ * Replaces the built-in text composer entirely, keeping the assistant-ui
+ * transcript above it. The mic-first voice composer (`mic-cloud`) uses this:
+ * its input is a push-to-talk button, not a text box. `undefined` keeps the
+ * normal composer.
+ */
+ composerReplacement?: ReactNode;
inputValue: string;
onInputValueChange: (value: string) => void;
onEscape?: () => void;
@@ -118,7 +130,6 @@ export function AssistantUiChat({
// `selectCustomPrimaryColor`: this component is mounted by suites that build
// a partial store, and those selectors dereference `state.mascot` unguarded,
// so a store without the slice crashes the whole chat surface on render.
- // `ChatThreadView` reads `state.theme?.` the same way for the same reason.
const mascotColor = useAppSelector(state => state.mascot?.color ?? DEFAULT_MASCOT_COLOR);
const mascotCustomPrimary = useAppSelector(state => state.mascot?.customPrimaryColor ?? null);
const selectedThreadId = useAppSelector(state => state.thread.selectedThreadId);
@@ -192,6 +203,12 @@ export function AssistantUiChat({
const composerHeaderRef = useRef(composerHeader);
composerHeaderRef.current = composerHeader;
const ComposerHeader = useCallback(() => <>{composerHeaderRef.current}</>, []);
+ // Same stable-type-through-a-ref pattern: the voice composer owns recording
+ // state (MicComposer) that a remount would drop mid-utterance.
+ const composerReplacementRef = useRef(composerReplacement);
+ composerReplacementRef.current = composerReplacement;
+ const hasComposerReplacement = composerReplacement !== undefined;
+ const ComposerReplacement = useCallback(() => <>{composerReplacementRef.current}</>, []);
const ComposerAttachments = useCallback(() => {
const { attachments, attachmentInteractionBlocked, onRemoveAttachment } = slotPropsRef.current;
return (
@@ -281,6 +298,7 @@ export function AssistantUiChat({
// one collapsed disclosure under the answer.
SourceGroup: ChatSources,
onSwitchToMicCloud,
+ ...(hasComposerReplacement ? { Composer: ComposerReplacement } : {}),
...(attachmentsEnabled
? {
ComposerAttachments,
@@ -303,6 +321,8 @@ export function AssistantUiChat({
ComposerExtras,
ComposerHeader,
ComposerIdleAction,
+ ComposerReplacement,
+ hasComposerReplacement,
attachmentInteractionBlocked,
handleComposerFiles,
maxAttachments,