import { createPortal } from "react-dom"; import { Popover, PopoverAnchor, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@tutti-os/ui-system"; import { cn } from "../../../app/renderer/lib/utils"; import styles from "../AgentGUINode.styles"; import { AgentInteractivePromptSurface } from "../AgentInteractivePromptSurface"; import { AgentQueuedPromptPanel } from "../AgentQueuedPromptPanel"; import { AgentProjectDropdown, AgentProjectMissingStatusProbe } from "../AgentComposerSettingsMenus"; import { AgentChromeNotice } from "../AgentSessionChrome"; import { AgentFullAccessRestoredWarning } from "../AgentFullAccessRestoredWarning"; import { AgentRichTextEditor } from "../agentRichText/AgentRichTextEditor"; import { AgentFileMentionPalette } from "../AgentFileMentionPalette"; import { AgentReferenceProvenanceFilterControl } from "../AgentReferenceProvenanceFilterControl"; import type { AgentMentionFilterId } from "../AgentMentionSearchController"; import { AgentSlashCommandPalette } from "../AgentSlashCommandPalette"; import { AgentSlashStatusPanel } from "../AgentSlashStatusPanel"; import { AgentReviewPickerPanel } from "../AgentReviewPickerPanel"; import { ComposerFloatingMenuSurface } from "../composerFloatingMenu/ComposerFloatingMenuSurface"; import type { AgentComposerViewProps } from "./AgentComposerView.types"; import { EMPTY_PROVIDER_SKILLS, EMPTY_WORKSPACE_APP_ICONS, SLASH_PALETTE_HEIGHT_PX, composerStyles } from "./AgentComposerChrome"; import { ComposerDraftAttachments } from "./ComposerDraftAttachments"; import { ComposerFooter } from "./ComposerFooter"; import { AgentSessionLaunchModeSelect } from "./AgentSessionLaunchModeSelect"; import { AgentQuickPromptPopover } from "./quickPrompts/AgentQuickPromptPopover"; import { agentComposerDraftHasContent, agentComposerDraftConnectors, agentComposerDraftImages, agentComposerDraftPrompt, agentComposerDraftQuotes, updateAgentComposerDraft } from "../model/agentComposerDraft"; export function AgentComposerView( input: AgentComposerViewProps ): React.JSX.Element { const { provider, slashStatus = null, usage = null, draftContent, engagement, availableSkills = EMPTY_PROVIDER_SKILLS, composerSettings, workspaceId, queueStatus = "active", queuedPrompts, drainingQueuedPromptId, workspaceAppIcons = EMPTY_WORKSPACE_APP_ICONS, activePromptDisabledReason = null, activePromptKeyboardShortcutsEnabled = true, promptImagesSupported = true, layoutMode = "dock", providerSelectLabel = "", composerActionAccessory, labels, workspaceUserProjectI18n, isSubmittingPrompt, onSendQueuedPromptNext, onRemoveQueuedPrompt, onEditQueuedPrompt, onPromptImagesUnsupported, onRequestWorkspaceReferences, referenceProvenanceFilters, selectProjectDirectory, projectSelectOptions, userProjectApi, onProjectPathChange = () => {}, onSettingsChange, onLinkAction, onSubmit, onProviderSelect, onHandoffConversation, onSlashStatusRefresh, compactSupported = null, hasCompactableContext = true } = input.props; const draftImages = agentComposerDraftImages(draftContent); const draftQuotes = agentComposerDraftQuotes(draftContent); const draftConnectors = agentComposerDraftConnectors(draftContent); const slashStatusAgentSessionId = slashStatus?.agentSessionId ?? null; const draftPrompt = agentComposerDraftPrompt(draftContent); const { availableCapabilities, slashPaletteEntries, slashQuery } = input.paletteCatalog; const { mentionPaletteFrame, mentionPaletteHeightPx, mentionPaletteStyle } = input.mentionFrame; const { closeReviewPicker, closeSlashFloatingMenu, closeSlashStatusPanel, composerControlsHardDisabled, permissionModeControlsDisabled, reviewBranchLoader, selectCapability, selectCapabilitySettings, selectCommand, selectSkill, settingsControlsDisabled, submit, submitCurrentPrompt, submitReviewCommand } = input.slashActions; const { handleFileMentionSuggestionChange, handleFileMentionKeyDown, handlePaletteKeyDown, handleMentionHighlightChange, navigateFileMentionHierarchy, navigateIntoFileMentionItem, selectFileMention } = input.mentionActions; const { clearGoalModeBadge, expandDraftLargeTextToPrompt, handleDraftChange, handleLinkClick, handleOpenReferencesForEntity, handlePastedLargeText, handleWorkspaceReferencePicker, removeDraftImage, removeDraftLargeText, removeDraftQuotes, setDraftConnectorSelected } = input.attachments; const { composerClassName, effectiveHandoffLabel, effectiveHandoffMenuLabel, handoffDisabled, handoffMenuTargets, inputDisabled, inputShellClassName, isHeroLayout, providerMenuTargets, providerSelectDisabled, selectedProviderLabel, selectedProviderSwitchTarget, showHandoffSelect, showProviderSelect } = input.providerState; const { handleMentionPaletteButton, handlePastedImages } = input.focusAndDrop; const { activePromptTip, activePromptTipText, composerStyle, inputShellStyle, promptInputAreaStyle, showEdgeGlow, showHeroProjectSelector, showProjectMissingProbe, showProjectRow } = input.layout; const { composerActionButton, disabledReasonText, effectivePlaceholder, fileDropOverlay, promptTipNode, submitInteractivePromptAndDismiss, visibleActivePrompt, visibleDraftLargeTexts } = input.presentation; const composerActionNode = composerActionAccessory ? (