Skip to content

Commit ad0c05f

Browse files
author
Julius Marminge
committed
fix(mobile): keep expanded drafts visible during dictation
1 parent c9650a1 commit ad0c05f

6 files changed

Lines changed: 275 additions & 252 deletions

File tree

‎apps/mobile/src/features/threads/NewTaskDraftScreen.tsx‎

Lines changed: 111 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ import { ComposerCommandPopover } from "./ComposerCommandPopover";
4040
import { useComposerCommandMenu } from "./use-composer-command-menu";
4141
import {
4242
ComposerDictationCancelAction,
43-
ComposerDictationDraftContent,
4443
ComposerDictationPrimaryAction,
4544
ComposerDictationStatus,
45+
ComposerDictationToolbar,
4646
} from "../voice-input/ComposerDictationControl";
4747
import { useVoiceInputController } from "../voice-input/useVoiceInputController";
4848
import { resolveVoiceComposerPresentation } from "../voice-input/voiceInputController";
@@ -1129,130 +1129,129 @@ export function NewTaskDraftScreen(props: {
11291129
<View className="pb-1">{workspaceControls}</View>
11301130

11311131
<ComposerSurface
1132-
style={
1133-
voiceInput.isBusy
1134-
? {
1135-
borderRadius: 27,
1136-
overflow: "hidden",
1137-
paddingHorizontal: 14,
1138-
paddingVertical: 2,
1139-
}
1140-
: {
1141-
borderRadius: 26,
1142-
minHeight: 140,
1143-
overflow: "hidden",
1144-
paddingBottom: 6,
1145-
paddingHorizontal: 14,
1146-
paddingTop: 14,
1147-
}
1148-
}
1132+
style={{
1133+
borderRadius: 26,
1134+
minHeight: 140,
1135+
overflow: "hidden",
1136+
paddingBottom: 6,
1137+
paddingHorizontal: 14,
1138+
paddingTop: 14,
1139+
}}
11491140
>
1150-
<ComposerDictationDraftContent collapsed={voiceInput.isBusy}>
1151-
{flow.attachments.length > 0 ? (
1152-
<View className="pb-2.5">
1153-
<ComposerAttachmentStrip
1154-
attachments={flow.attachments}
1155-
imageBorderRadius={16}
1156-
imageSize={72}
1157-
onRemove={isComposerInteractionLocked ? () => undefined : flow.removeAttachment}
1158-
/>
1159-
</View>
1160-
) : null}
1141+
{flow.attachments.length > 0 ? (
1142+
<View className="pb-2.5">
1143+
<ComposerAttachmentStrip
1144+
attachments={flow.attachments}
1145+
imageBorderRadius={16}
1146+
imageSize={72}
1147+
onRemove={
1148+
isComposerInteractionLocked || voiceInput.isBusy
1149+
? () => undefined
1150+
: flow.removeAttachment
1151+
}
1152+
/>
1153+
</View>
1154+
) : null}
11611155

1162-
{promptEditor}
1163-
<View className="h-1" />
1164-
</ComposerDictationDraftContent>
1156+
{promptEditor}
1157+
<View className="h-1" />
11651158

11661159
<Animated.View layout={COMPOSER_LAYOUT_TRANSITION} collapsable={false}>
1167-
<ComposerToolbarRow paddingBottom={0} paddingHorizontal={0} paddingTop={0}>
1168-
<ComposerDictationCancelAction
1169-
presentation={voicePresentation}
1170-
onCancel={voiceInput.cancel}
1171-
/>
1172-
{isVoiceInputPresented ? (
1173-
<ComposerDictationStatus
1174-
audioLevels={voiceInput.audioLevels}
1175-
elapsedSeconds={voiceInput.elapsedSeconds}
1176-
phase={voiceInput.state.phase}
1160+
<ComposerDictationToolbar showsDictation={isVoiceInputPresented}>
1161+
<ComposerToolbarRow paddingBottom={0} paddingHorizontal={0} paddingTop={0}>
1162+
<ComposerDictationCancelAction
11771163
presentation={voicePresentation}
1178-
onDismissError={voiceInput.cancel}
1164+
onCancel={voiceInput.cancel}
11791165
/>
1180-
) : (
1181-
<ComposerToolbarScroller contentPaddingRight={8} fadeSurface="sheet">
1182-
<ComposerToolbarButton
1183-
accessibilityLabel="Add attachment"
1184-
disabled={isComposerInteractionLocked}
1185-
icon="plus"
1186-
onPress={() => {
1187-
if (selectedEnvironmentServerConfig?.environment.capabilities.fileAttachments) {
1188-
Alert.alert("Add attachment", undefined, [
1189-
{ text: "Photos", onPress: () => void handlePickImages() },
1190-
{ text: "Files", onPress: () => void handlePickFiles() },
1191-
{ text: "Cancel", style: "cancel" },
1192-
]);
1193-
return;
1194-
}
1195-
void handlePickImages();
1196-
}}
1197-
showChevron={false}
1198-
/>
1199-
<ComposerInlineControl
1200-
accessibilityLabel="Model and reasoning settings"
1201-
disabled={isComposerInteractionLocked}
1202-
emphasized
1203-
iconNode={
1204-
<ProviderIcon provider={flow.selectedModelOption?.providerDriver} size={16} />
1205-
}
1206-
label={flow.selectedModelOption?.label ?? "Choose model"}
1207-
maxWidth={152}
1208-
onPress={settingsSheetPresentation.open}
1166+
{isVoiceInputPresented ? (
1167+
<ComposerDictationStatus
1168+
audioLevels={voiceInput.audioLevels}
1169+
elapsedSeconds={voiceInput.elapsedSeconds}
1170+
phase={voiceInput.state.phase}
1171+
presentation={voicePresentation}
1172+
onDismissError={voiceInput.cancel}
12091173
/>
1210-
{flow.planModeEnabled ? (
1174+
) : (
1175+
<ComposerToolbarScroller contentPaddingRight={8} fadeSurface="sheet">
1176+
<ComposerToolbarButton
1177+
accessibilityLabel="Add attachment"
1178+
disabled={isComposerInteractionLocked}
1179+
icon="plus"
1180+
onPress={() => {
1181+
if (
1182+
selectedEnvironmentServerConfig?.environment.capabilities.fileAttachments
1183+
) {
1184+
Alert.alert("Add attachment", undefined, [
1185+
{ text: "Photos", onPress: () => void handlePickImages() },
1186+
{ text: "Files", onPress: () => void handlePickFiles() },
1187+
{ text: "Cancel", style: "cancel" },
1188+
]);
1189+
return;
1190+
}
1191+
void handlePickImages();
1192+
}}
1193+
showChevron={false}
1194+
/>
12111195
<ComposerInlineControl
1212-
accessibilityHint={`Switches to ${flow.interactionMode === "plan" ? "Build" : "Plan"} mode`}
1213-
accessibilityLabel={`Interaction mode: ${flow.interactionMode === "plan" ? "Plan" : "Build"}`}
1196+
accessibilityLabel="Model and reasoning settings"
12141197
disabled={isComposerInteractionLocked}
12151198
emphasized
1216-
icon={
1217-
flow.interactionMode === "plan"
1218-
? { ios: "list.bullet.clipboard", android: "auto_awesome" }
1219-
: { ios: "hammer", android: "construction" }
1199+
iconNode={
1200+
<ProviderIcon provider={flow.selectedModelOption?.providerDriver} size={16} />
12201201
}
1221-
label={flow.interactionMode === "plan" ? "Plan" : "Build"}
1222-
onPress={() =>
1223-
flow.setInteractionMode(flow.interactionMode === "plan" ? "default" : "plan")
1224-
}
1225-
showChevron={false}
1202+
label={flow.selectedModelOption?.label ?? "Choose model"}
1203+
maxWidth={152}
1204+
onPress={settingsSheetPresentation.open}
12261205
/>
1227-
) : null}
1228-
</ComposerToolbarScroller>
1229-
)}
1230-
<ComposerDictationPrimaryAction
1231-
state={voiceInput.state}
1232-
presentation={voicePresentation}
1233-
isAvailable={voiceInput.isAvailable}
1234-
disabled={isIncomingShareTransferPending || isImportingShare || flow.submitting}
1235-
onStart={voiceInput.start}
1236-
onConfirm={voiceInput.stop}
1237-
onCancel={voiceInput.cancel}
1238-
/>
1239-
{voicePresentation.showsSend ? (
1240-
<ComposerToolbarButton
1241-
accessibilityLabel={
1242-
flow.submitting
1243-
? "Starting task"
1244-
: environmentConnected
1245-
? "Start task"
1246-
: "Queue task"
1247-
}
1248-
disabled={!canStart}
1249-
icon={environmentConnected ? "arrow.up" : "tray.and.arrow.up"}
1250-
onPress={() => void handleStart()}
1251-
showChevron={false}
1252-
variant="primary"
1206+
{flow.planModeEnabled ? (
1207+
<ComposerInlineControl
1208+
accessibilityHint={`Switches to ${flow.interactionMode === "plan" ? "Build" : "Plan"} mode`}
1209+
accessibilityLabel={`Interaction mode: ${flow.interactionMode === "plan" ? "Plan" : "Build"}`}
1210+
disabled={isComposerInteractionLocked}
1211+
emphasized
1212+
icon={
1213+
flow.interactionMode === "plan"
1214+
? { ios: "list.bullet.clipboard", android: "auto_awesome" }
1215+
: { ios: "hammer", android: "construction" }
1216+
}
1217+
label={flow.interactionMode === "plan" ? "Plan" : "Build"}
1218+
onPress={() =>
1219+
flow.setInteractionMode(
1220+
flow.interactionMode === "plan" ? "default" : "plan",
1221+
)
1222+
}
1223+
showChevron={false}
1224+
/>
1225+
) : null}
1226+
</ComposerToolbarScroller>
1227+
)}
1228+
<ComposerDictationPrimaryAction
1229+
state={voiceInput.state}
1230+
presentation={voicePresentation}
1231+
isAvailable={voiceInput.isAvailable}
1232+
disabled={isIncomingShareTransferPending || isImportingShare || flow.submitting}
1233+
onStart={voiceInput.start}
1234+
onConfirm={voiceInput.stop}
1235+
onCancel={voiceInput.cancel}
12531236
/>
1254-
) : null}
1255-
</ComposerToolbarRow>
1237+
{voicePresentation.showsSend ? (
1238+
<ComposerToolbarButton
1239+
accessibilityLabel={
1240+
flow.submitting
1241+
? "Starting task"
1242+
: environmentConnected
1243+
? "Start task"
1244+
: "Queue task"
1245+
}
1246+
disabled={!canStart}
1247+
icon={environmentConnected ? "arrow.up" : "tray.and.arrow.up"}
1248+
onPress={() => void handleStart()}
1249+
showChevron={false}
1250+
variant="primary"
1251+
/>
1252+
) : null}
1253+
</ComposerToolbarRow>
1254+
</ComposerDictationToolbar>
12561255
</Animated.View>
12571256
</ComposerSurface>
12581257
</View>

0 commit comments

Comments
 (0)