Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 23 additions & 13 deletions apps/mobile/src/features/threads/ThreadComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
onChangeDraftMessage: (text) => setComposerDraftText(composerDraftKey, text),
onChangeSelection: composerMenu.onSelectionChange,
});
const isSubmissionLocked = queuedEdit?.saving === true || voiceInput.blocksSubmission;
const voicePresentation = resolveVoiceComposerPresentation(
voiceInput.state,
voiceInput.elapsedSeconds,
Expand Down Expand Up @@ -552,7 +553,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
(props.canOperateThread || props.connectionState !== "connected") &&
hasContent &&
!contextImports[composerDraftKey] &&
!voiceInput.blocksSubmission &&
!isSubmissionLocked &&
sendBlockedReason === null &&
!modelUnavailable;

Expand Down Expand Up @@ -602,7 +603,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
setComposerEditing(false);
};
const handleSend = async (followUp?: ActiveTurnComposerAction) => {
if (voiceInput.blocksSubmission || pendingPastedTextAttachmentCountRef.current > 0) return;
if (isSubmissionLocked || pendingPastedTextAttachmentCountRef.current > 0) return;
if (usageLimitsOffered && isUsageLimitsCommand(draftMessage) && draftAttachments.length === 0) {
if (openUsageLimits()) onChangeDraftMessage("");
return;
Expand Down Expand Up @@ -725,7 +726,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
<ComposerQueuedEditAttachments
environmentId={props.environmentId}
attachments={queuedEdit.existingAttachments}
disabled={queuedEdit.saving || voiceInput.isBusy}
disabled={isSubmissionLocked}
onRemove={queuedEdit.onRemoveExistingAttachment}
/>
</Animated.View>
Expand All @@ -739,11 +740,11 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
<ComposerAttachmentStrip
environmentId={props.environmentId}
attachments={stripAttachments}
onRemove={voiceInput.isBusy ? () => undefined : props.onRemoveDraftImage}
onPressPreview={voiceInput.isBusy ? undefined : onPressPreview}
onPressVideo={voiceInput.isBusy ? undefined : onPressVideo}
onRemove={isSubmissionLocked ? () => undefined : props.onRemoveDraftImage}
onPressPreview={isSubmissionLocked ? undefined : onPressPreview}
onPressVideo={isSubmissionLocked ? undefined : onPressVideo}
onPressDocument={
voiceInput.isBusy
isSubmissionLocked
? undefined
: (attachment) =>
openDraftDocument({
Expand Down Expand Up @@ -807,7 +808,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
style={{ maxWidth: props.contentMaxWidth }}
onLayout={(event) => measureRow("surfaceWidth", event.nativeEvent.layout.width)}
>
{!voiceInput.isBusy &&
{!isSubmissionLocked &&
composerMenu.trigger &&
(composerMenu.items.length > 0 || composerMenu.trigger.kind === "pull-request") ? (
<ComposerPopoverAnchor>
Expand Down Expand Up @@ -874,6 +875,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
>
{!usesCard ? (
<ComposerAttachmentButton
disabled={isSubmissionLocked}
supportsFiles={Boolean(
props.serverConfig?.environment.capabilities.fileAttachments,
)}
Expand Down Expand Up @@ -911,13 +913,18 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
multiline
value={draftMessage}
// The save uses a draft snapshot; further typing would be discarded on success.
readOnly={voiceInput.freezesEditor || queuedEdit?.saving === true}
readOnly={isSubmissionLocked}
skills={composerMenu.skills}
selection={composerMenu.selection}
onChangeText={props.onChangeDraftMessage}
onChangeText={(text) => {
if (!isSubmissionLocked) props.onChangeDraftMessage(text);
}}
onSelectionChange={composerMenu.onSelectionChange}
onPasteImages={(uris) => void props.onNativePasteImages(uris)}
onPasteImages={(uris) => {
if (!isSubmissionLocked) void props.onNativePasteImages(uris);
}}
onPasteText={(paste) => {
if (isSubmissionLocked) return;
const insertPaste = () => {
const insertion = replaceTextSelection({
value: paste.value,
Expand Down Expand Up @@ -1045,8 +1052,8 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
size={30}
borderRadius={8}
compact
onPressPreview={onPressPreview}
onPressVideo={onPressVideo}
onPressPreview={isSubmissionLocked ? undefined : onPressPreview}
onPressVideo={isSubmissionLocked ? undefined : onPressVideo}
/>
))}
{stripAttachments.length > 3 ? (
Expand All @@ -1067,6 +1074,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
<ComposerDictationStartAction
state={voiceInput.state}
isAvailable={voiceInput.isAvailable}
disabled={isSubmissionLocked}
onStart={voiceInput.start}
onCancel={voiceInput.cancel}
/>
Expand Down Expand Up @@ -1139,6 +1147,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
) : (
<View className="min-w-0 flex-1 flex-row items-center justify-between">
<ComposerAttachmentButton
disabled={isSubmissionLocked}
supportsFiles={Boolean(
props.serverConfig?.environment.capabilities.fileAttachments,
)}
Expand All @@ -1153,6 +1162,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
state={voiceInput.state}
presentation={voicePresentation}
isAvailable={voiceInput.isAvailable}
disabled={isSubmissionLocked}
onStart={voiceInput.start}
onConfirm={voiceInput.stop}
onCancel={voiceInput.cancel}
Expand Down
Loading