Skip to content

Commit 1566115

Browse files
committed
more
1 parent 6dbd3e6 commit 1566115

File tree

2 files changed

+6
-33
lines changed

2 files changed

+6
-33
lines changed

web/src/app/chat/ChatPage.tsx

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,10 +1956,7 @@ export function ChatPage({
19561956
}
19571957
};
19581958

1959-
const handleImageUpload = async (
1960-
acceptedFiles: File[],
1961-
intent: UploadIntent
1962-
) => {
1959+
const handleFileUpload = async (acceptedFiles: File[]) => {
19631960
const [_, llmModel] = getFinalLLM(
19641961
llmProviders,
19651962
liveAssistant ?? null,
@@ -1982,8 +1979,6 @@ export function ChatPage({
19821979

19831980
updateChatState("uploading", currentSessionId());
19841981

1985-
const newlyUploadedFileDescriptors: FileDescriptor[] = [];
1986-
19871982
for (let file of acceptedFiles) {
19881983
const formData = new FormData();
19891984
formData.append("files", file);
@@ -1992,24 +1987,7 @@ export function ChatPage({
19921987
if (response.length > 0 && response[0] !== undefined) {
19931988
const uploadedFile = response[0];
19941989

1995-
if (intent == UploadIntent.ADD_TO_DOCUMENTS) {
1996-
addSelectedFile(uploadedFile);
1997-
} else {
1998-
const newFileDescriptor: FileDescriptor = {
1999-
// Use file_id (storage ID) if available, otherwise fallback to DB id
2000-
// Ensure it's a string as FileDescriptor expects
2001-
id: uploadedFile.file_id
2002-
? String(uploadedFile.file_id)
2003-
: String(uploadedFile.id),
2004-
type: uploadedFile.chat_file_type
2005-
? uploadedFile.chat_file_type
2006-
: ChatFileType.PLAIN_TEXT,
2007-
name: uploadedFile.name,
2008-
isUploading: false, // Mark as successfully uploaded
2009-
};
2010-
2011-
setCurrentMessageFiles((prev) => [...prev, newFileDescriptor]);
2012-
}
1990+
addSelectedFile(uploadedFile);
20131991
} else {
20141992
setPopup({
20151993
type: "error",
@@ -2615,12 +2593,7 @@ export function ChatPage({
26152593
{documentSidebarInitialWidth !== undefined && isReady ? (
26162594
<Dropzone
26172595
key={currentSessionId()}
2618-
onDrop={(acceptedFiles) =>
2619-
handleImageUpload(
2620-
acceptedFiles,
2621-
UploadIntent.ATTACH_TO_MESSAGE
2622-
)
2623-
}
2596+
onDrop={(acceptedFiles) => handleFileUpload(acceptedFiles)}
26242597
noClick
26252598
>
26262599
{({ getRootProps }) => (
@@ -3354,7 +3327,7 @@ export function ChatPage({
33543327
}
33553328
setAlternativeAssistant={setAlternativeAssistant}
33563329
setFiles={setCurrentMessageFiles}
3357-
handleFileUpload={handleImageUpload}
3330+
handleFileUpload={handleFileUpload}
33583331
textAreaRef={textAreaRef}
33593332
/>
33603333
{enterpriseSettings &&

web/src/app/chat/input/ChatInputBar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ interface ChatInputBarProps {
188188
setAlternativeAssistant: (alternativeAssistant: Persona | null) => void;
189189
toggleDocumentSidebar: () => void;
190190
setFiles: (files: FileDescriptor[]) => void;
191-
handleFileUpload: (files: File[], intent: UploadIntent) => void;
191+
handleFileUpload: (files: File[]) => void;
192192
textAreaRef: React.RefObject<HTMLTextAreaElement>;
193193
filterManager: FilterManager;
194194
availableSources: SourceMetadata[];
@@ -270,7 +270,7 @@ export function ChatInputBar({
270270
}
271271
if (pastedFiles.length > 0) {
272272
event.preventDefault();
273-
handleFileUpload(pastedFiles, UploadIntent.ATTACH_TO_MESSAGE);
273+
handleFileUpload(pastedFiles);
274274
}
275275
}
276276
};

0 commit comments

Comments
 (0)