@@ -158,12 +158,7 @@ import {
158158 type ComposerBannerStackContent ,
159159 type ComposerBannerStackItem ,
160160} from "./ComposerBannerStack" ;
161- import {
162- compressImageForStash ,
163- isHeicImageFile ,
164- prepareImageForAttachment ,
165- } from "../../lib/imageCompression" ;
166- import { AttachmentImage } from "../media/AttachmentImage" ;
161+ import { compressImageForStash , prepareImageForAttachment } from "../../lib/imageCompression" ;
167162import {
168163 fileAttachmentTooLargeMessage ,
169164 formatAttachmentSize ,
@@ -201,7 +196,6 @@ import {
201196 toKindScopedComposerContextId ,
202197} from "@t3tools/shared/composerContextReferences" ;
203198import {
204- getRestingComposerImagePreviewCounts ,
205199 resolveRestingComposerControlsLayout ,
206200 shouldAnimateComposerRestingTransition ,
207201 shouldUseCompactComposerPrimaryActions ,
@@ -286,11 +280,12 @@ import {
286280} from "./ComposerCommandMenu" ;
287281import { ComposerPendingApprovalActions } from "./ComposerPendingApprovalActions" ;
288282import { CompactComposerControlsMenu } from "./CompactComposerControlsMenu" ;
289- import { ComposerImageThumbnail } from "./ComposerImageThumbnail" ;
290283import {
291284 ComposerAttachmentFileList ,
292285 ComposerAttachmentMediaRow ,
293286 ComposerFilePreviewDialog ,
287+ ComposerQueuedAttachmentRow ,
288+ ComposerRestingImagePreviews ,
294289} from "./ComposerAttachmentStrip" ;
295290import { ComposerPrimaryActions } from "./ComposerPrimaryActions" ;
296291import { ComposerPendingApprovalPanel } from "./ComposerPendingApprovalPanel" ;
@@ -344,7 +339,6 @@ import {
344339 submitComposerDraft ,
345340} from "./composerSubmission" ;
346341import { ComposerPromptLengthValidation } from "./ComposerPromptLengthValidation" ;
347- import { PierreEntryIcon } from "./PierreEntryIcon" ;
348342import { pendingDraftWork } from "./pendingDraftWork" ;
349343import {
350344 importComposerThreadAttachment ,
@@ -989,7 +983,6 @@ import {
989983 PencilRulerIcon ,
990984 PlayIcon ,
991985 ShieldIcon ,
992- XIcon ,
993986} from "lucide-react" ;
994987import { proposedPlanTitle } from "@t3tools/shared/proposedPlanText" ;
995988import { hasProviderSetup } from "./ProviderStatusBanner" ;
@@ -4830,85 +4823,24 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
48304823 measure ( ) ;
48314824 return observeResize ( restingActionsElement , measure ) ;
48324825 } , [ isComposerResting , restingActionsElement ] ) ;
4833- const restingImagePreviewCounts = getRestingComposerImagePreviewCounts (
4834- standaloneComposerImages . length ,
4835- ) ;
4836- const restingComposerImages = standaloneComposerImages . slice (
4837- 0 ,
4838- restingImagePreviewCounts . visibleCount ,
4839- ) ;
4826+ const showMoreRestingImages = ( ) => {
4827+ if ( isComposerCollapsedMobile ) {
4828+ expandMobileComposer ( ) ;
4829+ return ;
4830+ }
4831+ setIsComposerScrollCollapsed ( false ) ;
4832+ setIsComposerFocused ( true ) ;
4833+ scheduleComposerFocus ( ) ;
4834+ } ;
48404835 const collapsedComposerImagePreviews =
4841- restingComposerImages . length > 0 ? (
4842- < div
4843- data-chat-composer-resting-images = "true"
4844- className = "flex shrink-0 items-center gap-1 ps-1"
4845- >
4846- { restingComposerImages . map ( ( image ) => (
4847- < button
4848- key = { image . id }
4849- type = "button"
4850- className = "relative size-7 shrink-0 cursor-zoom-in overflow-hidden rounded-md border border-border/70 bg-muted/60"
4851- aria-label = { `Preview ${ image . name } ` }
4852- onPointerDown = { ( event ) => event . preventDefault ( ) }
4853- onClick = { ( ) => {
4854- const preview = buildExpandedImagePreview ( composerImages , image . id ) ;
4855- if ( preview ) onExpandImage ( preview ) ;
4856- } }
4857- >
4858- { image . previewUrl ? (
4859- < ComposerImageThumbnail
4860- file = { image . file }
4861- alt = ""
4862- className = "size-full object-cover"
4863- fallback = {
4864- isHeicImageFile ( { name : image . name , type : image . mimeType } ) ? (
4865- < AttachmentImage
4866- name = { image . name }
4867- mimeType = { image . mimeType }
4868- src = { image . previewUrl }
4869- alt = ""
4870- className = "size-full object-cover"
4871- />
4872- ) : (
4873- < PierreEntryIcon
4874- pathValue = { image . name }
4875- kind = "file"
4876- theme = { resolvedTheme }
4877- className = "m-auto size-3.5"
4878- />
4879- )
4880- }
4881- />
4882- ) : (
4883- < PierreEntryIcon
4884- pathValue = { image . name }
4885- kind = "file"
4886- theme = { resolvedTheme }
4887- className = "m-auto size-3.5"
4888- />
4889- ) }
4890- </ button >
4891- ) ) }
4892- { restingImagePreviewCounts . overflowCount > 0 ? (
4893- < button
4894- type = "button"
4895- className = "flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-md border border-border/70 bg-muted/60 font-medium text-secondary-label text-xs tabular-nums outline-none hover:bg-muted focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"
4896- aria-label = { `Show ${ String ( restingImagePreviewCounts . overflowCount ) } more image attachments` }
4897- onPointerDown = { ( event ) => event . preventDefault ( ) }
4898- onClick = { ( ) => {
4899- if ( isComposerCollapsedMobile ) {
4900- expandMobileComposer ( ) ;
4901- return ;
4902- }
4903- setIsComposerScrollCollapsed ( false ) ;
4904- setIsComposerFocused ( true ) ;
4905- scheduleComposerFocus ( ) ;
4906- } }
4907- >
4908- +{ restingImagePreviewCounts . overflowCount }
4909- </ button >
4910- ) : null }
4911- </ div >
4836+ standaloneComposerImages . length > 0 ? (
4837+ < ComposerRestingImagePreviews
4838+ images = { standaloneComposerImages }
4839+ allImages = { composerImages }
4840+ resolvedTheme = { resolvedTheme }
4841+ onExpandImage = { onExpandImage }
4842+ onShowMore = { showMoreRestingImages }
4843+ />
49124844 ) : null ;
49134845 const { active : panelAnimationsActive , durationMs : panelAnimationDurationMs } =
49144846 usePanelAnimationSettings ( ) ;
@@ -6695,35 +6627,10 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
66956627 pendingUserInputs . length === 0 &&
66966628 editingQueuedAttachments !== null &&
66976629 editingQueuedAttachments . length > 0 && (
6698- < div className = "mb-3 flex flex-wrap gap-2" >
6699- { editingQueuedAttachments . map ( ( { attachment, url } ) => (
6700- < div
6701- key = { attachment . id }
6702- className = "relative h-16 w-16 overflow-hidden rounded-lg border border-border/80 bg-background"
6703- >
6704- { attachment . type === "image" && url ? (
6705- < img
6706- src = { url }
6707- alt = { attachment . name }
6708- className = "h-full w-full object-cover"
6709- />
6710- ) : (
6711- < div className = "flex h-full w-full items-center justify-center px-1 text-center text-3xs text-secondary-label" >
6712- { attachment . name }
6713- </ div >
6714- ) }
6715- < Button
6716- variant = "media-close"
6717- size = "icon-xs"
6718- className = "absolute right-1 top-1"
6719- onClick = { ( ) => onRemoveEditingQueuedAttachment ( attachment . id ) }
6720- aria-label = { `Remove ${ attachment . name } ` }
6721- >
6722- < XIcon />
6723- </ Button >
6724- </ div >
6725- ) ) }
6726- </ div >
6630+ < ComposerQueuedAttachmentRow
6631+ attachments = { editingQueuedAttachments }
6632+ onRemove = { onRemoveEditingQueuedAttachment }
6633+ />
67276634 ) }
67286635
67296636 { composerAttachmentMediaRow }
0 commit comments