Something went wrong. Try again.
source dump of claude code forked from oppi.li/claude-code
Something went wrong. Try again.
1.2 kB · 32 lines
TypeScript
at main
123456789101112131415161718192021222324252627282930313233/** * Normalize camelCase `requestId` → snake_case `request_id` on incoming * control messages (control_request, control_response). * * Older iOS app builds send `requestId` due to a missing Swift CodingKeys * mapping. Without this shim, `isSDKControlRequest` in replBridge.ts rejects * the message (it checks `'request_id' in value`), and structuredIO.ts reads * `message.response.request_id` as undefined — both silently drop the message. * * If both `request_id` and `requestId` are present, snake_case wins. * Mutates the object in place. */export function normalizeControlMessageKeys(obj: unknown): unknown { if (obj === null || typeof obj !== 'object') return obj const record = obj as Record<string, unknown> if ('requestId' in record && !('request_id' in record)) { record.request_id = record.requestId delete record.requestId } if ( 'response' in record && record.response !== null && typeof record.response === 'object' ) { const response = record.response as Record<string, unknown> if ('requestId' in response && !('request_id' in response)) { response.request_id = response.requestId delete response.requestId } } return obj}