fix(ai-chat): make the new-chat composer text-only so a sticker or file first move cannot strand the user
This commit is contained in:
parent
1de93f3c88
commit
e66d8cf7bf
2 changed files with 14 additions and 5 deletions
|
|
@ -63,6 +63,7 @@ function NewChatComposer({ preset, room }: { preset: BotPreset; room: Room }) {
|
|||
roomId={room.roomId}
|
||||
fileDropContainerRef={fileDropRef}
|
||||
onSend={handleSend}
|
||||
textOnly
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -205,9 +205,14 @@ interface RoomInputProps {
|
|||
// freshly-rooted thread (the just-sent top-level event IS the thread root).
|
||||
// Channel / DM / thread composers omit it and stay fire-and-forget.
|
||||
onSend?: (eventId: string) => void;
|
||||
// Text-only mode: hides the file/sticker affordances and no-ops file
|
||||
// paste/drop. The AI "new chat" landing uses it because only a text send
|
||||
// navigates into the freshly-rooted thread (onSend) — a sticker/file first
|
||||
// move would otherwise strand the user on the landing.
|
||||
textOnly?: boolean;
|
||||
}
|
||||
export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
({ editor, fileDropContainerRef, roomId, room, threadId, onSend }, ref) => {
|
||||
({ editor, fileDropContainerRef, roomId, room, threadId, onSend, textOnly }, ref) => {
|
||||
const { t } = useTranslation();
|
||||
const mx = useMatrixClient();
|
||||
const useAuthentication = useMediaAuthentication();
|
||||
|
|
@ -276,6 +281,9 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
|||
|
||||
const handleFiles = useCallback(
|
||||
async (files: File[]) => {
|
||||
// Text-only composer (AI new-chat landing) ignores every file vector —
|
||||
// picker, paste and drop all funnel through here.
|
||||
if (textOnly) return;
|
||||
setUploadBoard(true);
|
||||
const safeFiles = files.map(safeFile);
|
||||
const fileItems: TUploadItem[] = [];
|
||||
|
|
@ -309,7 +317,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
|||
item: fileItems,
|
||||
});
|
||||
},
|
||||
[setSelectedFiles, room]
|
||||
[setSelectedFiles, room, textOnly]
|
||||
);
|
||||
const pickFile = useFilePicker(handleFiles, true);
|
||||
const handlePaste = useFilePasteHandler(handleFiles);
|
||||
|
|
@ -764,7 +772,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
|||
</UploadBoard>
|
||||
)}
|
||||
<Overlay
|
||||
open={dropZoneVisible}
|
||||
open={dropZoneVisible && !textOnly}
|
||||
backdrop={<OverlayBackdrop />}
|
||||
style={{ pointerEvents: 'none' }}
|
||||
>
|
||||
|
|
@ -873,9 +881,9 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
|||
gap="200"
|
||||
style={{ padding: `${toRem(2)} ${toRem(8)} ${toRem(4)}` }}
|
||||
>
|
||||
{plusButton}
|
||||
{!textOnly && plusButton}
|
||||
<Box grow="Yes" />
|
||||
{emojiButton}
|
||||
{!textOnly && emojiButton}
|
||||
{sendButton}
|
||||
</Box>
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue