@@ -19,7 +19,6 @@ import {
19
19
useSendChatRequest ,
20
20
useCompressChat ,
21
21
useAutoFocusOnce ,
22
- // useTotalTokenUsage,
23
22
} from "../../hooks" ;
24
23
import { ErrorCallout , Callout } from "../Callout" ;
25
24
import { ComboBox } from "../ComboBox" ;
@@ -30,17 +29,16 @@ import { useCommandCompletionAndPreviewFiles } from "./useCommandCompletionAndPr
30
29
import { useAppSelector , useAppDispatch } from "../../hooks" ;
31
30
import { clearError , getErrorMessage } from "../../features/Errors/errorsSlice" ;
32
31
import { useTourRefs } from "../../features/Tour" ;
33
- import { useCheckboxes } from "./useCheckBoxes" ;
32
+ import { useAttachedFiles , useCheckboxes } from "./useCheckBoxes" ;
34
33
import { useInputValue } from "./useInputValue" ;
35
34
import {
36
35
clearInformation ,
37
36
getInformationMessage ,
38
- // setInformation,
39
37
} from "../../features/Errors/informationSlice" ;
40
38
import { InformationCallout } from "../Callout/Callout" ;
41
39
import { ToolConfirmation } from "./ToolConfirmation" ;
42
40
import { getPauseReasonsWithPauseStatus } from "../../features/ToolConfirmation/confirmationSlice" ;
43
- import { AttachFileButton , FileList } from "../Dropzone" ;
41
+ import { AttachImagesButton , FileList } from "../Dropzone" ;
44
42
import { useAttachedImages } from "../../hooks/useAttachedImages" ;
45
43
import {
46
44
enableSend ,
@@ -51,15 +49,13 @@ import {
51
49
selectLastSentCompression ,
52
50
selectMessages ,
53
51
selectPreventSend ,
54
- // selectThreadMaximumTokens,
55
52
selectThreadToolUse ,
56
53
selectToolUse ,
57
54
} from "../../features/Chat" ;
58
55
import { telemetryApi } from "../../services/refact" ;
59
56
import { push } from "../../features/Pages/pagesSlice" ;
60
57
import { AgentCapabilities } from "./AgentCapabilities" ;
61
58
import { TokensPreview } from "./TokensPreview" ;
62
- // import { useUsageCounter } from "../UsageCounter/useUsageCounter";
63
59
import classNames from "classnames" ;
64
60
import { ArchiveIcon } from "@radix-ui/react-icons" ;
65
61
@@ -97,6 +93,7 @@ export const ChatForm: React.FC<ChatFormProps> = ({
97
93
const lastSentCompression = useAppSelector ( selectLastSentCompression ) ;
98
94
const { compressChat, compressChatRequest } = useCompressChat ( ) ;
99
95
const autoFocus = useAutoFocusOnce ( ) ;
96
+ const attachedFiles = useAttachedFiles ( ) ;
100
97
101
98
const shouldAgentCapabilitiesBeShown = useMemo ( ( ) => {
102
99
return threadToolUse === "agent" ;
@@ -161,7 +158,6 @@ export const ChatForm: React.FC<ChatFormProps> = ({
161
158
checkboxes,
162
159
onToggleCheckbox,
163
160
unCheckAll,
164
- setFileInteracted,
165
161
setLineSelectionInteracted,
166
162
} = useCheckboxes ( ) ;
167
163
@@ -184,21 +180,23 @@ export const ChatForm: React.FC<ChatFormProps> = ({
184
180
const handleSubmit = useCallback ( ( ) => {
185
181
const trimmedValue = value . trim ( ) ;
186
182
if ( ! disableSend && trimmedValue . length > 0 ) {
183
+ const valueWithFiles = attachedFiles . addFilesToInput ( trimmedValue ) ;
187
184
const valueIncludingChecks = addCheckboxValuesToInput (
188
- trimmedValue ,
185
+ valueWithFiles ,
189
186
checkboxes ,
190
187
) ;
191
- setFileInteracted ( false ) ;
188
+ // TODO: add @files
192
189
setLineSelectionInteracted ( false ) ;
193
190
onSubmit ( valueIncludingChecks ) ;
194
191
setValue ( ( ) => "" ) ;
195
192
unCheckAll ( ) ;
193
+ attachedFiles . removeAll ( ) ;
196
194
}
197
195
} , [
198
196
value ,
199
197
disableSend ,
198
+ attachedFiles ,
200
199
checkboxes ,
201
- setFileInteracted ,
202
200
setLineSelectionInteracted ,
203
201
onSubmit ,
204
202
setValue ,
@@ -241,7 +239,6 @@ export const ChatForm: React.FC<ChatFormProps> = ({
241
239
setValue ( command ) ;
242
240
const trimmedCommand = command . trim ( ) ;
243
241
if ( ! trimmedCommand ) {
244
- setFileInteracted ( false ) ;
245
242
setLineSelectionInteracted ( false ) ;
246
243
}
247
244
@@ -251,7 +248,7 @@ export const ChatForm: React.FC<ChatFormProps> = ({
251
248
handleHelpInfo ( null ) ;
252
249
}
253
250
} ,
254
- [ handleHelpInfo , setValue , setFileInteracted , setLineSelectionInteracted ] ,
251
+ [ handleHelpInfo , setValue , setLineSelectionInteracted ] ,
255
252
) ;
256
253
257
254
const handleAgentIntegrationsClick = useCallback ( ( ) => {
@@ -423,7 +420,9 @@ export const ChatForm: React.FC<ChatFormProps> = ({
423
420
/>
424
421
) }
425
422
{ config . features ?. images !== false &&
426
- isMultimodalitySupportedForCurrentModel && < AttachFileButton /> }
423
+ isMultimodalitySupportedForCurrentModel && (
424
+ < AttachImagesButton />
425
+ ) }
427
426
{ /* TODO: Reserved space for microphone button coming later on */ }
428
427
< PaperPlaneButton
429
428
disabled = { disableSend }
@@ -435,12 +434,14 @@ export const ChatForm: React.FC<ChatFormProps> = ({
435
434
</ Flex >
436
435
</ Form >
437
436
</ Flex >
438
- < FileList />
437
+ < FileList attachedFiles = { attachedFiles } />
439
438
440
439
< ChatControls
440
+ // handle adding files
441
441
host = { config . host }
442
442
checkboxes = { checkboxes }
443
443
onCheckedChange = { onToggleCheckbox }
444
+ attachedFiles = { attachedFiles }
444
445
/>
445
446
</ Card >
446
447
) ;
0 commit comments