fix: pass draft starter text as command arguments
This commit is contained in:
@@ -1271,12 +1271,14 @@ const ChatInputComponent: React.FC<ChatInputProps> = ({ onOpenSettings, scrollTo
|
||||
}, [inputMode, getCurrentInputSnapshot, currentSessionId, sessionPhase, autoReviewRunning, followUpBehavior, handleQueueMessage]);
|
||||
|
||||
// Draft welcome presets: submit immediately.
|
||||
const submitPresetPrompt = React.useCallback((text: string) => {
|
||||
const submitPresetPrompt = React.useCallback((text: string, type: 'command' | 'skill') => {
|
||||
// The text goes straight into the submit (see SubmitOptions.presetText)
|
||||
// instead of through the composer input — the collapsed mobile pill has
|
||||
// no mounted textarea to stage it in.
|
||||
const draft = (composerRef.current?.getValue() ?? messageRef.current).trim();
|
||||
const presetText = draft ? `${text}\n${draft}` : text;
|
||||
// OpenCode recognizes slash commands only when their arguments follow
|
||||
// the command on the same line. Skills retain the multiline prompt form.
|
||||
const presetText = draft ? `${text}${type === 'command' ? ' ' : '\n'}${draft}` : text;
|
||||
void handleSubmitRef.current({ presetText });
|
||||
}, []);
|
||||
|
||||
@@ -1308,7 +1310,7 @@ const ChatInputComponent: React.FC<ChatInputProps> = ({ onOpenSettings, scrollTo
|
||||
React.useEffect(() => {
|
||||
if (pendingPresetSubmit == null) return;
|
||||
const text = useInputStore.getState().consumePendingPresetSubmit();
|
||||
if (text) submitPresetPrompt(text);
|
||||
if (text) submitPresetPrompt(text.text, text.type);
|
||||
}, [pendingPresetSubmit, submitPresetPrompt]);
|
||||
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
@@ -2718,7 +2720,10 @@ const ChatInputComponent: React.FC<ChatInputProps> = ({ onOpenSettings, scrollTo
|
||||
) : null}
|
||||
</div>
|
||||
{newSessionDraftOpen && !isDesktopExpanded && !isMobile && !isVSCode && !isMiniChatSurface ? (
|
||||
<DraftPresetChips onSubmit={submitPresetPrompt} className="chat-input-column mt-4" />
|
||||
<DraftPresetChips
|
||||
onSubmit={(starter) => submitPresetPrompt(starter.submitText, starter.ref.type)}
|
||||
className="chat-input-column mt-4"
|
||||
/>
|
||||
) : null}
|
||||
</form>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user