Repository navigation
fix(mobile): submit terminal messages through terminal.send, add a newline button #6527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f286e03
c6c06df
1dff390
b5b6e0b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import { forwardRef, useImperativeHandle, useRef } from "react"; | ||
| import { forwardRef, useImperativeHandle, useRef, useState } from "react"; | ||
| import { Alert, View } from "react-native"; | ||
| import type { PromptInputMessage } from "@/components/ai-elements/prompt-input"; | ||
| import { | ||
|
|
@@ -14,8 +14,8 @@ import { | |
|
|
||
| interface TerminalComposerProps { | ||
| placeholder?: string; | ||
| /** Submit the current draft to the PTY. */ | ||
| onSubmit: (text: string) => void; | ||
| /** Submit the current draft to the PTY. Rejects if it never got there. */ | ||
| onSubmit: (text: string) => Promise<void>; | ||
| onQuickKey: (key: TerminalQuickKey) => void; | ||
| /** Where attachments land; null while the workspace or host is unresolved. */ | ||
| attachmentTarget: TerminalAttachmentTarget | null; | ||
|
|
@@ -61,33 +61,44 @@ export const TerminalComposer = forwardRef< | |
| })); | ||
| const writeAttachments = useWriteTerminalAttachments(); | ||
|
|
||
| const submit = ({ text, attachments }: PromptInputMessage) => { | ||
| if (attachments.length === 0) { | ||
| onSubmit(text); | ||
| composerRef.current?.clear(); | ||
| return; | ||
| const [isSubmitting, setIsSubmitting] = useState(false); | ||
|
|
||
| const submit = async ({ text, attachments }: PromptInputMessage) => { | ||
| let body = text; | ||
| if (attachments.length > 0) { | ||
| if (!attachmentTarget) { | ||
| Alert.alert("Attachments need an online host"); | ||
| return; | ||
| } | ||
| // A PTY takes bytes, not files: the agent gets the attachments as | ||
| // worktree-relative paths appended to the message. The hook alerts on | ||
| // its own failures. | ||
| const paths = await writeAttachments | ||
| .mutateAsync({ target: attachmentTarget, attachments }) | ||
| .catch(() => null); | ||
| if (!paths) return; | ||
| body = text ? `${text}\n\n${paths.join("\n")}` : paths.join("\n"); | ||
| } | ||
| if (!attachmentTarget) { | ||
| Alert.alert("Attachments need an online host"); | ||
| return; | ||
| setIsSubmitting(true); | ||
| try { | ||
| await onSubmit(body); | ||
| composerRef.current?.clear(); | ||
| } catch (cause) { | ||
| Alert.alert( | ||
| "Could not send", | ||
| cause instanceof Error ? cause.message : String(cause), | ||
| ); | ||
| } finally { | ||
| setIsSubmitting(false); | ||
| } | ||
| writeAttachments | ||
| .mutateAsync({ target: attachmentTarget, attachments }) | ||
| .then((paths) => { | ||
| // A PTY takes bytes, not files: the agent gets the attachments as | ||
| // worktree-relative paths appended to the message. | ||
| onSubmit(text ? `${text}\n\n${paths.join("\n")}` : paths.join("\n")); | ||
| composerRef.current?.clear(); | ||
| }) | ||
| .catch(() => {}); | ||
| }; | ||
|
|
||
| return ( | ||
| <View className="px-3 pb-2"> | ||
| <GlassComposer | ||
| ref={composerRef} | ||
| above={<QuickKeysRow onKey={onQuickKey} />} | ||
| isSending={writeAttachments.isPending} | ||
| isSending={writeAttachments.isPending || isSubmitting} | ||
|
Comment on lines
96
to
+101
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Disable quick keys while Line 100 keeps 🤖 Prompt for AI Agents |
||
| showAttachments={allowAttachments} | ||
| onActiveChange={onActiveChange} | ||
| onSubmit={submit} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 50379
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 50377
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 50377
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 50377
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 3548
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 10268
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 9290
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 50377
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 5441
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 50377
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 14324
Block unsupported hosts before enabling
terminal.send.v2Host.listand mobile host selection check only host access and online status. They do not enforce host-service version 1.22.0. An older host cannot serveterminal.send, so submission fails at runtime.🤖 Prompt for AI Agents