feat(webui): interject via the send button while streaming
While a turn is streaming, the primary action button stays Stop only while the composer is empty. Once the user types, the send affordance takes over (ChatGPT-style): tapping Send stops the running turn for the agent and immediately delivers the new message with continueActiveTurn semantics — the same backend contract the queued-guidance flush uses. This restores 插嘴 (interjection) on touch devices, where Enter now inserts a newline instead of queueing guidance (the queue-guidance flow stays available on precision-pointer devices via Enter, and the queued prompt stack still sends already-queued prompts anywhere). submit() now carries continueActiveTurn while streaming; the button icon switches to the send arrow in that state.
This commit is contained in:
1 parent
2750a19601
commit
42b85efa98
2 files changed
+70
-6
No files matched your search
@@ -971,8 +971,8 @@ export function ThreadComposer({
|
||||
const [recentSlashCommands, setRecentSlashCommands] = useState<string[]>(() => readSlashRecents());
|
||||
const [queuedPrompts, setQueuedPrompts] = useState<QueuedPrompt[]>([]);
|
||||
const hasTouchPrimaryPointer = useMediaQuery("(hover: none) and (pointer: coarse)");
|
||||
// Wider than hasTouchPrimaryPointer on purpose: tablets with a physical
|
||||
// keyboard still count as touch for the Enter key behavior below.
|
||||
// Coarser than hasTouchPrimaryPointer on purpose: tablets with a physical
|
||||
// keyboard still get the newline-on-Enter behavior.
|
||||
const hasCoarsePointer = useMediaQuery("(pointer: coarse)");
|
||||
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
||||
const mentionOverlayRef = useRef<HTMLDivElement>(null);
|
||||
@@ -2034,11 +2034,14 @@ export function ThreadComposer({
|
||||
: undefined;
|
||||
const attachedCliApps = activeCliMentionApps.map(cliAppMentionPayload);
|
||||
const attachedMcpPresets = activeMcpPresetMentions.map(mcpPresetMentionPayload);
|
||||
// While streaming, sending carries continueActiveTurn so the new message
|
||||
// interjects instead of waiting for the running turn to finish.
|
||||
const options: SendOptions | undefined =
|
||||
attachedCliApps.length > 0
|
||||
|| attachedMcpPresets.length > 0
|
||||
|| activeSessionMentions.length > 0
|
||||
|| normalizedQuotedContext
|
||||
|| isStreaming
|
||||
? {
|
||||
...(attachedCliApps.length > 0 ? { cliApps: attachedCliApps } : {}),
|
||||
...(attachedMcpPresets.length > 0 ? { mcpPresets: attachedMcpPresets } : {}),
|
||||
@@ -2046,6 +2049,7 @@ export function ThreadComposer({
|
||||
? { sessionMentions: activeSessionMentions }
|
||||
: {}),
|
||||
...(normalizedQuotedContext ? { quotedContext: normalizedQuotedContext } : {}),
|
||||
...(isStreaming ? { continueActiveTurn: true } : {}),
|
||||
}
|
||||
: undefined;
|
||||
const hasPlainTextCommandPayload =
|
||||
@@ -2285,7 +2289,12 @@ export function ThreadComposer({
|
||||
: voiceRecorder.state === "transcribing"
|
||||
? t("thread.composer.voice.transcribing")
|
||||
: t("thread.composer.voice.hint");
|
||||
const showStopButton = isStreaming && !!onStop;
|
||||
// While streaming, the primary action is Stop only while the composer is
|
||||
// empty. Once the user types, the send affordance takes over (like ChatGPT):
|
||||
// tapping send interjects instead of waiting — this keeps the flow working
|
||||
// on touch devices where Enter now inserts a newline instead of queueing
|
||||
// guidance.
|
||||
const showStopButton = isStreaming && !!onStop && !hasComposerContent;
|
||||
const relaxedHeroInput = isHero && images.length === 0 && !isStreaming;
|
||||
const compactIdle = compactWhenIdle && !compactControls && !isHero && !composerFocused
|
||||
&& value.length === 0 && images.length === 0 && !inlineError
|
||||
@@ -2705,10 +2714,10 @@ export function ThreadComposer({
|
||||
>
|
||||
{showStopButton ? (
|
||||
<Square className={cn("fill-current stroke-current", isHero ? "h-3 w-3" : "h-3.5 w-3.5")} />
|
||||
) : isStreaming ? (
|
||||
<Loader2 className={cn(isHero ? "h-4 w-4" : "h-4 w-4", "animate-spin")} />
|
||||
) : (
|
||||
) : canSend || !isStreaming ? (
|
||||
<ArrowUp className={cn(isHero ? "h-4 w-4" : "h-4 w-4")} />
|
||||
) : (
|
||||
<Loader2 className={cn(isHero ? "h-4 w-4" : "h-4 w-4", "animate-spin")} />
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user