From ca356d03a13817d3659ead212697046699378da8 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Fri, 30 Oct 2026 12:04:33 -0700 Subject: [PATCH 01/27] Advertise mid-turn queueing as queued-messages.v2 Released clients read the v1 name with an unfinished queue UI; they never see v2 and keep sending immediately. (cherry picked from commit f39382e090d892addf3879a05f3822223904235e) --- .../mobile-structured-agent-session-send.ts | 2 +- .../structured-agent-session-queued-edit.test.ts | 5 +++-- .../structured-agent-session-queued-methods.ts | 2 +- ...use-structured-agent-session-queued-messages.ts | 2 +- src/shared/agent-session-runtime-capabilities.ts | 14 ++++++++------ src/shared/agent-session-wire.ts | 2 +- .../structured-agent-session-params.ts | 4 ++-- 7 files changed, 17 insertions(+), 14 deletions(-) diff --git a/mobile/src/session/mobile-structured-agent-session-send.ts b/mobile/src/session/mobile-structured-agent-session-send.ts index 7e67badf8121..11d886b7c93a 100644 --- a/mobile/src/session/mobile-structured-agent-session-send.ts +++ b/mobile/src/session/mobile-structured-agent-session-send.ts @@ -27,7 +27,7 @@ export async function sendMobileStructuredAgentSessionMessage(input: { attachments: readonly StructuredAgentSessionAttachment[] /** Sent only when the host advertises `agent-session.send-skills.v1`. */ skills?: readonly AgentJournalSkillRef[] - /** Sent only when the host advertises `agent-session.queued-messages.v1`. */ + /** Sent only when the host advertises `agent-session.queued-messages.v2`. */ delivery?: 'queue-if-active' /** Sent only when the host advertises `agent-session.send-selection.v1`. */ selection?: Readonly> diff --git a/src/main/runtime/rpc/methods/structured-agent-session-queued-edit.test.ts b/src/main/runtime/rpc/methods/structured-agent-session-queued-edit.test.ts index b3ee7ecc3bfe..23401ec6bde9 100644 --- a/src/main/runtime/rpc/methods/structured-agent-session-queued-edit.test.ts +++ b/src/main/runtime/rpc/methods/structured-agent-session-queued-edit.test.ts @@ -43,9 +43,10 @@ beforeEach(() => { afterEach(clearStructuredHostStub) describe('queued edit methods', () => { - it('the host advertises editing on its own, with mid-turn queueing still dark', () => { + it('the host advertises editing and mid-turn queueing, never the v1 name released clients read', () => { expect(RUNTIME_CAPABILITIES).toContain(AGENT_SESSION_QUEUED_MESSAGE_EDIT_RUNTIME_CAPABILITY) - expect(RUNTIME_CAPABILITIES).not.toContain(AGENT_SESSION_QUEUED_MESSAGES_RUNTIME_CAPABILITY) + expect(RUNTIME_CAPABILITIES).toContain(AGENT_SESSION_QUEUED_MESSAGES_RUNTIME_CAPABILITY) + expect(RUNTIME_CAPABILITIES).not.toContain('agent-session.queued-messages.v1') }) it.each([ diff --git a/src/main/runtime/rpc/methods/structured-agent-session-queued-methods.ts b/src/main/runtime/rpc/methods/structured-agent-session-queued-methods.ts index 94d4897f9303..06bb8dcb4692 100644 --- a/src/main/runtime/rpc/methods/structured-agent-session-queued-methods.ts +++ b/src/main/runtime/rpc/methods/structured-agent-session-queued-methods.ts @@ -1,4 +1,4 @@ -// Do not gate queued-card actions on queued-messages.v1: hosts without it still publish unsent cards. Older pre-queue/edit hosts lack the methods. +// Do not gate queued-card actions on queued-messages.v2: hosts without it still publish unsent cards. Older pre-queue/edit hosts lack the methods. import { defineMethod } from '../core' import { diff --git a/src/renderer/src/components/native-chat/use-structured-agent-session-queued-messages.ts b/src/renderer/src/components/native-chat/use-structured-agent-session-queued-messages.ts index b9269eb58618..a7a9d0978fbd 100644 --- a/src/renderer/src/components/native-chat/use-structured-agent-session-queued-messages.ts +++ b/src/renderer/src/components/native-chat/use-structured-agent-session-queued-messages.ts @@ -80,7 +80,7 @@ function alreadySentNotice(): void { } export function useStructuredAgentSessionQueuedMessages(args: { - /** Host advertises `agent-session.queued-messages.v1` and the transport has a fence. */ + /** Host advertises `agent-session.queued-messages.v2` and the transport has a fence. */ enabled: boolean queuedMessages: readonly AgentSessionQueuedMessage[] | null queuePause: AgentSessionQueuePause | null diff --git a/src/shared/agent-session-runtime-capabilities.ts b/src/shared/agent-session-runtime-capabilities.ts index e747cc085ddb..0a70338bc5cd 100644 --- a/src/shared/agent-session-runtime-capabilities.ts +++ b/src/shared/agent-session-runtime-capabilities.ts @@ -37,14 +37,15 @@ export const AGENT_SESSION_ACCEPTED_SEND_RUNTIME_CAPABILITY = export const AGENT_SESSION_SEND_ANSWERS_PROOF_RUNTIME_CAPABILITY = 'agent-session.send-answers-proof.v1' as const // Older hosts reject delivery; older clients cannot render queued replies. Gate queue-if-active, -// its setting and chord, but never kept-draft lists/actions. DARK until the shipped host passes -// the integrated Codex steer matrix (#21062); keep out of AGENT_SESSION_RUNTIME_CAPABILITIES. -// v1 links hand-offs via submission.queuedMessageId, never equal draft/submission IDs. queuePause +// its setting and chords, but never kept-draft lists/actions. v2, not v1: released clients that +// read v1 (desktop 1.4.219+, native phone builds) carry an unfinished queue UI, so they never see +// this and keep sending immediately. The Codex steer paths it hands cards to are pinned in +// codex-structured-turn-steer.test.ts. +// Hand-offs link via submission.queuedMessageId, never equal draft/submission IDs. queuePause // holds every card until queuedMessagesResume or a later turn starts. nextQueuedMessageId names // the next eligible card; null/missing means none. Per-card holds: send_failed conversion or kept. -// Host mechanisms land first; this capability gates rollout. export const AGENT_SESSION_QUEUED_MESSAGES_RUNTIME_CAPABILITY = - 'agent-session.queued-messages.v1' as const + 'agent-session.queued-messages.v2' as const // Advertise in-place update/edit holds separately from mid-turn queueing: kept/mail cards remain editable while queueing is off. Never fall back to copy/delete. export const AGENT_SESSION_QUEUED_MESSAGE_EDIT_RUNTIME_CAPABILITY = 'agent-session.queued-message-edit.v1' as const @@ -60,7 +61,7 @@ export const AGENT_SESSION_QUEUED_MESSAGE_IMAGE_EDIT_RUNTIME_CAPABILITY = // Publish image cards only to capable readers that preserve images on edit; older copy/delete editing would lose them. export const AGENT_SESSION_QUEUED_IMAGE_CARDS_CLIENT_CAPABILITY = 'agent-session.queued-image-cards.v1' as const -// Strict conversationCommand rejects unknown delivery. Offer queued /compact only with this and queued-messages.v1; its card is the sole waiting surface. +// Strict conversationCommand rejects unknown delivery. Offer queued /compact only with this and queued-messages.v2; its card is the sole waiting surface. export const AGENT_SESSION_QUEUED_COMMANDS_RUNTIME_CAPABILITY = 'agent-session.queued-commands.v1' as const // Gate Claude journal/lifecycle independently of Codex for paired clients. @@ -112,6 +113,7 @@ export const AGENT_SESSION_RUNTIME_CAPABILITIES = [ // turn starts, so a client may gate on either. AGENT_SESSION_ACCEPTED_SEND_RUNTIME_CAPABILITY, AGENT_SESSION_SEND_ANSWERS_PROOF_RUNTIME_CAPABILITY, + AGENT_SESSION_QUEUED_MESSAGES_RUNTIME_CAPABILITY, AGENT_SESSION_QUEUED_COMMANDS_RUNTIME_CAPABILITY, AGENT_SESSION_QUEUED_MESSAGE_EDIT_RUNTIME_CAPABILITY, AGENT_SESSION_QUEUED_MESSAGE_REORDER_RUNTIME_CAPABILITY, diff --git a/src/shared/agent-session-wire.ts b/src/shared/agent-session-wire.ts index c01839026acc..b781afa1252b 100644 --- a/src/shared/agent-session-wire.ts +++ b/src/shared/agent-session-wire.ts @@ -322,7 +322,7 @@ export type AgentSessionAttachResult = { tabId?: string } -/** Only queue-if-active callers with queued-messages.v1 receive this draft arm; non-waiting states occur only on settled-draft replays. */ +/** Only queue-if-active callers with queued-messages.v2 receive this draft arm; non-waiting states occur only on settled-draft replays. */ export type AgentSessionQueuedSendReceipt = { messageId: string position: number diff --git a/src/shared/rpc-contract/structured-agent-session-params.ts b/src/shared/rpc-contract/structured-agent-session-params.ts index d9072db1fb09..ba781f1cca84 100644 --- a/src/shared/rpc-contract/structured-agent-session-params.ts +++ b/src/shared/rpc-contract/structured-agent-session-params.ts @@ -122,7 +122,7 @@ export const SendParams = z .object({ envelope: MutationEnvelope, retryUnknown: z.literal(true).optional(), - /** Host-held draft while active; gate strict payloads on agent-session.queued-messages.v1. + /** Host-held draft while active; gate strict payloads on agent-session.queued-messages.v2. * Operation fingerprint only, never body fingerprint. */ delivery: z.literal('queue-if-active').optional(), /** Preserve composer options until dispatch; requires agent-session.send-options.v1. Operation fingerprint only. */ @@ -189,7 +189,7 @@ export const CancelParams = z } }) -/** Queued draft actions require agent-session.queued-messages.v1; older hosts lack these methods. */ +/** Queued draft actions require agent-session.queued-messages.v2; older hosts lack these methods. */ export const QueuedMessageActionParams = z .object({ envelope: MutationEnvelope, From 3011eed23b6892e54332466db999d94d57ab377f Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Fri, 30 Oct 2026 12:54:14 -0700 Subject: [PATCH 02/27] Let each desktop send choose queue or steer while the agent works The follow-up choice is now a Queue / Steer setting saved under nativeChatFollowUpBehavior, Steer by default; the old nativeChatQueueFollowUps switch, which every install saved as true while queueing was dark, is retired on load. Every reader goes through native-chat-follow-up-behavior. While the agent works, Enter follows the setting and Cmd/Ctrl+Enter sends the draft the other way; the alternate flips the setting before the queue's own rules (a waiting command still queues, prompts no one here can answer still send now) and never applies while Stopping. Cmd/Ctrl+Shift+Enter steers the head card only and leaves the draft. An idle agent's card reads Send, and the card menu no longer offers "Turn off queueing". (cherry picked from commit 55b48694e743ed64a2849e61e88be3c63207e5fa) --- .../persistence-settings-ui-defaults.test.ts | 13 +++ .../terminal-settings-migrations.ts | 4 + .../runtime/runtime-client-settings-shape.ts | 2 +- src/main/runtime/runtime-client-settings.ts | 5 +- src/main/runtime/runtime-store-contract.ts | 2 +- ...-session-codex-turn-end-settlement.test.ts | 2 + .../NativeChatAgentMessageRow.test.tsx | 2 +- .../native-chat/NativeChatComposerPane.tsx | 4 +- .../NativeChatQueuedMessageCard.tsx | 50 ++++---- ...hatQueuedMessageComposer.raw-task.test.tsx | 1 + ...tiveChatQueuedMessageList.arrival.test.tsx | 3 +- ...ChatQueuedMessageList.inline-edit.test.tsx | 3 +- .../NativeChatQueuedMessageList.test.tsx | 86 ++++++-------- .../NativeChatQueuedMessageList.tsx | 16 ++- ...iveChatStructuredSession.stopping.test.tsx | 6 +- ...tiveChatStructuredSession.test-harness.tsx | 11 +- .../NativeChatStructuredSession.test.tsx | 11 +- .../NativeChatStructuredSession.tsx | 9 +- .../native-chat/native-chat-composer-types.ts | 7 +- ...ative-chat-structured-composer-dispatch.ts | 9 +- .../native-chat-structured-stop-controls.ts | 4 +- ...native-chat-submission-navigation.test.tsx | 3 +- ...ctured-agent-session-queue-request.test.ts | 99 ++++++++++++++++ .../structured-agent-session-queue-request.ts | 33 +++++- .../structured-agent-session-send-slot.ts | 6 +- .../structured-agent-session-view-contract.ts | 2 +- .../use-native-chat-composer-edit-session.ts | 24 ++-- ...ative-chat-composer-keydown.steer.test.tsx | 86 +++++++------- .../use-native-chat-composer-keydown.ts | 32 +++--- .../use-native-chat-composer-submit.ts | 107 ++++++++++-------- ...se-native-chat-structured-composer-send.ts | 13 ++- ...red-agent-session-queued-messages.test.tsx | 10 +- ...tructured-agent-session-queued-messages.ts | 20 ++-- .../use-structured-agent-session-sends.ts | 2 +- ...tured-agent-session.queued-gating.test.tsx | 48 ++++---- .../use-structured-agent-session.ts | 26 +++-- ...ructured-native-chat-submit-reveal.test.ts | 10 +- ...se-structured-native-chat-submit-reveal.ts | 6 +- .../settings/ChatBehaviorSetting.test.tsx | 48 +++++++- .../settings/ChatBehaviorSetting.tsx | 44 +++++-- .../settings/chat-behavior-search.ts | 9 +- src/renderer/src/i18n/locales/de.json | 8 +- src/renderer/src/i18n/locales/en.json | 8 +- src/renderer/src/i18n/locales/es.json | 8 +- src/renderer/src/i18n/locales/fr.json | 8 +- src/renderer/src/i18n/locales/ja.json | 8 +- src/renderer/src/i18n/locales/ko.json | 8 +- src/renderer/src/i18n/locales/pt.json | 8 +- src/renderer/src/i18n/locales/ru.json | 8 +- src/renderer/src/i18n/locales/tr.json | 8 +- src/renderer/src/i18n/locales/zh-Hant.json | 8 +- src/renderer/src/i18n/locales/zh.json | 8 +- src/shared/default-global-settings.ts | 2 +- src/shared/global-settings-types.ts | 4 +- src/shared/native-chat-follow-up-behavior.ts | 16 +++ ...uctured-agent-session-queued-cards.test.ts | 14 ++- .../structured-agent-session-queued-cards.ts | 16 ++- 57 files changed, 652 insertions(+), 366 deletions(-) create mode 100644 src/renderer/src/components/native-chat/structured-agent-session-queue-request.test.ts create mode 100644 src/shared/native-chat-follow-up-behavior.ts diff --git a/src/main/persistence/applying-settings/persistence-settings-ui-defaults.test.ts b/src/main/persistence/applying-settings/persistence-settings-ui-defaults.test.ts index 7d7ed9f042ae..2e1ea7f0c5b8 100644 --- a/src/main/persistence/applying-settings/persistence-settings-ui-defaults.test.ts +++ b/src/main/persistence/applying-settings/persistence-settings-ui-defaults.test.ts @@ -13,6 +13,7 @@ import { tmpdir } from 'node:os' import type { GlobalSettings } from '../../../shared/global-settings-types' import type { PersistedState } from '../../../shared/persisted-state-types' import { getDefaultPersistedState } from '../../../shared/constants' +import { nativeChatFollowUpBehavior } from '../../../shared/native-chat-follow-up-behavior' import { ONBOARDING_FINAL_STEP, ONBOARDING_FLOW_VERSION } from '../../../shared/onboarding-defaults' const { loadUserSshConfigMock, sshConfigHostsToTargetsMock } = vi.hoisted(() => ({ @@ -137,6 +138,18 @@ describe('Store', () => { expect(readDataFile()).not.toHaveProperty('settings.orchestrationHeartbeatIntervalMinutes') }) + it('drops the saved queue switch and loads Steer', async () => { + const persisted = getDefaultPersistedState(testState.dir) + const { nativeChatFollowUpBehavior: _absent, ...settings } = persisted.settings + void _absent + writeDataFile({ ...persisted, settings: { ...settings, nativeChatQueueFollowUps: true } }) + const store = await createStore() + expect(store.getSettings()).not.toHaveProperty('nativeChatQueueFollowUps') + expect(nativeChatFollowUpBehavior(store.getSettings())).toBe('steer') + store.flush() + expect(readDataFile()).not.toHaveProperty('settings.nativeChatQueueFollowUps') + }) + it('returns default UI state when no data file exists', async () => { const store = await createStore() const ui = store.getUI() diff --git a/src/main/persistence/applying-settings/terminal-settings-migrations.ts b/src/main/persistence/applying-settings/terminal-settings-migrations.ts index bccce6f16cac..c1241c066fc7 100644 --- a/src/main/persistence/applying-settings/terminal-settings-migrations.ts +++ b/src/main/persistence/applying-settings/terminal-settings-migrations.ts @@ -83,6 +83,8 @@ type RetiredGlobalSettings = { orchestrationHeartbeatIntervalMinutes?: unknown // Full-access plugins now need only their own approval. pluginFullAccessEnabled?: unknown + // Retired: saved true by default while queueing was dark; Steer is the default. + nativeChatQueueFollowUps?: unknown } export function stripRetiredGlobalSettings( @@ -102,6 +104,7 @@ export function stripRetiredGlobalSettings( orchestrationHeartbeatsEnabled: _retiredHeartbeatsEnabled, orchestrationHeartbeatIntervalMinutes: _retiredHeartbeatInterval, pluginFullAccessEnabled: _retiredPluginFullAccessSwitch, + nativeChatQueueFollowUps: _retiredQueueFollowUps, ...rest } = (settings ?? {}) as Partial & RetiredGlobalSettings void _retiredChatPermissionCopies @@ -117,6 +120,7 @@ export function stripRetiredGlobalSettings( void _retiredHeartbeatsEnabled void _retiredHeartbeatInterval void _retiredPluginFullAccessSwitch + void _retiredQueueFollowUps return rest } diff --git a/src/main/runtime/runtime-client-settings-shape.ts b/src/main/runtime/runtime-client-settings-shape.ts index 094ef7f1a59a..b1916906be51 100644 --- a/src/main/runtime/runtime-client-settings-shape.ts +++ b/src/main/runtime/runtime-client-settings-shape.ts @@ -34,7 +34,7 @@ export type RuntimeClientSettings = Pick< | 'agentSkillSharingEnabled' | 'machineName' | 'nativeChatPermissionMode' - | 'nativeChatQueueFollowUps' + | 'nativeChatFollowUpBehavior' | 'sourceControlGroupOrder' | 'sourceControlCompareAgainstUpstream' | 'diffShowWhitespace' diff --git a/src/main/runtime/runtime-client-settings.ts b/src/main/runtime/runtime-client-settings.ts index 5e200cf4e154..85ed0ea09176 100644 --- a/src/main/runtime/runtime-client-settings.ts +++ b/src/main/runtime/runtime-client-settings.ts @@ -17,6 +17,7 @@ import type { GlobalSettings } from '../../shared/global-settings-types' import { applyNativeChatSessionOptionSettingsMutation } from '../../shared/native-chat/input/native-chat-session-option-defaults' import type { NativeChatSessionOptionSettingsMutation } from '../../shared/native-chat/input/native-chat-session-options' import { getHostDisplayLabelOverrides } from '../../shared/host-setting-overrides' +import { nativeChatFollowUpBehavior } from '../../shared/native-chat-follow-up-behavior' import type { TerminalQuickCommand } from '../../shared/terminal-quick-command-types' import { recordManagedHookInstallFailure } from '../agent-hooks/install-telemetry' import { applyAgentStatusHooksEnabled } from '../agent-hooks/managed-agent-hook-controls' @@ -108,8 +109,8 @@ export class RuntimeClientSettingsController { : { agentSkillSharingEnabled: isAgentSkillSharingEnabled(settings) }), machineName: settings.machineName ?? '', nativeChatPermissionMode: publishedLegacyChatPermissionMode(settings), - // Phone sends queue mid-turn only while this is on; absence from older hosts means on. - nativeChatQueueFollowUps: settings.nativeChatQueueFollowUps !== false, + // Phone sends queue mid-turn only with Queue; older hosts omit it, which reads as Steer. + nativeChatFollowUpBehavior: nativeChatFollowUpBehavior(settings), // Why projected: a paired client's AI buttons start these actions' agents, and must honour // the agent saved for each one as the desktop does. Absent on older hosts. sourceControlAi: projectSourceControlLaunchRecipes(settings), diff --git a/src/main/runtime/runtime-store-contract.ts b/src/main/runtime/runtime-store-contract.ts index c4917e5279af..b80d55fbafa4 100644 --- a/src/main/runtime/runtime-store-contract.ts +++ b/src/main/runtime/runtime-store-contract.ts @@ -184,7 +184,7 @@ export type RuntimeStore = { agentSkillSharingEnabled?: GlobalSettings['agentSkillSharingEnabled'] nativeChatSessionOptions?: GlobalSettings['nativeChatSessionOptions'] nativeChatPermissionMode?: GlobalSettings['nativeChatPermissionMode'] - nativeChatQueueFollowUps?: GlobalSettings['nativeChatQueueFollowUps'] + nativeChatFollowUpBehavior?: GlobalSettings['nativeChatFollowUpBehavior'] nativeChatInlineVisuals?: GlobalSettings['nativeChatInlineVisuals'] nativeChatInheritShellEnvironment?: GlobalSettings['nativeChatInheritShellEnvironment'] nativeChatShellEnvironmentVariables?: GlobalSettings['nativeChatShellEnvironmentVariables'] diff --git a/src/main/runtime/structured-agent-session-codex-turn-end-settlement.test.ts b/src/main/runtime/structured-agent-session-codex-turn-end-settlement.test.ts index 48fc0a08b196..c7f19271fa67 100644 --- a/src/main/runtime/structured-agent-session-codex-turn-end-settlement.test.ts +++ b/src/main/runtime/structured-agent-session-codex-turn-end-settlement.test.ts @@ -518,6 +518,8 @@ describe("a queued card's Send-now while a Codex turn runs", () => { expect(verdictOf((await settled()).submissions, sent)).toBe('accepted') ) expect((await settled()).owesWork).toBe(false) + // Delivered once: the turn's end neither steers it again nor starts a turn with it. + expect([steers, answers]).toEqual([1, 1]) }) it('is settled when a Stop ends that turn, on a Codex that names a steered start falsely', async () => { diff --git a/src/renderer/src/components/native-chat/NativeChatAgentMessageRow.test.tsx b/src/renderer/src/components/native-chat/NativeChatAgentMessageRow.test.tsx index bbf9729a7296..cb6ddad060b7 100644 --- a/src/renderer/src/components/native-chat/NativeChatAgentMessageRow.test.tsx +++ b/src/renderer/src/components/native-chat/NativeChatAgentMessageRow.test.tsx @@ -143,7 +143,7 @@ describe("another agent's queued card", () => { onSteer={vi.fn()} onDelete={vi.fn()} onEdit={vi.fn()} - onTurnOffQueueing={vi.fn()} + agentWorking /> ) } diff --git a/src/renderer/src/components/native-chat/NativeChatComposerPane.tsx b/src/renderer/src/components/native-chat/NativeChatComposerPane.tsx index 1b91a1f0df7a..19a02e89fab1 100644 --- a/src/renderer/src/components/native-chat/NativeChatComposerPane.tsx +++ b/src/renderer/src/components/native-chat/NativeChatComposerPane.tsx @@ -56,7 +56,7 @@ export const NativeChatComposerPane = forwardRef 0, - ...(!editSession && steerQueued ? { steerQueued } : {}), + ...(!editSession && steerHead ? { steerHead } : {}), setActiveSuggestion, setDraft, setCaret diff --git a/src/renderer/src/components/native-chat/NativeChatQueuedMessageCard.tsx b/src/renderer/src/components/native-chat/NativeChatQueuedMessageCard.tsx index e1bdb19a3e3c..a85161b31461 100644 --- a/src/renderer/src/components/native-chat/NativeChatQueuedMessageCard.tsx +++ b/src/renderer/src/components/native-chat/NativeChatQueuedMessageCard.tsx @@ -88,14 +88,17 @@ export function queuedMessageCardCaption( } } -/** Steer's or Send's label and tooltip (`queuedMessageCardSteers`). */ -export function queuedMessageCardSendNow(card: QueuedMessageCard): { +/** Steer's or Send's label and tooltip: Steer only into a turn that is running (`queuedMessageCardSteers`). */ +export function queuedMessageCardSendNow( + card: QueuedMessageCard, + agentWorking: boolean +): { /** Steer's ↳, or Send's paper plane. */ steers: boolean label: string hint: string } { - if (!queuedMessageCardSteers(card)) { + if (!agentWorking || !queuedMessageCardSteers(card)) { return { steers: false, label: translate('components.native-chat.queuedMessages.send', 'Send'), @@ -118,6 +121,7 @@ export function NativeChatQueuedMessageCard({ agentName, statedFailures, showsSteerShortcut, + agentWorking, steerHeld = false, pending = null, onSteer, @@ -126,16 +130,17 @@ export function NativeChatQueuedMessageCard({ editor, editAttachTo, editDisabled = false, - drag, - onTurnOffQueueing + drag }: { card: QueuedMessageCard /** The chat's worktree, whose host its sender is found on; null shows the sender unlinked. */ chatWorktreeId: string | null agentName?: string statedFailures?: readonly AgentSessionFailureFact[] - /** Only the newest card answers Cmd/Ctrl+Enter; only it may show the chord. */ + /** Only the head card answers Cmd/Ctrl+Shift+Enter; only it may show the chord. */ showsSteerShortcut: boolean + /** The agent is working: a steerable card's action reads Steer, otherwise Send. */ + agentWorking: boolean /** The chat reads Stopping: the card waits for the stop (`NativeChatQueuedMessageList`). */ steerHeld?: boolean /** Disable the card during its own action or Clear all; spin only the pressed action. */ @@ -151,14 +156,12 @@ export function NativeChatQueuedMessageCard({ /** Another card in this pane is being edited. */ editDisabled?: boolean drag?: QueuedMessageDragPresentation - /** Absent when the host does not queue sends, so there is nothing to turn off. */ - onTurnOffQueueing?: () => void }): React.JSX.Element { const caption = queuedMessageCardCaption(card, agentName, statedFailures) const line = queuedMessageCardLine(card, nativeChatImageLabelCopy()) const returned = card.state === 'returned' const attention = queuedMessageCardNeedsAttention(card) - const sendNow = queuedMessageCardSendNow(card) + const sendNow = queuedMessageCardSendNow(card, agentWorking) const busy = pending !== null const isMac = isMacPlatform() // Allow inspecting clipped text before acting; another agent may have authored the card. @@ -275,7 +278,9 @@ export function NativeChatQueuedMessageCard({ {sendNow.hint} {showsSteerShortcut ? ( - + ) : null} @@ -300,7 +305,8 @@ export function NativeChatQueuedMessageCard({ {translate('components.native-chat.queuedMessages.delete', 'Delete')} - {(!card.command && onEdit) || onTurnOffQueueing ? ( + {/* A command's text is not a draft: edited, it would become a message. */} + {!card.command && onEdit ? ( ) : null} + {followUp && stops && !editSession ? ( + + ) : null} {sendReason ? ( @@ -229,6 +241,64 @@ export const NativeChatComposerActions = memo(function NativeChatComposerActions ) }) +const FOLLOW_UP_ICON = { queue: ListEnd, steer: CornerDownRight } as const + +/** Sends exactly as Enter does; its tooltip names Enter and, when it would differ, Cmd/Ctrl+Enter. */ +function NativeChatFollowUpSendButton({ + followUp, + onSend +}: { + followUp: NativeChatSendFollowUp + onSend: () => void +}): React.JSX.Element { + const label = { + queue: translate('components.native-chat.composer.queueMessage', 'Queue message'), + steer: translate('components.native-chat.composer.steerMessage', 'Steer message') + } + const hint = { + queue: translate('components.native-chat.composer.queueHint', 'Queue for after this turn'), + steer: translate('components.native-chat.composer.steerHint', 'Send into the running turn') + } + const alternate: NativeChatFollowUpBehavior = followUp.action === 'queue' ? 'steer' : 'queue' + const isMac = isMacPlatform() + const Icon = FOLLOW_UP_ICON[followUp.action] + return ( + + + + + + + + {hint[followUp.action]} + + + {followUp.offersChoice ? ( + + {hint[alternate]} + + + ) : null} + + + + ) +} + function DraftNotSavedIcon({ shown }: { shown: boolean }): React.JSX.Element | null { if (!shown) { return null diff --git a/src/renderer/src/components/native-chat/NativeChatComposerField.tsx b/src/renderer/src/components/native-chat/NativeChatComposerField.tsx index db3ca3104e2c..afb3dc7cf60c 100644 --- a/src/renderer/src/components/native-chat/NativeChatComposerField.tsx +++ b/src/renderer/src/components/native-chat/NativeChatComposerField.tsx @@ -12,6 +12,7 @@ import type { import { NativeChatMentionMenu, NativeChatPickerMenu } from './NativeChatAutocompleteMenus' import type { NativeChatMentionFiles } from './use-native-chat-mention-files' import { NativeChatComposerActions } from './NativeChatComposerActions' +import type { NativeChatSendFollowUp } from '../../../../shared/native-chat-follow-up-behavior' import { NativeChatComposerNotices } from './NativeChatComposerNotices' import type { NativeChatComposerNotice } from './native-chat-composer-notice' import type { NativeChatContextUsageSummary } from './native-chat-context-usage-summary' @@ -60,6 +61,8 @@ export type NativeChatComposerFieldProps = { isStopping?: boolean /** After Stop, describe whether the host queues the next message as a card or holds the send. */ afterStop?: NativeChatAfterStopSend + /** Mid-turn on a host that queues: what Enter does, and whether Cmd/Ctrl+Enter would differ. */ + sendFollowUp?: NativeChatSendFollowUp attachDisabled: boolean dictationDisabled: boolean isDictating: boolean @@ -143,6 +146,7 @@ export function NativeChatComposerField({ isWorking, isStopping = false, afterStop, + sendFollowUp, attachDisabled, dictationDisabled, isDictating, @@ -172,6 +176,18 @@ export function NativeChatComposerField({ agent }: NativeChatComposerFieldProps): React.JSX.Element { const draftNotSaved = useNativeChatComposerDraftUnsaved(draftScopeKey) + // Mid-turn with something to send, a control beside Stop says what Enter does; never while Stopping. + const followUpAction = + !editSession && isWorking && !afterStop && (draft.trim() !== '' || imageAttachments.length > 0) + ? sendFollowUp?.action + : undefined + const followUpOffersChoice = sendFollowUp?.offersChoice === true + // Keyed on its parts: a fresh object each keystroke would re-render the memoized actions. + const followUp = useMemo( + () => + followUpAction ? { action: followUpAction, offersChoice: followUpOffersChoice } : undefined, + [followUpAction, followUpOffersChoice] + ) const optionCount = autocomplete.mode === 'slash' ? autocomplete.items.length @@ -368,6 +384,7 @@ export function NativeChatComposerField({ draftNotSaved={draftNotSaved} isWorking={isWorking} isStopping={isStopping} + followUp={followUp} isDictating={isDictating} isDictationHoldMode={isDictationHoldMode} onAttach={attach} diff --git a/src/renderer/src/components/native-chat/NativeChatComposerPane.tsx b/src/renderer/src/components/native-chat/NativeChatComposerPane.tsx index 19a02e89fab1..19b0d0d330ea 100644 --- a/src/renderer/src/components/native-chat/NativeChatComposerPane.tsx +++ b/src/renderer/src/components/native-chat/NativeChatComposerPane.tsx @@ -383,6 +383,7 @@ export const NativeChatComposerPane = forwardRef Promise optionsSurface: SessionOptionsSurface optionSnapshot: SessionOptionDescriptor[] diff --git a/src/renderer/src/components/native-chat/use-native-chat-structured-composer-transport.ts b/src/renderer/src/components/native-chat/use-native-chat-structured-composer-transport.ts index 48ecd379d4fb..0520d9d65a2c 100644 --- a/src/renderer/src/components/native-chat/use-native-chat-structured-composer-transport.ts +++ b/src/renderer/src/components/native-chat/use-native-chat-structured-composer-transport.ts @@ -95,6 +95,7 @@ export function useNativeChatStructuredComposerTransport(args: { ...(setThreadGoalObjective ? { threadGoal: { setObjective: setThreadGoalObjective } } : {}), sendOut: controller.sendOut || starting, ...(sendBlockedReason !== null ? { sendBlockedReason } : {}), + ...(controller.sendFollowUp ? { sendFollowUp: controller.sendFollowUp } : {}), optionsSurface: controller.optionSurface, conversationCommands: controller.conversationCommands, optionSnapshot: controller.optionSnapshot, diff --git a/src/renderer/src/components/native-chat/use-structured-agent-session.ts b/src/renderer/src/components/native-chat/use-structured-agent-session.ts index 1683123312c8..7c6f8a1eeb39 100644 --- a/src/renderer/src/components/native-chat/use-structured-agent-session.ts +++ b/src/renderer/src/components/native-chat/use-structured-agent-session.ts @@ -6,7 +6,10 @@ import { useStructuredAgentSessionSendOptions } from './use-structured-agent-ses import { useStructuredAgentSessionSends } from './use-structured-agent-session-sends' import { useStructuredAgentSessionCommandWrite } from './use-structured-agent-session-command-write' import { structuredAgentSessionSendQueues } from './structured-agent-session-queue-request' -import { nativeChatQueueFollowUps } from '../../../../shared/native-chat-follow-up-behavior' +import { + nativeChatQueueFollowUps, + nativeChatSendFollowUp +} from '../../../../shared/native-chat-follow-up-behavior' import type { AgentSessionCancelResult } from '../../../../shared/agent-session-wire' import { structuredAgentLabel } from '@/lib/structured-agent-session-launch-label' import { useStructuredLegacyLaunchStop } from '@/lib/structured-agent-session-legacy-launch-stop' @@ -281,6 +284,14 @@ export function useStructuredAgentSession(args: StructuredAgentSessionViewArgs) capturePresentation, /** A plain send would queue: the host takes it, the setting or a waiting command asks, and no unanswerable prompt blocks it. */ sendsQueue: structuredAgentSessionSendQueues(queue), + /** Mid-turn on a host that queues: what Enter does, and whether Cmd/Ctrl+Enter would send differently. */ + ...(queueCapability === 'supported' && isWorking && !stopControl.stopping + ? { + sendFollowUp: nativeChatSendFollowUp((alternate) => + structuredAgentSessionSendQueues(queue, alternate) + ) + } + : {}), cancel: (turnId: string | undefined, prompt?: { itemId: string; expectedRevision: number }) => cancelStructuredAgentSessionPrompt(admit(), turnId, prompt), stopBackgroundTask: (taskId?: string) => diff --git a/src/renderer/src/i18n/locales/de.json b/src/renderer/src/i18n/locales/de.json index 5a297ca065eb..acee34ff4201 100644 --- a/src/renderer/src/i18n/locales/de.json +++ b/src/renderer/src/i18n/locales/de.json @@ -19080,6 +19080,10 @@ }, "composer": { "send": "Senden", + "queueMessage": "Nachricht einreihen", + "steerMessage": "Nachricht steuern", + "queueHint": "Für nach diesem Durchgang einreihen", + "steerHint": "In den laufenden Durchgang senden", "noPty": "Kein aktives Terminal — zurückwechseln, um die Verbindung wiederherzustellen.", "locked": "Die Eingabe wird von einem anderen Gerät gesteuert.", "placeholder": "Frage stellen, @ für Dateiverweise, / für Befehle", diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index 2911dcd413ec..6229cf11b3fe 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -19380,6 +19380,10 @@ }, "composer": { "send": "Send", + "queueMessage": "Queue message", + "steerMessage": "Steer message", + "queueHint": "Queue for after this turn", + "steerHint": "Send into the running turn", "noPty": "No live terminal — toggle back to reconnect.", "locked": "Input is held by another device.", "placeholder": "Ask anything, @ to mention files, / for commands", diff --git a/src/renderer/src/i18n/locales/es.json b/src/renderer/src/i18n/locales/es.json index 3b24d4faffa9..3583133dd976 100644 --- a/src/renderer/src/i18n/locales/es.json +++ b/src/renderer/src/i18n/locales/es.json @@ -18960,6 +18960,10 @@ "composer": { "imageUnavailable": "Vista previa no disponible", "send": "Enviar", + "queueMessage": "Poner mensaje en cola", + "steerMessage": "Enviar mensaje ahora", + "queueHint": "Poner en cola para después de este turno", + "steerHint": "Enviar al turno en curso", "noPty": "No hay terminal activa: vuelva a alternar para volver a conectarse.", "locked": "La entrada está retenida por otro dispositivo.", "placeholder": "Pregunta lo que quieras, @ para referenciar archivos, / para comandos", diff --git a/src/renderer/src/i18n/locales/fr.json b/src/renderer/src/i18n/locales/fr.json index 4bfb7db6d719..06299c4527e1 100644 --- a/src/renderer/src/i18n/locales/fr.json +++ b/src/renderer/src/i18n/locales/fr.json @@ -19180,6 +19180,10 @@ "composer": { "imageUnavailable": "Aperçu indisponible", "send": "Envoyer", + "queueMessage": "Mettre le message en file d’attente", + "steerMessage": "Envoyer le message maintenant", + "queueHint": "Mettre en file d’attente pour après ce tour", + "steerHint": "Envoyer dans le tour en cours", "noPty": "Aucun terminal actif — rebasculez pour vous reconnecter.", "locked": "La saisie est détenue par un autre appareil.", "placeholder": "Posez votre question, @ pour référencer des fichiers, / pour les commandes", diff --git a/src/renderer/src/i18n/locales/ja.json b/src/renderer/src/i18n/locales/ja.json index 9f4af9a2570f..2dcfa6b62b7a 100644 --- a/src/renderer/src/i18n/locales/ja.json +++ b/src/renderer/src/i18n/locales/ja.json @@ -18516,6 +18516,10 @@ }, "composer": { "send": "送信", + "queueMessage": "メッセージをキューに入れる", + "steerMessage": "メッセージを今すぐ送信", + "queueHint": "このターンの後に実行するようキューに入れる", + "steerHint": "実行中のターンに送信", "noPty": "ライブターミナルがありません - 再接続するには元に切り替えてください。", "locked": "入力は別のデバイスによって保持されます。", "placeholder": "何でも聞いてください。@ でファイルを参照、/ でコマンドを実行", diff --git a/src/renderer/src/i18n/locales/ko.json b/src/renderer/src/i18n/locales/ko.json index f6eae81c1db3..6d94ef28b65d 100644 --- a/src/renderer/src/i18n/locales/ko.json +++ b/src/renderer/src/i18n/locales/ko.json @@ -18516,6 +18516,10 @@ }, "composer": { "send": "보내기", + "queueMessage": "메시지를 대기열에 추가", + "steerMessage": "메시지 지금 보내기", + "queueHint": "이 턴이 끝난 뒤 실행하도록 대기열에 추가", + "steerHint": "진행 중인 턴에 보내기", "noPty": "라이브 terminal이 없습니다. 다시 연결하려면 다시 전환하세요.", "locked": "입력이 다른 장치에 의해 보류됩니다.", "placeholder": "무엇이든 물어보세요. @로 파일 참조, /로 명령어 실행", diff --git a/src/renderer/src/i18n/locales/pt.json b/src/renderer/src/i18n/locales/pt.json index fff679df188b..b7acc139b6c4 100644 --- a/src/renderer/src/i18n/locales/pt.json +++ b/src/renderer/src/i18n/locales/pt.json @@ -19853,6 +19853,10 @@ }, "composer": { "send": "Enviar", + "queueMessage": "Colocar mensagem na fila", + "steerMessage": "Orientar mensagem", + "queueHint": "Colocar na fila para depois deste turno", + "steerHint": "Enviar ao turno em andamento", "noPty": "Nenhum terminal ativo — alterne de volta para reconectar.", "locked": "A entrada está retida por outro dispositivo.", "placeholder": "Enviar uma mensagem…", diff --git a/src/renderer/src/i18n/locales/ru.json b/src/renderer/src/i18n/locales/ru.json index 9c452169fff0..b853926b6c57 100644 --- a/src/renderer/src/i18n/locales/ru.json +++ b/src/renderer/src/i18n/locales/ru.json @@ -19659,6 +19659,10 @@ }, "composer": { "send": "Отправить", + "queueMessage": "Поставить сообщение в очередь", + "steerMessage": "Отправить сообщение сейчас", + "queueHint": "Поставить в очередь до конца этого хода", + "steerHint": "Отправить в текущий ход", "noPty": "Терминал отключён. Вернитесь в него, чтобы подключиться снова.", "locked": "Вводом управляет другое устройство.", "placeholder": "Задайте вопрос; @ — файлы, / — команды", diff --git a/src/renderer/src/i18n/locales/tr.json b/src/renderer/src/i18n/locales/tr.json index e719caf0f14f..691473966c4b 100644 --- a/src/renderer/src/i18n/locales/tr.json +++ b/src/renderer/src/i18n/locales/tr.json @@ -19067,6 +19067,10 @@ }, "composer": { "send": "Gönder", + "queueMessage": "Mesajı sıraya al", + "steerMessage": "Mesajı yönlendir", + "queueHint": "Bu turdan sonrası için sıraya al", + "steerHint": "Çalışan tura gönder", "noPty": "Canlı terminal yok, yeniden bağlanmak için geri geçin.", "locked": "Giriş başka bir cihaz tarafından tutuluyor.", "placeholder": "Bir şey sorun; dosyalara başvurmak için @, komutlar için / kullanın", diff --git a/src/renderer/src/i18n/locales/zh-Hant.json b/src/renderer/src/i18n/locales/zh-Hant.json index cf8d3f0e20cb..f1a6d331ae25 100644 --- a/src/renderer/src/i18n/locales/zh-Hant.json +++ b/src/renderer/src/i18n/locales/zh-Hant.json @@ -18821,6 +18821,10 @@ }, "composer": { "send": "傳送", + "queueMessage": "將訊息加入佇列", + "steerMessage": "引導訊息", + "queueHint": "加入佇列,於此回合結束後執行", + "steerHint": "傳送到正在進行的回合", "noPty": "沒有作用中的終端機,請切回終端機以重新連線。", "locked": "輸入正被另一台裝置佔用。", "placeholder": "隨心輸入,@ 引用檔案,/ 使用命令", diff --git a/src/renderer/src/i18n/locales/zh.json b/src/renderer/src/i18n/locales/zh.json index f25611afc750..247f3c5c4d91 100644 --- a/src/renderer/src/i18n/locales/zh.json +++ b/src/renderer/src/i18n/locales/zh.json @@ -18482,6 +18482,10 @@ }, "composer": { "send": "发送", + "queueMessage": "将消息加入队列", + "steerMessage": "立即发送消息", + "queueHint": "加入队列,在此回合结束后运行", + "steerHint": "发送到正在进行的回合", "noPty": "没有实时终端,请切回终端以重新连接。", "locked": "输入正被另一台设备占用。", "placeholder": "随心输入,@ 引用文件,/ 使用命令", diff --git a/src/shared/native-chat-follow-up-behavior.ts b/src/shared/native-chat-follow-up-behavior.ts index e8e146f3b722..056f2039c399 100644 --- a/src/shared/native-chat-follow-up-behavior.ts +++ b/src/shared/native-chat-follow-up-behavior.ts @@ -6,3 +6,14 @@ export function nativeChatQueueFollowUps( ): boolean { return settings?.nativeChatQueueFollowUps !== false } + +/** While the agent works on a host that queues: what a plain send does, and whether its alternate would send any differently. */ +export type NativeChatSendFollowUp = { action: NativeChatFollowUpBehavior; offersChoice: boolean } + +/** Read from the send's own resolver, so a waiting command or unanswerable prompts that override the choice also withdraw it. */ +export function nativeChatSendFollowUp( + sendQueues: (alternate?: true) => boolean +): NativeChatSendFollowUp { + const queues = sendQueues() + return { action: queues ? 'queue' : 'steer', offersChoice: queues !== sendQueues(true) } +} From 5ca22989fce388e36d4c12151cb36455cdd46274 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Fri, 30 Oct 2026 22:29:07 -0700 Subject: [PATCH 16/27] Test the send keys and Queue follow-ups search against real wiring One desktop test drives Enter and Cmd+Enter through the real composer, transport and session to the outgoing send and checks its delivery with queueing on and off. Settings search is checked against the capability list this build's host advertises. --- ...ve-chat-structured-alternate-send.test.tsx | 168 ++++++++++++++++++ ...vigationMetadata.capability-owner.test.tsx | 26 +++ 2 files changed, 194 insertions(+) create mode 100644 src/renderer/src/components/native-chat/native-chat-structured-alternate-send.test.tsx diff --git a/src/renderer/src/components/native-chat/native-chat-structured-alternate-send.test.tsx b/src/renderer/src/components/native-chat/native-chat-structured-alternate-send.test.tsx new file mode 100644 index 000000000000..a87b213a8fb2 --- /dev/null +++ b/src/renderer/src/components/native-chat/native-chat-structured-alternate-send.test.tsx @@ -0,0 +1,168 @@ +// @vitest-environment happy-dom + +// Enter and Cmd/Ctrl+Enter reach the outgoing agentSession.send through the real composer, transport and session. + +import { act, cleanup, fireEvent, render, screen } from '@testing-library/react' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import type { AgentJournalRenderItem } from '../../../../shared/agent-session-journal-types' + +const mocks = vi.hoisted(() => ({ call: vi.fn() })) + +vi.mock('@/runtime/structured-agent-session-client', () => ({ + subscribeStructuredAgentSessionStatus: vi.fn(async () => ({ unsubscribe: vi.fn() })), + callStructuredAgentSession: mocks.call, + supportsStructuredAgentSessionPromptCancel: vi.fn(async () => false) +})) + +const RUNNING_TURN: AgentJournalRenderItem = { + itemId: 'turn-1', + revision: 1, + sequence: 1, + observedAt: 1, + body: { kind: 'turn', turnId: 'provider-turn', state: 'running' } +} + +vi.mock('./use-structured-agent-session-read', () => ({ + useStructuredAgentSessionRead: () => ({ + state: { + fence: 3, + items: [RUNNING_TURN], + submissions: [], + status: 'ready', + error: null, + hasOlder: false, + queuedMessages: [], + nextQueuedMessageId: null + }, + loadingOlder: false, + loadOlder: vi.fn() + }) +})) +vi.mock('./native-chat-shortcut', async (importOriginal) => ({ + ...(await importOriginal()), + isMacPlatform: () => true +})) +vi.mock('./use-native-chat-skills', () => ({ + useNativeChatSkills: () => ({ status: 'ready', skills: [], error: null, retry: () => {} }) +})) + +import { + AGENT_SESSION_CONVERSATION_STOP_RUNTIME_CAPABILITY, + AGENT_SESSION_QUEUED_MESSAGES_RUNTIME_CAPABILITY +} from '../../../../shared/protocol-version' +import { setLocalRuntimeCapabilitiesForTests } from '@/runtime/local-runtime-capabilities' +import { TooltipProvider } from '@/components/ui/tooltip' +import { NativeChatComposer } from './NativeChatComposer' +import { useStructuredAgentSession } from './use-structured-agent-session' +import { useNativeChatStructuredComposerTransport } from './use-native-chat-structured-composer-transport' +import { nativeChatStructuredStopControls } from './native-chat-structured-stop-controls' +import { changePrompt } from './native-chat-prompt-editor.test-support' + +function Chat({ queueFollowUps }: { queueFollowUps: boolean }): React.JSX.Element { + const props = { agent: 'claude', sessionId: 'session-1', target: { kind: 'local' } } as const + const controller = useStructuredAgentSession({ + ...props, + isVisible: true, + composerScopeKey: `alternate-send-${queueFollowUps}`, + queueFollowUps + }) + const transport = useNativeChatStructuredComposerTransport({ + props, + controller, + sendThroughLaunch: (_text, _withImages, send) => send(), + starting: false, + transportEnabled: true, + worktreeId: undefined, + optionPickerRequest: null, + setOptionPickerRequest: () => {}, + onError: vi.fn(), + onSubmitted: () => {} + }) + return ( + + ) +} + +function sends(): Record[] { + return mocks.call.mock.calls + .filter(([, method]) => method === 'agentSession.send') + .map(([, , params]) => params) +} + +async function type(text: string, key: { metaKey?: boolean } = {}): Promise { + const input = screen.getByRole('textbox') + changePrompt(input, text) + await act(async () => { + fireEvent.keyDown(input, { key: 'Enter', keyCode: 13, isComposing: false, ...key }) + }) +} + +beforeEach(() => { + mocks.call.mockReset() + mocks.call.mockImplementation(async (_target, method) => + method === 'agentSession.send' + ? { + ok: true, + replayed: false, + fence: 3, + cursor: { epoch: 'e', sequence: 2 }, + value: { + clientMessageId: 'c', + submission: { + clientMessageId: 'c', + fence: 3, + payloadFingerprint: 'fingerprint', + dispatchState: 'accepted', + providerItemId: null, + reason: null, + submittedAt: 10, + resolvedAt: 10 + } + } + } + : null + ) + setLocalRuntimeCapabilitiesForTests([ + AGENT_SESSION_CONVERSATION_STOP_RUNTIME_CAPABILITY, + AGENT_SESSION_QUEUED_MESSAGES_RUNTIME_CAPABILITY + ]) +}) + +afterEach(() => { + cleanup() + setLocalRuntimeCapabilitiesForTests(null) +}) + +describe('mid-turn send keys on a host that queues', () => { + it.each([ + { queueFollowUps: true, enter: 'queue-if-active', alternate: undefined }, + { queueFollowUps: false, enter: undefined, alternate: 'queue-if-active' } + ])( + 'with queueing $queueFollowUps, Enter and Cmd+Enter reach the host the opposite ways', + async ({ queueFollowUps, enter, alternate }) => { + render( + + + + ) + // The control beside Stop says what Enter does once there is something to send. + expect(screen.queryByRole('button', { name: /^(Queue|Steer) message$/ })).toBeNull() + changePrompt(screen.getByRole('textbox'), 'draft') + expect( + screen.getByRole('button', { name: queueFollowUps ? 'Queue message' : 'Steer message' }) + ).toBeTruthy() + + await type('by enter') + await type('by cmd enter', { metaKey: true }) + expect(sends().map((params) => params.delivery)).toEqual([enter, alternate]) + } + ) +}) diff --git a/src/renderer/src/hooks/useSettingsNavigationMetadata.capability-owner.test.tsx b/src/renderer/src/hooks/useSettingsNavigationMetadata.capability-owner.test.tsx index 4be7dff1a38c..ad33f7af7d9e 100644 --- a/src/renderer/src/hooks/useSettingsNavigationMetadata.capability-owner.test.tsx +++ b/src/renderer/src/hooks/useSettingsNavigationMetadata.capability-owner.test.tsx @@ -10,6 +10,7 @@ import type { RuntimeEnvironmentStatus } from '@/store/slices/runtime-status-typ import type { Repo } from '../../../shared/repo-types' import { resetWindowsTerminalCapabilitiesForTests } from '@/lib/windows-terminal-capabilities' import { setLocalRuntimeCapabilitiesForTests } from '@/runtime/local-runtime-capabilities' +import { AGENT_SESSION_RUNTIME_CAPABILITIES } from '../../../shared/agent-session-runtime-capabilities' const testState = vi.hoisted(() => ({ settings: null as GlobalSettings | null, @@ -143,4 +144,29 @@ describe('settings navigation capability ownership', () => { expect(runtimeGetStatus).toHaveBeenCalledTimes(2) expect(runtimeEnvironmentCall).not.toHaveBeenCalled() }) + + it.each([ + { name: 'advertises', capabilities: AGENT_SESSION_RUNTIME_CAPABILITIES, found: true }, + { name: 'does not advertise', capabilities: [], found: false } + ])('finds Queue follow-ups in search only when this host $name queueing', async (args) => { + setLocalRuntimeCapabilitiesForTests([...args.capabilities]) + Object.defineProperty(window, 'api', { + configurable: true, + value: { + wsl: { isAvailable: vi.fn().mockResolvedValue(false), listDistros: vi.fn() }, + pwsh: { isAvailable: vi.fn().mockResolvedValue(false) }, + gitBash: { isAvailable: vi.fn().mockResolvedValue(false) }, + runtime: { getStatus: vi.fn().mockResolvedValue({ hostPlatform: 'darwin' }) }, + runtimeEnvironments: { call: vi.fn() } + } as unknown as Window['api'] + }) + await act(async () => { + root.render(createElement(Probe)) + await Promise.resolve() + }) + const chat = testState.sections?.find((section) => section.id === 'chat') + expect( + chat?.searchEntries.some((entry) => entry.targetSectionId === 'chat-queue-follow-ups') + ).toBe(args.found) + }) }) From 6099958f8b96f7ac6fa73b1b496fefdcf9c0a9ff Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Fri, 30 Oct 2026 22:46:55 -0700 Subject: [PATCH 17/27] Move the composer's send-hold check into its own helper The pane had grown past the file length limit after the main merge. --- .../native-chat/NativeChatComposerPane.tsx | 15 +++++-------- .../native-chat-composer-send-hold.ts | 22 +++++++++++++++++++ 2 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 src/renderer/src/components/native-chat/native-chat-composer-send-hold.ts diff --git a/src/renderer/src/components/native-chat/NativeChatComposerPane.tsx b/src/renderer/src/components/native-chat/NativeChatComposerPane.tsx index 3e0a6ccd8a49..10f20d37ccd1 100644 --- a/src/renderer/src/components/native-chat/NativeChatComposerPane.tsx +++ b/src/renderer/src/components/native-chat/NativeChatComposerPane.tsx @@ -11,7 +11,7 @@ import { useNativeChatComposerRecall } from './use-native-chat-composer-recall' import { useNativeChatLaunchDraftAdoption } from './use-native-chat-launch-draft-adoption' import { NativeChatComposerField } from './NativeChatComposerField' import { useNativeChatComposerAttachments } from './use-native-chat-composer-attachments' -import { nativeChatImageSendBlock } from './native-chat-image-reattach' +import { nativeChatComposerSendHold } from './native-chat-composer-send-hold' import { useNativeChatComposerHandle } from './use-native-chat-composer-handle' import { useNativeChatFileDrops } from './use-native-chat-file-drops' import { useNativeChatComposerKeyDown } from './use-native-chat-composer-keydown' @@ -161,14 +161,11 @@ export const NativeChatComposerPane = forwardRef Date: Fri, 30 Oct 2026 22:47:18 -0700 Subject: [PATCH 18/27] Disable the mid-turn Queue/Steer button whenever Send would be disabled While an image is still loading, another device holds the input, or a send is blocked for a stated reason, the button beside Stop is now disabled and says why, the same way the idle Send button does. Before, it stayed clickable and a click did nothing. --- .../NativeChatComposerActions.test.tsx | 10 +- .../native-chat/NativeChatComposerActions.tsx | 93 ++++++++++++------- .../native-chat/NativeChatComposerField.tsx | 9 +- .../native-chat/NativeChatComposerPane.tsx | 1 + ...ve-chat-structured-alternate-send.test.tsx | 46 ++++++++- ...nt-session-draft-position.test-fixture.tsx | 1 + 6 files changed, 121 insertions(+), 39 deletions(-) diff --git a/src/renderer/src/components/native-chat/NativeChatComposerActions.test.tsx b/src/renderer/src/components/native-chat/NativeChatComposerActions.test.tsx index 97f7c0400923..57ed3f485e7d 100644 --- a/src/renderer/src/components/native-chat/NativeChatComposerActions.test.tsx +++ b/src/renderer/src/components/native-chat/NativeChatComposerActions.test.tsx @@ -128,7 +128,10 @@ describe('NativeChatComposerActions', () => { ).toEqual(['Attach file', 'Start dictation', 'Stop the agent']) rerender( - + ) fireEvent.click(screen.getByRole('button', { name: 'Queue message' })) expect(onSend).toHaveBeenCalledExactlyOnceWith() @@ -138,7 +141,10 @@ describe('NativeChatComposerActions', () => { expect(container.textContent).toContain('Send into the running turn⌘+⏎') rerender( - + ) expect(screen.getByRole('button', { name: 'Steer message' })).toBeTruthy() expect(container.textContent).toContain('Send into the running turn⏎') diff --git a/src/renderer/src/components/native-chat/NativeChatComposerActions.tsx b/src/renderer/src/components/native-chat/NativeChatComposerActions.tsx index f5a9ea5a79e8..09ec03cd54b1 100644 --- a/src/renderer/src/components/native-chat/NativeChatComposerActions.tsx +++ b/src/renderer/src/components/native-chat/NativeChatComposerActions.tsx @@ -21,6 +21,9 @@ import type { } from '../../../../shared/native-chat-follow-up-behavior' import { isMacPlatform } from './native-chat-shortcut' +/** `held`: the idle Send would be disabled here, so this control is too, with the same reason. */ +export type NativeChatComposerFollowUp = NativeChatSendFollowUp & { held: boolean } + export type NativeChatComposerActionsProps = { editSession?: { cancel: () => void } attachDisabled: boolean @@ -34,7 +37,7 @@ export type NativeChatComposerActionsProps = { /** This client's Stop request is in flight: the Stop control is disabled and says so. */ isStopping?: boolean /** Mid-turn: a send control beside Stop, so the user sees what Enter does. */ - followUp?: NativeChatSendFollowUp + followUp?: NativeChatComposerFollowUp isDictating: boolean isDictationHoldMode: boolean onAttach: () => void @@ -221,21 +224,13 @@ export const NativeChatComposerActions = memo(function NativeChatComposerActions ) : null} {followUp && stops && !editSession ? ( - + ) : null} - {sendReason ? ( - - - {/* A disabled button gets no pointer events, so the wrapper carries the hover. */} - {sendButton} - - - {sendReason} - - - ) : ( - sendButton - )} + {sendButton} ) @@ -246,9 +241,11 @@ const FOLLOW_UP_ICON = { queue: ListEnd, steer: CornerDownRight } as const /** Sends exactly as Enter does; its tooltip names Enter and, when it would differ, Cmd/Ctrl+Enter. */ function NativeChatFollowUpSendButton({ followUp, + reason, onSend }: { - followUp: NativeChatSendFollowUp + followUp: NativeChatComposerFollowUp + reason: string | null onSend: () => void }): React.JSX.Element { const label = { @@ -262,25 +259,31 @@ function NativeChatFollowUpSendButton({ const alternate: NativeChatFollowUpBehavior = followUp.action === 'queue' ? 'steer' : 'queue' const isMac = isMacPlatform() const Icon = FOLLOW_UP_ICON[followUp.action] + const button = ( + + ) + // Held, it reads as the idle Send does: the reason when there is one, otherwise nothing. + if (followUp.held) { + return {button} + } return ( - - - + {button} @@ -299,6 +302,30 @@ function NativeChatFollowUpSendButton({ ) } +/** A disabled send control that says why, when the user can do something about it. */ +function HeldSendReason({ + reason, + children +}: { + reason: string | null + children: React.JSX.Element +}): React.JSX.Element { + if (!reason) { + return children + } + return ( + + + {/* A disabled button gets no pointer events, so the wrapper carries the hover. */} + {children} + + + {reason} + + + ) +} + function DraftNotSavedIcon({ shown }: { shown: boolean }): React.JSX.Element | null { if (!shown) { return null diff --git a/src/renderer/src/components/native-chat/NativeChatComposerField.tsx b/src/renderer/src/components/native-chat/NativeChatComposerField.tsx index afb3dc7cf60c..9e936083250b 100644 --- a/src/renderer/src/components/native-chat/NativeChatComposerField.tsx +++ b/src/renderer/src/components/native-chat/NativeChatComposerField.tsx @@ -54,6 +54,8 @@ export type NativeChatComposerFieldProps = { /** The paired server a structured chat runs on, which reads back files stored there. */ attachmentEnvironmentId?: string sendButtonDisabled: boolean + /** No send can leave this device now; mid-turn this disables the follow-up control as it does Send. */ + sendHeld: boolean /** Why the send button is disabled, when the user can do something about it. */ sendBlockedReason?: string | null isWorking: boolean @@ -142,6 +144,7 @@ export function NativeChatComposerField({ numberImages = false, attachmentEnvironmentId, sendButtonDisabled, + sendHeld, sendBlockedReason, isWorking, isStopping = false, @@ -185,8 +188,10 @@ export function NativeChatComposerField({ // Keyed on its parts: a fresh object each keystroke would re-render the memoized actions. const followUp = useMemo( () => - followUpAction ? { action: followUpAction, offersChoice: followUpOffersChoice } : undefined, - [followUpAction, followUpOffersChoice] + followUpAction + ? { action: followUpAction, offersChoice: followUpOffersChoice, held: sendHeld } + : undefined, + [followUpAction, followUpOffersChoice, sendHeld] ) const optionCount = autocomplete.mode === 'slash' diff --git a/src/renderer/src/components/native-chat/NativeChatComposerPane.tsx b/src/renderer/src/components/native-chat/NativeChatComposerPane.tsx index 10f20d37ccd1..5f713eb6b8e1 100644 --- a/src/renderer/src/components/native-chat/NativeChatComposerPane.tsx +++ b/src/renderer/src/components/native-chat/NativeChatComposerPane.tsx @@ -381,6 +381,7 @@ export const NativeChatComposerPane = forwardRef +}): React.JSX.Element { const props = { agent: 'claude', sessionId: 'session-1', target: { kind: 'local' } } as const const controller = useStructuredAgentSession({ ...props, @@ -86,7 +95,8 @@ function Chat({ queueFollowUps }: { queueFollowUps: boolean }): React.JSX.Elemen targetPtyId={null} agent="claude" {...nativeChatStructuredStopControls(controller, false).composer} - structuredTransport={transport} + canSend={canSend} + structuredTransport={{ ...transport, ...overrides }} /> ) } @@ -165,4 +175,36 @@ describe('mid-turn send keys on a host that queues', () => { expect(sends().map((params) => params.delivery)).toEqual([enter, alternate]) } ) + + it('disables the control beside Stop wherever the idle Send would be, with the same reason', async () => { + const view = render( + + + + ) + changePrompt(screen.getByRole('textbox'), 'draft') + expect(screen.getByRole('button', { name: 'Queue message' }).hasAttribute('disabled')).toBe( + false + ) + + // Another device holds the input: disabled, and like Send it gives no reason. + view.rerender( + + + + ) + expect(screen.getByRole('button', { name: 'Queue message' }).hasAttribute('disabled')).toBe( + true + ) + + view.rerender( + + + + ) + const held = screen.getByRole('button', { name: 'Reconnect to send.' }) + expect(held.hasAttribute('disabled')).toBe(true) + fireEvent.click(held) + expect(sends()).toEqual([]) + }) }) diff --git a/src/renderer/src/lib/agent-session/structured-agent-session-draft-position.test-fixture.tsx b/src/renderer/src/lib/agent-session/structured-agent-session-draft-position.test-fixture.tsx index 1dcc5b313575..4fbec90767a0 100644 --- a/src/renderer/src/lib/agent-session/structured-agent-session-draft-position.test-fixture.tsx +++ b/src/renderer/src/lib/agent-session/structured-agent-session-draft-position.test-fixture.tsx @@ -147,6 +147,7 @@ export function PositionField({ notices: [], imageAttachments: [], sendButtonDisabled: true, + sendHeld: true, isWorking: false, attachDisabled: true, dictationDisabled: true, From 51c214c3e58c3ef5e9c5d7b7ec4d88d1c988783f Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Fri, 30 Oct 2026 22:47:28 -0700 Subject: [PATCH 19/27] Hide the mid-turn Queue/Steer button in goal mode In goal mode Enter sets the goal, so a button promising to queue or steer the message was wrong. It is now hidden there, as it already is while editing a queued message. --- .../native-chat/NativeChatComposerField.tsx | 9 +++++++-- ...ve-chat-structured-alternate-send.test.tsx | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/components/native-chat/NativeChatComposerField.tsx b/src/renderer/src/components/native-chat/NativeChatComposerField.tsx index 9e936083250b..4a72cf76dd6b 100644 --- a/src/renderer/src/components/native-chat/NativeChatComposerField.tsx +++ b/src/renderer/src/components/native-chat/NativeChatComposerField.tsx @@ -179,9 +179,14 @@ export function NativeChatComposerField({ agent }: NativeChatComposerFieldProps): React.JSX.Element { const draftNotSaved = useNativeChatComposerDraftUnsaved(draftScopeKey) - // Mid-turn with something to send, a control beside Stop says what Enter does; never while Stopping. + // Mid-turn with something to send, a control beside Stop says what Enter does; never while + // Stopping, nor in goal mode, where Enter sets the goal. const followUpAction = - !editSession && isWorking && !afterStop && (draft.trim() !== '' || imageAttachments.length > 0) + !editSession && + !goalMode?.active && + isWorking && + !afterStop && + (draft.trim() !== '' || imageAttachments.length > 0) ? sendFollowUp?.action : undefined const followUpOffersChoice = sendFollowUp?.offersChoice === true diff --git a/src/renderer/src/components/native-chat/native-chat-structured-alternate-send.test.tsx b/src/renderer/src/components/native-chat/native-chat-structured-alternate-send.test.tsx index 2cc0983e095d..40b48d1f6b5d 100644 --- a/src/renderer/src/components/native-chat/native-chat-structured-alternate-send.test.tsx +++ b/src/renderer/src/components/native-chat/native-chat-structured-alternate-send.test.tsx @@ -207,4 +207,23 @@ describe('mid-turn send keys on a host that queues', () => { fireEvent.click(held) expect(sends()).toEqual([]) }) + + it('shows no Queue or Steer control in goal mode, where Enter sets the goal', async () => { + const setObjective = vi.fn(async () => true) + render( + + + + ) + await type('/goal') + changePrompt(screen.getByRole('textbox'), 'ship the fix') + expect(screen.queryByRole('button', { name: /^(Queue|Steer) message$/ })).toBeNull() + expect(screen.getByRole('button', { name: 'Stop the agent' })).toBeTruthy() + + await act(async () => { + fireEvent.keyDown(screen.getByRole('textbox'), { key: 'Enter', keyCode: 13 }) + }) + expect(setObjective).toHaveBeenCalledExactlyOnceWith('ship the fix') + expect(sends()).toEqual([]) + }) }) From 5f4f964fb5237097da7df0554aeb468aff217039 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Fri, 30 Oct 2026 22:47:30 -0700 Subject: [PATCH 20/27] Fix the Russian queue hint to say the message runs after this turn It read as queueing until the end of this turn. --- src/renderer/src/i18n/locales/ru.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/src/i18n/locales/ru.json b/src/renderer/src/i18n/locales/ru.json index b853926b6c57..0c6dbad86523 100644 --- a/src/renderer/src/i18n/locales/ru.json +++ b/src/renderer/src/i18n/locales/ru.json @@ -19661,7 +19661,7 @@ "send": "Отправить", "queueMessage": "Поставить сообщение в очередь", "steerMessage": "Отправить сообщение сейчас", - "queueHint": "Поставить в очередь до конца этого хода", + "queueHint": "Поставить в очередь: выполнится после этого хода", "steerHint": "Отправить в текущий ход", "noPty": "Терминал отключён. Вернитесь в него, чтобы подключиться снова.", "locked": "Вводом управляет другое устройство.", From be27d1549b0e2ea9a95bd1e894b549d384257343 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Fri, 30 Oct 2026 22:56:38 -0700 Subject: [PATCH 21/27] Stub window.api without a type assertion in the Queue follow-ups settings search test --- .../useSettingsNavigationMetadata.capability-owner.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/src/hooks/useSettingsNavigationMetadata.capability-owner.test.tsx b/src/renderer/src/hooks/useSettingsNavigationMetadata.capability-owner.test.tsx index ad33f7af7d9e..8797d249e313 100644 --- a/src/renderer/src/hooks/useSettingsNavigationMetadata.capability-owner.test.tsx +++ b/src/renderer/src/hooks/useSettingsNavigationMetadata.capability-owner.test.tsx @@ -158,7 +158,7 @@ describe('settings navigation capability ownership', () => { gitBash: { isAvailable: vi.fn().mockResolvedValue(false) }, runtime: { getStatus: vi.fn().mockResolvedValue({ hostPlatform: 'darwin' }) }, runtimeEnvironments: { call: vi.fn() } - } as unknown as Window['api'] + } }) await act(async () => { root.render(createElement(Probe)) From df44a46670c07446ad93d94d2ca5fbc904c0482c Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Fri, 30 Oct 2026 23:03:18 -0700 Subject: [PATCH 22/27] Pass sendHeld to the composer field in tests and drop an unknown setting from the German Queue test --- .../native-chat/native-chat-composer-composition.test.tsx | 1 + .../native-chat/native-chat-composer-ime-file-drop.test.tsx | 1 + .../native-chat/native-chat-composer-mobile-hold.test.tsx | 1 + .../native-chat-composer-workspace-file-drop.test.tsx | 1 + .../src/components/settings/ChatBehaviorSetting.test.tsx | 2 +- 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/components/native-chat/native-chat-composer-composition.test.tsx b/src/renderer/src/components/native-chat/native-chat-composer-composition.test.tsx index f0aaf381f0a1..7161947b152a 100644 --- a/src/renderer/src/components/native-chat/native-chat-composer-composition.test.tsx +++ b/src/renderer/src/components/native-chat/native-chat-composer-composition.test.tsx @@ -79,6 +79,7 @@ function fieldProps(overrides: Partial = {}): TestFieldProps { notices: [], imageAttachments: [], sendButtonDisabled: false, + sendHeld: false, isWorking: false, attachDisabled: false, dictationDisabled: false, diff --git a/src/renderer/src/components/native-chat/native-chat-composer-ime-file-drop.test.tsx b/src/renderer/src/components/native-chat/native-chat-composer-ime-file-drop.test.tsx index 02ff00442d9c..d6b1c1f158ce 100644 --- a/src/renderer/src/components/native-chat/native-chat-composer-ime-file-drop.test.tsx +++ b/src/renderer/src/components/native-chat/native-chat-composer-ime-file-drop.test.tsx @@ -162,6 +162,7 @@ function ComposerProbe({ notices={notices} imageAttachments={attachments.imageAttachments} sendButtonDisabled={false} + sendHeld={false} isWorking={false} attachDisabled={disabled} dictationDisabled diff --git a/src/renderer/src/components/native-chat/native-chat-composer-mobile-hold.test.tsx b/src/renderer/src/components/native-chat/native-chat-composer-mobile-hold.test.tsx index 7a5a9f486219..bde74f64ab93 100644 --- a/src/renderer/src/components/native-chat/native-chat-composer-mobile-hold.test.tsx +++ b/src/renderer/src/components/native-chat/native-chat-composer-mobile-hold.test.tsx @@ -75,6 +75,7 @@ function HeldField({ notices={notices} imageAttachments={[]} sendButtonDisabled + sendHeld={false} isWorking={false} attachDisabled dictationDisabled diff --git a/src/renderer/src/components/native-chat/native-chat-composer-workspace-file-drop.test.tsx b/src/renderer/src/components/native-chat/native-chat-composer-workspace-file-drop.test.tsx index 6416b2be73b1..86510948ce4d 100644 --- a/src/renderer/src/components/native-chat/native-chat-composer-workspace-file-drop.test.tsx +++ b/src/renderer/src/components/native-chat/native-chat-composer-workspace-file-drop.test.tsx @@ -160,6 +160,7 @@ function ComposerProbe({ notices={notice ? [{ key: 'composer', kind: 'attachment', text: notice }] : []} imageAttachments={attachments.imageAttachments} sendButtonDisabled={false} + sendHeld={false} isWorking={false} attachDisabled={disabled} dictationDisabled diff --git a/src/renderer/src/components/settings/ChatBehaviorSetting.test.tsx b/src/renderer/src/components/settings/ChatBehaviorSetting.test.tsx index db41af1681b5..df4b03e1f34a 100644 --- a/src/renderer/src/components/settings/ChatBehaviorSetting.test.tsx +++ b/src/renderer/src/components/settings/ChatBehaviorSetting.test.tsx @@ -189,7 +189,7 @@ it('renders the Queue switch and description using the German catalog', async () await i18n.changeLanguage('de') }) try { - const { container } = renderSetting({ experimentalNativeChat: true }) + const { container } = renderSetting({}) const copy = de.components.settings.nativeChat expect( container From 22cc9a039d3163c342742bc7e29409d98703af20 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Fri, 30 Oct 2026 23:18:49 -0700 Subject: [PATCH 23/27] Let Cmd-click (Ctrl-click elsewhere) on the mid-turn Queue/Steer button send the other way, like Cmd/Ctrl+Enter The button shows the other action while the modifier is held, and its tooltip names the click. Only when the other way would send differently; otherwise a modified click is a plain send. --- .../NativeChatComposerActions.test.tsx | 43 ++++++++++++++++ .../native-chat/NativeChatComposerActions.tsx | 50 +++++++++++++++---- .../native-chat/NativeChatComposerField.tsx | 7 ++- .../native-chat/use-platform-modifier-held.ts | 27 ++++++++++ src/renderer/src/i18n/locales/de.json | 1 + src/renderer/src/i18n/locales/en.json | 1 + src/renderer/src/i18n/locales/es.json | 1 + src/renderer/src/i18n/locales/fr.json | 1 + src/renderer/src/i18n/locales/ja.json | 1 + src/renderer/src/i18n/locales/ko.json | 1 + src/renderer/src/i18n/locales/pt.json | 1 + src/renderer/src/i18n/locales/ru.json | 1 + src/renderer/src/i18n/locales/tr.json | 1 + src/renderer/src/i18n/locales/zh-Hant.json | 1 + src/renderer/src/i18n/locales/zh.json | 1 + 15 files changed, 127 insertions(+), 11 deletions(-) create mode 100644 src/renderer/src/components/native-chat/use-platform-modifier-held.ts diff --git a/src/renderer/src/components/native-chat/NativeChatComposerActions.test.tsx b/src/renderer/src/components/native-chat/NativeChatComposerActions.test.tsx index 57ed3f485e7d..218455dba0bf 100644 --- a/src/renderer/src/components/native-chat/NativeChatComposerActions.test.tsx +++ b/src/renderer/src/components/native-chat/NativeChatComposerActions.test.tsx @@ -151,6 +151,49 @@ describe('NativeChatComposerActions', () => { expect(container.textContent).not.toContain('Queue for after this turn') }) + it('a Cmd-click on the follow-up control sends the other way, only when that differs', () => { + const onSend = vi.fn() + const props = { + attachDisabled: false, + dictationDisabled: false, + sendDisabled: false, + isWorking: true, + isDictating: false, + isDictationHoldMode: false, + onAttach: vi.fn(), + onDictationToggle: vi.fn(), + onDictationHoldStart: vi.fn(), + onDictationHoldEnd: vi.fn(), + onSend, + onStop: vi.fn(), + sessionOptionsSurface: null, + sessionOptionsSnapshot: [], + followUp: { action: 'queue' as const, offersChoice: true, held: false } + } + const { rerender, container } = render() + expect(container.textContent).toContain('Send into the running turn⌘+⏎/⌘+Click') + + fireEvent.click(screen.getByRole('button', { name: 'Queue message' })) + expect(onSend).toHaveBeenLastCalledWith() + // Holding the modifier shows what a click does now. + fireEvent.keyDown(window, { key: 'Meta', metaKey: true }) + fireEvent.click(screen.getByRole('button', { name: 'Steer message' }), { metaKey: true }) + expect(onSend).toHaveBeenLastCalledWith({ alternate: true }) + fireEvent.keyUp(window, { key: 'Meta', metaKey: false }) + expect(screen.getByRole('button', { name: 'Queue message' })).toBeTruthy() + + rerender( + + ) + fireEvent.keyDown(window, { key: 'Meta', metaKey: true }) + fireEvent.click(screen.getByRole('button', { name: 'Queue message' }), { metaKey: true }) + expect(onSend).toHaveBeenLastCalledWith() + expect(onSend).toHaveBeenCalledTimes(3) + }) + it('marks the streaming Stop control as the critical hit target', () => { render( void onDictationHoldStart: () => void onDictationHoldEnd: () => void - onSend: () => void + onSend: (intent?: NativeChatComposerSendIntent) => void onStop?: () => void sessionOptionsSurface: SessionOptionsSurface | null sessionOptionsSnapshot: SessionOptionDescriptor[] @@ -238,7 +240,7 @@ export const NativeChatComposerActions = memo(function NativeChatComposerActions const FOLLOW_UP_ICON = { queue: ListEnd, steer: CornerDownRight } as const -/** Sends exactly as Enter does; its tooltip names Enter and, when it would differ, Cmd/Ctrl+Enter. */ +/** A click sends as Enter does and, when it would differ, a Cmd/Ctrl-click as Cmd/Ctrl+Enter does. */ function NativeChatFollowUpSendButton({ followUp, reason, @@ -246,7 +248,7 @@ function NativeChatFollowUpSendButton({ }: { followUp: NativeChatComposerFollowUp reason: string | null - onSend: () => void + onSend: (intent?: NativeChatComposerSendIntent) => void }): React.JSX.Element { const label = { queue: translate('components.native-chat.composer.queueMessage', 'Queue message'), @@ -258,16 +260,26 @@ function NativeChatFollowUpSendButton({ } const alternate: NativeChatFollowUpBehavior = followUp.action === 'queue' ? 'steer' : 'queue' const isMac = isMacPlatform() - const Icon = FOLLOW_UP_ICON[followUp.action] + const offersChoice = followUp.offersChoice && !followUp.held + // While the modifier is held, the button shows what a click would do now. + const shown = usePlatformModifierHeld(offersChoice, isMac) ? alternate : followUp.action + const Icon = FOLLOW_UP_ICON[shown] + const click = translate('components.native-chat.composer.clickKey', 'Click') + const modifier = isMac ? '⌘' : 'Ctrl' const button = ( @@ -283,8 +285,8 @@ function NativeChatFollowUpSendButton({ onSend() } }} - size="icon" - className="size-8 rounded-full pointer-coarse:size-10" + size="icon-round" + className="pointer-coarse:size-10" > diff --git a/src/renderer/src/components/ui/button.tsx b/src/renderer/src/components/ui/button.tsx index bfcd65aa90e7..0d30cb7185b6 100644 --- a/src/renderer/src/components/ui/button.tsx +++ b/src/renderer/src/components/ui/button.tsx @@ -32,6 +32,8 @@ const buttonVariants = cva( 'icon-xs': "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3", 'icon-sm': 'size-8', 'icon-lg': 'size-10', + // The chat composer's Send, Stop and Queue/Steer buttons. + 'icon-round': 'size-8 rounded-full', chip: "h-4 gap-0.5 rounded px-0.5 text-[10px] leading-none has-[>svg]:px-0.5 [&_svg:not([class*='size-'])]:size-2.5" } }, From c6046b1b845c3383e037082675f3dc1a1f7265db Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Fri, 30 Oct 2026 23:33:43 -0700 Subject: [PATCH 25/27] Share one window key listener across every chat's Queue/Steer button, and count Cmd/Ctrl as held only from its own key press Each mounted chat with a mid-turn draft used to add its own window key listeners, so every keystroke did work per chat, hidden tabs included. One shared listener set now serves them all and wakes a button only when the held state really changes. Other keys can now only clear the held state, so a dictation paste that leaves the Cmd flag on later key events no longer flips the button with Cmd up. Also tests the Ctrl-click on Windows and Linux. --- .../NativeChatComposerActions.test.tsx | 37 +++++- .../use-platform-modifier-held.test.tsx | 98 ++++++++++++++++ .../native-chat/use-platform-modifier-held.ts | 107 ++++++++++++++---- 3 files changed, 219 insertions(+), 23 deletions(-) create mode 100644 src/renderer/src/components/native-chat/use-platform-modifier-held.test.tsx diff --git a/src/renderer/src/components/native-chat/NativeChatComposerActions.test.tsx b/src/renderer/src/components/native-chat/NativeChatComposerActions.test.tsx index 218455dba0bf..2f18219b0e93 100644 --- a/src/renderer/src/components/native-chat/NativeChatComposerActions.test.tsx +++ b/src/renderer/src/components/native-chat/NativeChatComposerActions.test.tsx @@ -36,7 +36,8 @@ vi.mock('@/components/ui/tooltip', () => ({ TooltipContent: ({ children }: { children: ReactNode }) =>
{children}
})) -vi.mock('./native-chat-shortcut', () => ({ isMacPlatform: () => true })) +const platform = vi.hoisted(() => ({ isMac: true })) +vi.mock('./native-chat-shortcut', () => ({ isMacPlatform: () => platform.isMac })) vi.mock('./NativeChatSessionOptionPickers', () => ({ NativeChatSessionOptionPickers: () =>
@@ -49,6 +50,7 @@ import { dispatchDictationControl } from '../dictation/dictation-control-events' afterEach(() => { cleanup() voice.dictationState = 'idle' + platform.isMac = true vi.clearAllMocks() }) @@ -194,6 +196,39 @@ describe('NativeChatComposerActions', () => { expect(onSend).toHaveBeenCalledTimes(3) }) + it('a Ctrl-click sends the other way off the Mac, and a Cmd-click there does not', () => { + platform.isMac = false + const onSend = vi.fn() + const { container } = render( + + ) + expect(container.textContent).toContain('Send into the running turnCtrl+Enter/Ctrl+Click') + + fireEvent.click(screen.getByRole('button', { name: 'Queue message' }), { metaKey: true }) + expect(onSend).toHaveBeenLastCalledWith() + fireEvent.keyDown(window, { key: 'Control', ctrlKey: true }) + fireEvent.click(screen.getByRole('button', { name: 'Steer message' }), { ctrlKey: true }) + expect(onSend).toHaveBeenLastCalledWith({ alternate: true }) + fireEvent.keyUp(window, { key: 'Control', ctrlKey: false }) + expect(screen.getByRole('button', { name: 'Queue message' })).toBeTruthy() + }) + it('marks the streaming Stop control as the critical hit target', () => { render( { + cleanup() + vi.restoreAllMocks() +}) + +const WATCHED = new Set(['keydown', 'keyup', 'paste', 'blur']) + +function mountConsumers(count: number, isMac = true) { + const renders = Array.from({ length: count }, () => 0) + const held = Array.from({ length: count }, () => false) + function Consumer({ index }: { index: number }) { + renders[index] += 1 + held[index] = usePlatformModifierHeld(true, isMac) + return null + } + render( + <> + {renders.map((_, index) => ( + + ))} + + ) + return { renders, held } +} + +describe('usePlatformModifierHeld', () => { + it.each([5, 50])( + 'shares one listener set across %i chats and renders only on a real modifier change', + (count) => { + const add = vi.spyOn(window, 'addEventListener') + const remove = vi.spyOn(window, 'removeEventListener') + const attached = (): number => + add.mock.calls.filter(([type]) => WATCHED.has(type)).length - + remove.mock.calls.filter(([type]) => WATCHED.has(type)).length + const { renders, held } = mountConsumers(count) + expect(attached()).toBe(4) + + const settled = [...renders] + act(() => { + fireEvent.keyDown(window, { key: 'a' }) + }) + act(() => { + fireEvent.keyUp(window, { key: 'a' }) + }) + act(() => { + fireEvent.keyDown(window, { key: 'Shift', shiftKey: true }) + }) + expect(renders).toEqual(settled) + + act(() => { + fireEvent.keyDown(window, { key: 'Meta', metaKey: true }) + }) + expect(renders).toEqual(settled.map((n) => n + 1)) + expect(held.every(Boolean)).toBe(true) + act(() => { + fireEvent.keyDown(window, { key: 'k', metaKey: true }) + }) + expect(renders).toEqual(settled.map((n) => n + 1)) + + cleanup() + expect(attached()).toBe(0) + } + ) + + it('counts the modifier as held only from its own keydown', () => { + const { held } = mountConsumers(1) + // A dictation paste can leave metaKey set on later key events with Cmd up. + fireEvent.paste(window) + fireEvent.keyDown(window, { key: 'a', metaKey: true }) + expect(held[0]).toBe(false) + + fireEvent.keyDown(window, { key: 'Meta', metaKey: true }) + expect(held[0]).toBe(true) + // A keyup another handler swallowed still clears on the next key. + fireEvent.keyDown(window, { key: 'a', metaKey: false }) + expect(held[0]).toBe(false) + + fireEvent.keyDown(window, { key: 'Meta', metaKey: true }) + fireEvent.blur(window) + expect(held[0]).toBe(false) + }) + + it('reads Ctrl, not Cmd, off the Mac', () => { + const { held } = mountConsumers(1, false) + fireEvent.keyDown(window, { key: 'Meta', metaKey: true }) + expect(held[0]).toBe(false) + fireEvent.keyDown(window, { key: 'Control', ctrlKey: true }) + expect(held[0]).toBe(true) + fireEvent.keyUp(window, { key: 'Control', ctrlKey: false }) + expect(held[0]).toBe(false) + }) +}) diff --git a/src/renderer/src/components/native-chat/use-platform-modifier-held.ts b/src/renderer/src/components/native-chat/use-platform-modifier-held.ts index 6cd009db4979..38c959b3d00b 100644 --- a/src/renderer/src/components/native-chat/use-platform-modifier-held.ts +++ b/src/renderer/src/components/native-chat/use-platform-modifier-held.ts @@ -1,27 +1,90 @@ -import { useEffect, useState } from 'react' +import { useSyncExternalStore } from 'react' -/** Whether Cmd (Mac) or Ctrl (elsewhere) is held now, so a control can show what a modified click does. */ -export function usePlatformModifierHeld(enabled: boolean, isMac: boolean): boolean { - const [held, setHeld] = useState(false) - useEffect(() => { - if (!enabled) { - return - } - // Read from every key event, so a keyup swallowed by another handler can't leave it stuck. - const read = (event: KeyboardEvent): void => setHeld(isMac ? event.metaKey : event.ctrlKey) - // Dictation tools can paste without the modifier's keyup, and a blurred window never sees one. - const release = (): void => setHeld(false) - window.addEventListener('keydown', read, true) - window.addEventListener('keyup', read, true) +type Listener = () => void +type HeldModifier = 'metaKey' | 'ctrlKey' + +// One window listener set for every mounted chat, so a keystroke costs the same with one chat or many. +const listeners = new Set() +let held: Record = { metaKey: false, ctrlKey: false } + +function publish(next: Record): void { + if (next.metaKey === held.metaKey && next.ctrlKey === held.ctrlKey) { + return + } + held = next + for (const listener of listeners) { + listener() + } +} + +/** The modifier this key is, null for a modifier that isn't tracked, undefined for any other key. */ +function modifierOfKey(key: string): HeldModifier | null | undefined { + switch (key) { + case 'Meta': + case 'OS': + case 'Command': + return 'metaKey' + case 'Control': + return 'ctrlKey' + case 'Alt': + case 'Option': + case 'Shift': + return null + default: + return undefined + } +} + +function readKeyboardEvent(event: KeyboardEvent): void { + const modifier = modifierOfKey(event.key) + if (modifier) { + publish({ ...held, [modifier]: event.type === 'keydown' }) + } else if (modifier === undefined) { + // Other keys can only clear: dictation's paste leaves metaKey set on later events until a real Meta press, + // and a keyup swallowed elsewhere still clears on the next key. + publish({ metaKey: held.metaKey && event.metaKey, ctrlKey: held.ctrlKey && event.ctrlKey }) + } +} + +// Dictation tools can paste without the modifier's keyup, and a blurred window never sees one. +function release(): void { + publish({ metaKey: false, ctrlKey: false }) +} + +function subscribeModifierHeld(listener: Listener): () => void { + if (listeners.size === 0) { + window.addEventListener('keydown', readKeyboardEvent, true) + window.addEventListener('keyup', readKeyboardEvent, true) window.addEventListener('paste', release, true) window.addEventListener('blur', release) - return () => { - window.removeEventListener('keydown', read, true) - window.removeEventListener('keyup', read, true) - window.removeEventListener('paste', release, true) - window.removeEventListener('blur', release) - setHeld(false) + } + listeners.add(listener) + return () => { + listeners.delete(listener) + if (listeners.size > 0) { + return } - }, [enabled, isMac]) - return enabled && held + window.removeEventListener('keydown', readKeyboardEvent, true) + window.removeEventListener('keyup', readKeyboardEvent, true) + window.removeEventListener('paste', release, true) + window.removeEventListener('blur', release) + // Unwatched, the state would go stale; the next subscriber starts from released. + held = { metaKey: false, ctrlKey: false } + } +} + +function subscribeNothing(): () => void { + return () => {} +} + +const getMetaHeld = (): boolean => held.metaKey +const getCtrlHeld = (): boolean => held.ctrlKey + +/** Whether Cmd (Mac) or Ctrl (elsewhere) is held now, so a control can show what a modified click does. */ +export function usePlatformModifierHeld(enabled: boolean, isMac: boolean): boolean { + const modifierHeld = useSyncExternalStore( + enabled ? subscribeModifierHeld : subscribeNothing, + isMac ? getMetaHeld : getCtrlHeld + ) + return enabled && modifierHeld } From ce94239a2502e3ca9171358b98899e76175fe375 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Sat, 31 Oct 2026 00:56:30 -0700 Subject: [PATCH 26/27] Remove the desktop Queue/Steer button shown beside Stop while the agent works While the agent works, the desktop composer goes back to its usual controls: Stop, with Enter and the send shortcuts doing what they did. Enter still follows the queue setting, Cmd/Ctrl+Enter still sends one message the other way, and Cmd/Ctrl+Shift+Enter still steers the first queued card. This also removes what only that button used: its Cmd/Ctrl-click alternate, the shared Cmd/Ctrl key listener, the extra round Button size, the send-preview value the desktop session passed to the composer, and the button's text in every language. The phone is unchanged. --- .../NativeChatComposerActions.test.tsx | 128 -------------- .../native-chat/NativeChatComposerActions.tsx | 167 ++---------------- .../native-chat/NativeChatComposerField.tsx | 34 +--- .../native-chat/NativeChatComposerPane.tsx | 2 - .../native-chat-composer-composition.test.tsx | 1 - ...ative-chat-composer-ime-file-drop.test.tsx | 1 - .../native-chat-composer-mobile-hold.test.tsx | 1 - .../native-chat/native-chat-composer-types.ts | 3 - ...chat-composer-workspace-file-drop.test.tsx | 1 - ...ve-chat-structured-alternate-send.test.tsx | 72 +------- ...tive-chat-structured-composer-transport.ts | 1 - .../use-platform-modifier-held.test.tsx | 98 ---------- .../native-chat/use-platform-modifier-held.ts | 90 ---------- .../use-structured-agent-session.ts | 13 +- src/renderer/src/components/ui/button.tsx | 2 - src/renderer/src/i18n/locales/de.json | 5 - src/renderer/src/i18n/locales/en.json | 5 - src/renderer/src/i18n/locales/es.json | 5 - src/renderer/src/i18n/locales/fr.json | 5 - src/renderer/src/i18n/locales/ja.json | 5 - src/renderer/src/i18n/locales/ko.json | 5 - src/renderer/src/i18n/locales/pt.json | 5 - src/renderer/src/i18n/locales/ru.json | 5 - src/renderer/src/i18n/locales/tr.json | 5 - src/renderer/src/i18n/locales/zh-Hant.json | 5 - src/renderer/src/i18n/locales/zh.json | 5 - ...nt-session-draft-position.test-fixture.tsx | 1 - 27 files changed, 23 insertions(+), 647 deletions(-) delete mode 100644 src/renderer/src/components/native-chat/use-platform-modifier-held.test.tsx delete mode 100644 src/renderer/src/components/native-chat/use-platform-modifier-held.ts diff --git a/src/renderer/src/components/native-chat/NativeChatComposerActions.test.tsx b/src/renderer/src/components/native-chat/NativeChatComposerActions.test.tsx index 2f18219b0e93..c4044f8310f7 100644 --- a/src/renderer/src/components/native-chat/NativeChatComposerActions.test.tsx +++ b/src/renderer/src/components/native-chat/NativeChatComposerActions.test.tsx @@ -36,9 +36,6 @@ vi.mock('@/components/ui/tooltip', () => ({ TooltipContent: ({ children }: { children: ReactNode }) =>
{children}
})) -const platform = vi.hoisted(() => ({ isMac: true })) -vi.mock('./native-chat-shortcut', () => ({ isMacPlatform: () => platform.isMac })) - vi.mock('./NativeChatSessionOptionPickers', () => ({ NativeChatSessionOptionPickers: () =>
})) @@ -50,7 +47,6 @@ import { dispatchDictationControl } from '../dictation/dictation-control-events' afterEach(() => { cleanup() voice.dictationState = 'idle' - platform.isMac = true vi.clearAllMocks() }) @@ -105,130 +101,6 @@ describe('NativeChatComposerActions', () => { expect(screen.getByRole('button', { name: 'Stopping…' }).hasAttribute('disabled')).toBe(true) }) - it('beside Stop, says what Enter does mid-turn and names Cmd+Enter only when it differs', () => { - const onSend = vi.fn() - const onStop = vi.fn() - const props = { - attachDisabled: false, - dictationDisabled: false, - sendDisabled: false, - isWorking: true, - isDictating: false, - isDictationHoldMode: false, - onAttach: vi.fn(), - onDictationToggle: vi.fn(), - onDictationHoldStart: vi.fn(), - onDictationHoldEnd: vi.fn(), - onSend, - onStop, - sessionOptionsSurface: null, - sessionOptionsSnapshot: [] - } - const { rerender, container } = render() - expect( - screen.getAllByRole('button').map((button) => button.getAttribute('aria-label')) - ).toEqual(['Attach file', 'Start dictation', 'Stop the agent']) - - rerender( - - ) - fireEvent.click(screen.getByRole('button', { name: 'Queue message' })) - expect(onSend).toHaveBeenCalledExactlyOnceWith() - expect(onStop).not.toHaveBeenCalled() - expect(screen.getByRole('button', { name: 'Stop the agent' })).toBeTruthy() - expect(container.textContent).toContain('Queue for after this turn⏎') - expect(container.textContent).toContain('Send into the running turn⌘+⏎') - - rerender( - - ) - expect(screen.getByRole('button', { name: 'Steer message' })).toBeTruthy() - expect(container.textContent).toContain('Send into the running turn⏎') - expect(container.textContent).not.toContain('Queue for after this turn') - }) - - it('a Cmd-click on the follow-up control sends the other way, only when that differs', () => { - const onSend = vi.fn() - const props = { - attachDisabled: false, - dictationDisabled: false, - sendDisabled: false, - isWorking: true, - isDictating: false, - isDictationHoldMode: false, - onAttach: vi.fn(), - onDictationToggle: vi.fn(), - onDictationHoldStart: vi.fn(), - onDictationHoldEnd: vi.fn(), - onSend, - onStop: vi.fn(), - sessionOptionsSurface: null, - sessionOptionsSnapshot: [], - followUp: { action: 'queue' as const, offersChoice: true, held: false } - } - const { rerender, container } = render() - expect(container.textContent).toContain('Send into the running turn⌘+⏎/⌘+Click') - - fireEvent.click(screen.getByRole('button', { name: 'Queue message' })) - expect(onSend).toHaveBeenLastCalledWith() - // Holding the modifier shows what a click does now. - fireEvent.keyDown(window, { key: 'Meta', metaKey: true }) - fireEvent.click(screen.getByRole('button', { name: 'Steer message' }), { metaKey: true }) - expect(onSend).toHaveBeenLastCalledWith({ alternate: true }) - fireEvent.keyUp(window, { key: 'Meta', metaKey: false }) - expect(screen.getByRole('button', { name: 'Queue message' })).toBeTruthy() - - rerender( - - ) - fireEvent.keyDown(window, { key: 'Meta', metaKey: true }) - fireEvent.click(screen.getByRole('button', { name: 'Queue message' }), { metaKey: true }) - expect(onSend).toHaveBeenLastCalledWith() - expect(onSend).toHaveBeenCalledTimes(3) - }) - - it('a Ctrl-click sends the other way off the Mac, and a Cmd-click there does not', () => { - platform.isMac = false - const onSend = vi.fn() - const { container } = render( - - ) - expect(container.textContent).toContain('Send into the running turnCtrl+Enter/Ctrl+Click') - - fireEvent.click(screen.getByRole('button', { name: 'Queue message' }), { metaKey: true }) - expect(onSend).toHaveBeenLastCalledWith() - fireEvent.keyDown(window, { key: 'Control', ctrlKey: true }) - fireEvent.click(screen.getByRole('button', { name: 'Steer message' }), { ctrlKey: true }) - expect(onSend).toHaveBeenLastCalledWith({ alternate: true }) - fireEvent.keyUp(window, { key: 'Control', ctrlKey: false }) - expect(screen.getByRole('button', { name: 'Queue message' })).toBeTruthy() - }) - it('marks the streaming Stop control as the critical hit target', () => { render( void } @@ -40,15 +27,13 @@ export type NativeChatComposerActionsProps = { isWorking: boolean /** This client's Stop request is in flight: the Stop control is disabled and says so. */ isStopping?: boolean - /** Mid-turn: a send control beside Stop, so the user sees what Enter does. */ - followUp?: NativeChatComposerFollowUp isDictating: boolean isDictationHoldMode: boolean onAttach: () => void onDictationToggle: () => void onDictationHoldStart: () => void onDictationHoldEnd: () => void - onSend: (intent?: NativeChatComposerSendIntent) => void + onSend: () => void onStop?: () => void sessionOptionsSurface: SessionOptionsSurface | null sessionOptionsSnapshot: SessionOptionDescriptor[] @@ -72,7 +57,6 @@ export const NativeChatComposerActions = memo(function NativeChatComposerActions draftNotSaved, isWorking, isStopping = false, - followUp, isDictating, isDictationHoldMode, onAttach, @@ -132,8 +116,8 @@ export const NativeChatComposerActions = memo(function NativeChatComposerActions onMouseDown={(event) => event.preventDefault()} onClick={handleCriticalAction} variant={stops ? 'secondary' : 'default'} - size="icon-round" - className="pointer-coarse:size-10" + size="icon" + className="size-8 rounded-full pointer-coarse:size-10" > {stops ? : } @@ -227,139 +211,24 @@ export const NativeChatComposerActions = memo(function NativeChatComposerActions {translate('common.cancel', 'Cancel')} ) : null} - {followUp && stops && !editSession ? ( - - ) : null} - {sendButton} + {sendReason ? ( + + + {/* A disabled button gets no pointer events, so the wrapper carries the hover. */} + {sendButton} + + + {sendReason} + + + ) : ( + sendButton + )}
) }) -const FOLLOW_UP_ICON = { queue: ListEnd, steer: CornerDownRight } as const - -/** A click sends as Enter does and, when it would differ, a Cmd/Ctrl-click as Cmd/Ctrl+Enter does. */ -function NativeChatFollowUpSendButton({ - followUp, - reason, - onSend -}: { - followUp: NativeChatComposerFollowUp - reason: string | null - onSend: (intent?: NativeChatComposerSendIntent) => void -}): React.JSX.Element { - const label = { - queue: translate('components.native-chat.composer.queueMessage', 'Queue message'), - steer: translate('components.native-chat.composer.steerMessage', 'Steer message') - } - const hint = { - queue: translate('components.native-chat.composer.queueHint', 'Queue for after this turn'), - steer: translate('components.native-chat.composer.steerHint', 'Send into the running turn') - } - const alternate: NativeChatFollowUpBehavior = followUp.action === 'queue' ? 'steer' : 'queue' - const isMac = isMacPlatform() - const offersChoice = followUp.offersChoice && !followUp.held - // While the modifier is held, the button shows what a click would do now. - const shown = usePlatformModifierHeld(offersChoice, isMac) ? alternate : followUp.action - const Icon = FOLLOW_UP_ICON[shown] - const click = translate('components.native-chat.composer.clickKey', 'Click') - const modifier = isMac ? '⌘' : 'Ctrl' - const button = ( - - ) - // Held, it reads as the idle Send does: the reason when there is one, otherwise nothing. - if (followUp.held) { - return {button} - } - return ( - - {button} - - - - {hint[followUp.action]} - - - {offersChoice ? ( - - {hint[alternate]} - - - ) : null} - - - - ) -} - -/** One way to send: its keys and, when a click differs from another way, the click too. */ -function FollowUpKeys({ - keys, - click -}: { - keys: string[] - click: string[] | null -}): React.JSX.Element { - if (!click) { - return - } - return ( - - - / - - - ) -} - -/** A disabled send control that says why, when the user can do something about it. */ -function HeldSendReason({ - reason, - children -}: { - reason: string | null - children: React.JSX.Element -}): React.JSX.Element { - if (!reason) { - return children - } - return ( - - - {/* A disabled button gets no pointer events, so the wrapper carries the hover. */} - {children} - - - {reason} - - - ) -} - function DraftNotSavedIcon({ shown }: { shown: boolean }): React.JSX.Element | null { if (!shown) { return null diff --git a/src/renderer/src/components/native-chat/NativeChatComposerField.tsx b/src/renderer/src/components/native-chat/NativeChatComposerField.tsx index ebf3b52ac75f..db3ca3104e2c 100644 --- a/src/renderer/src/components/native-chat/NativeChatComposerField.tsx +++ b/src/renderer/src/components/native-chat/NativeChatComposerField.tsx @@ -12,7 +12,6 @@ import type { import { NativeChatMentionMenu, NativeChatPickerMenu } from './NativeChatAutocompleteMenus' import type { NativeChatMentionFiles } from './use-native-chat-mention-files' import { NativeChatComposerActions } from './NativeChatComposerActions' -import type { NativeChatSendFollowUp } from '../../../../shared/native-chat-follow-up-behavior' import { NativeChatComposerNotices } from './NativeChatComposerNotices' import type { NativeChatComposerNotice } from './native-chat-composer-notice' import type { NativeChatContextUsageSummary } from './native-chat-context-usage-summary' @@ -24,10 +23,7 @@ import type { SessionOptionDescriptor, SessionOptionsSurface } from '../../../../shared/native-chat/input/native-chat-session-options' -import type { - NativeChatComposerSendIntent, - NativeChatOptionPickerRequest -} from './native-chat-composer-types' +import type { NativeChatOptionPickerRequest } from './native-chat-composer-types' import { NativeChatImageAttachmentPreview } from './NativeChatImageAttachmentPreview' import type { NativeChatComposerGoalMode } from './use-native-chat-composer-submit' import { translate } from '@/i18n/i18n' @@ -57,8 +53,6 @@ export type NativeChatComposerFieldProps = { /** The paired server a structured chat runs on, which reads back files stored there. */ attachmentEnvironmentId?: string sendButtonDisabled: boolean - /** No send can leave this device now; mid-turn this disables the follow-up control as it does Send. */ - sendHeld: boolean /** Why the send button is disabled, when the user can do something about it. */ sendBlockedReason?: string | null isWorking: boolean @@ -66,8 +60,6 @@ export type NativeChatComposerFieldProps = { isStopping?: boolean /** After Stop, describe whether the host queues the next message as a card or holds the send. */ afterStop?: NativeChatAfterStopSend - /** Mid-turn on a host that queues: what Enter does, and whether Cmd/Ctrl+Enter would differ. */ - sendFollowUp?: NativeChatSendFollowUp attachDisabled: boolean dictationDisabled: boolean isDictating: boolean @@ -87,7 +79,7 @@ export type NativeChatComposerFieldProps = { onDictationToggle: () => void onDictationHoldStart: () => void onDictationHoldEnd: () => void - onSend: (intent?: NativeChatComposerSendIntent) => void + onSend: () => void onStop?: () => void sessionOptionsSurface: SessionOptionsSurface | null sessionOptionsSnapshot: SessionOptionDescriptor[] @@ -147,12 +139,10 @@ export function NativeChatComposerField({ numberImages = false, attachmentEnvironmentId, sendButtonDisabled, - sendHeld, sendBlockedReason, isWorking, isStopping = false, afterStop, - sendFollowUp, attachDisabled, dictationDisabled, isDictating, @@ -182,25 +172,6 @@ export function NativeChatComposerField({ agent }: NativeChatComposerFieldProps): React.JSX.Element { const draftNotSaved = useNativeChatComposerDraftUnsaved(draftScopeKey) - // Mid-turn with something to send, a control beside Stop says what Enter does; never while - // Stopping, nor in goal mode, where Enter sets the goal. - const followUpAction = - !editSession && - !goalMode?.active && - isWorking && - !afterStop && - (draft.trim() !== '' || imageAttachments.length > 0) - ? sendFollowUp?.action - : undefined - const followUpOffersChoice = sendFollowUp?.offersChoice === true - // Keyed on its parts: a fresh object each keystroke would re-render the memoized actions. - const followUp = useMemo( - () => - followUpAction - ? { action: followUpAction, offersChoice: followUpOffersChoice, held: sendHeld } - : undefined, - [followUpAction, followUpOffersChoice, sendHeld] - ) const optionCount = autocomplete.mode === 'slash' ? autocomplete.items.length @@ -397,7 +368,6 @@ export function NativeChatComposerField({ draftNotSaved={draftNotSaved} isWorking={isWorking} isStopping={isStopping} - followUp={followUp} isDictating={isDictating} isDictationHoldMode={isDictationHoldMode} onAttach={attach} diff --git a/src/renderer/src/components/native-chat/NativeChatComposerPane.tsx b/src/renderer/src/components/native-chat/NativeChatComposerPane.tsx index 5f713eb6b8e1..e77f37729e94 100644 --- a/src/renderer/src/components/native-chat/NativeChatComposerPane.tsx +++ b/src/renderer/src/components/native-chat/NativeChatComposerPane.tsx @@ -381,12 +381,10 @@ export const NativeChatComposerPane = forwardRef = {}): TestFieldProps { notices: [], imageAttachments: [], sendButtonDisabled: false, - sendHeld: false, isWorking: false, attachDisabled: false, dictationDisabled: false, diff --git a/src/renderer/src/components/native-chat/native-chat-composer-ime-file-drop.test.tsx b/src/renderer/src/components/native-chat/native-chat-composer-ime-file-drop.test.tsx index d6b1c1f158ce..02ff00442d9c 100644 --- a/src/renderer/src/components/native-chat/native-chat-composer-ime-file-drop.test.tsx +++ b/src/renderer/src/components/native-chat/native-chat-composer-ime-file-drop.test.tsx @@ -162,7 +162,6 @@ function ComposerProbe({ notices={notices} imageAttachments={attachments.imageAttachments} sendButtonDisabled={false} - sendHeld={false} isWorking={false} attachDisabled={disabled} dictationDisabled diff --git a/src/renderer/src/components/native-chat/native-chat-composer-mobile-hold.test.tsx b/src/renderer/src/components/native-chat/native-chat-composer-mobile-hold.test.tsx index bde74f64ab93..7a5a9f486219 100644 --- a/src/renderer/src/components/native-chat/native-chat-composer-mobile-hold.test.tsx +++ b/src/renderer/src/components/native-chat/native-chat-composer-mobile-hold.test.tsx @@ -75,7 +75,6 @@ function HeldField({ notices={notices} imageAttachments={[]} sendButtonDisabled - sendHeld={false} isWorking={false} attachDisabled dictationDisabled diff --git a/src/renderer/src/components/native-chat/native-chat-composer-types.ts b/src/renderer/src/components/native-chat/native-chat-composer-types.ts index cc1839b37126..c9662500ce80 100644 --- a/src/renderer/src/components/native-chat/native-chat-composer-types.ts +++ b/src/renderer/src/components/native-chat/native-chat-composer-types.ts @@ -16,7 +16,6 @@ import type { import type { NativeChatLaunchDraft } from '@/lib/native-chat-launch-prompt' import type { NativeChatComposerImageAttachment } from './NativeChatComposerField' import type { NativeChatAfterStopSend } from './native-chat-composer-target' -import type { NativeChatSendFollowUp } from '../../../../shared/native-chat-follow-up-behavior' import type { NativeChatLocalCommandAnswer } from './use-native-chat-local-command-answer' import type { NativeChatRecallSource } from './native-chat-sent-prompt-history' @@ -49,8 +48,6 @@ export type NativeChatStructuredComposerTransport = { sendOut?: boolean /** Send is held for this reason, which the disabled button says. */ sendBlockedReason?: string - /** Mid-turn on a host that queues: what Enter does, and whether Cmd/Ctrl+Enter would differ. */ - sendFollowUp?: NativeChatSendFollowUp dispatchCommand: (text: string) => Promise optionsSurface: SessionOptionsSurface optionSnapshot: SessionOptionDescriptor[] diff --git a/src/renderer/src/components/native-chat/native-chat-composer-workspace-file-drop.test.tsx b/src/renderer/src/components/native-chat/native-chat-composer-workspace-file-drop.test.tsx index 86510948ce4d..6416b2be73b1 100644 --- a/src/renderer/src/components/native-chat/native-chat-composer-workspace-file-drop.test.tsx +++ b/src/renderer/src/components/native-chat/native-chat-composer-workspace-file-drop.test.tsx @@ -160,7 +160,6 @@ function ComposerProbe({ notices={notice ? [{ key: 'composer', kind: 'attachment', text: notice }] : []} imageAttachments={attachments.imageAttachments} sendButtonDisabled={false} - sendHeld={false} isWorking={false} attachDisabled={disabled} dictationDisabled diff --git a/src/renderer/src/components/native-chat/native-chat-structured-alternate-send.test.tsx b/src/renderer/src/components/native-chat/native-chat-structured-alternate-send.test.tsx index 40b48d1f6b5d..297c14d1f30e 100644 --- a/src/renderer/src/components/native-chat/native-chat-structured-alternate-send.test.tsx +++ b/src/renderer/src/components/native-chat/native-chat-structured-alternate-send.test.tsx @@ -57,17 +57,8 @@ import { useStructuredAgentSession } from './use-structured-agent-session' import { useNativeChatStructuredComposerTransport } from './use-native-chat-structured-composer-transport' import { nativeChatStructuredStopControls } from './native-chat-structured-stop-controls' import { changePrompt } from './native-chat-prompt-editor.test-support' -import type { NativeChatStructuredComposerTransport } from './native-chat-composer-types' -function Chat({ - queueFollowUps, - canSend, - overrides -}: { - queueFollowUps: boolean - canSend?: boolean - overrides?: Partial -}): React.JSX.Element { +function Chat({ queueFollowUps }: { queueFollowUps: boolean }): React.JSX.Element { const props = { agent: 'claude', sessionId: 'session-1', target: { kind: 'local' } } as const const controller = useStructuredAgentSession({ ...props, @@ -95,8 +86,7 @@ function Chat({ targetPtyId={null} agent="claude" {...nativeChatStructuredStopControls(controller, false).composer} - canSend={canSend} - structuredTransport={{ ...transport, ...overrides }} + structuredTransport={transport} /> ) } @@ -163,67 +153,9 @@ describe('mid-turn send keys on a host that queues', () => { ) - // The control beside Stop says what Enter does once there is something to send. - expect(screen.queryByRole('button', { name: /^(Queue|Steer) message$/ })).toBeNull() - changePrompt(screen.getByRole('textbox'), 'draft') - expect( - screen.getByRole('button', { name: queueFollowUps ? 'Queue message' : 'Steer message' }) - ).toBeTruthy() - await type('by enter') await type('by cmd enter', { metaKey: true }) expect(sends().map((params) => params.delivery)).toEqual([enter, alternate]) } ) - - it('disables the control beside Stop wherever the idle Send would be, with the same reason', async () => { - const view = render( - - - - ) - changePrompt(screen.getByRole('textbox'), 'draft') - expect(screen.getByRole('button', { name: 'Queue message' }).hasAttribute('disabled')).toBe( - false - ) - - // Another device holds the input: disabled, and like Send it gives no reason. - view.rerender( - - - - ) - expect(screen.getByRole('button', { name: 'Queue message' }).hasAttribute('disabled')).toBe( - true - ) - - view.rerender( - - - - ) - const held = screen.getByRole('button', { name: 'Reconnect to send.' }) - expect(held.hasAttribute('disabled')).toBe(true) - fireEvent.click(held) - expect(sends()).toEqual([]) - }) - - it('shows no Queue or Steer control in goal mode, where Enter sets the goal', async () => { - const setObjective = vi.fn(async () => true) - render( - - - - ) - await type('/goal') - changePrompt(screen.getByRole('textbox'), 'ship the fix') - expect(screen.queryByRole('button', { name: /^(Queue|Steer) message$/ })).toBeNull() - expect(screen.getByRole('button', { name: 'Stop the agent' })).toBeTruthy() - - await act(async () => { - fireEvent.keyDown(screen.getByRole('textbox'), { key: 'Enter', keyCode: 13 }) - }) - expect(setObjective).toHaveBeenCalledExactlyOnceWith('ship the fix') - expect(sends()).toEqual([]) - }) }) diff --git a/src/renderer/src/components/native-chat/use-native-chat-structured-composer-transport.ts b/src/renderer/src/components/native-chat/use-native-chat-structured-composer-transport.ts index 0520d9d65a2c..48ecd379d4fb 100644 --- a/src/renderer/src/components/native-chat/use-native-chat-structured-composer-transport.ts +++ b/src/renderer/src/components/native-chat/use-native-chat-structured-composer-transport.ts @@ -95,7 +95,6 @@ export function useNativeChatStructuredComposerTransport(args: { ...(setThreadGoalObjective ? { threadGoal: { setObjective: setThreadGoalObjective } } : {}), sendOut: controller.sendOut || starting, ...(sendBlockedReason !== null ? { sendBlockedReason } : {}), - ...(controller.sendFollowUp ? { sendFollowUp: controller.sendFollowUp } : {}), optionsSurface: controller.optionSurface, conversationCommands: controller.conversationCommands, optionSnapshot: controller.optionSnapshot, diff --git a/src/renderer/src/components/native-chat/use-platform-modifier-held.test.tsx b/src/renderer/src/components/native-chat/use-platform-modifier-held.test.tsx deleted file mode 100644 index 32c41218a838..000000000000 --- a/src/renderer/src/components/native-chat/use-platform-modifier-held.test.tsx +++ /dev/null @@ -1,98 +0,0 @@ -// @vitest-environment happy-dom - -import { act, cleanup, fireEvent, render } from '@testing-library/react' -import { afterEach, describe, expect, it, vi } from 'vitest' -import { usePlatformModifierHeld } from './use-platform-modifier-held' - -afterEach(() => { - cleanup() - vi.restoreAllMocks() -}) - -const WATCHED = new Set(['keydown', 'keyup', 'paste', 'blur']) - -function mountConsumers(count: number, isMac = true) { - const renders = Array.from({ length: count }, () => 0) - const held = Array.from({ length: count }, () => false) - function Consumer({ index }: { index: number }) { - renders[index] += 1 - held[index] = usePlatformModifierHeld(true, isMac) - return null - } - render( - <> - {renders.map((_, index) => ( - - ))} - - ) - return { renders, held } -} - -describe('usePlatformModifierHeld', () => { - it.each([5, 50])( - 'shares one listener set across %i chats and renders only on a real modifier change', - (count) => { - const add = vi.spyOn(window, 'addEventListener') - const remove = vi.spyOn(window, 'removeEventListener') - const attached = (): number => - add.mock.calls.filter(([type]) => WATCHED.has(type)).length - - remove.mock.calls.filter(([type]) => WATCHED.has(type)).length - const { renders, held } = mountConsumers(count) - expect(attached()).toBe(4) - - const settled = [...renders] - act(() => { - fireEvent.keyDown(window, { key: 'a' }) - }) - act(() => { - fireEvent.keyUp(window, { key: 'a' }) - }) - act(() => { - fireEvent.keyDown(window, { key: 'Shift', shiftKey: true }) - }) - expect(renders).toEqual(settled) - - act(() => { - fireEvent.keyDown(window, { key: 'Meta', metaKey: true }) - }) - expect(renders).toEqual(settled.map((n) => n + 1)) - expect(held.every(Boolean)).toBe(true) - act(() => { - fireEvent.keyDown(window, { key: 'k', metaKey: true }) - }) - expect(renders).toEqual(settled.map((n) => n + 1)) - - cleanup() - expect(attached()).toBe(0) - } - ) - - it('counts the modifier as held only from its own keydown', () => { - const { held } = mountConsumers(1) - // A dictation paste can leave metaKey set on later key events with Cmd up. - fireEvent.paste(window) - fireEvent.keyDown(window, { key: 'a', metaKey: true }) - expect(held[0]).toBe(false) - - fireEvent.keyDown(window, { key: 'Meta', metaKey: true }) - expect(held[0]).toBe(true) - // A keyup another handler swallowed still clears on the next key. - fireEvent.keyDown(window, { key: 'a', metaKey: false }) - expect(held[0]).toBe(false) - - fireEvent.keyDown(window, { key: 'Meta', metaKey: true }) - fireEvent.blur(window) - expect(held[0]).toBe(false) - }) - - it('reads Ctrl, not Cmd, off the Mac', () => { - const { held } = mountConsumers(1, false) - fireEvent.keyDown(window, { key: 'Meta', metaKey: true }) - expect(held[0]).toBe(false) - fireEvent.keyDown(window, { key: 'Control', ctrlKey: true }) - expect(held[0]).toBe(true) - fireEvent.keyUp(window, { key: 'Control', ctrlKey: false }) - expect(held[0]).toBe(false) - }) -}) diff --git a/src/renderer/src/components/native-chat/use-platform-modifier-held.ts b/src/renderer/src/components/native-chat/use-platform-modifier-held.ts deleted file mode 100644 index 38c959b3d00b..000000000000 --- a/src/renderer/src/components/native-chat/use-platform-modifier-held.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { useSyncExternalStore } from 'react' - -type Listener = () => void -type HeldModifier = 'metaKey' | 'ctrlKey' - -// One window listener set for every mounted chat, so a keystroke costs the same with one chat or many. -const listeners = new Set() -let held: Record = { metaKey: false, ctrlKey: false } - -function publish(next: Record): void { - if (next.metaKey === held.metaKey && next.ctrlKey === held.ctrlKey) { - return - } - held = next - for (const listener of listeners) { - listener() - } -} - -/** The modifier this key is, null for a modifier that isn't tracked, undefined for any other key. */ -function modifierOfKey(key: string): HeldModifier | null | undefined { - switch (key) { - case 'Meta': - case 'OS': - case 'Command': - return 'metaKey' - case 'Control': - return 'ctrlKey' - case 'Alt': - case 'Option': - case 'Shift': - return null - default: - return undefined - } -} - -function readKeyboardEvent(event: KeyboardEvent): void { - const modifier = modifierOfKey(event.key) - if (modifier) { - publish({ ...held, [modifier]: event.type === 'keydown' }) - } else if (modifier === undefined) { - // Other keys can only clear: dictation's paste leaves metaKey set on later events until a real Meta press, - // and a keyup swallowed elsewhere still clears on the next key. - publish({ metaKey: held.metaKey && event.metaKey, ctrlKey: held.ctrlKey && event.ctrlKey }) - } -} - -// Dictation tools can paste without the modifier's keyup, and a blurred window never sees one. -function release(): void { - publish({ metaKey: false, ctrlKey: false }) -} - -function subscribeModifierHeld(listener: Listener): () => void { - if (listeners.size === 0) { - window.addEventListener('keydown', readKeyboardEvent, true) - window.addEventListener('keyup', readKeyboardEvent, true) - window.addEventListener('paste', release, true) - window.addEventListener('blur', release) - } - listeners.add(listener) - return () => { - listeners.delete(listener) - if (listeners.size > 0) { - return - } - window.removeEventListener('keydown', readKeyboardEvent, true) - window.removeEventListener('keyup', readKeyboardEvent, true) - window.removeEventListener('paste', release, true) - window.removeEventListener('blur', release) - // Unwatched, the state would go stale; the next subscriber starts from released. - held = { metaKey: false, ctrlKey: false } - } -} - -function subscribeNothing(): () => void { - return () => {} -} - -const getMetaHeld = (): boolean => held.metaKey -const getCtrlHeld = (): boolean => held.ctrlKey - -/** Whether Cmd (Mac) or Ctrl (elsewhere) is held now, so a control can show what a modified click does. */ -export function usePlatformModifierHeld(enabled: boolean, isMac: boolean): boolean { - const modifierHeld = useSyncExternalStore( - enabled ? subscribeModifierHeld : subscribeNothing, - isMac ? getMetaHeld : getCtrlHeld - ) - return enabled && modifierHeld -} diff --git a/src/renderer/src/components/native-chat/use-structured-agent-session.ts b/src/renderer/src/components/native-chat/use-structured-agent-session.ts index 7c6f8a1eeb39..1683123312c8 100644 --- a/src/renderer/src/components/native-chat/use-structured-agent-session.ts +++ b/src/renderer/src/components/native-chat/use-structured-agent-session.ts @@ -6,10 +6,7 @@ import { useStructuredAgentSessionSendOptions } from './use-structured-agent-ses import { useStructuredAgentSessionSends } from './use-structured-agent-session-sends' import { useStructuredAgentSessionCommandWrite } from './use-structured-agent-session-command-write' import { structuredAgentSessionSendQueues } from './structured-agent-session-queue-request' -import { - nativeChatQueueFollowUps, - nativeChatSendFollowUp -} from '../../../../shared/native-chat-follow-up-behavior' +import { nativeChatQueueFollowUps } from '../../../../shared/native-chat-follow-up-behavior' import type { AgentSessionCancelResult } from '../../../../shared/agent-session-wire' import { structuredAgentLabel } from '@/lib/structured-agent-session-launch-label' import { useStructuredLegacyLaunchStop } from '@/lib/structured-agent-session-legacy-launch-stop' @@ -284,14 +281,6 @@ export function useStructuredAgentSession(args: StructuredAgentSessionViewArgs) capturePresentation, /** A plain send would queue: the host takes it, the setting or a waiting command asks, and no unanswerable prompt blocks it. */ sendsQueue: structuredAgentSessionSendQueues(queue), - /** Mid-turn on a host that queues: what Enter does, and whether Cmd/Ctrl+Enter would send differently. */ - ...(queueCapability === 'supported' && isWorking && !stopControl.stopping - ? { - sendFollowUp: nativeChatSendFollowUp((alternate) => - structuredAgentSessionSendQueues(queue, alternate) - ) - } - : {}), cancel: (turnId: string | undefined, prompt?: { itemId: string; expectedRevision: number }) => cancelStructuredAgentSessionPrompt(admit(), turnId, prompt), stopBackgroundTask: (taskId?: string) => diff --git a/src/renderer/src/components/ui/button.tsx b/src/renderer/src/components/ui/button.tsx index 0d30cb7185b6..bfcd65aa90e7 100644 --- a/src/renderer/src/components/ui/button.tsx +++ b/src/renderer/src/components/ui/button.tsx @@ -32,8 +32,6 @@ const buttonVariants = cva( 'icon-xs': "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3", 'icon-sm': 'size-8', 'icon-lg': 'size-10', - // The chat composer's Send, Stop and Queue/Steer buttons. - 'icon-round': 'size-8 rounded-full', chip: "h-4 gap-0.5 rounded px-0.5 text-[10px] leading-none has-[>svg]:px-0.5 [&_svg:not([class*='size-'])]:size-2.5" } }, diff --git a/src/renderer/src/i18n/locales/de.json b/src/renderer/src/i18n/locales/de.json index afe609e1196f..f6622f4d550a 100644 --- a/src/renderer/src/i18n/locales/de.json +++ b/src/renderer/src/i18n/locales/de.json @@ -19087,11 +19087,6 @@ }, "composer": { "send": "Senden", - "queueMessage": "Nachricht einreihen", - "steerMessage": "Nachricht steuern", - "queueHint": "Für nach diesem Durchgang einreihen", - "steerHint": "In den laufenden Durchgang senden", - "clickKey": "Klick", "noPty": "Kein aktives Terminal — zurückwechseln, um die Verbindung wiederherzustellen.", "locked": "Die Eingabe wird von einem anderen Gerät gesteuert.", "placeholder": "Frage stellen, @ für Dateiverweise, / für Befehle", diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index e27a35a04597..46e3e892ac41 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -19398,11 +19398,6 @@ }, "composer": { "send": "Send", - "queueMessage": "Queue message", - "steerMessage": "Steer message", - "queueHint": "Queue for after this turn", - "steerHint": "Send into the running turn", - "clickKey": "Click", "noPty": "No live terminal — toggle back to reconnect.", "locked": "Input is held by another device.", "placeholder": "Ask anything, @ to mention files, / for commands", diff --git a/src/renderer/src/i18n/locales/es.json b/src/renderer/src/i18n/locales/es.json index 42df3d0e472f..ed2e4b980359 100644 --- a/src/renderer/src/i18n/locales/es.json +++ b/src/renderer/src/i18n/locales/es.json @@ -18962,11 +18962,6 @@ "composer": { "imageUnavailable": "Vista previa no disponible", "send": "Enviar", - "queueMessage": "Poner mensaje en cola", - "steerMessage": "Enviar mensaje ahora", - "queueHint": "Poner en cola para después de este turno", - "steerHint": "Enviar al turno en curso", - "clickKey": "Clic", "noPty": "No hay terminal activa: vuelva a alternar para volver a conectarse.", "locked": "La entrada está retenida por otro dispositivo.", "placeholder": "Pregunta lo que quieras, @ para referenciar archivos, / para comandos", diff --git a/src/renderer/src/i18n/locales/fr.json b/src/renderer/src/i18n/locales/fr.json index b6ba46db1e8d..3a387faa4fd3 100644 --- a/src/renderer/src/i18n/locales/fr.json +++ b/src/renderer/src/i18n/locales/fr.json @@ -19182,11 +19182,6 @@ "composer": { "imageUnavailable": "Aperçu indisponible", "send": "Envoyer", - "queueMessage": "Mettre le message en file d’attente", - "steerMessage": "Envoyer le message maintenant", - "queueHint": "Mettre en file d’attente pour après ce tour", - "steerHint": "Envoyer dans le tour en cours", - "clickKey": "Clic", "noPty": "Aucun terminal actif — rebasculez pour vous reconnecter.", "locked": "La saisie est détenue par un autre appareil.", "placeholder": "Posez votre question, @ pour référencer des fichiers, / pour les commandes", diff --git a/src/renderer/src/i18n/locales/ja.json b/src/renderer/src/i18n/locales/ja.json index 0936eacb1cd7..396227a3d6c7 100644 --- a/src/renderer/src/i18n/locales/ja.json +++ b/src/renderer/src/i18n/locales/ja.json @@ -18518,11 +18518,6 @@ }, "composer": { "send": "送信", - "queueMessage": "メッセージをキューに入れる", - "steerMessage": "メッセージを今すぐ送信", - "queueHint": "このターンの後に実行するようキューに入れる", - "steerHint": "実行中のターンに送信", - "clickKey": "クリック", "noPty": "ライブターミナルがありません - 再接続するには元に切り替えてください。", "locked": "入力は別のデバイスによって保持されます。", "placeholder": "何でも聞いてください。@ でファイルを参照、/ でコマンドを実行", diff --git a/src/renderer/src/i18n/locales/ko.json b/src/renderer/src/i18n/locales/ko.json index 82a820cd9acc..cbf0d7c9d71e 100644 --- a/src/renderer/src/i18n/locales/ko.json +++ b/src/renderer/src/i18n/locales/ko.json @@ -18518,11 +18518,6 @@ }, "composer": { "send": "보내기", - "queueMessage": "메시지를 대기열에 추가", - "steerMessage": "메시지 지금 보내기", - "queueHint": "이 턴이 끝난 뒤 실행하도록 대기열에 추가", - "steerHint": "진행 중인 턴에 보내기", - "clickKey": "클릭", "noPty": "라이브 terminal이 없습니다. 다시 연결하려면 다시 전환하세요.", "locked": "입력이 다른 장치에 의해 보류됩니다.", "placeholder": "무엇이든 물어보세요. @로 파일 참조, /로 명령어 실행", diff --git a/src/renderer/src/i18n/locales/pt.json b/src/renderer/src/i18n/locales/pt.json index 2881a576c582..c963aab4e174 100644 --- a/src/renderer/src/i18n/locales/pt.json +++ b/src/renderer/src/i18n/locales/pt.json @@ -19860,11 +19860,6 @@ }, "composer": { "send": "Enviar", - "queueMessage": "Colocar mensagem na fila", - "steerMessage": "Orientar mensagem", - "queueHint": "Colocar na fila para depois deste turno", - "steerHint": "Enviar ao turno em andamento", - "clickKey": "Clique", "noPty": "Nenhum terminal ativo — alterne de volta para reconectar.", "locked": "A entrada está retida por outro dispositivo.", "placeholder": "Enviar uma mensagem…", diff --git a/src/renderer/src/i18n/locales/ru.json b/src/renderer/src/i18n/locales/ru.json index 6ea734962351..cb3a6b983f69 100644 --- a/src/renderer/src/i18n/locales/ru.json +++ b/src/renderer/src/i18n/locales/ru.json @@ -19666,11 +19666,6 @@ }, "composer": { "send": "Отправить", - "queueMessage": "Поставить сообщение в очередь", - "steerMessage": "Отправить сообщение сейчас", - "queueHint": "Поставить в очередь: выполнится после этого хода", - "steerHint": "Отправить в текущий ход", - "clickKey": "Клик", "noPty": "Терминал отключён. Вернитесь в него, чтобы подключиться снова.", "locked": "Вводом управляет другое устройство.", "placeholder": "Задайте вопрос; @ — файлы, / — команды", diff --git a/src/renderer/src/i18n/locales/tr.json b/src/renderer/src/i18n/locales/tr.json index b5231e6ff088..3f2c24e4bf64 100644 --- a/src/renderer/src/i18n/locales/tr.json +++ b/src/renderer/src/i18n/locales/tr.json @@ -19074,11 +19074,6 @@ }, "composer": { "send": "Gönder", - "queueMessage": "Mesajı sıraya al", - "steerMessage": "Mesajı yönlendir", - "queueHint": "Bu turdan sonrası için sıraya al", - "steerHint": "Çalışan tura gönder", - "clickKey": "Tıkla", "noPty": "Canlı terminal yok, yeniden bağlanmak için geri geçin.", "locked": "Giriş başka bir cihaz tarafından tutuluyor.", "placeholder": "Bir şey sorun; dosyalara başvurmak için @, komutlar için / kullanın", diff --git a/src/renderer/src/i18n/locales/zh-Hant.json b/src/renderer/src/i18n/locales/zh-Hant.json index dc91c2bb8d7c..e7de96c02d93 100644 --- a/src/renderer/src/i18n/locales/zh-Hant.json +++ b/src/renderer/src/i18n/locales/zh-Hant.json @@ -18828,11 +18828,6 @@ }, "composer": { "send": "傳送", - "queueMessage": "將訊息加入佇列", - "steerMessage": "引導訊息", - "queueHint": "加入佇列,於此回合結束後執行", - "steerHint": "傳送到正在進行的回合", - "clickKey": "點按", "noPty": "沒有作用中的終端機,請切回終端機以重新連線。", "locked": "輸入正被另一台裝置佔用。", "placeholder": "隨心輸入,@ 引用檔案,/ 使用命令", diff --git a/src/renderer/src/i18n/locales/zh.json b/src/renderer/src/i18n/locales/zh.json index 938a1504df92..798ad27ff0b0 100644 --- a/src/renderer/src/i18n/locales/zh.json +++ b/src/renderer/src/i18n/locales/zh.json @@ -18484,11 +18484,6 @@ }, "composer": { "send": "发送", - "queueMessage": "将消息加入队列", - "steerMessage": "立即发送消息", - "queueHint": "加入队列,在此回合结束后运行", - "steerHint": "发送到正在进行的回合", - "clickKey": "点击", "noPty": "没有实时终端,请切回终端以重新连接。", "locked": "输入正被另一台设备占用。", "placeholder": "随心输入,@ 引用文件,/ 使用命令", diff --git a/src/renderer/src/lib/agent-session/structured-agent-session-draft-position.test-fixture.tsx b/src/renderer/src/lib/agent-session/structured-agent-session-draft-position.test-fixture.tsx index 4fbec90767a0..1dcc5b313575 100644 --- a/src/renderer/src/lib/agent-session/structured-agent-session-draft-position.test-fixture.tsx +++ b/src/renderer/src/lib/agent-session/structured-agent-session-draft-position.test-fixture.tsx @@ -147,7 +147,6 @@ export function PositionField({ notices: [], imageAttachments: [], sendButtonDisabled: true, - sendHeld: true, isWorking: false, attachDisabled: true, dictationDisabled: true, From e0636aa907a83064676210fa39c370ff695fcc90 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Sat, 31 Oct 2026 00:58:55 -0700 Subject: [PATCH 27/27] Put the composer's send-hold checks back inline in the pane The separate send-hold helper only existed because the removed mid-turn Queue/Steer button pushed the pane over the file-length limit. Without the button the pane fits again, so it goes back to main's inline code. --- .../native-chat/NativeChatComposerPane.tsx | 15 ++++++++----- .../native-chat-composer-send-hold.ts | 22 ------------------- 2 files changed, 9 insertions(+), 28 deletions(-) delete mode 100644 src/renderer/src/components/native-chat/native-chat-composer-send-hold.ts diff --git a/src/renderer/src/components/native-chat/NativeChatComposerPane.tsx b/src/renderer/src/components/native-chat/NativeChatComposerPane.tsx index e77f37729e94..1c93a3fd8608 100644 --- a/src/renderer/src/components/native-chat/NativeChatComposerPane.tsx +++ b/src/renderer/src/components/native-chat/NativeChatComposerPane.tsx @@ -11,7 +11,7 @@ import { useNativeChatComposerRecall } from './use-native-chat-composer-recall' import { useNativeChatLaunchDraftAdoption } from './use-native-chat-launch-draft-adoption' import { NativeChatComposerField } from './NativeChatComposerField' import { useNativeChatComposerAttachments } from './use-native-chat-composer-attachments' -import { nativeChatComposerSendHold } from './native-chat-composer-send-hold' +import { nativeChatImageSendBlock } from './native-chat-image-reattach' import { useNativeChatComposerHandle } from './use-native-chat-composer-handle' import { useNativeChatFileDrops } from './use-native-chat-file-drops' import { useNativeChatComposerKeyDown } from './use-native-chat-composer-keydown' @@ -161,11 +161,14 @@ export const NativeChatComposerPane = forwardRef