Skip to content

The agent that grows with you

fix(desktop): honor macOS replacements in message composers

brooklyn!d7c7af771a89
diff --git a/apps/desktop/src/app/chat/composer/index.tsx b/apps/desktop/src/app/chat/composer/index.tsx
index dfb440c6f43..5d1381fbe4a 100644
--- a/apps/desktop/src/app/chat/composer/index.tsx
+++ b/apps/desktop/src/app/chat/composer/index.tsx
@@ -15,6 +15,7 @@ import { chatMessageText } from '@/lib/chat-messages'
import { sanitizeComposerInput } from '@/lib/composer-input-sanitize'
import { DATA_IMAGE_URL_RE } from '@/lib/embedded-images'
import { triggerHaptic } from '@/lib/haptics'
+import { isMacPlatform } from '@/lib/platform'
import { useStoreSelector, useStoresSelector } from '@/lib/use-session-slice'
import { cn } from '@/lib/utils'
import { interceptsTypedVoiceStop } from '@/lib/voice-stop-word'
@@ -1124,7 +1125,9 @@ export function ChatBar({
aria-disabled={inputDisabled ? true : undefined}
aria-label={t.composer.message}
autoCapitalize="off"
- autoCorrect="off"
+ // Chromium's macOS text-replacement path shares the autocorrect gate.
+ // Keeping spellcheck off below still excludes smart quotes and dashes.
+ autoCorrect={isMacPlatform() ? 'on' : 'off'}
className={cn(
'min-h-[1.625rem] min-h-(--composer-input-min-height) max-h-(--composer-input-max-height) cursor-text overflow-y-auto whitespace-pre-wrap break-words [overflow-wrap:anywhere] bg-transparent pb-1 pr-1 pt-1 leading-normal text-foreground outline-none disabled:cursor-not-allowed',
'**:data-ref-text:cursor-default',
diff --git a/apps/desktop/src/app/chat/composer/native-text-replacements.test.tsx b/apps/desktop/src/app/chat/composer/native-text-replacements.test.tsx
new file mode 100644
index 00000000000..82b798b0634
--- /dev/null
+++ b/apps/desktop/src/app/chat/composer/native-text-replacements.test.tsx
@@ -0,0 +1,67 @@
+// @vitest-environment jsdom
+import { AssistantRuntimeProvider, type ThreadMessageLike, useExternalStoreRuntime } from '@assistant-ui/react'
+import { cleanup, render } from '@testing-library/react'
+import { MemoryRouter } from 'react-router'
+import { afterEach, describe, expect, it, vi } from 'vitest'
+
+import { I18nProvider } from '@/i18n'
+import { mainComposerScope } from '@/store/composer'
+
+import { ChatBar } from './index'
+import { RICH_INPUT_SLOT } from './rich-editor'
+import type { ChatBarState } from './types'
+
+const state: ChatBarState = {
+ model: { canSwitch: false, model: '', provider: '' },
+ tools: { enabled: false, label: '' },
+ voice: { enabled: false, active: false }
+}
+
+function Harness() {
+ const runtime = useExternalStoreRuntime({
+ convertMessage: (message: ThreadMessageLike) => message,
+ isRunning: false,
+ messages: [] as ThreadMessageLike[],
+ onNew: async () => {}
+ })
+
+ return (
+ <AssistantRuntimeProvider runtime={runtime}>
+ <MemoryRouter>
+ <I18nProvider configClient={null} initialLocale="en">
+ <ChatBar
+ busy={false}
+ disabled={false}
+ gateway={null}
+ onCancel={() => {}}
+ onSubmit={async () => true}
+ state={state}
+ />
+ </I18nProvider>
+ </MemoryRouter>
+ </AssistantRuntimeProvider>
+ )
+}
+
+afterEach(() => {
+ cleanup()
+ mainComposerScope.clear()
+ vi.restoreAllMocks()
+})
+
+describe('native composer text replacements', () => {
+ it.each([
+ ['MacIntel', 'on'],
+ ['Win32', 'off'],
+ ['Linux x86_64', 'off']
+ ])('admits macOS substitutions without enabling spellcheck on %s', (platform, autocorrect) => {
+ vi.spyOn(navigator, 'platform', 'get').mockReturnValue(platform)
+ const { container } = render(<Harness />)
+ const editor = container.querySelector(`[data-slot="${RICH_INPUT_SLOT}"]`)!
+
+ expect(editor.getAttribute('autocorrect')).toBe(autocorrect)
+ expect(editor.getAttribute('spellcheck')).toBe('false')
+ expect(editor.getAttribute('autocapitalize')).toBe('off')
+ expect(container.querySelector('textarea[aria-hidden]')?.getAttribute('autocorrect')).toBe('off')
+ })
+})
diff --git a/apps/desktop/src/components/assistant-ui/thread/user-edit-composer.tsx b/apps/desktop/src/components/assistant-ui/thread/user-edit-composer.tsx
index 1e3c5246efd..d0824a282c2 100644
--- a/apps/desktop/src/components/assistant-ui/thread/user-edit-composer.tsx
+++ b/apps/desktop/src/components/assistant-ui/thread/user-edit-composer.tsx
@@ -73,6 +73,7 @@ import { sanitizeComposerInput } from '@/lib/composer-input-sanitize'
import { DATA_IMAGE_URL_RE } from '@/lib/embedded-images'
import { triggerHaptic } from '@/lib/haptics'
import { Loader2Icon } from '@/lib/icons'
+import { isMacPlatform } from '@/lib/platform'
import { cn } from '@/lib/utils'
import type { ComposerAttachment } from '@/store/composer'
import { notifyError } from '@/store/notifications'
@@ -844,7 +845,8 @@ export const UserEditComposer: FC<UserEditComposerProps> = ({ cwd, gateway, sess
<div
aria-label={copy.editMessage}
autoCapitalize="off"
- autoCorrect="off"
+ // Match the main composer: allow macOS replacements, not spellcheck.
+ autoCorrect={isMacPlatform() ? 'on' : 'off'}
className={cn(
'ui-prompt-input-editor__input max-h-48 w-full resize-none overflow-y-auto bg-transparent p-0 pr-7 text-[length:var(--conversation-text-font-size)] text-foreground/95 outline-none',
'**:data-ref-text:cursor-default',
diff --git a/apps/desktop/src/components/assistant-ui/thread/user-message-edit-shared-composer.test.tsx b/apps/desktop/src/components/assistant-ui/thread/user-message-edit-shared-composer.test.tsx
index 7e540d6204a..5791c432aac 100644
--- a/apps/desktop/src/components/assistant-ui/thread/user-message-edit-shared-composer.test.tsx
+++ b/apps/desktop/src/components/assistant-ui/thread/user-message-edit-shared-composer.test.tsx
@@ -8,7 +8,7 @@
import { AssistantRuntimeProvider, ExportedMessageRepository, type ThreadMessage } from '@assistant-ui/react'
import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
import { useState } from 'react'
-import { afterEach, beforeAll, describe, expect, it } from 'vitest'
+import { afterEach, beforeAll, describe, expect, it, vi } from 'vitest'
import { FloatingComposerSurface } from '@/app/chat/composer/floating-surface'
import { ComposerScopeProvider, ComposerSurfaceProvider, MAIN_COMPOSER_SCOPE } from '@/app/chat/composer/scope'
@@ -38,6 +38,7 @@ beforeAll(() => {
afterEach(() => {
cleanup()
+ vi.restoreAllMocks()
})
const noopAsync = async () => {}
@@ -105,6 +106,19 @@ const settleBlurGuard = () =>
})
describe('inline edit inside a shared composer surface', () => {
+ it.each([
+ ['MacIntel', 'on'],
+ ['Win32', 'off'],
+ ['Linux x86_64', 'off']
+ ])('admits native text replacements without spelling corrections on %s', async (platform, autocorrect) => {
+ vi.spyOn(navigator, 'platform', 'get').mockReturnValue(platform)
+ const { editor } = await openEdit()
+
+ expect(editor.getAttribute('autocorrect')).toBe(autocorrect)
+ expect(editor.getAttribute('spellcheck')).toBe('false')
+ expect(editor.getAttribute('autocapitalize')).toBe('off')
+ })
+
it('keeps the edit composer open and focused after the bubble click', async () => {
const { container, editor } = await openEdit()