Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(web): drop the composer microphone on touch devices (#7383)

Peter Chinman4a79d95679f2
diff --git a/apps/web/src/components/ui/components/CollapsedInput.tsx b/apps/web/src/components/ui/components/CollapsedInput.tsx
index 6511d7fd6f..1ef2dda3be 100644
--- a/apps/web/src/components/ui/components/CollapsedInput.tsx
+++ b/apps/web/src/components/ui/components/CollapsedInput.tsx
@@ -27,8 +27,6 @@ export type CollapsedInputProps = {
*/
disabled?: boolean;
class?: string;
- /** Extra composer action placed immediately before Send. */
- trailingAction?: JSX.Element;
/** Replaces the attach button at the start of the input. */
leadingAction?: JSX.Element;
/**
@@ -124,10 +122,6 @@ export function CollapsedInput(props: CollapsedInputProps) {
<span>{attachmentCount()}</span>
</Button>
</Show>
- {props.trailingAction}
- {/* Fades out rather than unmounting, the way the expanded composer's
- send action does: dropping it would slide the trailing action
- across as soon as the draft emptied. */}
<SendButton
appearance="composer"
pending={props.pending}
diff --git a/apps/web/src/components/ui/components/SendButton.tsx b/apps/web/src/components/ui/components/SendButton.tsx
index 19dd8ed7e0..a41f523e9d 100644
--- a/apps/web/src/components/ui/components/SendButton.tsx
+++ b/apps/web/src/components/ui/components/SendButton.tsx
@@ -64,8 +64,8 @@ export function SendButton(props: SendButtonProps) {
'data-disabled:opacity-100 data-disabled:text-ink-extra-muted! data-disabled:bg-ink-muted/5',
'active:not-disabled:scale-95',
// Out of the flow, not just invisible: a transparent send button
- // holds its slot and strands whatever sits before it (the dictation
- // button) well short of the composer's edge.
+ // holds its slot and strands whatever sits before it well short of
+ // the composer's edge.
local.hidden && 'hidden',
local.class
)}
diff --git a/apps/web/src/features/channel/Input/ChannelInput.tsx b/apps/web/src/features/channel/Input/ChannelInput.tsx
index 374ddcdd4a..d2e932358b 100644
--- a/apps/web/src/features/channel/Input/ChannelInput.tsx
+++ b/apps/web/src/features/channel/Input/ChannelInput.tsx
@@ -204,11 +204,8 @@ function WebDefaultActions(props: {
);
}
-function IosDefaultActions(props: {
- input: InputData;
- dictation: DictationController;
- addMenu: JSX.Element;
-}) {
+// The iOS keyboard dictates on its own, so there is no microphone to place.
+function IosDefaultActions(props: { input: InputData; addMenu: JSX.Element }) {
return (
<>
<Input.Layout.ActionsLeft>
@@ -218,7 +215,6 @@ function IosDefaultActions(props: {
</Show>
</Input.Layout.ActionsLeft>
<Input.Layout.ActionsRight>
- <DictationButton dictation={props.dictation} />
<Input.SendAction />
</Input.Layout.ActionsRight>
</>
@@ -241,11 +237,7 @@ function DefaultActions(props: {
/>
}
>
- <IosDefaultActions
- input={props.input}
- dictation={props.dictation}
- addMenu={props.addMenu}
- />
+ <IosDefaultActions input={props.input} addMenu={props.addMenu} />
</Show>
);
}
@@ -866,7 +858,6 @@ export function ChannelInput(props: ChannelInputProps) {
getFocusTarget={() => lexicalEditor().getRootElement()}
leadingAction={addMenu(true)}
onOpen={collapsedInput.expand}
- trailingAction={<DictationButton dictation={dictation} />}
onSend={() => fireAndForget(commands.send(), 'channel-input')}
/>
</Show>
diff --git a/apps/web/src/features/channel/Input/tests/input-slots.test.tsx b/apps/web/src/features/channel/Input/tests/input-slots.test.tsx
index f5aac691d0..0ed301ac9d 100644
--- a/apps/web/src/features/channel/Input/tests/input-slots.test.tsx
+++ b/apps/web/src/features/channel/Input/tests/input-slots.test.tsx
@@ -105,6 +105,11 @@ vi.hoisted(() => {
vi.mock('@core/mobile/isMobile', () => ({ isMobile: vi.fn(() => false) }));
+const device = vi.hoisted(() => ({ touch: false }));
+vi.mock('@core/mobile/isTouchDevice', () => ({
+ isTouchDevice: () => device.touch,
+}));
+
vi.mock('@core/component/LexicalMarkdown/utils/create-composer-layout', () => ({
createComposerLayout: (
_editor: unknown,
@@ -412,6 +417,7 @@ describe('Input slots', () => {
editorMocks.inlineMenuOpen = false;
editorMocks.onEscape = undefined;
editorMocks.mentionUsers = undefined;
+ device.touch = false;
editorMocks.ignoredActions = [];
vi.mocked(isMobile).mockReturnValue(false);
});
@@ -471,23 +477,23 @@ describe('Input slots', () => {
expect(editorMocks.onEscape?.()).toBe(false);
});
- it('starts dictation from the collapsed channel composer', async () => {
+ it('omits the microphone on touch devices, whose keyboards dictate', () => {
+ device.touch = true;
vi.mocked(isMobile).mockReturnValue(true);
- const user = userEvent.setup();
- const { container } = render(() => (
+ const collapsed = render(() => (
<ChannelInput input={baseInput} collapsible />
));
- const collapsed = container.querySelector('[data-composer-collapsed]');
- expect(collapsed).toBeTruthy();
- const microphone = collapsed?.querySelector(
- 'button[aria-label="Start dictation"]'
- );
- expect(microphone).toBeTruthy();
- await user.click(microphone!);
- expect(container.querySelector('[data-composer-collapsed]')).toBeNull();
- expect(screen.getByRole('group', { name: 'Dictation' })).toBeTruthy();
- await user.click(screen.getByRole('button', { name: 'Cancel dictation' }));
- expect(screen.queryByRole('group', { name: 'Dictation' })).toBeNull();
+ expect(
+ collapsed.container.querySelector('[data-composer-collapsed]')
+ ).toBeTruthy();
+ expect(
+ collapsed.queryByRole('button', { name: 'Start dictation' })
+ ).toBeNull();
+
+ const expanded = render(() => <ChannelInput input={baseInput} />);
+ expect(
+ expanded.queryByRole('button', { name: 'Start dictation' })
+ ).toBeNull();
});
it('offers Cursor and Codex within their rollouts before account setup', () => {
diff --git a/apps/web/src/features/dictation/availability.ts b/apps/web/src/features/dictation/availability.ts
new file mode 100644
index 0000000000..a03437349b
--- /dev/null
+++ b/apps/web/src/features/dictation/availability.ts
@@ -0,0 +1,11 @@
+import { enableDictation, isFeatureEnabled } from '@core/constant/featureFlags';
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
+
+/**
+ * Touch keyboards already dictate, so the composer microphone only adds a
+ * target to miss next to Send. Off here means no button and no recorder: the
+ * controller reports `unavailable`, so nothing can start a session either.
+ */
+export function isDictationAvailable(): boolean {
+ return isFeatureEnabled(enableDictation) && !isTouchDevice();
+}
diff --git a/apps/web/src/features/dictation/components/dictation-controls.test.tsx b/apps/web/src/features/dictation/components/dictation-controls.test.tsx
new file mode 100644
index 0000000000..13b7c6f708
--- /dev/null
+++ b/apps/web/src/features/dictation/components/dictation-controls.test.tsx
@@ -0,0 +1,61 @@
+import { cleanup, render, screen } from '@solidjs/testing-library';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import type { DictationController } from '../core/types';
+import { DictationButton } from './dictation-controls';
+
+const device = vi.hoisted(() => ({ touch: false }));
+vi.mock('@core/mobile/isTouchDevice', () => ({
+ isTouchDevice: () => device.touch,
+}));
+
+const flags = vi.hoisted(() => ({ dictation: true }));
+vi.mock('@core/constant/featureFlags', async (original) => {
+ const actual = await original<typeof import('@core/constant/featureFlags')>();
+ return {
+ ...actual,
+ isFeatureEnabled: (flag: Parameters<typeof actual.isFeatureEnabled>[0]) =>
+ flag === actual.enableDictation
+ ? flags.dictation
+ : actual.isFeatureEnabled(flag),
+ };
+});
+
+function controller(): DictationController {
+ return {
+ phase: () => 'idle',
+ active: () => false,
+ volumeHistory: () => [],
+ message: () => '',
+ label: () => 'Start dictation',
+ disabled: () => false,
+ start: async () => {},
+ confirm: async () => {},
+ cancel: () => {},
+ };
+}
+
+beforeEach(() => {
+ device.touch = false;
+ flags.dictation = true;
+});
+afterEach(cleanup);
+
+describe('DictationButton', () => {
+ it('offers the microphone on a pointer device within the rollout', () => {
+ render(() => <DictationButton dictation={controller()} />);
+ expect(
+ screen.getByRole('button', { name: 'Start dictation' })
+ ).toBeTruthy();
+ });
+
+ it.each([
+ ['a touch device', () => (device.touch = true)],
+ ['an account outside the rollout', () => (flags.dictation = false)],
+ ])('renders nothing on %s', (_case, arrange) => {
+ arrange();
+ const { container } = render(() => (
+ <DictationButton dictation={controller()} />
+ ));
+ expect(container.querySelector('button')).toBeNull();
+ });
+});
diff --git a/apps/web/src/features/dictation/components/dictation-controls.tsx b/apps/web/src/features/dictation/components/dictation-controls.tsx
index bae4fead3c..e505ed927a 100644
--- a/apps/web/src/features/dictation/components/dictation-controls.tsx
+++ b/apps/web/src/features/dictation/components/dictation-controls.tsx
@@ -1,4 +1,3 @@
-import { enableDictation, isFeatureEnabled } from '@core/constant/featureFlags';
import { fireAndForget } from '@core/util/fireAndForget';
import CheckIcon from '@icon/system/regular/check.svg?component-solid';
import MicrophoneIcon from '@icon/system/regular/microphone.svg?component-solid';
@@ -6,6 +5,7 @@ import XIcon from '@icon/system/regular/x.svg?component-solid';
import { Button } from '@ui';
import { Show } from 'solid-js';
import { match } from 'ts-pattern';
+import { isDictationAvailable } from '../availability';
import type { DictationController } from '../core/types';
import { VolumeTimeline } from './volume-timeline';
@@ -14,11 +14,11 @@ export function DictationButton(props: {
disabled?: boolean;
}) {
return (
- <Show when={isFeatureEnabled(enableDictation)}>
+ <Show when={isDictationAvailable()}>
<Button
variant="ghost"
size="icon-composer"
- class="text-ink not-touch:text-composer-ink"
+ class="text-composer-ink"
label={props.dictation.label()}
tooltip={props.dictation.label()}
disabled={props.disabled || props.dictation.disabled()}
@@ -34,7 +34,7 @@ export function DictationPanel(props: { dictation: DictationController }) {
return (
<Show when={props.dictation.active()}>
<div
- class="absolute inset-0 z-10 flex items-center gap-2 rounded-[inherit] bg-composer px-[9.375px] text-composer-ink touch:gap-1.5 touch:bg-chrome touch:pr-2 touch:pl-3"
+ class="absolute inset-0 z-10 flex items-center gap-2 rounded-[inherit] bg-composer px-[9.375px] text-composer-ink"
role="group"
aria-label="Dictation"
onKeyDown={(event) => {
@@ -45,7 +45,7 @@ export function DictationPanel(props: { dictation: DictationController }) {
}
}}
>
- <div class="flex min-w-0 flex-1 items-center gap-3 px-2 touch:gap-2 touch:px-0">
+ <div class="flex min-w-0 flex-1 items-center gap-3 px-2">
<VolumeTimeline levels={props.dictation.volumeHistory()} />
<span
class="shrink-0 text-xs text-ink-muted"
@@ -62,7 +62,7 @@ export function DictationPanel(props: { dictation: DictationController }) {
<Button
variant="ghost"
size="icon-composer"
- class="text-composer-ink touch:bg-ink/5 touch:text-ink-muted"
+ class="text-composer-ink"
label="Cancel dictation"
ref={(element) =>
queueMicrotask(() => {
@@ -73,12 +73,10 @@ export function DictationPanel(props: { dictation: DictationController }) {
>
<XIcon />
</Button>
- {/* Confirm is the composer's primary action while recording, so on
- touch it borrows the send button's filled circle. */}
<Button
variant="ghost"
size="icon-composer"
- class="text-composer-ink touch:bg-ink touch:text-surface-4"
+ class="text-composer-ink"
label="Use dictation"
disabled={
props.dictation.phase() === 'starting' ||
diff --git a/apps/web/src/features/dictation/components/volume-timeline.tsx b/apps/web/src/features/dictation/components/volume-timeline.tsx
index 890408ddea..994f9c9dea 100644
--- a/apps/web/src/features/dictation/components/volume-timeline.tsx
+++ b/apps/web/src/features/dictation/components/volume-timeline.tsx
@@ -39,7 +39,7 @@ export function VolumeTimeline(props: { levels: readonly number[] }) {
<div
ref={setContainer}
aria-hidden="true"
- class="relative h-8 min-w-0 flex-1 overflow-hidden touch:h-6"
+ class="relative h-8 min-w-0 flex-1 overflow-hidden"
>
<div
ref={strip}
@@ -49,8 +49,7 @@ export function VolumeTimeline(props: { levels: readonly number[] }) {
{(level) => (
<span
class="w-[3px] shrink-0 rounded-full bg-current"
- // Heights are relative so the strip scales with the container,
- // which is shorter on touch than it is on the desktop composer.
+ // Heights are relative so the strip scales with the container.
style={{
height: `${(3 + level() * 29) / 0.32}%`,
opacity: level() > 0 ? '0.65' : '0.3',
diff --git a/apps/web/src/features/dictation/composer-dictation.ts b/apps/web/src/features/dictation/composer-dictation.ts
index 15eaea7f7a..e1d7ca811d 100644
--- a/apps/web/src/features/dictation/composer-dictation.ts
+++ b/apps/web/src/features/dictation/composer-dictation.ts
@@ -1,8 +1,8 @@
-import { enableDictation, isFeatureEnabled } from '@core/constant/featureFlags';
import { Telemetry } from '@macro-inc/observability';
import { transcribeAudio } from '@queries/dictation/transcribe';
import type { LexicalEditor } from 'lexical';
import { $getRoot } from 'lexical';
+import { isDictationAvailable } from './availability';
import { AudioRecorder, audioRecorder } from './browser/audio-recorder';
import { createRecordedDictation } from './primitives/create-recorded-dictation';
@@ -12,7 +12,7 @@ export function createComposerDictation(editor: () => LexicalEditor) {
return createRecordedDictation({
// Off means the recorder is never created: no microphone prompt, no audio
// in memory, and no transcription request.
- supported: isFeatureEnabled(enableDictation) && AudioRecorder.isSupported(),
+ supported: isDictationAvailable() && AudioRecorder.isSupported(),
startTrace: () => Telemetry.span('dictation.session'),
createRecorder: (callbacks) => audioRecorder.createSession(callbacks),
transcribe: (audio, signal, trace) =>
diff --git a/docs/agent-guide/ai-chat.md b/docs/agent-guide/ai-chat.md
index f658a40503..81232d92fd 100644
--- a/docs/agent-guide/ai-chat.md
+++ b/docs/agent-guide/ai-chat.md
@@ -1086,10 +1086,11 @@ preserve the submitted tool selection.
## Composer anatomy (a11y)
-AI chat (including Home and doc-scoped chat) and agent session composers have
-a **Start dictation** microphone beside Send. It records
-in memory and uploads to the
-authenticated `/dictation/transcribe` storage endpoint only on confirmation.
+On pointer devices, AI chat (including Home and doc-scoped chat) and agent
+session composers have a **Start dictation** microphone beside Send. Touch
+devices omit it because their keyboards already dictate. It records in memory
+and uploads to the authenticated `/dictation/transcribe` storage endpoint only
+on confirmation.
Whisper is available on all plans without consuming chat credits; its server
credential is never exposed to the browser. Unsupported recording environments
show a disabled microphone. Every supported browser uses Whisper; there are
@@ -1106,7 +1107,6 @@ If the browser stops listening on its own, **Ready** waits for confirmation.
While **Finishing…**, the checkmark is disabled and Cancel remains available.
No provider name or transcription hint appears below the composer; only the
recording limit and failures do.
-Mobile chat stays expanded when focus moves into dictation controls.
Starting dictation in another composer releases the previous session without
moving focus back to it. Closing the composer releases the microphone. Capture failures
appear below the composer.
diff --git a/docs/agent-guide/channels.md b/docs/agent-guide/channels.md
index 41e3a4e435..09fe3118df 100644
--- a/docs/agent-guide/channels.md
+++ b/docs/agent-guide/channels.md
@@ -277,15 +277,16 @@ verify that its tool response includes the matching attachment URLs.
## Message composer
-Channel messages and thread replies have a microphone next to Send, including
-the collapsed composer. It uses the same OpenAI Whisper dictation and scrolling
-volume timeline as AI chat. **Use dictation** appends text to the draft without
+Channel messages and thread replies have a microphone next to Send on pointer
+devices. It uses the same OpenAI Whisper dictation and scrolling volume
+timeline as AI chat. **Use dictation** appends text to the draft without
sending; **Cancel dictation** or Escape preserves the existing draft. Sending
is blocked during dictation, including keyboard and external send actions.
-When local recognition is unavailable, confirming uploads the in-memory audio
-to Whisper. This fallback is available on all plans without consuming chat credits.
-Browsers without microphone recording show a disabled button.
-The first click downloads a language pack when needed; click again to record.
+Confirming uploads the in-memory audio to Whisper, which is available on all
+plans without consuming chat credits. Browsers without microphone recording
+show a disabled button. Touch devices have no microphone in either the
+collapsed or the expanded composer — their keyboards already dictate — so Send
+is the only control on that edge.
Composer and conversation body text use `text-base` (15px at the default root
size) on desktop and mobile. The shared scale uses 14px for `text-sm` and 12px
@@ -1365,8 +1366,8 @@ For mobile send regressions, keep the software keyboard open and send several
short and multiline messages consecutively. The keyboard should remain open,
the cleared composer should retain focus, and a pinned chat should remain at the
bottom through composer resizing and server acknowledgement. Check that restoring
-the caret after send does not pan the page while the keyboard resizes. Repeat with dictation
-and check that sent text does not return. Scroll into history before an incoming
+the caret after send does not pan the page while the keyboard resizes. Repeat with the
+keyboard's own dictation and check that sent text does not return. Scroll into history before an incoming
message or acknowledgement and verify that it does not pull you to latest.
For composer cleanup, repeatedly open and leave channels and threads, then