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 thread state on initial render

Steven Enamakelc3f341fcf654
diff --git a/app/src/components/assistant-ui/thread.tsx b/app/src/components/assistant-ui/thread.tsx
index 996fadf439..9c6543dc21 100644
--- a/app/src/components/assistant-ui/thread.tsx
+++ b/app/src/components/assistant-ui/thread.tsx
@@ -63,6 +63,7 @@ import {
RefreshCwIcon,
SlashIcon,
SquareIcon,
+ UserRoundIcon,
} from 'lucide-react';
import {
type ComponentType,
@@ -107,6 +108,13 @@ export type ThreadComponents = {
hasComposerAttachments?: boolean | undefined;
/** Sends an attachment-only message through the host's normal send path. */
onComposerAttachmentSend?: (() => void) | undefined;
+ /**
+ * Opens the host's voice/presence surface. When supplied, the composer's
+ * primary slot shows it as a person glyph while there is nothing to send,
+ * and reverts to Send on the first character or attachment — the slot
+ * ChatGPT gives its voice mode. Omit it and the slot is always Send.
+ */
+ onOpenHumanMode?: (() => void) | undefined;
};
export type ThreadProps = {
@@ -337,7 +345,7 @@ const Composer: FC<{
<ComposerPrimitive.AttachmentDropzone asChild>
<div
data-slot="aui_composer-shell"
- className="border-border/60 data-[dragging=true]:border-ring focus-within:border-border dark:border-muted-foreground/15 dark:focus-within:border-muted-foreground/30 flex w-full cursor-text flex-col gap-2 rounded-(--composer-radius) border bg-(--composer-bg) p-(--composer-padding) transition-[border-color] data-[dragging=true]:border-dashed data-[dragging=true]:bg-[color-mix(in_oklab,var(--color-accent)_50%,var(--color-background))]">
+ className="border-line focus-within:border-line-strong data-[dragging=true]:border-ring flex w-full cursor-text flex-col gap-2 rounded-(--composer-radius) border bg-(--composer-bg) p-(--composer-padding) transition-[border-color] data-[dragging=true]:border-dashed data-[dragging=true]:bg-[color-mix(in_oklab,var(--color-accent)_50%,var(--color-background))]">
{HostComposerAttachments ? <HostComposerAttachments /> : <ComposerAttachments />}
{/*
* Lexical rather than the plain `ComposerPrimitive.Input` textarea,
@@ -404,7 +412,14 @@ const ComposerAction: FC<{
ComposerAddAttachment: HostComposerAddAttachment,
hasComposerAttachments,
onComposerAttachmentSend,
+ onOpenHumanMode,
} = useContext(ThreadComponentsContext);
+ // Nothing to send: the primary slot offers the host's presence surface
+ // instead of a Send button that would refuse the click anyway. Guarded on
+ // `isRunning` by the surrounding `AuiIf`, so a streaming turn still shows
+ // Cancel.
+ const showHumanMode =
+ !!onOpenHumanMode && composerText.trim().length === 0 && !hasComposerAttachments;
return (
<div className="aui-composer-action-wrapper relative flex items-center justify-between">
<div className="flex min-w-0 items-center gap-1">
@@ -444,7 +459,20 @@ const ComposerAction: FC<{
</AuiIf>
</AuiIf>
<AuiIf condition={s => !s.thread.isRunning}>
- {hasComposerAttachments && composerText.trim().length === 0 ? (
+ {showHumanMode ? (
+ <TooltipIconButton
+ tooltip="Human mode"
+ side="bottom"
+ type="button"
+ variant="ghost"
+ size="icon"
+ className="aui-composer-human-mode text-muted-foreground hover:text-foreground size-7 rounded-full"
+ data-testid="composer-human-mode"
+ aria-label="Human mode"
+ onClick={() => onOpenHumanMode?.()}>
+ <UserRoundIcon className="aui-composer-human-mode-icon size-4" />
+ </TooltipIconButton>
+ ) : hasComposerAttachments && composerText.trim().length === 0 ? (
<TooltipIconButton
tooltip="Send message"
side="bottom"