|
|
|
@@ -71,6 +71,7 @@ import { ComposerPendingUserInputPanel } from "./ComposerPendingUserInputPanel";
|
|
|
|
|
import { ComposerPlanFollowUpBanner } from "./ComposerPlanFollowUpBanner";
|
|
|
|
|
import { resolveComposerMenuActiveItemId } from "./composerMenuHighlight";
|
|
|
|
|
import { searchSlashCommandItems } from "./composerSlashCommandSearch";
|
|
|
|
|
import { expandMobileComposerForKeyboard } from "./mobileComposerFocus";
|
|
|
|
|
import {
|
|
|
|
|
getComposerProviderState,
|
|
|
|
|
renderProviderTraitsMenuContent,
|
|
|
|
@@ -139,13 +140,6 @@ const runtimeModeConfig: Record<
|
|
|
|
|
const runtimeModeOptions = Object.keys(runtimeModeConfig) as RuntimeMode[];
|
|
|
|
|
const COMPOSER_PATH_QUERY_DEBOUNCE_MS = 120;
|
|
|
|
|
const EMPTY_PROJECT_ENTRIES: ProjectEntry[] = [];
|
|
|
|
|
const COMPOSER_FLOATING_LAYER_SELECTOR = [
|
|
|
|
|
'[data-slot="popover-popup"]',
|
|
|
|
|
'[data-slot="menu-popup"]',
|
|
|
|
|
'[data-slot="select-popup"]',
|
|
|
|
|
'[data-slot="combobox-popup"]',
|
|
|
|
|
'[data-slot="autocomplete-popup"]',
|
|
|
|
|
].join(",");
|
|
|
|
|
|
|
|
|
|
const extendReplacementRangeForTrailingSpace = (
|
|
|
|
|
text: string,
|
|
|
|
@@ -175,10 +169,6 @@ const terminalContextIdListsEqual = (
|
|
|
|
|
): boolean =>
|
|
|
|
|
contexts.length === ids.length && contexts.every((context, index) => context.id === ids[index]);
|
|
|
|
|
|
|
|
|
|
function isInsideComposerFloatingLayer(element: Element): boolean {
|
|
|
|
|
return element.closest(COMPOSER_FLOATING_LAYER_SELECTOR) !== null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ComposerFooterModeControls = memo(function ComposerFooterModeControls(props: {
|
|
|
|
|
showInteractionModeToggle: boolean;
|
|
|
|
|
interactionMode: ProviderInteractionMode;
|
|
|
|
@@ -795,9 +785,15 @@ export const ChatComposer = memo(
|
|
|
|
|
const [isComposerFooterCompact, setIsComposerFooterCompact] = useState(false);
|
|
|
|
|
const [isComposerPrimaryActionsCompact, setIsComposerPrimaryActionsCompact] = useState(false);
|
|
|
|
|
const [isComposerModelPickerOpen, setIsComposerModelPickerOpen] = useState(false);
|
|
|
|
|
const [isComposerFocused, setIsComposerFocused] = useState(false);
|
|
|
|
|
const [isComposerCompactMenuOpen, setIsComposerCompactMenuOpen] = useState(false);
|
|
|
|
|
const isMobileViewport = useMediaQuery("max-sm");
|
|
|
|
|
const isComposerCollapsedMobile = isMobileViewport && !isComposerFocused;
|
|
|
|
|
const isMobileFloatingLayerOpen = isComposerModelPickerOpen || isComposerCompactMenuOpen;
|
|
|
|
|
const mobileCollapsedOnlyClassName =
|
|
|
|
|
"sm:hidden max-sm:group-focus-within/composer:hidden max-sm:group-data-[mobile-focus-primed=true]/composer:hidden max-sm:group-data-[mobile-floating-open=true]/composer:hidden";
|
|
|
|
|
const mobileExpandedOnlyClassName =
|
|
|
|
|
"max-sm:hidden max-sm:group-focus-within/composer:block max-sm:group-data-[mobile-focus-primed=true]/composer:block max-sm:group-data-[mobile-floating-open=true]/composer:block";
|
|
|
|
|
const mobileExpandedFlexOnlyClassName =
|
|
|
|
|
"max-sm:hidden max-sm:group-focus-within/composer:flex max-sm:group-data-[mobile-focus-primed=true]/composer:flex max-sm:group-data-[mobile-floating-open=true]/composer:flex";
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
|
// Refs
|
|
|
|
@@ -810,10 +806,7 @@ export const ChatComposer = memo(
|
|
|
|
|
const composerMenuOpenRef = useRef(false);
|
|
|
|
|
const composerMenuItemsRef = useRef<ComposerCommandItem[]>([]);
|
|
|
|
|
const activeComposerMenuItemRef = useRef<ComposerCommandItem | null>(null);
|
|
|
|
|
const composerBlurFrameRef = useRef<number | null>(null);
|
|
|
|
|
const mobileComposerExpandFrameRef = useRef<number | null>(null);
|
|
|
|
|
const mobileComposerExpandReleaseFrameRef = useRef<number | null>(null);
|
|
|
|
|
const mobileComposerExpandInFlightRef = useRef(false);
|
|
|
|
|
const mobileComposerPrimeReleaseFrameRef = useRef<number | null>(null);
|
|
|
|
|
const dragDepthRef = useRef(0);
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
@@ -958,8 +951,7 @@ export const ChatComposer = memo(
|
|
|
|
|
isComposerApprovalState ||
|
|
|
|
|
pendingUserInputs.length > 0 ||
|
|
|
|
|
(showPlanFollowUpPrompt && activeProposedPlan !== null);
|
|
|
|
|
const showCollapsedMobilePromptRow =
|
|
|
|
|
isComposerCollapsedMobile && !isComposerApprovalState && pendingUserInputs.length === 0;
|
|
|
|
|
const showCollapsedMobilePromptRow = !isComposerApprovalState && pendingUserInputs.length === 0;
|
|
|
|
|
|
|
|
|
|
const composerFooterHasWideActions = showPlanFollowUpPrompt || activePendingProgress !== null;
|
|
|
|
|
const showPlanSidebarToggle = Boolean(activePlan || sidebarProposedPlan || planSidebarOpen);
|
|
|
|
@@ -1055,8 +1047,7 @@ export const ChatComposer = memo(
|
|
|
|
|
const collapsedComposerPrimaryActionDisabled =
|
|
|
|
|
phase === "running" || isSendBusy || isConnecting || !composerSendState.hasSendableContent;
|
|
|
|
|
const collapsedComposerPrimaryActionLabel = "Send message";
|
|
|
|
|
const showMobilePendingAnswerActions =
|
|
|
|
|
isMobileViewport && !isComposerCollapsedMobile && pendingPrimaryAction !== null;
|
|
|
|
|
const showMobilePendingAnswerActions = isMobileViewport && pendingPrimaryAction !== null;
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
|
// Prompt helpers
|
|
|
|
@@ -1588,15 +1579,15 @@ export const ChatComposer = memo(
|
|
|
|
|
|
|
|
|
|
const blurMobileComposerAfterSend = useCallback(() => {
|
|
|
|
|
if (!isMobileViewport) return;
|
|
|
|
|
if (composerBlurFrameRef.current !== null) {
|
|
|
|
|
window.cancelAnimationFrame(composerBlurFrameRef.current);
|
|
|
|
|
composerBlurFrameRef.current = null;
|
|
|
|
|
if (mobileComposerPrimeReleaseFrameRef.current !== null) {
|
|
|
|
|
window.cancelAnimationFrame(mobileComposerPrimeReleaseFrameRef.current);
|
|
|
|
|
mobileComposerPrimeReleaseFrameRef.current = null;
|
|
|
|
|
}
|
|
|
|
|
composerSurfaceRef.current?.setAttribute("data-mobile-focus-primed", "false");
|
|
|
|
|
const activeElement = document.activeElement;
|
|
|
|
|
if (activeElement instanceof HTMLElement) {
|
|
|
|
|
activeElement.blur();
|
|
|
|
|
}
|
|
|
|
|
setIsComposerFocused(false);
|
|
|
|
|
}, [isMobileViewport]);
|
|
|
|
|
|
|
|
|
|
const shouldBlurMobileComposerOnSubmit = useCallback(() => {
|
|
|
|
@@ -1627,25 +1618,25 @@ export const ChatComposer = memo(
|
|
|
|
|
[blurMobileComposerAfterSend, onSend, shouldBlurMobileComposerOnSubmit],
|
|
|
|
|
);
|
|
|
|
|
const expandMobileComposer = useCallback(() => {
|
|
|
|
|
if (composerBlurFrameRef.current !== null) {
|
|
|
|
|
window.cancelAnimationFrame(composerBlurFrameRef.current);
|
|
|
|
|
composerBlurFrameRef.current = null;
|
|
|
|
|
}
|
|
|
|
|
if (mobileComposerExpandFrameRef.current !== null) {
|
|
|
|
|
window.cancelAnimationFrame(mobileComposerExpandFrameRef.current);
|
|
|
|
|
}
|
|
|
|
|
if (mobileComposerExpandReleaseFrameRef.current !== null) {
|
|
|
|
|
window.cancelAnimationFrame(mobileComposerExpandReleaseFrameRef.current);
|
|
|
|
|
}
|
|
|
|
|
mobileComposerExpandInFlightRef.current = true;
|
|
|
|
|
setIsComposerFocused(true);
|
|
|
|
|
mobileComposerExpandFrameRef.current = window.requestAnimationFrame(() => {
|
|
|
|
|
mobileComposerExpandFrameRef.current = null;
|
|
|
|
|
composerEditorRef.current?.focusAtEnd();
|
|
|
|
|
mobileComposerExpandReleaseFrameRef.current = window.requestAnimationFrame(() => {
|
|
|
|
|
mobileComposerExpandReleaseFrameRef.current = null;
|
|
|
|
|
mobileComposerExpandInFlightRef.current = false;
|
|
|
|
|
});
|
|
|
|
|
expandMobileComposerForKeyboard({
|
|
|
|
|
cancelPendingRelease: () => {
|
|
|
|
|
if (mobileComposerPrimeReleaseFrameRef.current !== null) {
|
|
|
|
|
window.cancelAnimationFrame(mobileComposerPrimeReleaseFrameRef.current);
|
|
|
|
|
mobileComposerPrimeReleaseFrameRef.current = null;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
primeExpandedState: () => {
|
|
|
|
|
composerSurfaceRef.current?.setAttribute("data-mobile-focus-primed", "true");
|
|
|
|
|
},
|
|
|
|
|
focusEditorAtEnd: () => {
|
|
|
|
|
composerEditorRef.current?.focusAtEnd();
|
|
|
|
|
},
|
|
|
|
|
scheduleRelease: () => {
|
|
|
|
|
mobileComposerPrimeReleaseFrameRef.current = window.requestAnimationFrame(() => {
|
|
|
|
|
mobileComposerPrimeReleaseFrameRef.current = null;
|
|
|
|
|
composerSurfaceRef.current?.setAttribute("data-mobile-focus-primed", "false");
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
@@ -1789,47 +1780,10 @@ export const ChatComposer = memo(
|
|
|
|
|
const handleImplementPlanInNewThreadPrimaryAction = useCallback(() => {
|
|
|
|
|
void onImplementPlanInNewThread();
|
|
|
|
|
}, [onImplementPlanInNewThread]);
|
|
|
|
|
const scheduleComposerCollapseCheck = useCallback(() => {
|
|
|
|
|
if (!isMobileViewport) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (mobileComposerExpandInFlightRef.current) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (composerBlurFrameRef.current !== null) {
|
|
|
|
|
window.cancelAnimationFrame(composerBlurFrameRef.current);
|
|
|
|
|
}
|
|
|
|
|
composerBlurFrameRef.current = window.requestAnimationFrame(() => {
|
|
|
|
|
composerBlurFrameRef.current = null;
|
|
|
|
|
if (mobileComposerExpandInFlightRef.current) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const composerSurface = composerSurfaceRef.current;
|
|
|
|
|
const activeElement = document.activeElement;
|
|
|
|
|
if (activeElement instanceof Element && isInsideComposerFloatingLayer(activeElement)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (
|
|
|
|
|
composerSurface &&
|
|
|
|
|
activeElement instanceof Node &&
|
|
|
|
|
composerSurface.contains(activeElement)
|
|
|
|
|
) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
setIsComposerFocused(false);
|
|
|
|
|
});
|
|
|
|
|
}, [isMobileViewport]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
return () => {
|
|
|
|
|
if (composerBlurFrameRef.current !== null) {
|
|
|
|
|
window.cancelAnimationFrame(composerBlurFrameRef.current);
|
|
|
|
|
}
|
|
|
|
|
if (mobileComposerExpandFrameRef.current !== null) {
|
|
|
|
|
window.cancelAnimationFrame(mobileComposerExpandFrameRef.current);
|
|
|
|
|
}
|
|
|
|
|
if (mobileComposerExpandReleaseFrameRef.current !== null) {
|
|
|
|
|
window.cancelAnimationFrame(mobileComposerExpandReleaseFrameRef.current);
|
|
|
|
|
if (mobileComposerPrimeReleaseFrameRef.current !== null) {
|
|
|
|
|
window.cancelAnimationFrame(mobileComposerPrimeReleaseFrameRef.current);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}, []);
|
|
|
|
@@ -1962,63 +1916,63 @@ export const ChatComposer = memo(
|
|
|
|
|
>
|
|
|
|
|
<div
|
|
|
|
|
ref={composerSurfaceRef}
|
|
|
|
|
data-chat-composer-mobile-collapsed={isComposerCollapsedMobile ? "true" : "false"}
|
|
|
|
|
data-mobile-focus-primed="false"
|
|
|
|
|
data-mobile-floating-open={isMobileFloatingLayerOpen ? "true" : "false"}
|
|
|
|
|
className={cn(
|
|
|
|
|
"rounded-[20px] border bg-card transition-colors duration-200 has-focus-visible:border-ring/45",
|
|
|
|
|
"group/composer rounded-[20px] border bg-card transition-colors duration-200 has-focus-visible:border-ring/45",
|
|
|
|
|
isDragOverComposer ? "border-primary/70 bg-accent/30" : "border-border",
|
|
|
|
|
environmentUnavailable ? "opacity-75" : null,
|
|
|
|
|
composerProviderState.composerSurfaceClassName,
|
|
|
|
|
)}
|
|
|
|
|
onFocusCapture={(event) => {
|
|
|
|
|
const activeElement = event.target;
|
|
|
|
|
if (
|
|
|
|
|
isComposerCollapsedMobile &&
|
|
|
|
|
activeElement instanceof HTMLElement &&
|
|
|
|
|
activeElement.closest('[data-chat-composer-collapsed-controls="true"]')
|
|
|
|
|
) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (composerBlurFrameRef.current !== null) {
|
|
|
|
|
window.cancelAnimationFrame(composerBlurFrameRef.current);
|
|
|
|
|
composerBlurFrameRef.current = null;
|
|
|
|
|
}
|
|
|
|
|
setIsComposerFocused(true);
|
|
|
|
|
}}
|
|
|
|
|
onBlurCapture={() => {
|
|
|
|
|
scheduleComposerCollapseCheck();
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{!isComposerCollapsedMobile &&
|
|
|
|
|
(activePendingApproval ? (
|
|
|
|
|
<div className="rounded-t-[19px] border-b border-border/65 bg-muted/20">
|
|
|
|
|
<ComposerPendingApprovalPanel
|
|
|
|
|
approval={activePendingApproval}
|
|
|
|
|
pendingCount={pendingApprovals.length}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
) : pendingUserInputs.length > 0 ? (
|
|
|
|
|
<div className="rounded-t-[19px] border-b border-border/65 bg-muted/20">
|
|
|
|
|
<ComposerPendingUserInputPanel
|
|
|
|
|
pendingUserInputs={pendingUserInputs}
|
|
|
|
|
respondingRequestIds={respondingRequestIds}
|
|
|
|
|
answers={activePendingDraftAnswers}
|
|
|
|
|
questionIndex={activePendingQuestionIndex}
|
|
|
|
|
onToggleOption={onSelectActivePendingUserInputOption}
|
|
|
|
|
onAdvance={onAdvanceActivePendingUserInput}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
) : showPlanFollowUpPrompt && activeProposedPlan ? (
|
|
|
|
|
<div className="rounded-t-[19px] border-b border-border/65 bg-muted/20">
|
|
|
|
|
<ComposerPlanFollowUpBanner
|
|
|
|
|
key={activeProposedPlan.id}
|
|
|
|
|
planTitle={proposedPlanTitle(activeProposedPlan.planMarkdown) ?? null}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
) : null)}
|
|
|
|
|
|
|
|
|
|
{isComposerCollapsedMobile && activePendingApproval ? (
|
|
|
|
|
{activePendingApproval ? (
|
|
|
|
|
<div
|
|
|
|
|
className="rounded-t-[19px] border-b border-border/65 bg-muted/20"
|
|
|
|
|
className={cn(
|
|
|
|
|
"rounded-t-[19px] border-b border-border/65 bg-muted/20",
|
|
|
|
|
mobileExpandedOnlyClassName,
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
<ComposerPendingApprovalPanel
|
|
|
|
|
approval={activePendingApproval}
|
|
|
|
|
pendingCount={pendingApprovals.length}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
) : pendingUserInputs.length > 0 ? (
|
|
|
|
|
<div
|
|
|
|
|
className={cn(
|
|
|
|
|
"rounded-t-[19px] border-b border-border/65 bg-muted/20",
|
|
|
|
|
mobileExpandedOnlyClassName,
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
<ComposerPendingUserInputPanel
|
|
|
|
|
pendingUserInputs={pendingUserInputs}
|
|
|
|
|
respondingRequestIds={respondingRequestIds}
|
|
|
|
|
answers={activePendingDraftAnswers}
|
|
|
|
|
questionIndex={activePendingQuestionIndex}
|
|
|
|
|
onToggleOption={onSelectActivePendingUserInputOption}
|
|
|
|
|
onAdvance={onAdvanceActivePendingUserInput}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
) : showPlanFollowUpPrompt && activeProposedPlan ? (
|
|
|
|
|
<div
|
|
|
|
|
className={cn(
|
|
|
|
|
"rounded-t-[19px] border-b border-border/65 bg-muted/20",
|
|
|
|
|
mobileExpandedOnlyClassName,
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
<ComposerPlanFollowUpBanner
|
|
|
|
|
key={activeProposedPlan.id}
|
|
|
|
|
planTitle={proposedPlanTitle(activeProposedPlan.planMarkdown) ?? null}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
) : null}
|
|
|
|
|
|
|
|
|
|
{activePendingApproval ? (
|
|
|
|
|
<div
|
|
|
|
|
className={cn(
|
|
|
|
|
"rounded-t-[19px] border-b border-border/65 bg-muted/20",
|
|
|
|
|
mobileCollapsedOnlyClassName,
|
|
|
|
|
)}
|
|
|
|
|
data-chat-composer-collapsed-controls="true"
|
|
|
|
|
>
|
|
|
|
|
<ComposerPendingApprovalPanel
|
|
|
|
@@ -2033,9 +1987,12 @@ export const ChatComposer = memo(
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
) : isComposerCollapsedMobile && pendingUserInputs.length > 0 ? (
|
|
|
|
|
) : pendingUserInputs.length > 0 ? (
|
|
|
|
|
<div
|
|
|
|
|
className="rounded-t-[19px] border-b border-border/65 bg-muted/20"
|
|
|
|
|
className={cn(
|
|
|
|
|
"rounded-t-[19px] border-b border-border/65 bg-muted/20",
|
|
|
|
|
mobileCollapsedOnlyClassName,
|
|
|
|
|
)}
|
|
|
|
|
data-chat-composer-collapsed-controls="true"
|
|
|
|
|
>
|
|
|
|
|
<ComposerPendingUserInputPanel
|
|
|
|
@@ -2063,7 +2020,10 @@ export const ChatComposer = memo(
|
|
|
|
|
: "text-muted-foreground/60",
|
|
|
|
|
!activePendingProgress?.activeQuestion?.multiSelect && "px-3 py-2",
|
|
|
|
|
)}
|
|
|
|
|
onPointerDown={(event) => event.preventDefault()}
|
|
|
|
|
onPointerDown={(event) => {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
expandMobileComposer();
|
|
|
|
|
}}
|
|
|
|
|
onClick={expandMobileComposer}
|
|
|
|
|
aria-label="Write custom answer"
|
|
|
|
|
>
|
|
|
|
@@ -2093,7 +2053,12 @@ export const ChatComposer = memo(
|
|
|
|
|
) : null}
|
|
|
|
|
|
|
|
|
|
{showCollapsedMobilePromptRow ? (
|
|
|
|
|
<div className="flex items-center justify-between gap-2 px-3 py-2">
|
|
|
|
|
<div
|
|
|
|
|
className={cn(
|
|
|
|
|
"flex items-center justify-between gap-2 px-3 py-2",
|
|
|
|
|
mobileCollapsedOnlyClassName,
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
className={cn(
|
|
|
|
@@ -2102,7 +2067,10 @@ export const ChatComposer = memo(
|
|
|
|
|
? "text-foreground"
|
|
|
|
|
: "text-muted-foreground/35",
|
|
|
|
|
)}
|
|
|
|
|
onPointerDown={(event) => event.preventDefault()}
|
|
|
|
|
onPointerDown={(event) => {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
expandMobileComposer();
|
|
|
|
|
}}
|
|
|
|
|
onClick={expandMobileComposer}
|
|
|
|
|
aria-label="Expand composer"
|
|
|
|
|
>
|
|
|
|
@@ -2139,7 +2107,7 @@ export const ChatComposer = memo(
|
|
|
|
|
className={cn(
|
|
|
|
|
"relative px-3 pb-2 sm:px-4",
|
|
|
|
|
hasComposerHeader ? "pt-2.5 sm:pt-3" : "pt-3.5 sm:pt-4",
|
|
|
|
|
isComposerCollapsedMobile && "hidden",
|
|
|
|
|
mobileExpandedOnlyClassName,
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
{composerMenuOpen && !isComposerApprovalState && (
|
|
|
|
@@ -2161,73 +2129,72 @@ export const ChatComposer = memo(
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{!isComposerCollapsedMobile &&
|
|
|
|
|
!isComposerApprovalState &&
|
|
|
|
|
pendingUserInputs.length === 0 &&
|
|
|
|
|
composerImages.length > 0 && (
|
|
|
|
|
<div className="mb-3 flex flex-wrap gap-2">
|
|
|
|
|
{composerImages.map((image) => (
|
|
|
|
|
<div
|
|
|
|
|
key={image.id}
|
|
|
|
|
className="relative h-16 w-16 overflow-hidden rounded-lg border border-border/80 bg-background"
|
|
|
|
|
>
|
|
|
|
|
{image.previewUrl ? (
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
className="h-full w-full cursor-zoom-in"
|
|
|
|
|
aria-label={`Preview ${image.name}`}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
const preview = buildExpandedImagePreview(composerImages, image.id);
|
|
|
|
|
if (!preview) return;
|
|
|
|
|
onExpandImage(preview);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<img
|
|
|
|
|
src={image.previewUrl}
|
|
|
|
|
alt={image.name}
|
|
|
|
|
className="h-full w-full object-cover"
|
|
|
|
|
/>
|
|
|
|
|
</button>
|
|
|
|
|
) : (
|
|
|
|
|
<div className="flex h-full w-full items-center justify-center px-1 text-center text-[10px] text-muted-foreground/70">
|
|
|
|
|
{image.name}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
{nonPersistedComposerImageIdSet.has(image.id) && (
|
|
|
|
|
<Tooltip>
|
|
|
|
|
<TooltipTrigger
|
|
|
|
|
render={
|
|
|
|
|
<span
|
|
|
|
|
role="img"
|
|
|
|
|
aria-label="Draft attachment may not persist"
|
|
|
|
|
className="absolute left-1 top-1 inline-flex items-center justify-center rounded bg-background/85 p-0.5 text-amber-600"
|
|
|
|
|
>
|
|
|
|
|
<CircleAlertIcon className="size-3" />
|
|
|
|
|
</span>
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
<TooltipPopup
|
|
|
|
|
side="top"
|
|
|
|
|
className="max-w-64 whitespace-normal leading-tight"
|
|
|
|
|
>
|
|
|
|
|
Draft attachment could not be saved locally and may be lost on
|
|
|
|
|
navigation.
|
|
|
|
|
</TooltipPopup>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
)}
|
|
|
|
|
<Button
|
|
|
|
|
variant="ghost"
|
|
|
|
|
size="icon-xs"
|
|
|
|
|
className="absolute right-1 top-1 bg-background/80 hover:bg-background/90"
|
|
|
|
|
onClick={() => removeComposerImage(image.id)}
|
|
|
|
|
aria-label={`Remove ${image.name}`}
|
|
|
|
|
{!isComposerApprovalState &&
|
|
|
|
|
pendingUserInputs.length === 0 &&
|
|
|
|
|
composerImages.length > 0 ? (
|
|
|
|
|
<div className="mb-3 flex flex-wrap gap-2">
|
|
|
|
|
{composerImages.map((image) => (
|
|
|
|
|
<div
|
|
|
|
|
key={image.id}
|
|
|
|
|
className="relative h-16 w-16 overflow-hidden rounded-lg border border-border/80 bg-background"
|
|
|
|
|
>
|
|
|
|
|
{image.previewUrl ? (
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
className="h-full w-full cursor-zoom-in"
|
|
|
|
|
aria-label={`Preview ${image.name}`}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
const preview = buildExpandedImagePreview(composerImages, image.id);
|
|
|
|
|
if (!preview) return;
|
|
|
|
|
onExpandImage(preview);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<XIcon />
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
<img
|
|
|
|
|
src={image.previewUrl}
|
|
|
|
|
alt={image.name}
|
|
|
|
|
className="h-full w-full object-cover"
|
|
|
|
|
/>
|
|
|
|
|
</button>
|
|
|
|
|
) : (
|
|
|
|
|
<div className="flex h-full w-full items-center justify-center px-1 text-center text-[10px] text-muted-foreground/70">
|
|
|
|
|
{image.name}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
{nonPersistedComposerImageIdSet.has(image.id) && (
|
|
|
|
|
<Tooltip>
|
|
|
|
|
<TooltipTrigger
|
|
|
|
|
render={
|
|
|
|
|
<span
|
|
|
|
|
role="img"
|
|
|
|
|
aria-label="Draft attachment may not persist"
|
|
|
|
|
className="absolute left-1 top-1 inline-flex items-center justify-center rounded bg-background/85 p-0.5 text-amber-600"
|
|
|
|
|
>
|
|
|
|
|
<CircleAlertIcon className="size-3" />
|
|
|
|
|
</span>
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
<TooltipPopup
|
|
|
|
|
side="top"
|
|
|
|
|
className="max-w-64 whitespace-normal leading-tight"
|
|
|
|
|
>
|
|
|
|
|
Draft attachment could not be saved locally and may be lost on
|
|
|
|
|
navigation.
|
|
|
|
|
</TooltipPopup>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
)}
|
|
|
|
|
<Button
|
|
|
|
|
variant="ghost"
|
|
|
|
|
size="icon-xs"
|
|
|
|
|
className="absolute right-1 top-1 bg-background/80 hover:bg-background/90"
|
|
|
|
|
onClick={() => removeComposerImage(image.id)}
|
|
|
|
|
aria-label={`Remove ${image.name}`}
|
|
|
|
|
>
|
|
|
|
|
<XIcon />
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
) : null}
|
|
|
|
|
|
|
|
|
|
<div className="relative">
|
|
|
|
|
<ComposerPromptEditor
|
|
|
|
@@ -2302,8 +2269,13 @@ export const ChatComposer = memo(
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Bottom toolbar */}
|
|
|
|
|
{isComposerCollapsedMobile ? null : activePendingApproval ? (
|
|
|
|
|
<div className="flex items-center justify-end gap-2 px-2.5 pb-2.5 sm:px-3 sm:pb-3">
|
|
|
|
|
{activePendingApproval ? (
|
|
|
|
|
<div
|
|
|
|
|
className={cn(
|
|
|
|
|
"flex items-center justify-end gap-2 px-2.5 pb-2.5 sm:px-3 sm:pb-3",
|
|
|
|
|
mobileExpandedFlexOnlyClassName,
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
<ComposerPendingApprovalActions
|
|
|
|
|
requestId={activePendingApproval.requestId}
|
|
|
|
|
isResponding={respondingRequestIds.includes(activePendingApproval.requestId)}
|
|
|
|
@@ -2317,7 +2289,9 @@ export const ChatComposer = memo(
|
|
|
|
|
className={cn(
|
|
|
|
|
"flex min-w-0 flex-nowrap items-center justify-between gap-2 overflow-visible px-2.5 pb-2.5 sm:px-3 sm:pb-3",
|
|
|
|
|
isComposerFooterCompact ? "gap-1.5" : "gap-2 sm:gap-0",
|
|
|
|
|
showMobilePendingAnswerActions && "hidden sm:flex",
|
|
|
|
|
showMobilePendingAnswerActions
|
|
|
|
|
? "max-sm:hidden"
|
|
|
|
|
: mobileExpandedFlexOnlyClassName,
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
<div className="-m-1 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto p-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
|
|
|
|
@@ -2353,6 +2327,7 @@ export const ChatComposer = memo(
|
|
|
|
|
runtimeMode={runtimeMode}
|
|
|
|
|
showInteractionModeToggle={composerProviderControls.showInteractionModeToggle}
|
|
|
|
|
traitsMenuContent={providerTraitsMenuContent}
|
|
|
|
|
onOpenChange={setIsComposerCompactMenuOpen}
|
|
|
|
|
onToggleInteractionMode={toggleInteractionMode}
|
|
|
|
|
onTogglePlanSidebar={togglePlanSidebar}
|
|
|
|
|
onRuntimeModeChange={handleRuntimeModeChange}
|
|
|
|
|