Skip to content

Commit 930aec1

Browse files
fix(mobile): keep the dictation timer from shifting width (#15504)
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
1 parent fe93a5d commit 930aec1

2 files changed

Lines changed: 33 additions & 22 deletions

File tree

‎apps/mobile/src/features/voice-input/ComposerDictationControl.tsx‎

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
Linking,
66
Platform,
77
Pressable,
8+
Text as SystemText,
89
View,
910
type LayoutChangeEvent,
1011
} from "react-native";
@@ -245,6 +246,25 @@ const VoiceWaveform = memo(function VoiceWaveform(props: {
245246
);
246247
});
247248

249+
/**
250+
* Renders the recording time in the system font: DM Sans has no tabular
251+
* figures, so `tabular-nums` alone would still let the width jitter.
252+
*/
253+
export function DictationElapsedTime(props: {
254+
readonly seconds: number;
255+
readonly className?: string;
256+
}) {
257+
return (
258+
<SystemText
259+
className={cn("text-xs", props.className)}
260+
numberOfLines={1}
261+
style={{ fontVariant: ["tabular-nums"] }}
262+
>
263+
{Math.floor(props.seconds / 60)}:{String(props.seconds % 60).padStart(2, "0")}
264+
</SystemText>
265+
);
266+
}
267+
248268
function VoiceActionButton(props: {
249269
readonly accessibilityLabel: string;
250270
readonly disabled?: boolean;
@@ -322,7 +342,6 @@ export function ComposerDictationStatus(props: {
322342

323343
if (!props.presentation.statusLabel) return null;
324344
const isError = props.presentation.statusKind === "error";
325-
const elapsedLabel = `${Math.floor(props.elapsedSeconds / 60)}:${String(props.elapsedSeconds % 60).padStart(2, "0")}`;
326345
return (
327346
<View className="relative h-11 min-w-0 flex-1 justify-center">
328347
{isError ? (
@@ -357,13 +376,10 @@ export function ComposerDictationStatus(props: {
357376
style={waveformStyle}
358377
>
359378
<VoiceWaveform audioLevels={props.audioLevels} />
360-
<Text
361-
className="text-xs text-foreground-muted"
362-
numberOfLines={1}
363-
style={{ fontVariant: ["tabular-nums"] }}
364-
>
365-
{elapsedLabel}
366-
</Text>
379+
<DictationElapsedTime
380+
className="text-foreground-muted"
381+
seconds={props.elapsedSeconds}
382+
/>
367383
</Animated.View>
368384
<Animated.View className="absolute inset-0 justify-center px-2" style={labelStyle}>
369385
<Text className="text-center text-sm text-foreground-muted" numberOfLines={1}>

‎apps/mobile/src/features/voice-input/GlobalVoiceInputControl.tsx‎

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { AppText as Text } from "../../components/AppText";
2424
import { SymbolView } from "../../components/AppSymbol";
2525
import { useAndroidControlSizing } from "../../components/useAndroidControlSizing";
2626
import { cn } from "../../lib/cn";
27-
import { CompactVoiceWaveform } from "./ComposerDictationControl";
27+
import { CompactVoiceWaveform, DictationElapsedTime } from "./ComposerDictationControl";
2828
import { useGlobalVoiceInput } from "./VoiceInputProvider";
2929
import { resolveVoiceComposerPresentation } from "./voiceInputPresentation";
3030

@@ -114,7 +114,6 @@ function EdgeDictationPill(props: { readonly collapseRef: RefObject<(() => void)
114114
const isError = phase === "error";
115115
const openSettings = isError && voice.state.errorAction === "settings";
116116
const label = voice.label ?? "Draft";
117-
const elapsedLabel = `${Math.floor(voice.elapsedSeconds / 60)}:${String(voice.elapsedSeconds % 60).padStart(2, "0")}`;
118117

119118
return (
120119
<View pointerEvents="box-none" className="absolute inset-0">
@@ -149,12 +148,10 @@ function EdgeDictationPill(props: { readonly collapseRef: RefObject<(() => void)
149148
) : phase === "recording" ? (
150149
<>
151150
<View className="size-2 rounded-full bg-danger-foreground" />
152-
<Text
153-
className="text-xs text-foreground"
154-
style={{ fontVariant: ["tabular-nums"] }}
155-
>
156-
{elapsedLabel}
157-
</Text>
151+
<DictationElapsedTime
152+
className="text-foreground"
153+
seconds={voice.elapsedSeconds}
154+
/>
158155
</>
159156
) : (
160157
<ActivityIndicator size="small" colorClassName="accent-icon-muted" />
@@ -202,12 +199,10 @@ function EdgeDictationPill(props: { readonly collapseRef: RefObject<(() => void)
202199
{phase === "recording" ? (
203200
<>
204201
<CompactVoiceWaveform audioLevels={voice.audioLevels} />
205-
<Text
206-
className="text-xs text-foreground-muted"
207-
style={{ fontVariant: ["tabular-nums"] }}
208-
>
209-
{elapsedLabel}
210-
</Text>
202+
<DictationElapsedTime
203+
className="text-foreground-muted"
204+
seconds={voice.elapsedSeconds}
205+
/>
211206
<Pressable
212207
accessibilityLabel="Finish dictation"
213208
accessibilityRole="button"

0 commit comments

Comments
 (0)