From 5d4c93afe476df79e5d3ae837e3af196ab30248b Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Fri, 5 Jun 2026 21:05:56 -0500 Subject: [PATCH] refactor(desktop): hoist single draft.trim() in composer Compute the trimmed draft once and reuse for hasComposerPayload + canSteer instead of trimming three times per render. --- apps/desktop/src/app/chat/composer/index.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/desktop/src/app/chat/composer/index.tsx b/apps/desktop/src/app/chat/composer/index.tsx index 1af6430ec16..e19128add30 100644 --- a/apps/desktop/src/app/chat/composer/index.tsx +++ b/apps/desktop/src/app/chat/composer/index.tsx @@ -166,14 +166,15 @@ export function ChatBar({ const slash = useSlashCompletions({ gateway: gateway ?? null }) const stacked = expanded || narrow || tight - const hasComposerPayload = draft.trim().length > 0 || attachments.length > 0 + const trimmedDraft = draft.trim() + const hasComposerPayload = trimmedDraft.length > 0 || attachments.length > 0 const canSubmit = busy || hasComposerPayload const editingQueuedPrompt = queueEdit ? (queuedPrompts.find(entry => entry.id === queueEdit.entryId) ?? null) : null const busyAction = busy && hasComposerPayload ? 'queue' : 'stop' // Steer only makes sense mid-turn, text-only (the gateway can't carry images // into a tool result) and never for a slash command (those execute inline). const canSteer = - busy && !!onSteer && attachments.length === 0 && draft.trim().length > 0 && !SLASH_COMMAND_RE.test(draft.trim()) + busy && !!onSteer && attachments.length === 0 && trimmedDraft.length > 0 && !SLASH_COMMAND_RE.test(trimmedDraft) const showHelpHint = draft === '?' const { t } = useI18n()