fix(mobile): preserve repeated iOS terminal hyphens (#5222)

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Jinwoo Hong
2026-06-11 15:53:56 -07:00
committed by GitHub
co-authored by Orca
parent c24d4c42c4
commit 58ce969fcb
4 changed files with 24 additions and 4 deletions
+1 -1
View File
@@ -16,7 +16,7 @@
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.stably.orca.mobile",
"buildNumber": "1",
"buildNumber": "2",
"infoPlist": {
"NSLocalNetworkUsageDescription": "Orca connects to the desktop app on your local network.",
"NSMicrophoneUsageDescription": "Allow Orca to record voice dictation and transcribe it on your paired desktop.",
@@ -4296,13 +4296,16 @@ export default function SessionScreen() {
<TextInput
style={styles.textInput}
value={input}
onChangeText={(text) => setInput(normalizeTerminalTextInput(text))}
onChangeText={(text) =>
setInput((previousText) => normalizeTerminalTextInput(text, previousText))
}
placeholder="Type a command…"
placeholderTextColor={colors.textMuted}
autoCapitalize="none"
autoCorrect={false}
spellCheck={false}
smartInsertDelete={false}
keyboardType={Platform.OS === 'ios' ? 'ascii-capable' : 'visible-password'}
returnKeyType="send"
editable={canSend}
onSubmitEditing={() => void handleSend()}
@@ -11,4 +11,10 @@ describe('normalizeTerminalTextInput', () => {
it('keeps ASCII hyphens unchanged', () => {
expect(normalizeTerminalTextInput('git checkout -- file')).toBe('git checkout -- file')
})
it('preserves longer trailing hyphen runs when iOS re-collapses the controlled value', () => {
expect(normalizeTerminalTextInput('—', '--')).toBe('---')
expect(normalizeTerminalTextInput('—', '---')).toBe('----')
expect(normalizeTerminalTextInput('git checkout —', 'git checkout --')).toBe('git checkout ---')
})
})
@@ -1,7 +1,18 @@
// Why: iOS smart punctuation can rewrite two ASCII hyphens into a single
// Unicode dash before React Native delivers terminal text input.
const IOS_SMART_DASH_REPLACEMENT_PATTERN = /[\u2013\u2014]/g
const IOS_SMART_DASH_REPLACEMENT_TEST = /[\u2013\u2014]/
export function normalizeTerminalTextInput(text: string): string {
return text.replace(IOS_SMART_DASH_REPLACEMENT_PATTERN, '--')
export function normalizeTerminalTextInput(text: string, previousText = ''): string {
const normalizedText = text.replace(IOS_SMART_DASH_REPLACEMENT_PATTERN, '--')
const previousTrailingHyphens = /-+$/.exec(previousText)?.[0] ?? ''
const previousPrefix = previousText.slice(0, previousText.length - previousTrailingHyphens.length)
const collapsedPreviousHyphenRun =
previousTrailingHyphens.length >= 2 &&
IOS_SMART_DASH_REPLACEMENT_TEST.test(text) &&
(text === `${previousPrefix}\u2013` || text === `${previousPrefix}\u2014`)
if (collapsedPreviousHyphenRun) {
return `${previousText}-`
}
return normalizedText
}