@@ -21,9 +21,9 @@ import {
2121import { convertToMentionPath } from "@/utils/path-mentions"
2222import { SelectDropdown , DropdownOptionType , Button , StandardTooltip } from "@/components/ui"
2323
24- import Thumbnails from "../common/Thumbnails"
2524import ModeSelector from "./ModeSelector"
2625import { MAX_IMAGES_PER_MESSAGE } from "./ChatView"
26+ import MediaThumbnails from "../common/MediaThumbnails"
2727import ContextMenu from "./ContextMenu"
2828import { VolumeX , Pin , Check , Image , WandSparkles , SendHorizontal } from "lucide-react"
2929import { IndexingStatusBadge } from "./IndexingStatusBadge"
@@ -37,15 +37,16 @@ interface ChatTextAreaProps {
3737 sendingDisabled : boolean
3838 selectApiConfigDisabled : boolean
3939 placeholderText : string
40- selectedImages : string [ ]
41- setSelectedImages : React . Dispatch < React . SetStateAction < string [ ] > >
40+ selectedMedia : string [ ]
41+ setSelectedMedia : React . Dispatch < React . SetStateAction < string [ ] > >
4242 onSend : ( ) => void
4343 onSelectImages : ( ) => void
4444 shouldDisableImages : boolean
4545 onHeightChange ?: ( height : number ) => void
4646 mode : Mode
4747 setMode : ( value : Mode ) => void
4848 modeShortcutText : string
49+ acceptedFileTypes : string [ ]
4950 // Edit mode props
5051 isEditMode ?: boolean
5152 onCancel ?: ( ) => void
@@ -59,8 +60,8 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
5960 sendingDisabled,
6061 selectApiConfigDisabled,
6162 placeholderText,
62- selectedImages ,
63- setSelectedImages ,
63+ selectedMedia ,
64+ setSelectedMedia ,
6465 onSend,
6566 onSelectImages,
6667 shouldDisableImages,
@@ -70,6 +71,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
7071 modeShortcutText,
7172 isEditMode = false ,
7273 onCancel,
74+ acceptedFileTypes,
7375 } ,
7476 ref ,
7577 ) => {
@@ -598,17 +600,15 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
598600 return
599601 }
600602
601- const acceptedTypes = [ "png" , "jpeg" , "webp" ]
602-
603- const imageItems = Array . from ( items ) . filter ( ( item ) => {
603+ const mediaItems = Array . from ( items ) . filter ( ( item ) => {
604604 const [ type , subtype ] = item . type . split ( "/" )
605- return type === "image" && acceptedTypes . includes ( subtype )
605+ return ( type === "image" || type === "video" ) && acceptedFileTypes . includes ( subtype )
606606 } )
607607
608- if ( ! shouldDisableImages && imageItems . length > 0 ) {
608+ if ( ! shouldDisableImages && mediaItems . length > 0 ) {
609609 e . preventDefault ( )
610610
611- const imagePromises = imageItems . map ( ( item ) => {
611+ const mediaPromises = mediaItems . map ( ( item ) => {
612612 return new Promise < string | null > ( ( resolve ) => {
613613 const blob = item . getAsFile ( )
614614
@@ -633,17 +633,17 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
633633 } )
634634 } )
635635
636- const imageDataArray = await Promise . all ( imagePromises )
637- const dataUrls = imageDataArray . filter ( ( dataUrl ) : dataUrl is string => dataUrl !== null )
636+ const mediaDataArray = await Promise . all ( mediaPromises )
637+ const dataUrls = mediaDataArray . filter ( ( dataUrl ) : dataUrl is string => dataUrl !== null )
638638
639639 if ( dataUrls . length > 0 ) {
640- setSelectedImages ( ( prevImages ) => [ ...prevImages , ...dataUrls ] . slice ( 0 , MAX_IMAGES_PER_MESSAGE ) )
640+ setSelectedMedia ( ( prevItems ) => [ ...prevItems , ...dataUrls ] . slice ( 0 , MAX_IMAGES_PER_MESSAGE ) )
641641 } else {
642642 console . warn ( t ( "chat:noValidImages" ) )
643643 }
644644 }
645645 } ,
646- [ shouldDisableImages , setSelectedImages , cursorPosition , setInputValue , inputValue , t ] ,
646+ [ shouldDisableImages , setSelectedMedia , cursorPosition , setInputValue , inputValue , t , acceptedFileTypes ] ,
647647 )
648648
649649 const handleMenuMouseDown = useCallback ( ( ) => {
@@ -732,15 +732,13 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
732732 const files = Array . from ( e . dataTransfer . files )
733733
734734 if ( files . length > 0 ) {
735- const acceptedTypes = [ "png" , "jpeg" , "webp" ]
736-
737- const imageFiles = files . filter ( ( file ) => {
735+ const mediaFiles = files . filter ( ( file ) => {
738736 const [ type , subtype ] = file . type . split ( "/" )
739- return type === "image" && acceptedTypes . includes ( subtype )
737+ return ( type === "image" || type === "video" ) && acceptedFileTypes . includes ( subtype )
740738 } )
741739
742- if ( ! shouldDisableImages && imageFiles . length > 0 ) {
743- const imagePromises = imageFiles . map ( ( file ) => {
740+ if ( ! shouldDisableImages && mediaFiles . length > 0 ) {
741+ const mediaPromises = mediaFiles . map ( ( file ) => {
744742 return new Promise < string | null > ( ( resolve ) => {
745743 const reader = new FileReader ( )
746744
@@ -758,12 +756,12 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
758756 } )
759757 } )
760758
761- const imageDataArray = await Promise . all ( imagePromises )
762- const dataUrls = imageDataArray . filter ( ( dataUrl ) : dataUrl is string => dataUrl !== null )
759+ const mediaDataArray = await Promise . all ( mediaPromises )
760+ const dataUrls = mediaDataArray . filter ( ( dataUrl ) : dataUrl is string => dataUrl !== null )
763761
764762 if ( dataUrls . length > 0 ) {
765- setSelectedImages ( ( prevImages ) =>
766- [ ...prevImages , ...dataUrls ] . slice ( 0 , MAX_IMAGES_PER_MESSAGE ) ,
763+ setSelectedMedia ( ( prevItems ) =>
764+ [ ...prevItems , ...dataUrls ] . slice ( 0 , MAX_IMAGES_PER_MESSAGE ) ,
767765 )
768766
769767 if ( typeof vscode !== "undefined" ) {
@@ -783,8 +781,9 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
783781 setCursorPosition ,
784782 setIntendedCursorPosition ,
785783 shouldDisableImages ,
786- setSelectedImages ,
784+ setSelectedMedia ,
787785 t ,
786+ acceptedFileTypes ,
788787 ] ,
789788 )
790789
@@ -1268,10 +1267,10 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
12681267 ) }
12691268 </ div >
12701269
1271- { selectedImages . length > 0 && (
1272- < Thumbnails
1273- images = { selectedImages }
1274- setImages = { setSelectedImages }
1270+ { selectedMedia . length > 0 && (
1271+ < MediaThumbnails
1272+ mediaItems = { selectedMedia }
1273+ setMediaItems = { setSelectedMedia }
12751274 style = { {
12761275 left : "16px" ,
12771276 zIndex : 2 ,
0 commit comments