Skip to content
TypeScript

feat(web): choose queue or steer for follow-up messages (#11964)

Bilal Bakr719a76ca1dbf
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx
index d0d05146c48..38f773cf037 100644
--- a/apps/web/src/components/ChatView.tsx
+++ b/apps/web/src/components/ChatView.tsx
@@ -6781,6 +6781,17 @@ export default function ChatView(props: ChatViewProps) {
return;
}
+ if (command === "thread.steerQueuedMessage") {
+ const message = activeThreadKey
+ ? useQueuedMessageStore.getState().queuesByThreadKey[activeThreadKey]?.[0]
+ : undefined;
+ if (!message) return;
+ event.preventDefault();
+ event.stopPropagation();
+ if (!event.repeat) queuedMessageActionsRef.current.steer(message.id);
+ return;
+ }
+
if (command === "thread.stop") {
// An unavailable command should not shadow contextual shortcuts such as Escape to close a dialog.
if (!canInterruptRunningThread) return;
@@ -6810,6 +6821,7 @@ export default function ChatView(props: ChatViewProps) {
activeThreadPinned,
activeThreadSettled,
canInterruptRunningThread,
+ activeThreadKey,
terminalUiState.terminalOpen,
terminalUiState.activeTerminalId,
activeThreadId,
@@ -7497,11 +7509,13 @@ export default function ChatView(props: ChatViewProps) {
);
return;
}
- // A send during a running turn waits in the queue. It leaves on the next
- // tool boundary, when the turn ends, or when the user clicks Steer. The
- // provider treats a mid-turn send as a steer of the active turn, so the
- // dispatch below is the same either way.
- if (!queuedMessage && !directAnnotation && phase === "running" && activeThreadKey) {
+ if (
+ !queuedMessage &&
+ !directAnnotation &&
+ phase === "running" &&
+ activeThreadKey &&
+ settings.followUpBehavior === "queue"
+ ) {
if (composerRef.current?.validateProviderInput(promptForSend) === false) {
return;
}
@@ -9501,6 +9515,11 @@ export default function ChatView(props: ChatViewProps) {
loadEarlier={paintOnlyDisplayedTimeline ? null : loadEarlierTurns}
queuedMessages={paintOnlyDisplayedTimeline ? EMPTY_QUEUED_MESSAGES : queuedMessages}
onSteerQueuedMessage={onSteerQueuedMessage}
+ steerQueuedMessageShortcutLabel={shortcutLabelForCommand(
+ keybindings,
+ "thread.steerQueuedMessage",
+ { context: { terminalFocus: false } },
+ )}
onRemoveQueuedMessage={onRemoveQueuedMessage}
/>
diff --git a/apps/web/src/components/chat/MessagesTimeline.tsx b/apps/web/src/components/chat/MessagesTimeline.tsx
index 61381ddb71f..307a893342f 100644
--- a/apps/web/src/components/chat/MessagesTimeline.tsx
+++ b/apps/web/src/components/chat/MessagesTimeline.tsx
@@ -285,6 +285,7 @@ interface TimelineRowSharedState {
onWorktreeSetupWorkLocally: (() => void) | null;
onOpenWorktreeSetupTerminal: ((terminalId: string) => void) | null;
onSteerQueuedMessage: (id: string) => void;
+ steerQueuedMessageShortcutLabel: string | null;
onRemoveQueuedMessage: (id: string) => void;
}
@@ -441,6 +442,7 @@ interface MessagesTimelineProps {
/** Messages sent during the running turn. They render as ghost bubbles after the live rows. */
queuedMessages?: ReadonlyArray<QueuedComposerMessage>;
onSteerQueuedMessage?: (id: string) => void;
+ steerQueuedMessageShortcutLabel?: string | null;
onRemoveQueuedMessage?: (id: string) => void;
}
@@ -496,6 +498,7 @@ export const MessagesTimeline = memo(function MessagesTimeline({
loadEarlier = null,
queuedMessages = EMPTY_QUEUED_MESSAGES,
onSteerQueuedMessage = NOOP_QUEUED_MESSAGE_ACTION,
+ steerQueuedMessageShortcutLabel = null,
onRemoveQueuedMessage = NOOP_QUEUED_MESSAGE_ACTION,
}: MessagesTimelineProps) {
const [expandedTurnIds, setExpandedTurnIds] = useState<ReadonlySet<TurnId>>(new Set());
@@ -940,6 +943,7 @@ export const MessagesTimeline = memo(function MessagesTimeline({
onWorktreeSetupWorkLocally: onWorktreeSetupWorkLocally ?? null,
onOpenWorktreeSetupTerminal: onOpenWorktreeSetupTerminal ?? null,
onSteerQueuedMessage,
+ steerQueuedMessageShortcutLabel,
onRemoveQueuedMessage,
}),
[
@@ -972,6 +976,7 @@ export const MessagesTimeline = memo(function MessagesTimeline({
onWorktreeSetupWorkLocally,
onOpenWorktreeSetupTerminal,
onSteerQueuedMessage,
+ steerQueuedMessageShortcutLabel,
onRemoveQueuedMessage,
],
);
@@ -1564,7 +1569,12 @@ function QueuedMessageTimelineRow({
>
<ArrowUpIcon className="size-3.5" aria-hidden />
</TooltipTrigger>
- <TooltipPopup side="bottom">Send now</TooltipPopup>
+ <TooltipPopup side="bottom">
+ Send now
+ {row.isNext && ctx.steerQueuedMessageShortcutLabel
+ ? ` (${ctx.steerQueuedMessageShortcutLabel})`
+ : null}
+ </TooltipPopup>
</Tooltip>
<Tooltip>
<TooltipTrigger
diff --git a/apps/web/src/components/settings/SettingsPanels.tsx b/apps/web/src/components/settings/SettingsPanels.tsx
index 6baa561a91f..5238cf19e19 100644
--- a/apps/web/src/components/settings/SettingsPanels.tsx
+++ b/apps/web/src/components/settings/SettingsPanels.tsx
@@ -578,6 +578,9 @@ export function useSettingsRestore(onRestored?: () => void) {
...(settings.composerCollapseOnScroll !== DEFAULT_UNIFIED_SETTINGS.composerCollapseOnScroll
? ["Collapse composer on scroll"]
: []),
+ ...(settings.followUpBehavior !== DEFAULT_UNIFIED_SETTINGS.followUpBehavior
+ ? ["Follow-up behavior"]
+ : []),
...(settings.contextWindowMeterEnabled !== DEFAULT_UNIFIED_SETTINGS.contextWindowMeterEnabled
? ["Context window indicator"]
: []),
@@ -636,6 +639,7 @@ export function useSettingsRestore(onRestored?: () => void) {
settings.confirmThreadDelete,
settings.confirmThreadUnpin,
settings.composerCollapseOnScroll,
+ settings.followUpBehavior,
settings.addProjectBaseDirectory,
settings.defaultThreadEnvMode,
settings.newWorktreesStartFromOrigin,
@@ -748,6 +752,7 @@ export function useSettingsRestore(onRestored?: () => void) {
proactivePanelsEnabled: DEFAULT_UNIFIED_SETTINGS.proactivePanelsEnabled,
showSkillsInSlashMenu: DEFAULT_UNIFIED_SETTINGS.showSkillsInSlashMenu,
composerCollapseOnScroll: DEFAULT_UNIFIED_SETTINGS.composerCollapseOnScroll,
+ followUpBehavior: DEFAULT_UNIFIED_SETTINGS.followUpBehavior,
contextWindowMeterEnabled: DEFAULT_UNIFIED_SETTINGS.contextWindowMeterEnabled,
environmentIdentificationMode: DEFAULT_UNIFIED_SETTINGS.environmentIdentificationMode,
glassOpacity: DEFAULT_UNIFIED_SETTINGS.glassOpacity,
@@ -2589,6 +2594,47 @@ export function GeneralSettingsPanel() {
}
/>
+ <SettingsRow
+ {...searchableSetting("follow-up-behavior")}
+ description="Queue follow-ups while the agent runs or steer the current turn."
+ resetAction={
+ settings.followUpBehavior !== DEFAULT_UNIFIED_SETTINGS.followUpBehavior ? (
+ <SettingResetButton
+ label="follow-up behavior"
+ onClick={() =>
+ updateSettings({
+ followUpBehavior: DEFAULT_UNIFIED_SETTINGS.followUpBehavior,
+ })
+ }
+ />
+ ) : null
+ }
+ control={
+ <Select
+ value={settings.followUpBehavior}
+ onValueChange={(value) => {
+ if (value === "queue" || value === "steer") {
+ updateSettings({ followUpBehavior: value });
+ }
+ }}
+ >
+ <SelectTrigger size="sm" className="w-full sm:w-40" aria-label="Follow-up behavior">
+ <SelectValue>
+ {settings.followUpBehavior === "queue" ? "Queue" : "Steer"}
+ </SelectValue>
+ </SelectTrigger>
+ <SelectPopup align="end" alignItemWithTrigger={false}>
+ <SelectItem hideIndicator value="queue">
+ Queue
+ </SelectItem>
+ <SelectItem hideIndicator value="steer">
+ Steer
+ </SelectItem>
+ </SelectPopup>
+ </Select>
+ }
+ />
+
<SettingsRow
serverScoped
settingKeys={["enableProviderUpdateChecks"]}
diff --git a/apps/web/src/components/settings/settingsSearch.ts b/apps/web/src/components/settings/settingsSearch.ts
index 19268e2cdae..7e999417f2a 100644
--- a/apps/web/src/components/settings/settingsSearch.ts
+++ b/apps/web/src/components/settings/settingsSearch.ts
@@ -298,6 +298,12 @@ export const SETTINGS_SEARCH_ITEMS = [
to: "/settings/general",
searchTerms: ["composer rest resting scroll wheel conversation timeline shrink minimize"],
},
+ {
+ id: "follow-up-behavior",
+ title: "Follow-up behavior",
+ to: "/settings/general",
+ searchTerms: ["queue steer running turn send default behavior composer"],
+ },
{
id: "provider-update-checks",
title: "Provider update checks",
diff --git a/apps/web/src/keybindings.test.ts b/apps/web/src/keybindings.test.ts
index 1e9e8adc7ba..d335c68869b 100644
--- a/apps/web/src/keybindings.test.ts
+++ b/apps/web/src/keybindings.test.ts
@@ -1119,6 +1119,7 @@ describe("composer and pull request shortcuts", () => {
["l", "composer.previousWorktree"],
["c", "thread.copyReference"],
["k", "pullRequest.copyNumber"],
+ ["Enter", "thread.steerQueuedMessage"],
] as const;
for (const platform of ["MacIntel", "Win32", "Linux"]) {
diff --git a/docs/user/composer.md b/docs/user/composer.md
index 8ed45837388..f3be7a5f342 100644
--- a/docs/user/composer.md
+++ b/docs/user/composer.md
@@ -31,12 +31,21 @@ See [images and videos](#images-and-videos-in-messages) for previewing and savin
## Send while the agent is working
-A message sent during a running turn waits at the end of the conversation as a
+On web and desktop, a message sent during a running turn waits at the end of the conversation as a
dashed bubble. It goes out on its own when the agent finishes its next tool
call, or when the turn ends. Use the arrow under the bubble to send it right
away, or the X to move it back into the composer. Stop returns every queued
message to the composer.
+In **Settings → General → Follow-up behavior**, choose **Queue** to keep this
+behavior or **Steer** to send new messages immediately. This setting applies to
+the current client. Messages already queued keep their place.
+
+Use `Cmd+Shift+Enter` on macOS or `Ctrl+Shift+Enter` on Windows and Linux to send
+the oldest queued message now. Change `thread.steerQueuedMessage` in
+**Settings → Keybindings** to use another shortcut. It leaves the current draft
+in the composer and waits if the agent needs an approval or an answer.
+
## Queue messages offline on mobile
Mobile keeps local copies of draft attachments, so you can preview them and queue
diff --git a/packages/contracts/src/keybindings.ts b/packages/contracts/src/keybindings.ts
index a285d2fcf4a..1256dcc7778 100644
--- a/packages/contracts/src/keybindings.ts
+++ b/packages/contracts/src/keybindings.ts
@@ -36,6 +36,7 @@ export type ModelPickerJumpKeybindingCommand =
const THREAD_KEYBINDING_COMMANDS = [
"thread.stop",
+ "thread.steerQueuedMessage",
"thread.previous",
"thread.next",
"thread.copyReference",
diff --git a/packages/contracts/src/settings.test.ts b/packages/contracts/src/settings.test.ts
index b090b47fba5..ba612edaf26 100644
--- a/packages/contracts/src/settings.test.ts
+++ b/packages/contracts/src/settings.test.ts
@@ -529,6 +529,19 @@ describe("ClientSettings context window meter", () => {
});
});
+describe("ClientSettings follow-up behavior", () => {
+ it("defaults to queue and accepts either behavior", () => {
+ expect(decodeClientSettings({}).followUpBehavior).toBe("queue");
+ for (const followUpBehavior of ["queue", "steer"]) {
+ expect(decodeClientSettings({ followUpBehavior }).followUpBehavior).toBe(followUpBehavior);
+ expect(decodeClientSettingsPatch({ followUpBehavior }).followUpBehavior).toBe(
+ followUpBehavior,
+ );
+ }
+ expect(() => decodeClientSettingsPatch({ followUpBehavior: "invalid" })).toThrow();
+ });
+});
+
describe("ClientSettings composer collapse", () => {
it("collapses on scroll by default and accepts opting out", () => {
expect(decodeClientSettings({}).composerCollapseOnScroll).toBe(true);
diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.ts
index 7b3715d704b..1c53b36037b 100644
--- a/packages/contracts/src/settings.ts
+++ b/packages/contracts/src/settings.ts
@@ -430,6 +430,9 @@ export const ClientSettingsSchema = Schema.Struct({
// Desktop resting composer: scrolling an existing thread's conversation
// settles the composer into its single-line layout. Losing focus never does.
composerCollapseOnScroll: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
+ followUpBehavior: Schema.Literals(["queue", "steer"]).pipe(
+ Schema.withDecodingDefault(Effect.succeed("queue")),
+ ),
proactivePanelsEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
showSkillsInSlashMenu: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
// Legacy sidebar (the original per-project tree). Deliberately a fresh key
@@ -1499,6 +1502,7 @@ export const ClientSettingsPatch = Schema.Struct({
planModeEnabled: Schema.optionalKey(Schema.Boolean),
contextWindowMeterEnabled: Schema.optionalKey(Schema.Boolean),
composerCollapseOnScroll: Schema.optionalKey(Schema.Boolean),
+ followUpBehavior: Schema.optionalKey(Schema.Literals(["queue", "steer"])),
proactivePanelsEnabled: Schema.optionalKey(Schema.Boolean),
showSkillsInSlashMenu: Schema.optionalKey(Schema.Boolean),
legacySidebarEnabled: Schema.optionalKey(Schema.Boolean),
diff --git a/packages/shared/src/keybindings.ts b/packages/shared/src/keybindings.ts
index 8d73c07f34a..0cc18680e6d 100644
--- a/packages/shared/src/keybindings.ts
+++ b/packages/shared/src/keybindings.ts
@@ -40,6 +40,7 @@ export const DEFAULT_KEYBINDINGS: ReadonlyArray<KeybindingRule> = [
{ key: "mod+shift+f", command: "projectSearch.toggle", when: "!terminalFocus" },
{ key: "mod+alt+shift+t", command: "themeEditor.toggle" },
{ key: "mod+s", command: "composer.stash", when: "!terminalFocus" },
+ { key: "mod+shift+enter", command: "thread.steerQueuedMessage", when: "!terminalFocus" },
{ key: "mod+n", command: "chat.new", when: "!terminalFocus" },
{ key: "mod+shift+o", command: "chat.new", when: "!terminalFocus" },
{ key: "mod+shift+n", command: "chat.newLocal", when: "!terminalFocus" },