Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions apps/web/src/components/chat/ComposerFooterControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ export const ComposerFooterPrimaryActions = memo(function ComposerFooterPrimaryA
) : props.reserveContextWindowMeter ? (
<ContextWindowMeterPlaceholder />
) : null}
{props.children}
<ComposerPrimaryActions
compact={props.compact}
canOperateThread={props.canOperateThread}
Expand Down Expand Up @@ -329,7 +328,9 @@ export const ComposerFooterPrimaryActions = memo(function ComposerFooterPrimaryA
compactBeforeSendTokens={props.compactBeforeSendTokens}
keepFullHistory={props.keepFullHistory}
onToggleKeepFullHistory={props.onToggleKeepFullHistory}
/>
>
{props.children}
</ComposerPrimaryActions>
</>
);
});
Expand Down
123 changes: 74 additions & 49 deletions apps/web/src/components/chat/ComposerPrimaryActions.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { memo, type MouseEventHandler, type PointerEventHandler } from "react";
import { memo, type MouseEventHandler, type PointerEventHandler, type ReactNode } from "react";
import { CheckIcon, ChevronDownIcon, ChevronLeftIcon, Minimize2Icon, PlayIcon } from "lucide-react";
import { CornerUpRight, ListPlus } from "lucide";
import { MorphIcon } from "~/components/MorphIcon";
Expand Down Expand Up @@ -26,6 +26,8 @@ interface PendingActionState {
}

interface ComposerPrimaryActionsProps {
/** Footer controls (dictation) that always sit right before the primary button. */
children?: ReactNode;
compact: boolean;
canOperateThread: boolean;
pendingAction: PendingActionState | null;
Expand Down Expand Up @@ -82,6 +84,7 @@ const preventPointerFocus: PointerEventHandler<HTMLElement> = (event) => {
};

export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
children,
compact,
canOperateThread,
pendingAction,
Expand Down Expand Up @@ -182,6 +185,7 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
</Button>
)
) : null}
{children}
<button
type="submit"
className={cn(messageActionPillClassName, "h-8 sm:h-7", compact ? "px-3" : "px-4")}
Expand Down Expand Up @@ -211,63 +215,76 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
if (showPlanFollowUpPrompt && (promptHasText || !canResume)) {
if (promptHasText) {
return (
<button
type="submit"
className={cn(messageActionPillClassName, "h-9 sm:h-8", compact ? "px-3" : "px-4")}
{...pointerFocusProps}
disabled={isSendBusy || isSendDisabled || isEnvironmentUnavailable}
>
{isSendBusy ? "Sending..." : "Refine"}
</button>
<>
{children}
<button
type="submit"
className={cn(messageActionPillClassName, "h-9 sm:h-8", compact ? "px-3" : "px-4")}
{...pointerFocusProps}
disabled={isSendBusy || isSendDisabled || isEnvironmentUnavailable}
>
{isSendBusy ? "Sending..." : "Refine"}
</button>
</>
);
}

return (
<div data-chat-composer-implement-actions="true" className="flex items-center justify-end">
<button
type="submit"
className={cn(messageActionPillClassName, "h-9 rounded-r-none px-4 sm:h-8")}
{...pointerFocusProps}
disabled={isSendBusy || isSendDisabled || isEnvironmentUnavailable}
>
{isSendBusy ? "Sending..." : "Implement"}
</button>
<Menu>
<MenuTrigger
render={
<button
type="button"
className={cn(
messageActionPillClassName,
"h-9 rounded-l-none border-l border-message-action-foreground/20 px-2 sm:h-8",
)}
aria-label="Implementation actions"
onMouseDown={
preserveComposerFocusOnPointerDown ? (event) => event.preventDefault() : undefined
}
disabled={isSendBusy || isSendDisabled || isEnvironmentUnavailable}
/>
}
<>
{children}
<div data-chat-composer-implement-actions="true" className="flex items-center justify-end">
<button
type="submit"
className={cn(messageActionPillClassName, "h-9 rounded-r-none px-4 sm:h-8")}
{...pointerFocusProps}
disabled={isSendBusy || isSendDisabled || isEnvironmentUnavailable}
>
<ChevronDownIcon className="size-3.5" />
</MenuTrigger>
<MenuPopup align="end" side="top" {...composerFloatingLayerProps}>
<MenuItem
disabled={isSendBusy || isSendDisabled || isEnvironmentUnavailable}
onClick={() => {
if (canOperateThread) onImplementPlanInNewThread();
}}
{isSendBusy ? "Sending..." : "Implement"}
</button>
<Menu>
<MenuTrigger
render={
<button
type="button"
className={cn(
messageActionPillClassName,
"h-9 rounded-l-none border-l border-message-action-foreground/20 px-2 sm:h-8",
)}
aria-label="Implementation actions"
onMouseDown={
preserveComposerFocusOnPointerDown
? (event) => event.preventDefault()
: undefined
}
disabled={isSendBusy || isSendDisabled || isEnvironmentUnavailable}
/>
}
>
Implement in a new thread
</MenuItem>
</MenuPopup>
</Menu>
</div>
<ChevronDownIcon className="size-3.5" />
</MenuTrigger>
<MenuPopup align="end" side="top" {...composerFloatingLayerProps}>
<MenuItem
disabled={isSendBusy || isSendDisabled || isEnvironmentUnavailable}
onClick={() => {
if (canOperateThread) onImplementPlanInNewThread();
}}
>
Implement in a new thread
</MenuItem>
</MenuPopup>
</Menu>
</div>
</>
);
}

if (canInterrupt && !hasSendableContent && !isEditingQueuedMessage) {
return renderStopGenerationButton(false);
return (
<>
{children}
{renderStopGenerationButton(false)}
</>
);
}

const showResume = canResume && !hasSendableContent && !isEditingQueuedMessage;
Expand Down Expand Up @@ -359,7 +376,14 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
<TooltipPopup>{submitTooltip}</TooltipPopup>
</Tooltip>
);
if (compactTokens === null) return submit;
if (compactTokens === null) {
return (
<>
{children}
{submit}
</>
);
}

return (
<div data-chat-composer-compact-send="true" className="flex items-center gap-2">
Expand Down Expand Up @@ -392,6 +416,7 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
<div>{keepFullHistory ? "Click to compact first" : "Click to keep full history"}</div>
</TooltipPopup>
</Tooltip>
{children}
{submit}
</div>
);
Expand Down
Loading