refactor(mobile): remove native chat re-export facades (#13436)
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { useMemo, useRef, useState } from 'react'
|
||||
import { Pressable, ScrollView, StyleSheet, Text, TextInput, View } from 'react-native'
|
||||
import { Check } from 'lucide-react-native'
|
||||
import type { AskAnswerSelection, AskPrompt } from '../../../src/shared/native-chat-ask'
|
||||
import { colors, radii, spacing, typography } from '../theme/mobile-theme'
|
||||
import type { AskAnswerSelection, AskPrompt } from './mobile-native-chat-ask'
|
||||
|
||||
type Props = {
|
||||
prompt: AskPrompt
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { createElement } from 'react'
|
||||
import { act, create, type ReactTestInstance, type ReactTestRenderer } from 'react-test-renderer'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { MAX_TOOL_DETAIL_LENGTH } from '../../../src/shared/native-chat-tool-summary'
|
||||
import type { NativeChatMessage } from '../../../src/shared/native-chat-types'
|
||||
import { MAX_TOOL_DETAIL_LENGTH } from './mobile-native-chat-tool-summary'
|
||||
|
||||
vi.mock('react-native', async () => {
|
||||
const React = await import('react')
|
||||
|
||||
@@ -2,25 +2,22 @@ import { memo, useEffect, useRef, useState } from 'react'
|
||||
import { Image, Pressable, Text, View } from 'react-native'
|
||||
import * as Clipboard from 'expo-clipboard'
|
||||
import { ArrowUp, ChevronDown, Copy, SquareChevronRight } from 'lucide-react-native'
|
||||
import type { NativeChatBlock, NativeChatMessage } from '../../../src/shared/native-chat-types'
|
||||
import { MobileMarkdown } from '../components/MobileMarkdown'
|
||||
import { colors } from '../theme/mobile-theme'
|
||||
import {
|
||||
isImageRefBlock,
|
||||
isTextBlock,
|
||||
pairToolBlocks,
|
||||
splitNativeChatBlocks,
|
||||
type ToolPair
|
||||
} from './mobile-native-chat-blocks'
|
||||
import { diffFromText, diffFromToolCall, type DiffLine } from './mobile-native-chat-diff'
|
||||
import { isRenderableImageUri } from './mobile-native-chat-image-preview'
|
||||
import { styles, TEXT_SIZE } from './mobile-native-chat-message-styles'
|
||||
import { nativeChatMessageText } from './mobile-native-chat-message-text'
|
||||
import { diffFromText, diffFromToolCall } from '../../../src/shared/native-chat-diff'
|
||||
import type { NativeChatDiffLine as DiffLine } from '../../../src/shared/native-chat-diff'
|
||||
import { pairToolBlocks, splitNativeChatBlocks } from '../../../src/shared/native-chat-tool-fold'
|
||||
import type { NativeChatToolPair as ToolPair } from '../../../src/shared/native-chat-tool-fold'
|
||||
import {
|
||||
createToolInputDisplay,
|
||||
summarizeToolRun,
|
||||
truncateToolDetail
|
||||
} from './mobile-native-chat-tool-summary'
|
||||
} from '../../../src/shared/native-chat-tool-summary'
|
||||
import { isImageRefBlock, isTextBlock } from '../../../src/shared/native-chat-types'
|
||||
import type { NativeChatBlock, NativeChatMessage } from '../../../src/shared/native-chat-types'
|
||||
import { MobileMarkdown } from '../components/MobileMarkdown'
|
||||
import { colors } from '../theme/mobile-theme'
|
||||
import { isRenderableImageUri } from './mobile-native-chat-image-preview'
|
||||
import { styles, TEXT_SIZE } from './mobile-native-chat-message-styles'
|
||||
import { nativeChatMessageText } from './mobile-native-chat-message-text'
|
||||
|
||||
const MAX_VISIBLE_TOOL_PAIRS = 6
|
||||
const MAX_TOOL_RUN_DIFF_ROWS = 240
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
||||
import { GestureDetector, GestureHandlerRootView } from 'react-native-gesture-handler'
|
||||
import { ArrowDown, ChevronsDownUp, ChevronsUpDown, Square } from 'lucide-react-native'
|
||||
import type { AskAnswerSelection, AskPrompt } from '../../../src/shared/native-chat-ask'
|
||||
import type { NativeChatMessage } from '../../../src/shared/native-chat-types'
|
||||
import { colors } from '../theme/mobile-theme'
|
||||
import { styles } from './mobile-native-chat-view-styles'
|
||||
@@ -26,7 +27,6 @@ import { MobileNativeChatComposer } from './MobileNativeChatComposer'
|
||||
import type { MobileNativeChatSessionOptionPickersProps } from './MobileNativeChatSessionOptionPickers'
|
||||
import { MobileNativeChatMessage } from './MobileNativeChatMessage'
|
||||
import { MobileNativeChatAsk } from './MobileNativeChatAsk'
|
||||
import type { AskAnswerSelection, AskPrompt } from './mobile-native-chat-ask'
|
||||
import { MobileNativeChatPermission } from './MobileNativeChatPermission'
|
||||
import type { MobileChatPermission } from './mobile-native-chat-permission'
|
||||
import { MobileNativeChatQuestion } from './MobileNativeChatQuestion'
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import type { NativeChatMessage } from '../../../src/shared/native-chat-types'
|
||||
import {
|
||||
buildAskAnswerKeys,
|
||||
extractPendingAsk,
|
||||
formatAskAnswer,
|
||||
parseAskFromStatus
|
||||
} from './mobile-native-chat-ask'
|
||||
} from '../../../src/shared/native-chat-ask'
|
||||
import type { NativeChatMessage } from '../../../src/shared/native-chat-types'
|
||||
|
||||
function msg(blocks: NativeChatMessage['blocks'], id = 'm'): NativeChatMessage {
|
||||
return { id, role: 'assistant', blocks, timestamp: 0, source: 'transcript' }
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
// Mobile and desktop share one parser/formatter so question-tool behavior cannot drift.
|
||||
export * from '../../../src/shared/native-chat-ask'
|
||||
@@ -1,10 +1,10 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import type { NativeChatMessage } from '../../../src/shared/native-chat-types'
|
||||
import {
|
||||
foldToolMessages,
|
||||
pairToolBlocks,
|
||||
splitNativeChatBlocks
|
||||
} from './mobile-native-chat-blocks'
|
||||
} from '../../../src/shared/native-chat-tool-fold'
|
||||
import type { NativeChatMessage } from '../../../src/shared/native-chat-types'
|
||||
|
||||
function msg(
|
||||
role: NativeChatMessage['role'],
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
export {
|
||||
isImageRefBlock,
|
||||
isTextBlock,
|
||||
NATIVE_CHAT_SOURCE_PRIORITY
|
||||
} from '../../../src/shared/native-chat-types'
|
||||
export {
|
||||
foldToolMessages,
|
||||
pairToolBlocks,
|
||||
splitNativeChatBlocks,
|
||||
type NativeChatToolPair as ToolPair
|
||||
} from '../../../src/shared/native-chat-tool-fold'
|
||||
@@ -1,7 +1,11 @@
|
||||
import type { Dispatch, MutableRefObject, SetStateAction } from 'react'
|
||||
import type {
|
||||
AskAnswerSelection,
|
||||
AskPrompt,
|
||||
parseAskFromStatus
|
||||
} from '../../../src/shared/native-chat-ask'
|
||||
import type { detectAgentPermission } from './mobile-native-chat-permission'
|
||||
import type { parseAgentQuestion } from './mobile-native-chat-question'
|
||||
import type { AskAnswerSelection, AskPrompt, parseAskFromStatus } from './mobile-native-chat-ask'
|
||||
import type { MobileNativeChatSendOutcome } from './mobile-native-chat-send'
|
||||
import type { MobileNativeChatPendingMessage } from './use-mobile-native-chat-drafts'
|
||||
import type { useMobileNativeChatSession } from './use-mobile-native-chat-session'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { diffFromText, diffFromToolCall } from './mobile-native-chat-diff'
|
||||
import { diffFromText, diffFromToolCall } from '../../../src/shared/native-chat-diff'
|
||||
|
||||
describe('diffFromToolCall', () => {
|
||||
it('builds del/add lines from an Edit tool call', () => {
|
||||
@@ -36,8 +36,6 @@ describe('diffFromText', () => {
|
||||
expect(diffFromText('Here is a list:\n- one bullet\nthat is all')).toBeNull()
|
||||
})
|
||||
|
||||
// Parity guard: the mobile module re-exports the shared parser, so the -- / ++
|
||||
// content collision must stay fixed on both platforms.
|
||||
it('counts a removed -- comment line despite the --- prefix collision', () => {
|
||||
const lines = diffFromText('@@ -1,2 +1,2 @@\n ctx\n---sql comment\n+new')
|
||||
expect(lines).toEqual([
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
export {
|
||||
diffFromText,
|
||||
diffFromToolCall,
|
||||
type NativeChatDiffLine as DiffLine,
|
||||
type NativeChatDiffLineKind as DiffLineKind
|
||||
} from '../../../src/shared/native-chat-diff'
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { mergeNativeChatMessages } from '../../../src/shared/native-chat-merge'
|
||||
import type { NativeChatMessage } from '../../../src/shared/native-chat-types'
|
||||
import { mergeNativeChatMessages } from './mobile-native-chat-merge'
|
||||
|
||||
function msg(id: string, overrides: Partial<NativeChatMessage> = {}): NativeChatMessage {
|
||||
return {
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
// Keep the established mobile import path while executing the shared desktop/mobile merger.
|
||||
export {
|
||||
applyAppend,
|
||||
boundNativeChatWindow,
|
||||
createNativeChatMerger,
|
||||
mergeNativeChatMessages,
|
||||
replaceList,
|
||||
type NativeChatMerger
|
||||
} from '../../../src/shared/native-chat-merge'
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
createNativeChatMerger,
|
||||
mergeNativeChatMessages,
|
||||
replaceList
|
||||
} from './mobile-native-chat-merge'
|
||||
} from '../../../src/shared/native-chat-merge'
|
||||
|
||||
function msg(id: string, overrides: Partial<NativeChatMessage> = {}): NativeChatMessage {
|
||||
return {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { NativeChatBlock } from '../../../src/shared/native-chat-types'
|
||||
import { isTextBlock } from './mobile-native-chat-blocks'
|
||||
import { isTextBlock, type NativeChatBlock } from '../../../src/shared/native-chat-types'
|
||||
|
||||
/** Concatenate a message's text blocks into a single copyable string. Tool
|
||||
* calls/results and image refs are skipped — Copy is for the agent's prose. */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { isNoiseMessage, stripNoiseMessages } from '../../../src/shared/native-chat-noise'
|
||||
import type { NativeChatMessage } from '../../../src/shared/native-chat-types'
|
||||
import { isNoiseMessage, stripNoiseMessages } from './mobile-native-chat-noise'
|
||||
|
||||
function msg(
|
||||
role: NativeChatMessage['role'],
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
export { isNoiseMessage, stripNoiseMessages } from '../../../src/shared/native-chat-noise'
|
||||
@@ -3,10 +3,10 @@ import {
|
||||
formatNativeChatEmptyStateCopy,
|
||||
type NativeChatEmptyStateCopy
|
||||
} from '../../../src/shared/native-chat-empty-state'
|
||||
import { stripNoiseMessages } from '../../../src/shared/native-chat-noise'
|
||||
import { foldToolMessages } from '../../../src/shared/native-chat-tool-fold'
|
||||
import { isImageRefBlock, type NativeChatMessage } from '../../../src/shared/native-chat-types'
|
||||
import { foldToolMessages } from './mobile-native-chat-blocks'
|
||||
import { normalizeImageTranscriptMessages } from './mobile-native-chat-image-transcript-markers'
|
||||
import { stripNoiseMessages } from './mobile-native-chat-noise'
|
||||
import type { MobileNativeChatStatus } from './use-mobile-native-chat-session'
|
||||
|
||||
/** The centered empty-state copy for a chat with no messages, mirroring the
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { createNativeChatMerger, replaceList } from '../../../src/shared/native-chat-merge'
|
||||
import type { NativeChatMessage } from '../../../src/shared/native-chat-types'
|
||||
import { createNativeChatMerger, replaceList } from './mobile-native-chat-merge'
|
||||
import { applyMobileNativeChatStreamFrame } from './mobile-native-chat-stream-frame'
|
||||
|
||||
function message(id: string): NativeChatMessage {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { applyAppend, replaceList } from '../../../src/shared/native-chat-merge'
|
||||
import type { NativeChatMerger } from '../../../src/shared/native-chat-merge'
|
||||
import type { NativeChatMessage } from '../../../src/shared/native-chat-types'
|
||||
import { applyAppend, replaceList, type NativeChatMerger } from './mobile-native-chat-merge'
|
||||
|
||||
export type MobileNativeChatStreamFrame = {
|
||||
type?: string
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
describeToolInput,
|
||||
summarizeToolInput,
|
||||
toolFilePath
|
||||
} from './mobile-native-chat-tool-summary'
|
||||
} from '../../../src/shared/native-chat-tool-summary'
|
||||
|
||||
describe('summarizeToolInput', () => {
|
||||
it('passes short strings through, collapsing whitespace', () => {
|
||||
@@ -59,7 +59,7 @@ describe('toolFilePath', () => {
|
||||
})
|
||||
|
||||
describe('describeToolInput', () => {
|
||||
it('is re-exported and labels rows with the path or primary argument', () => {
|
||||
it('labels rows with the path or primary argument', () => {
|
||||
expect(describeToolInput({ file_path: 'src/a.ts', offset: 3 })).toBe('src/a.ts')
|
||||
expect(describeToolInput('{"cmd":"git status"}')).toBe('git status')
|
||||
})
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
export {
|
||||
briefToolArg,
|
||||
countToolCalls,
|
||||
createToolInputDisplay,
|
||||
describeToolInput,
|
||||
formatToolInput,
|
||||
isStructuredToolInput,
|
||||
MAX_TOOL_DETAIL_LENGTH,
|
||||
summarizeToolInput,
|
||||
summarizeToolRun,
|
||||
toolFilePath,
|
||||
truncateToolDetail
|
||||
} from '../../../src/shared/native-chat-tool-summary'
|
||||
@@ -1,11 +1,11 @@
|
||||
import { createElement } from 'react'
|
||||
import { act, create, type ReactTestRenderer } from 'react-test-renderer'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { AskPrompt } from '../../../src/shared/native-chat-ask'
|
||||
import type { AgentType } from '../../../src/shared/native-chat-types'
|
||||
import type { RpcClient } from '../transport/rpc-client'
|
||||
import { markRpcDeliveryUnknown } from '../transport/rpc-delivery-ambiguity'
|
||||
import { MOBILE_NATIVE_CHAT_QUESTION_STEP_MS } from './mobile-native-chat-answer-stepping'
|
||||
import type { AskPrompt } from './mobile-native-chat-ask'
|
||||
import {
|
||||
isMobileNativeChatInputStale,
|
||||
markMobileNativeChatInputStale,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { useCallback, useEffect, useRef, type MutableRefObject } from 'react'
|
||||
import type { RpcClient } from '../transport/rpc-client'
|
||||
import { MOBILE_NATIVE_CHAT_QUESTION_STEP_MS } from './mobile-native-chat-answer-stepping'
|
||||
import {
|
||||
buildAskAnswerKeys,
|
||||
buildCodexAskAnswerKeys,
|
||||
@@ -8,7 +6,9 @@ import {
|
||||
hasAskAnswer,
|
||||
type AskAnswerSelection,
|
||||
type AskPrompt
|
||||
} from './mobile-native-chat-ask'
|
||||
} from '../../../src/shared/native-chat-ask'
|
||||
import type { RpcClient } from '../transport/rpc-client'
|
||||
import { MOBILE_NATIVE_CHAT_QUESTION_STEP_MS } from './mobile-native-chat-answer-stepping'
|
||||
import {
|
||||
openMobileNativeChatSendBudget,
|
||||
sendMobileNativeChatMessageWithOutcome
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createElement } from 'react'
|
||||
import { act, create, type ReactTestRenderer } from 'react-test-renderer'
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
||||
import type { AskPrompt } from './mobile-native-chat-ask'
|
||||
import type { AskPrompt } from '../../../src/shared/native-chat-ask'
|
||||
import { useMobileNativeChatAskDismiss } from './use-mobile-native-chat-ask-dismiss'
|
||||
|
||||
describe('useMobileNativeChatAskDismiss', () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { nativeChatAskDismissKey, type AskPrompt } from './mobile-native-chat-ask'
|
||||
import { nativeChatAskDismissKey, type AskPrompt } from '../../../src/shared/native-chat-ask'
|
||||
|
||||
type AskDismissal = { sessionKey: string | null; askKey: string }
|
||||
type DetectedAsk = { sessionKey: string | null; askKey: string | null }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useMemo } from 'react'
|
||||
import type { AgentStatusEntry } from '../../../src/shared/agent-status-types'
|
||||
import { parseAskFromStatus, resolveNativeChatAsk } from '../../../src/shared/native-chat-ask'
|
||||
import type { NativeChatMessage } from '../../../src/shared/native-chat-types'
|
||||
import { parseAskFromStatus, resolveNativeChatAsk } from './mobile-native-chat-ask'
|
||||
import { detectAgentPermission, parseApprovalFromStatus } from './mobile-native-chat-permission'
|
||||
import { parseAgentQuestion } from './mobile-native-chat-question'
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@ import {
|
||||
createNativeChatTranscriptRetention,
|
||||
encodeNativeChatTranscriptIdentity
|
||||
} from '../../../src/shared/native-chat-transcript-retention'
|
||||
import { createNativeChatMerger, replaceList } from '../../../src/shared/native-chat-merge'
|
||||
import type { NativeChatMessage } from '../../../src/shared/native-chat-types'
|
||||
import { buildNativeChatSubscriptionId } from '../../../src/shared/native-chat-stream-unsubscribe'
|
||||
import type { RpcClient } from '../transport/rpc-client'
|
||||
import { createNativeChatMerger, replaceList } from './mobile-native-chat-merge'
|
||||
import {
|
||||
applyMobileNativeChatStreamFrame,
|
||||
type MobileNativeChatStreamFrame
|
||||
|
||||
Reference in New Issue
Block a user