The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { T, useGT, useMessages } from "gt-react-native"; |
| 2 | import { TextInput, View } from "react-native"; |
| 3 | |
| 4 | import { AppText as Text } from "../../../components/ui/AppText"; |
| 5 | import type { ComposerEditorSelection } from "../../../components/ComposerEditor"; |
| 6 | import { |
| 7 | ComposerDictationCancelAction, |
| 8 | ComposerDictationError, |
| 9 | ComposerDictationPrimaryAction, |
| 10 | ComposerDictationStartAction, |
| 11 | ComposerDictationStatus, |
| 12 | ComposerDictationToolbar, |
| 13 | } from "../../voice-input/ComposerDictationControl"; |
| 14 | import type { useVoiceInputController } from "../../voice-input/useVoiceInputController"; |
| 15 | import { resolveVoiceComposerPresentation } from "../../voice-input/voiceInputPresentation"; |
| 16 | |
| 17 | export function ScheduledTaskPromptField(props: { |
| 18 | readonly value: string; |
| 19 | readonly onChange: (value: string) => void; |
| 20 | readonly selection: ComposerEditorSelection; |
| 21 | readonly onChangeSelection: (selection: ComposerEditorSelection) => void; |
| 22 | readonly disabled: boolean; |
| 23 | readonly voiceInput: ReturnType<typeof useVoiceInputController>; |
| 24 | }) { |
| 25 | const gt = useGT(); |
| 26 | const m = useMessages(); |
| 27 | const voice = props.voiceInput; |
| 28 | const presentation = resolveVoiceComposerPresentation(voice.state, voice.elapsedSeconds, m); |
| 29 | const showsDictation = presentation.statusKind === "active"; |
| 30 | const showsIdleTrigger = voice.isAvailable && !showsDictation; |
| 31 | |
| 32 | return ( |
| 33 | <View className="gap-2 border-t border-border-subtle px-4 py-3"> |
| 34 | <Text className="text-sm text-foreground-muted"> |
| 35 | <T>Prompt</T> |
| 36 | </Text> |
| 37 | <View className="flex-row items-end"> |
| 38 | <TextInput |
| 39 | accessibilityLabel={gt("Prompt")} |
| 40 | value={props.value} |
| 41 | onChangeText={props.onChange} |
| 42 | selection={props.selection} |
| 43 | onSelectionChange={({ nativeEvent }) => props.onChangeSelection(nativeEvent.selection)} |
| 44 | readOnly={props.disabled || voice.freezesEditor} |
| 45 | multiline |
| 46 | scrollEnabled |
| 47 | textAlignVertical="top" |
| 48 | placeholder={gt("What should the agent do each time?")} |
| 49 | placeholderTextColorClassName="accent-foreground-muted" |
| 50 | className="max-h-40 min-h-24 min-w-0 flex-1 font-sans text-base text-foreground" |
| 51 | /> |
| 52 | {showsIdleTrigger ? ( |
| 53 | <ComposerDictationStartAction |
| 54 | state={voice.state} |
| 55 | isAvailable={voice.isAvailable} |
| 56 | disabled={props.disabled} |
| 57 | onStart={voice.start} |
| 58 | onCancel={voice.cancel} |
| 59 | /> |
| 60 | ) : null} |
| 61 | </View> |
| 62 | <ComposerDictationError |
| 63 | error={voice.state.phase === "error" ? voice.state.error : null} |
| 64 | onDismiss={voice.cancel} |
| 65 | /> |
| 66 | {showsDictation ? ( |
| 67 | <ComposerDictationToolbar showsDictation> |
| 68 | <View className="h-11 flex-row items-center"> |
| 69 | <ComposerDictationCancelAction presentation={presentation} onCancel={voice.cancel} /> |
| 70 | <ComposerDictationStatus |
| 71 | audioLevels={voice.audioLevels} |
| 72 | elapsedSeconds={voice.elapsedSeconds} |
| 73 | phase={voice.state.phase} |
| 74 | presentation={presentation} |
| 75 | /> |
| 76 | <ComposerDictationPrimaryAction |
| 77 | state={voice.state} |
| 78 | presentation={presentation} |
| 79 | isAvailable={voice.isAvailable} |
| 80 | disabled={props.disabled} |
| 81 | onStart={voice.start} |
| 82 | onConfirm={voice.stop} |
| 83 | onCancel={voice.cancel} |
| 84 | /> |
| 85 | </View> |
| 86 | </ComposerDictationToolbar> |
| 87 | ) : null} |
| 88 | </View> |
| 89 | ); |
| 90 | } |