next.tsx

Overview

next.tsx defines a React functional component named NextMessageInput designed for message input in chat or conversation interfaces within a web application. It integrates rich file upload capabilities alongside text input, enabling users to compose messages with attachments. The component handles file drag-and-drop, file selection via a button trigger, file preview and removal, message submission (including handling keyboard shortcuts), and upload progress indication.

Key features include:

This component relies on several UI and utility components from the codebase, such as FileUpload and its subcomponents, buttons, textareas, and icons.


Detailed API Documentation

Component: NextMessageInput

A React functional component that renders a message input area with file upload support.

Props (IProps)

Prop

Type

Required

Description

disabled

boolean

Yes

Disables the entire input area and file uploads.

value

string

Yes

The current text message value displayed in the textarea.

sendDisabled

boolean

Yes

Disables the send button.

sendLoading

boolean

Yes

Shows a loading state on the send button (e.g., while sending).

conversationId

string

Yes

The current conversation identifier (not used directly in this component).

uploadMethod

string

No

Optional upload method identifier (not used directly here).

isShared

boolean

No

Indicates if the conversation is shared (not used directly here).

showUploadIcon

boolean

No

Toggles visibility of the upload (attach file) icon button; defaults to true.

isUploading

boolean

No

Indicates if files are currently uploading; disables input and buttons accordingly; defaults to false.

onPressEnter

(...params: any[]) => void

Yes

Callback triggered when the user submits the message (via enter or form submit).

onInputChange

React.ChangeEventHandler

Yes

Handler for textarea input change events.

createConversationBeforeUploadDocument

(message: string) => Promise

No

Optional async function to create a conversation before uploading documents (not used internally here).

stopOutputMessage

() => void

No

Optional function to stop ongoing message output/streaming.

onUpload

NonNullable

No

Handler called when files are uploaded via the FileUpload component.

removeFile

(file: File) => void

No

Callback to remove a selected file from the upload queue.


Description and Usage

The component manages an internal state files (array of File objects) representing currently selected files to upload.

Core Behaviors:


Internal Methods

onFileReject(file: File, message: string): void

submit(): void

handleKeyDown(e: React.KeyboardEvent<HTMLTextAreaElement>): void

onSubmit(event: React.FormEvent<HTMLFormElement>): void

handleRemoveFile(file: File): () => void


JSX Structure and Interaction


Usage Example

<NextMessageInput
  disabled={false}
  value={message}
  sendDisabled={false}
  sendLoading={isSending}
  conversationId="12345"
  onPressEnter={() => sendMessage(message)}
  onInputChange={(e) => setMessage(e.target.value)}
  isUploading={uploadingFiles}
  onUpload={handleFileUpload}
  removeFile={handleFileRemove}
  stopOutputMessage={cancelMessageStreaming}
  showUploadIcon={true}
/>

Implementation Details


Interaction with Other Parts of the System


Mermaid Component Diagram

componentDiagram
    component NextMessageInput {
        +files: File[]
        +onFileReject(file, message): void
        +submit(): void
        +handleKeyDown(e): void
        +onSubmit(event): void
        +handleRemoveFile(file): () => void
    }
    component FileUpload {
        +value
        +onValueChange
        +onUpload
        +onFileReject
    }
    component FileUploadDropzone
    component FileUploadList
    component FileUploadItem
    component FileUploadItemPreview
    component FileUploadItemProgress
    component FileUploadItemMetadata
    component FileUploadItemDelete
    component FileUploadTrigger
    component Textarea
    component Button
    NextMessageInput --> FileUpload
    FileUpload --> FileUploadDropzone
    FileUpload --> FileUploadList
    FileUploadList --> FileUploadItem
    FileUploadItem --> FileUploadItemPreview
    FileUploadItemPreview --> FileUploadItemProgress
    FileUploadItem --> FileUploadItemMetadata
    FileUploadItem --> FileUploadItemDelete
    FileUpload --> FileUploadTrigger
    NextMessageInput --> Textarea
    NextMessageInput --> Button

Summary

The NextMessageInput component is a sophisticated UI control for chat-like applications that require combined text and file message input. It cleanly encapsulates file handling, user interaction, and message submission logic, while delegating actual upload and message sending to parent handlers. The component is highly reusable and integrates seamlessly with a design system and localization framework.