mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
refactor(mobile): group native chat modules by feature owner
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -8013,7 +8013,7 @@
|
||||
"tests/e2e/host-agent-launch-preferences-work.unit.test.ts": 3882,
|
||||
"tests/e2e/host-agent-launch-settings-hook-bookkeeping.unit.test.ts": 21972,
|
||||
"tests/e2e/host-cold-park-remote-subscriber.unit.test.ts": 5314,
|
||||
"tests/e2e/journal-restored-consumers.unit.test.ts": 33933,
|
||||
|
||||
"tests/e2e/launch-agent-background-session-remote.unit.test.ts": 1016,
|
||||
"tests/e2e/launch-agent-in-new-tab-web-runtime.unit.test.ts": 14288,
|
||||
"tests/e2e/linear-cli-recovery.unit.test.ts": 7592,
|
||||
@@ -8025,7 +8025,7 @@
|
||||
"tests/e2e/native-chat-rewind-boundary.unit.test.ts": 2977,
|
||||
"tests/e2e/native-chat-ssh-transcript.unit.test.ts": 1166,
|
||||
"tests/e2e/native-chat-startup-option-pickers.unit.test.ts": 9377,
|
||||
"tests/e2e/native-chat-transcript-file-order.unit.test.ts": 1066,
|
||||
|
||||
"tests/e2e/native-chat-transcript-reasoning.unit.test.ts": 3341,
|
||||
"tests/e2e/nested-agent-idle-owner.unit.test.ts": 2469,
|
||||
"tests/e2e/omp-child-session-recovery.unit.test.ts": 2205,
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ import { View } from 'react-native'
|
||||
import { GestureHandlerRootView } from 'react-native-gesture-handler'
|
||||
import { MobileNativeChatQueuedMessages } from './src/session/native-chat/input/MobileNativeChatQueuedMessages'
|
||||
import { MobileNativeChatComposer } from './src/session/native-chat/composer/MobileNativeChatComposer'
|
||||
import { mobileQueuedMessageCards } from './src/session/mobile-structured-queued-message-cards'
|
||||
import { mobileQueuedMessageCards } from './src/session/native-chat/input/mobile-structured-queued-message-cards'
|
||||
import { activateMobileUiLocale, translate } from './src/i18n/mobile-i18n'
|
||||
|
||||
const [mode, locale] = location.hash.slice(1).split(':')
|
||||
|
||||
@@ -18029,7 +18029,7 @@
|
||||
"id": "native-chat-write-accepted",
|
||||
"operation": "nativeChat.terminal-write",
|
||||
"family": "nativeChat.terminal-write",
|
||||
"sites": ["mobile/src/session/native-chat/mobile-native-chat-send.ts"],
|
||||
"sites": ["mobile/src/session/native-chat/composer/mobile-native-chat-send.ts"],
|
||||
"schedules": [],
|
||||
"steps": [
|
||||
{
|
||||
@@ -18065,7 +18065,7 @@
|
||||
"id": "native-chat-write-rejected",
|
||||
"operation": "nativeChat.terminal-write",
|
||||
"family": "nativeChat.terminal-write",
|
||||
"sites": ["mobile/src/session/native-chat/mobile-native-chat-send.ts"],
|
||||
"sites": ["mobile/src/session/native-chat/composer/mobile-native-chat-send.ts"],
|
||||
"schedules": [],
|
||||
"steps": [
|
||||
{
|
||||
@@ -18101,7 +18101,7 @@
|
||||
"id": "native-chat-write-delivery-unknown",
|
||||
"operation": "nativeChat.terminal-write",
|
||||
"family": "nativeChat.terminal-write",
|
||||
"sites": ["mobile/src/session/native-chat/mobile-native-chat-send.ts"],
|
||||
"sites": ["mobile/src/session/native-chat/composer/mobile-native-chat-send.ts"],
|
||||
"schedules": [],
|
||||
"steps": [
|
||||
{
|
||||
@@ -18133,7 +18133,7 @@
|
||||
"id": "native-chat-write-clear-line",
|
||||
"operation": "nativeChat.terminal-write",
|
||||
"family": "nativeChat.terminal-write",
|
||||
"sites": ["mobile/src/session/native-chat/mobile-native-chat-send.ts"],
|
||||
"sites": ["mobile/src/session/native-chat/composer/mobile-native-chat-send.ts"],
|
||||
"schedules": [],
|
||||
"steps": [
|
||||
{
|
||||
@@ -18169,7 +18169,7 @@
|
||||
"id": "native-chat-write-typed-command",
|
||||
"operation": "nativeChat.terminal-write",
|
||||
"family": "nativeChat.terminal-write",
|
||||
"sites": ["mobile/src/session/native-chat/mobile-native-chat-send.ts"],
|
||||
"sites": ["mobile/src/session/native-chat/composer/mobile-native-chat-send.ts"],
|
||||
"schedules": [],
|
||||
"steps": [
|
||||
{
|
||||
@@ -18840,7 +18840,9 @@
|
||||
"id": "structured-launch-unsupported",
|
||||
"operation": "agentSession.structured-launch",
|
||||
"family": "agentSession.structured-launch",
|
||||
"sites": ["mobile/src/session/mobile-structured-agent-session-launch.ts"],
|
||||
"sites": [
|
||||
"mobile/src/session/native-chat/agent-session/mobile-structured-agent-session-launch.ts"
|
||||
],
|
||||
"schedules": [],
|
||||
"steps": [
|
||||
{
|
||||
@@ -18870,7 +18872,9 @@
|
||||
"id": "structured-launch-support-refused",
|
||||
"operation": "agentSession.structured-launch",
|
||||
"family": "agentSession.structured-launch",
|
||||
"sites": ["mobile/src/session/mobile-structured-agent-session-launch.ts"],
|
||||
"sites": [
|
||||
"mobile/src/session/native-chat/agent-session/mobile-structured-agent-session-launch.ts"
|
||||
],
|
||||
"schedules": [],
|
||||
"steps": [
|
||||
{
|
||||
@@ -18900,7 +18904,9 @@
|
||||
"id": "structured-launch-created",
|
||||
"operation": "agentSession.structured-launch",
|
||||
"family": "agentSession.structured-launch",
|
||||
"sites": ["mobile/src/session/mobile-structured-agent-session-launch.ts"],
|
||||
"sites": [
|
||||
"mobile/src/session/native-chat/agent-session/mobile-structured-agent-session-launch.ts"
|
||||
],
|
||||
"schedules": [],
|
||||
"steps": [
|
||||
{
|
||||
@@ -18951,7 +18957,9 @@
|
||||
"id": "structured-launch-definitive-refusal",
|
||||
"operation": "agentSession.structured-launch",
|
||||
"family": "agentSession.structured-launch",
|
||||
"sites": ["mobile/src/session/mobile-structured-agent-session-launch.ts"],
|
||||
"sites": [
|
||||
"mobile/src/session/native-chat/agent-session/mobile-structured-agent-session-launch.ts"
|
||||
],
|
||||
"schedules": [],
|
||||
"steps": [
|
||||
{
|
||||
@@ -19003,7 +19011,9 @@
|
||||
"id": "structured-launch-replays-dropped-create",
|
||||
"operation": "agentSession.structured-launch",
|
||||
"family": "agentSession.structured-launch",
|
||||
"sites": ["mobile/src/session/mobile-structured-agent-session-launch.ts"],
|
||||
"sites": [
|
||||
"mobile/src/session/native-chat/agent-session/mobile-structured-agent-session-launch.ts"
|
||||
],
|
||||
"schedules": [],
|
||||
"steps": [
|
||||
{
|
||||
@@ -19443,7 +19453,7 @@
|
||||
"id": "native-chat-stop-accepted",
|
||||
"operation": "session.native-chat-stop",
|
||||
"family": "session.native-chat-stop",
|
||||
"sites": ["mobile/src/session/native-chat/use-mobile-native-chat-stop.ts"],
|
||||
"sites": ["mobile/src/session/native-chat/composer/use-mobile-native-chat-stop.ts"],
|
||||
"schedules": [],
|
||||
"steps": [
|
||||
{
|
||||
@@ -19504,7 +19514,7 @@
|
||||
"id": "native-chat-stop-both-rejected",
|
||||
"operation": "session.native-chat-stop",
|
||||
"family": "session.native-chat-stop",
|
||||
"sites": ["mobile/src/session/native-chat/use-mobile-native-chat-stop.ts"],
|
||||
"sites": ["mobile/src/session/native-chat/composer/use-mobile-native-chat-stop.ts"],
|
||||
"schedules": [],
|
||||
"steps": [
|
||||
{
|
||||
@@ -19562,7 +19572,7 @@
|
||||
"id": "native-chat-stop-delivery-unknown",
|
||||
"operation": "session.native-chat-stop",
|
||||
"family": "session.native-chat-stop",
|
||||
"sites": ["mobile/src/session/native-chat/use-mobile-native-chat-stop.ts"],
|
||||
"sites": ["mobile/src/session/native-chat/composer/use-mobile-native-chat-stop.ts"],
|
||||
"schedules": [],
|
||||
"steps": [
|
||||
{
|
||||
@@ -19962,7 +19972,7 @@
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-comment-actions.ts",
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-git-actions.ts",
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-send-actions.ts",
|
||||
"mobile/src/session/native-chat/mobile-native-chat-stale-input.ts"
|
||||
"mobile/src/session/native-chat/composer/mobile-native-chat-stale-input.ts"
|
||||
],
|
||||
"schedules": [],
|
||||
"steps": [
|
||||
@@ -20039,7 +20049,7 @@
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-comment-actions.ts",
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-git-actions.ts",
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-send-actions.ts",
|
||||
"mobile/src/session/native-chat/mobile-native-chat-stale-input.ts"
|
||||
"mobile/src/session/native-chat/composer/mobile-native-chat-stale-input.ts"
|
||||
],
|
||||
"schedules": [],
|
||||
"steps": [
|
||||
@@ -20117,7 +20127,7 @@
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-comment-actions.ts",
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-git-actions.ts",
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-send-actions.ts",
|
||||
"mobile/src/session/native-chat/mobile-native-chat-stale-input.ts"
|
||||
"mobile/src/session/native-chat/composer/mobile-native-chat-stale-input.ts"
|
||||
],
|
||||
"schedules": [],
|
||||
"steps": [
|
||||
@@ -20152,7 +20162,7 @@
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-comment-actions.ts",
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-git-actions.ts",
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-send-actions.ts",
|
||||
"mobile/src/session/native-chat/mobile-native-chat-stale-input.ts"
|
||||
"mobile/src/session/native-chat/composer/mobile-native-chat-stale-input.ts"
|
||||
],
|
||||
"schedules": [],
|
||||
"steps": [
|
||||
@@ -20188,7 +20198,7 @@
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-comment-actions.ts",
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-git-actions.ts",
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-send-actions.ts",
|
||||
"mobile/src/session/native-chat/mobile-native-chat-stale-input.ts"
|
||||
"mobile/src/session/native-chat/composer/mobile-native-chat-stale-input.ts"
|
||||
],
|
||||
"schedules": [],
|
||||
"steps": [
|
||||
@@ -20224,7 +20234,7 @@
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-comment-actions.ts",
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-git-actions.ts",
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-send-actions.ts",
|
||||
"mobile/src/session/native-chat/mobile-native-chat-stale-input.ts"
|
||||
"mobile/src/session/native-chat/composer/mobile-native-chat-stale-input.ts"
|
||||
],
|
||||
"schedules": [],
|
||||
"steps": [
|
||||
@@ -20280,7 +20290,7 @@
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-comment-actions.ts",
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-git-actions.ts",
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-send-actions.ts",
|
||||
"mobile/src/session/native-chat/mobile-native-chat-stale-input.ts"
|
||||
"mobile/src/session/native-chat/composer/mobile-native-chat-stale-input.ts"
|
||||
],
|
||||
"schedules": [],
|
||||
"steps": [
|
||||
@@ -24889,7 +24899,7 @@
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-comment-actions.ts",
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-git-actions.ts",
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-send-actions.ts",
|
||||
"mobile/src/session/native-chat/mobile-native-chat-stale-input.ts"
|
||||
"mobile/src/session/native-chat/composer/mobile-native-chat-stale-input.ts"
|
||||
],
|
||||
"schedules": [],
|
||||
"steps": [
|
||||
@@ -24944,7 +24954,7 @@
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-comment-actions.ts",
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-git-actions.ts",
|
||||
"mobile/src/source-control/review/use-mobile-diff-review-send-actions.ts",
|
||||
"mobile/src/session/native-chat/mobile-native-chat-stale-input.ts"
|
||||
"mobile/src/session/native-chat/composer/mobile-native-chat-stale-input.ts"
|
||||
],
|
||||
"schedules": [],
|
||||
"steps": [
|
||||
@@ -25018,7 +25028,9 @@
|
||||
"id": "structured-agent-session-created",
|
||||
"operation": "agentSession.structured-launch",
|
||||
"family": "agentSession.structured-create",
|
||||
"sites": ["mobile/src/session/mobile-structured-agent-session-launch.ts"],
|
||||
"sites": [
|
||||
"mobile/src/session/native-chat/agent-session/mobile-structured-agent-session-launch.ts"
|
||||
],
|
||||
"schedules": [],
|
||||
"steps": [
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { openMobileAgentHistoryChat } from './open-mobile-agent-history-chat'
|
||||
import { mobileStructuredSessionOpenMessage } from '../session/mobile-structured-session-open-message'
|
||||
import { mobileStructuredSessionOpenMessage } from '../session/native-chat/agent-session/mobile-structured-session-open-message'
|
||||
import { prepareMobileHistoryResumeTarget } from './mobile-history-resume-target-preparation'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { View } from 'react-native'
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { RpcClient } from '../transport/rpc/rpc-client-contract'
|
||||
import {
|
||||
openMobileStructuredSession,
|
||||
mobileStructuredSessionHref
|
||||
} from '../session/open-mobile-structured-session'
|
||||
} from '../session/native-chat/agent-session/open-mobile-structured-session'
|
||||
|
||||
/** Consume native opens and ambiguous failures; only an explicit pre-effect refusal resumes in a terminal. */
|
||||
export async function openMobileAgentHistoryChat(args: {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import { mobileStructuredSessionStatusFeed } from '../session/mobile-structured-session-status-feed'
|
||||
import { mobileStructuredSessionStatusFeed } from '../session/native-chat/agent-session/mobile-structured-session-status-feed'
|
||||
import type { AgentSessionConversationNames } from '../../../src/shared/agent-session/agent-session-conversation-names'
|
||||
import { useForceReconnect } from '../transport/connection/host-client-hooks'
|
||||
import { useWorkspaceClient } from '../worktree/use-workspace-client'
|
||||
|
||||
@@ -4,8 +4,8 @@ import type { MobileImageSource } from '../../platform/media-picker-contract'
|
||||
import type {
|
||||
MobileNativeChatSendIntent,
|
||||
MobileNativeChatSendOutcome
|
||||
} from '../../session/native-chat/mobile-native-chat-send'
|
||||
import type { StructuredMobileSendAttachment } from '../../session/use-mobile-structured-send-with-outcome'
|
||||
} from '../../session/native-chat/composer/mobile-native-chat-send'
|
||||
import type { StructuredMobileSendAttachment } from '../../session/native-chat/composer/use-mobile-structured-send-with-outcome'
|
||||
import { useMobileImageAttachment } from './use-mobile-image-attachment'
|
||||
import {
|
||||
useMobileNativeChatImageAttachments,
|
||||
|
||||
@@ -16,7 +16,7 @@ import { hostProjectSectionsQuery } from '../host-screen/use-host-project-sectio
|
||||
import { sessionTabsFamily, sessionTabsKey } from '../session/tabs/mobile-session-last-tabs'
|
||||
import type { MobileSessionTab } from '../session/tabs/mobile-session-tabs'
|
||||
import { activeSessionTabOf } from '../session/tabs/active-session-tab'
|
||||
import { storedTabChatTranscriptIdentity } from '../session/native-chat/mobile-native-chat-transcript-store'
|
||||
import { storedTabChatTranscriptIdentity } from '../session/native-chat/transcript/mobile-native-chat-transcript-store'
|
||||
import { gitStatusQuery } from '../source-control/mobile-git-status-query'
|
||||
import { firstPaintTaskKeys } from '../tasks/task-query-storage'
|
||||
import { hostQueryKey } from './host-query-key'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { QueryClient } from '@tanstack/react-query'
|
||||
import type { PageDeviceStore } from '../mobile-web-shell/bridge/page-device-store'
|
||||
import { primeStoredChatTranscripts } from '../session/native-chat/mobile-native-chat-transcript-store'
|
||||
import { primeStoredChatTranscripts } from '../session/native-chat/transcript/mobile-native-chat-transcript-store'
|
||||
import { firstPaintChatTranscriptIdentity, firstPaintQueryKeys } from './first-paint-query-keys'
|
||||
import { createHostQueryPersistence } from './host-query-persistence'
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useCallback, useLayoutEffect, useMemo, useRef } from 'react'
|
||||
import { useHostProtocolGates } from '../components/host-protocol-gates-context'
|
||||
import type { TuiAgent } from '../../../src/shared/agent-launch/catalog/tui-agent'
|
||||
import type { StructuredAgentSessionForkSource } from '../../../src/shared/agent-session/structured-agent-session-create'
|
||||
import { MobileNativeChatForkedFromContext } from './mobile-native-chat-notice-context'
|
||||
import { MobileNativeChatForkedFromContext } from './native-chat/transcript/mobile-native-chat-notice-context'
|
||||
import { forkMobileStructuredChat } from './mobile-structured-chat-fork'
|
||||
import {
|
||||
MobileNativeChatForkContext,
|
||||
|
||||
@@ -2,7 +2,7 @@ import './mobile-prompt-render-mocks'
|
||||
import { createElement } from 'react'
|
||||
import { Pressable } from 'react-native'
|
||||
import type { NativeChatMessage } from '../../../../src/shared/native-chat/native-chat-types'
|
||||
import type { MobileNativeChatSendOutcome } from '../native-chat/mobile-native-chat-send'
|
||||
import type { MobileNativeChatSendOutcome } from '../native-chat/composer/mobile-native-chat-send'
|
||||
import type { RpcClient } from '../../transport/rpc/rpc-client-contract'
|
||||
import type { RpcResponse } from '../../transport/rpc/rpc-wire-types'
|
||||
import type { ConnectionState } from '../../transport/connection/connection-state'
|
||||
@@ -55,7 +55,7 @@ vi.mock('../use-mobile-session-view-mode', () => ({
|
||||
})
|
||||
}))
|
||||
// The chat's per-connection CI setting read isn't a prompt write; these tests count only those.
|
||||
vi.mock('../use-mobile-native-chat-ci-result-lines', () => ({
|
||||
vi.mock('../native-chat/preferences/use-mobile-native-chat-ci-result-lines', () => ({
|
||||
useMobileNativeChatCiResultLines: () => false
|
||||
}))
|
||||
vi.mock('../native-chat/use-mobile-native-chat-session-lane', () => ({
|
||||
|
||||
@@ -22,9 +22,9 @@ import {
|
||||
isAgentLaunchReservationTakenRefusal
|
||||
} from '../../../../src/shared/agent-launch/contracts/agent-launch-replay-refusal'
|
||||
import { sendReplayingAmbiguousDelivery } from '../../tasks/replay-on-ambiguous-delivery'
|
||||
import { structuredSessionOperationId } from '../structured-session-operation-id'
|
||||
import { structuredSessionOperationId } from '../native-chat/agent-session/structured-session-operation-id'
|
||||
import { randomV4Uuid } from '../../platform/random-v4-uuid'
|
||||
import { rememberMobileCreatedStructuredSession } from '../mobile-created-structured-sessions'
|
||||
import { rememberMobileCreatedStructuredSession } from '../native-chat/agent-session/mobile-created-structured-sessions'
|
||||
|
||||
// Why: the host waits up to 60s for a terminal agent to become ready before pasting the prompt,
|
||||
// so a prompted launch must outlive that wait or the phone reports a launch that is still running.
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { agentSessionWriteNoticeParts } from '../../../src/shared/agent-session/failures/agent-session-refusal-notice'
|
||||
import { agentSessionRefusalFailure } from '../../../src/shared/agent-session/failures/agent-session-write-failure'
|
||||
import { mobileAgentSessionWriteNoticeText } from './agent-session-write-notice-copy'
|
||||
|
||||
describe('mobileAgentSessionWriteNoticeText', () => {
|
||||
it('names the attachment an expired refusal lists, as its card labels it', () => {
|
||||
const failure = agentSessionRefusalFailure({
|
||||
code: 'agent_session_operation_invalid',
|
||||
details: {
|
||||
reason: 'attachmentExpired',
|
||||
expiredAttachments: [{ uploadId: 'upload-1', name: 'notes.pdf' }]
|
||||
}
|
||||
})
|
||||
expect(
|
||||
mobileAgentSessionWriteNoticeText(agentSessionWriteNoticeParts(failure, 'composer-send'))
|
||||
).toBe('notes.pdf expired. Your message was not sent. Remove it and attach it again.')
|
||||
})
|
||||
})
|
||||
@@ -1,109 +0,0 @@
|
||||
import { createElement, type ReactNode } from 'react'
|
||||
import { act, create, type ReactTestRenderer } from 'react-test-renderer'
|
||||
import { afterEach, expect, it, vi } from 'vitest'
|
||||
import { MobileNativeChatComposer } from './native-chat/composer/MobileNativeChatComposer'
|
||||
import { captureMobileNativeChatTextDestination } from './native-chat/composer/mobile-native-chat-draft-inputs'
|
||||
import {
|
||||
closeMobileNativeChatTabDraft,
|
||||
readMobileNativeChatDraftEditGeneration,
|
||||
resetMobileNativeChatDraftStoreForTests,
|
||||
setMobileNativeChatDraftText
|
||||
} from './native-chat/composer/mobile-native-chat-draft-store'
|
||||
import { findByHostType } from '../test-support/react-test-renderer-host-nodes'
|
||||
|
||||
vi.mock('../components/MobileSwitch', () => ({ MobileSwitch: 'Switch' }))
|
||||
vi.mock('./native-chat/composer/MobileNativeChatContextUsageRing', () => ({
|
||||
useMobileNativeChatContextRing: () => ({ barProps: {}, ring: null })
|
||||
}))
|
||||
// BottomDrawer also carries the option pager, which loads Reanimated at import.
|
||||
vi.mock('react-native-reanimated', async () =>
|
||||
(await import('../test-support/reanimated-pager-stub')).reanimatedPagerStub()
|
||||
)
|
||||
vi.mock('react-native', async () => {
|
||||
const React = await import('react')
|
||||
return {
|
||||
...(await import('../test-support/react-native-motion-stub')).reactNativeMotionStub(),
|
||||
ActivityIndicator: 'ActivityIndicator',
|
||||
Image: 'Image',
|
||||
Keyboard: { dismiss: vi.fn() },
|
||||
Platform: { OS: 'ios' },
|
||||
Pressable: 'Pressable',
|
||||
ScrollView: ({ children, ...props }: { children?: ReactNode }) =>
|
||||
React.createElement('ScrollView', props, children),
|
||||
StyleSheet: { create: (styles: unknown) => styles, hairlineWidth: 1 },
|
||||
Text: 'Text',
|
||||
TextInput: 'TextInput',
|
||||
View: 'View'
|
||||
}
|
||||
})
|
||||
vi.mock('lucide-react-native', () => ({
|
||||
ArrowUp: 'ArrowUp',
|
||||
ListEnd: 'ListEnd',
|
||||
CornerDownRight: 'CornerDownRight',
|
||||
Check: 'Check',
|
||||
ChevronDown: 'ChevronDown',
|
||||
ChevronLeft: 'ChevronLeft',
|
||||
ChevronRight: 'ChevronRight',
|
||||
FileText: 'FileText',
|
||||
Mic: 'Mic',
|
||||
Package: 'Package',
|
||||
Plus: 'Plus',
|
||||
ShieldAlert: 'ShieldAlert',
|
||||
Square: 'Square',
|
||||
Terminal: 'Terminal',
|
||||
X: 'X'
|
||||
}))
|
||||
vi.mock('../components/bottom-drawer/mounted-bottom-drawer', () => ({
|
||||
MountedBottomDrawer: 'BottomDrawer'
|
||||
}))
|
||||
vi.mock('../components/bottom-drawer/bottom-drawer-modal-host-scope', () => ({
|
||||
useBottomDrawerModalHost: () => null
|
||||
}))
|
||||
|
||||
let renderer: ReactTestRenderer | undefined
|
||||
afterEach(async () => {
|
||||
await act(async () => renderer?.unmount())
|
||||
renderer = undefined
|
||||
resetMobileNativeChatDraftStoreForTests()
|
||||
})
|
||||
|
||||
it.each([false, true])(
|
||||
'rejects captured dictation after tab retirement with custom insert=%s',
|
||||
async (customInsert) => {
|
||||
const scope = `retired-dictation-${customInsert}`
|
||||
const insertDictation = vi.fn(() => true)
|
||||
setMobileNativeChatDraftText(scope, 'old text')
|
||||
await act(async () => {
|
||||
renderer = create(
|
||||
createElement(MobileNativeChatComposer, {
|
||||
value: 'old text',
|
||||
draftScopeKey: scope,
|
||||
insertDictation: customInsert ? insertDictation : undefined,
|
||||
onChangeText: vi.fn(),
|
||||
onSend: async () => true,
|
||||
sendSurfaceId: scope,
|
||||
getSendCompletionGeneration: () => 0,
|
||||
getComposerEditGeneration: () => 0
|
||||
})
|
||||
)
|
||||
})
|
||||
act(() => findByHostType(renderer!.root, 'TextInput').props.onFocus())
|
||||
const insert = captureMobileNativeChatTextDestination()?.insert
|
||||
if (!insert) {
|
||||
throw new Error('composer did not register dictation')
|
||||
}
|
||||
act(() => {
|
||||
insert('live dictation')
|
||||
})
|
||||
if (customInsert) {
|
||||
expect(insertDictation).toHaveBeenCalledOnce()
|
||||
} else {
|
||||
expect(readMobileNativeChatDraftEditGeneration(scope)).toBe(2)
|
||||
}
|
||||
insertDictation.mockClear()
|
||||
await act(async () => closeMobileNativeChatTabDraft(scope))
|
||||
expect(insert('late dictation')).toBe(false)
|
||||
expect(insertDictation).not.toHaveBeenCalled()
|
||||
expect(readMobileNativeChatDraftEditGeneration(scope)).toBe(0)
|
||||
}
|
||||
)
|
||||
@@ -4,7 +4,7 @@ import { act } from 'react-test-renderer'
|
||||
import { createWithQueryClient } from '../test-support/query-client-test-renderer'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { createFakeRpcClient, type FakeRpcClient } from '../mobile-web-shell/bridge-host-test-fakes'
|
||||
import type * as NativeChatSendError from './native-chat/use-mobile-native-chat-send-error'
|
||||
import type * as NativeChatSendError from './native-chat/composer/use-mobile-native-chat-send-error'
|
||||
import type * as NativeChatDraftStore from './native-chat/composer/mobile-native-chat-draft-store'
|
||||
|
||||
type ChatView = { shown: boolean; scope: string | null }
|
||||
@@ -69,7 +69,7 @@ vi.mock('../platform/clipboard', () => {
|
||||
})
|
||||
|
||||
// Stub off-path native chat dependencies to keep Expo out of this mic test.
|
||||
vi.mock('./native-chat/use-mobile-native-chat-send-error', async (importOriginal) => ({
|
||||
vi.mock('./native-chat/composer/use-mobile-native-chat-send-error', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof NativeChatSendError>()),
|
||||
useMobileNativeChatSendError: () => ({
|
||||
message: null,
|
||||
@@ -82,7 +82,7 @@ vi.mock('./native-chat/use-mobile-native-chat-send-error', async (importOriginal
|
||||
vi.mock('./native-chat/transcript/use-mobile-native-chat-readability', () => ({
|
||||
useMobileNativeChatReadability: () => false
|
||||
}))
|
||||
vi.mock('./native-chat/use-mobile-native-chat-input-lease', () => ({
|
||||
vi.mock('./native-chat/composer/use-mobile-native-chat-input-lease', () => ({
|
||||
useMobileNativeChatInputLease: () => ({
|
||||
ready: true,
|
||||
readyRef: { current: true },
|
||||
@@ -297,41 +297,6 @@ describe('a mic tap after the host reported dictation is not set up', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('an audio interruption while recording', () => {
|
||||
it('finishes the dictation and keeps what was said', async () => {
|
||||
const rpc = createFakeRpcClient()
|
||||
await startRecording(rpc)
|
||||
act(() => seen.audioListeners.get('onAudioInterruption')?.({ data: 'began' }))
|
||||
const methods = await settle(rpc, 'call me back')
|
||||
expect(methods).toContain('speech.dictation.finish')
|
||||
expect(methods).not.toContain('speech.dictation.cancel')
|
||||
expect(seen.inputs).toEqual(['call me back'])
|
||||
expect(seen.toasts).toEqual(['Dictation inserted'])
|
||||
})
|
||||
})
|
||||
|
||||
describe('leaving the session while recording', () => {
|
||||
it('stops and inserts what was said instead of leaving, and lets the next leave go', async () => {
|
||||
const rpc = createFakeRpcClient()
|
||||
const mounted = await startRecording(rpc)
|
||||
const held: boolean[] = []
|
||||
act(() => {
|
||||
held.push(mounted.current().dictationLeaveHold.hold())
|
||||
})
|
||||
// Back is released while transcribing, so a swipe can leave too.
|
||||
expect(mounted.current().dictationLeaveHold.holdsLeave).toBe(false)
|
||||
act(() => {
|
||||
held.push(mounted.current().dictationLeaveHold.hold())
|
||||
})
|
||||
expect(held).toEqual([true, false])
|
||||
const methods = await settle(rpc, 'one more thing')
|
||||
expect(methods.filter((method) => method === 'speech.dictation.finish')).toHaveLength(1)
|
||||
expect(methods).not.toContain('speech.dictation.cancel')
|
||||
expect(seen.inputs).toEqual(['one more thing'])
|
||||
expect(seen.toasts).toEqual(['Dictation inserted'])
|
||||
})
|
||||
})
|
||||
|
||||
describe('a mic tap while the transcript is processing', () => {
|
||||
it('keeps the transcript that comes back', async () => {
|
||||
const rpc = createFakeRpcClient()
|
||||
@@ -367,19 +332,3 @@ describe('a dictation that ends after switching between chat and terminal', () =
|
||||
expect(seen.inputs).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('a dictation whose session screen was left', () => {
|
||||
it('keeps recording, then puts its words in the chat it started in with a toast that opens it', async () => {
|
||||
seen.chat = { shown: true, scope: 'chat-a' }
|
||||
const rpc = createFakeRpcClient()
|
||||
const mounted = await startRecording(rpc)
|
||||
mounted.leave()
|
||||
expect(mounted.host().getDictation().isRecording).toBe(true)
|
||||
expect(mounted.host().pill?.away).toBe(true)
|
||||
act(() => mounted.host().stop())
|
||||
await settle(rpc, 'ship it')
|
||||
expect(seen.chatWrites).toEqual([['chat-a', 'ship it']])
|
||||
expect(mounted.host().pill?.toast?.message).toBe('Inserted in Claude Code')
|
||||
expect(mounted.host().pill?.toast?.open).toBeTypeOf('function')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
import { afterEach, expect, it, vi } from 'vitest'
|
||||
import capture from '../../../src/shared/__fixtures__/omp-native-commands.json'
|
||||
import * as catalog from '../../../src/shared/native-chat/input/native-chat-slash-commands'
|
||||
import type { NativeChatPickerItem } from '../../../src/shared/native-chat/input/native-chat-picker-items'
|
||||
import { deriveComposerAutocomplete } from '../../../src/shared/native-chat/input/native-chat-composer-autocomplete'
|
||||
import {
|
||||
mobileComposerCatalog,
|
||||
boundedMenuItems
|
||||
} from './native-chat/composer/mobile-native-chat-composer-menu'
|
||||
|
||||
afterEach(() => vi.restoreAllMocks())
|
||||
|
||||
it('bounds native OMP picker name reads at N/10N while preserving first duplicate descriptions', () => {
|
||||
const reportedSkills = catalog.sessionReportedSkills
|
||||
let visits = 0
|
||||
vi.spyOn(catalog, 'sessionReportedSkills').mockImplementation((...args) =>
|
||||
reportedSkills(...args).map((skill) => ({
|
||||
...skill,
|
||||
get name() {
|
||||
visits += 1
|
||||
return skill.name
|
||||
}
|
||||
}))
|
||||
)
|
||||
const native = capture.enabled.availableCommands.find((row) => row.name === 'skill:plan')!
|
||||
for (const surface of ['desktop', 'mobile'] as const) {
|
||||
const counts = [10, 100].map((size) => {
|
||||
const reported = [
|
||||
...Array.from({ length: size }, (_, i) => ({
|
||||
name: `${native.name}-${i}`,
|
||||
kind: 'command' as const,
|
||||
description: i === 0 ? undefined : native.description
|
||||
})),
|
||||
{ name: `${native.name}-0`, kind: 'command' as const, description: 'Later duplicate' },
|
||||
{ name: `${native.name}-1`, kind: 'command' as const, description: 'Later duplicate' }
|
||||
]
|
||||
visits = 0
|
||||
let rows: NativeChatPickerItem[]
|
||||
if (surface === 'desktop') {
|
||||
const picker = deriveComposerAutocomplete(
|
||||
'/plan',
|
||||
5,
|
||||
catalog.sessionSlashCommandSuggestions('omp', reported),
|
||||
[],
|
||||
null,
|
||||
{ status: 'ready', skills: [] },
|
||||
null,
|
||||
catalog.sessionReportedSkills(reported, 'omp')
|
||||
)
|
||||
expect(picker.mode).toBe('slash')
|
||||
if (picker.mode !== 'slash') {
|
||||
throw new Error('Missing native picker')
|
||||
}
|
||||
rows = picker.items
|
||||
} else {
|
||||
const menu = mobileComposerCatalog({
|
||||
agent: 'omp',
|
||||
structured: { reported, conversationCommands: [] }
|
||||
})
|
||||
const picker = deriveComposerAutocomplete(
|
||||
'/plan',
|
||||
5,
|
||||
menu.commands,
|
||||
menu.discovery.skills,
|
||||
menu.profile,
|
||||
menu.discovery,
|
||||
null,
|
||||
menu.sessionSkills
|
||||
)
|
||||
expect(picker.mode).toBe('slash')
|
||||
rows = picker.mode === 'slash' ? boundedMenuItems(picker.items) : []
|
||||
}
|
||||
const skills = rows.filter((row) => row.kind === 'skill')
|
||||
expect(skills).toHaveLength(Math.min(size, surface === 'desktop' ? 50 : 10))
|
||||
expect(new Set(skills.map((row) => row.token)).size).toBe(skills.length)
|
||||
expect(skills.find((row) => row.token === '/skill:plan-0')?.description).toBeNull()
|
||||
expect(skills.find((row) => row.token === '/skill:plan-1')?.description).toBe(
|
||||
native.description
|
||||
)
|
||||
expect(visits).toBeGreaterThanOrEqual(reported.length)
|
||||
expect(visits).toBeLessThanOrEqual(10 * reported.length)
|
||||
return visits
|
||||
})
|
||||
expect(counts[1]).toBeLessThanOrEqual(12 * counts[0]!)
|
||||
}
|
||||
})
|
||||
@@ -1,261 +0,0 @@
|
||||
import { QueuedMessageUpdateParams } from '../../../src/shared/rpc-contract/structured-agent-session-queued-edit-params'
|
||||
import { useMobileNativeChatComposerMenu } from './native-chat/composer/use-mobile-native-chat-composer-menu'
|
||||
import {
|
||||
resetMobileNativeChatDraftStoreForTests,
|
||||
useMobileNativeChatDraft
|
||||
} from './native-chat/composer/mobile-native-chat-draft-store'
|
||||
import {
|
||||
updateMobileNativeChatDraftInputs,
|
||||
resetMobileNativeChatDraftInputsForTests
|
||||
} from './native-chat/composer/mobile-native-chat-draft-inputs'
|
||||
import { createElement, type ReactNode } from 'react'
|
||||
import { act, type ReactTestRenderer } from 'react-test-renderer'
|
||||
import { createWithQueryClient } from '../test-support/query-client-test-renderer'
|
||||
import { afterEach, expect, vi } from 'vitest'
|
||||
import type {
|
||||
AgentSessionQueuedMessage,
|
||||
AgentSessionQueuedMessageEditHoldResult
|
||||
} from '../../../src/shared/agent-session/requests/agent-session-queued-message-wire'
|
||||
import { agentSessionSendBodyFingerprint } from '../../../src/shared/agent-session/requests/structured-agent-session-send-mutation'
|
||||
import { queuedMessageWithEdit } from '../../../src/shared/queued-message-edit'
|
||||
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
|
||||
import type { RpcResponse } from '../transport/rpc/rpc-wire-types'
|
||||
import { useMobileStructuredAgentSession } from './use-mobile-structured-agent-session'
|
||||
import {
|
||||
CAPABLE,
|
||||
SESSION_ID,
|
||||
fieldsOf,
|
||||
mutationOk,
|
||||
ok,
|
||||
snapshotEvent
|
||||
} from './native-chat/agent-session/use-mobile-structured-agent-session-queued.test-fixture'
|
||||
|
||||
export function withText(body: AgentSessionQueuedMessage['body'], text: string) {
|
||||
const edited = queuedMessageWithEdit(body, { text })
|
||||
if (!edited.ok) {
|
||||
throw new Error(edited.reason)
|
||||
}
|
||||
return edited.body
|
||||
}
|
||||
|
||||
export function editHoldReply(params: unknown): RpcResponse {
|
||||
const result: AgentSessionQueuedMessageEditHoldResult =
|
||||
fieldsOf(params).action === 'release'
|
||||
? { status: 'released' }
|
||||
: { status: 'held', fingerprint: 'fp', leaseDurationMs: 120_000, remainingMs: 120_000 }
|
||||
return ok(result)
|
||||
}
|
||||
|
||||
export function readOrHoldReply(method: string, params: unknown): RpcResponse {
|
||||
return method === 'agentSession.queuedMessageEditHold'
|
||||
? editHoldReply(params)
|
||||
: ok({ models: [], current: {} })
|
||||
}
|
||||
|
||||
vi.mock('react-native', async () => ({
|
||||
...(await import('../test-support/react-native-motion-stub')).reactNativeMotionStub(),
|
||||
Text: 'Text',
|
||||
View: 'View',
|
||||
Pressable: 'Pressable',
|
||||
ScrollView: 'ScrollView',
|
||||
TextInput: 'TextInput',
|
||||
ActivityIndicator: 'ActivityIndicator',
|
||||
Image: 'Image',
|
||||
Keyboard: { dismiss: vi.fn() },
|
||||
Platform: { OS: 'ios' },
|
||||
useWindowDimensions: () => ({ fontScale: 1 }),
|
||||
StyleSheet: { create: (styles: unknown) => styles }
|
||||
}))
|
||||
vi.mock('lucide-react-native', () => ({
|
||||
FileText: 'FileText',
|
||||
Package: 'Package',
|
||||
Terminal: 'Terminal',
|
||||
ArrowUp: 'ArrowUp',
|
||||
AtSign: 'AtSign',
|
||||
AlertCircle: 'AlertCircle',
|
||||
Image: 'Image',
|
||||
Paperclip: 'Paperclip',
|
||||
Check: 'Check',
|
||||
ChevronDown: 'ChevronDown',
|
||||
ChevronLeft: 'ChevronLeft',
|
||||
ChevronRight: 'ChevronRight',
|
||||
CornerDownRight: 'CornerDownRight',
|
||||
ListEnd: 'ListEnd',
|
||||
MoreHorizontal: 'MoreHorizontal',
|
||||
Mic: 'Mic',
|
||||
Pencil: 'Pencil',
|
||||
Play: 'Play',
|
||||
Plus: 'Plus',
|
||||
Send: 'Send',
|
||||
ShieldAlert: 'ShieldAlert',
|
||||
Square: 'Square',
|
||||
Trash2: 'Trash2',
|
||||
X: 'X'
|
||||
}))
|
||||
vi.mock('@react-native-async-storage/async-storage', () => ({
|
||||
default: { getItem: async () => null, setItem: async () => {}, removeItem: async () => {} }
|
||||
}))
|
||||
|
||||
export function mobileQueuedEditHarness() {
|
||||
const state: {
|
||||
renderer?: ReactTestRenderer
|
||||
bottomText: string
|
||||
hook?: ReturnType<typeof useMobileStructuredAgentSession>
|
||||
menu?: ReturnType<typeof useMobileNativeChatComposerMenu>
|
||||
listener?: (data: unknown) => void
|
||||
} = { bottomText: '' }
|
||||
const append = vi.fn(() => true)
|
||||
const error = vi.fn()
|
||||
const notice = vi.fn()
|
||||
const resolved = vi.fn()
|
||||
const sendRequest = vi.fn<RpcClient['sendRequest']>()
|
||||
const client: RpcClient = {
|
||||
sendRequest,
|
||||
subscribe: (_method, _params, onData) => {
|
||||
if (_method === 'agentSession.subscribe') {
|
||||
state.listener = onData
|
||||
}
|
||||
return () => {}
|
||||
},
|
||||
updateTerminalSubscriptionViewport: () => {},
|
||||
getState: () => 'connected',
|
||||
getReconnectAttempt: () => 0,
|
||||
getLastConnectedAt: () => null,
|
||||
onStateChange: () => () => {},
|
||||
notifyForeground: () => {},
|
||||
close: () => {}
|
||||
}
|
||||
function Harness({
|
||||
sessionId = SESSION_ID,
|
||||
editSupport = true,
|
||||
enabled = true,
|
||||
connected = true,
|
||||
transport = client,
|
||||
composerScopeKey,
|
||||
imagesSupport = false,
|
||||
skillsSupport = false,
|
||||
agent = 'codex',
|
||||
renderContent
|
||||
}: {
|
||||
sessionId?: string
|
||||
editSupport?: boolean | null
|
||||
enabled?: boolean
|
||||
connected?: boolean
|
||||
transport?: RpcClient | null
|
||||
composerScopeKey?: string
|
||||
imagesSupport?: boolean
|
||||
skillsSupport?: boolean
|
||||
agent?: string
|
||||
renderContent?: (hook: ReturnType<typeof useMobileStructuredAgentSession>) => ReactNode
|
||||
}): ReactNode {
|
||||
state.bottomText = useMobileNativeChatDraft('original-bottom')
|
||||
state.hook = useMobileStructuredAgentSession({
|
||||
client: transport,
|
||||
pairedHostClient: transport,
|
||||
sessionId,
|
||||
sourceIdentity: 'host-a',
|
||||
enabled,
|
||||
connected,
|
||||
agent,
|
||||
hostSupport:
|
||||
editSupport === null
|
||||
? null
|
||||
: {
|
||||
...CAPABLE,
|
||||
sendSkills: true,
|
||||
queuedMessages: false,
|
||||
queuedMessageImageEdit: imagesSupport,
|
||||
queuedMessageSkillsEdit: skillsSupport,
|
||||
queuedMessageEdit: editSupport
|
||||
},
|
||||
composerScopeKey,
|
||||
appendComposerText: append,
|
||||
onSendError: error,
|
||||
onQueuedEditNotice: notice,
|
||||
onActionResolved: resolved
|
||||
})
|
||||
state.menu = useMobileNativeChatComposerMenu({
|
||||
value: state.hook.queued.editor?.text ?? '',
|
||||
onChangeText: (text) => state.hook?.queued.editor?.change(text),
|
||||
agent,
|
||||
structuredCatalog: {
|
||||
reported: [{ name: 'review', kind: 'skill', path: '/B/SKILL.md' }],
|
||||
conversationCommands: []
|
||||
},
|
||||
filePaths: [],
|
||||
focusField: () => {},
|
||||
editing: true,
|
||||
// Mirrors the real composer: the menu hands over its row; the draft keeps name and path.
|
||||
onPickSkill: ({ token, path }) => {
|
||||
const key = state.hook?.queued.editor?.scopeKey
|
||||
if (key && path) {
|
||||
updateMobileNativeChatDraftInputs(key, (before) => ({
|
||||
...before,
|
||||
skills: [{ name: token.slice(1), path }]
|
||||
}))
|
||||
}
|
||||
}
|
||||
})
|
||||
return renderContent?.(state.hook) ?? null
|
||||
}
|
||||
function requestedFingerprint(message: AgentSessionQueuedMessage) {
|
||||
const params = sendRequest.mock.calls.findLast(
|
||||
([method]) => method === 'agentSession.queuedMessageUpdate'
|
||||
)?.[1]
|
||||
const fields = QueuedMessageUpdateParams.parse(params)
|
||||
const edited = queuedMessageWithEdit(message.body, fields)
|
||||
if (!edited.ok) {
|
||||
throw new Error(edited.reason)
|
||||
}
|
||||
return agentSessionSendBodyFingerprint(SESSION_ID, edited.body)
|
||||
}
|
||||
async function mount(
|
||||
message: AgentSessionQueuedMessage,
|
||||
editSupport: boolean | null = true,
|
||||
agent = 'codex',
|
||||
sessionId = SESSION_ID
|
||||
) {
|
||||
vi.clearAllMocks()
|
||||
resetMobileNativeChatDraftInputsForTests()
|
||||
resetMobileNativeChatDraftStoreForTests()
|
||||
sendRequest.mockImplementation(async (method, params) =>
|
||||
method === 'agentSession.queuedMessageUpdate'
|
||||
? mutationOk({
|
||||
status: 'updated',
|
||||
messageId: message.messageId,
|
||||
fingerprint: requestedFingerprint(message)
|
||||
})
|
||||
: readOrHoldReply(method, params)
|
||||
)
|
||||
await act(async () => {
|
||||
state.renderer = createWithQueryClient(
|
||||
createElement(Harness, { editSupport, agent, sessionId })
|
||||
)
|
||||
})
|
||||
const snapshot = snapshotEvent({ queuedMessages: [message], runningTurn: true })
|
||||
act(() => state.listener?.({ ...snapshot, sessionId, page: { ...snapshot.page, sessionId } }))
|
||||
if (editSupport !== null) {
|
||||
await act(async () => {
|
||||
expect(await state.hook!.queued.edit!(message.messageId)).toBe(true)
|
||||
})
|
||||
}
|
||||
}
|
||||
afterEach(async () => {
|
||||
await act(async () => state.renderer?.unmount())
|
||||
vi.useRealTimers()
|
||||
vi.unstubAllGlobals()
|
||||
})
|
||||
|
||||
return {
|
||||
state,
|
||||
Harness,
|
||||
mount,
|
||||
client,
|
||||
sendRequest,
|
||||
append,
|
||||
error,
|
||||
notice,
|
||||
resolved,
|
||||
requestedFingerprint
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import type { AgentJournalFreeTextInput } from '../../../src/shared/agent-session/journal/agent-session-journal-types'
|
||||
import { formatQuestionFreeTextAnswer } from './native-chat/input/mobile-native-chat-question'
|
||||
import {
|
||||
projectStructuredQuestion,
|
||||
structuredQuestionResponseTarget,
|
||||
type StructuredQuestionItem
|
||||
} from './mobile-structured-agent-prompts'
|
||||
|
||||
function prompt(freeTextInput?: AgentJournalFreeTextInput): StructuredQuestionItem {
|
||||
return {
|
||||
itemId: 'item-1',
|
||||
revision: 3,
|
||||
sequence: 1,
|
||||
observedAt: 1,
|
||||
body: {
|
||||
kind: 'question',
|
||||
question: 'Edit the draft',
|
||||
options: [],
|
||||
freeTextQuestionId: 'q1',
|
||||
...(freeTextInput ? { freeTextInput } : {}),
|
||||
resolution: { state: 'pending', selectedOptionId: null, resolvedBy: null, resolvedAt: null }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
describe('mobile structured free-text questions', () => {
|
||||
it('accepts empty and whitespace text only for the matching allowed prompt', () => {
|
||||
const current = prompt({ allowEmpty: true })
|
||||
const projected = projectStructuredQuestion(current)!
|
||||
for (const answer of ['', ' \n ']) {
|
||||
const response = formatQuestionFreeTextAnswer(projected, answer)
|
||||
expect(structuredQuestionResponseTarget(response, current)).toEqual({
|
||||
itemId: 'item-1',
|
||||
expectedRevision: 3,
|
||||
answer: { questionId: 'q1', optionIds: [], other: answer }
|
||||
})
|
||||
expect(structuredQuestionResponseTarget(response, prompt())).toBeNull()
|
||||
}
|
||||
expect(
|
||||
structuredQuestionResponseTarget(formatQuestionFreeTextAnswer(projected, ''), {
|
||||
...current,
|
||||
revision: 4
|
||||
})
|
||||
).toBeNull()
|
||||
})
|
||||
|
||||
it('keeps legacy trimming for ordinary free-text answers', () => {
|
||||
const current = prompt()
|
||||
const projected = projectStructuredQuestion(current)!
|
||||
expect(
|
||||
structuredQuestionResponseTarget(
|
||||
formatQuestionFreeTextAnswer(projected, ' draft '),
|
||||
current
|
||||
)
|
||||
).toMatchObject({ answer: { other: 'draft' } })
|
||||
expect(structuredQuestionResponseTarget('', current)).toBeNull()
|
||||
})
|
||||
})
|
||||
@@ -7,7 +7,7 @@ import type {
|
||||
StructuredAgentSessionForkSource
|
||||
} from '../../../src/shared/agent-session/structured-agent-session-create'
|
||||
import { AGENT_SESSION_CREATE_TAB_PLACEMENT_RUNTIME_CAPABILITY } from '../../../src/shared/agent-session/agent-session-create-capabilities'
|
||||
import { createMobileStructuredAgentSession } from './mobile-structured-agent-session-launch'
|
||||
import { createMobileStructuredAgentSession } from './native-chat/agent-session/mobile-structured-agent-session-launch'
|
||||
import {
|
||||
launchedSelection,
|
||||
withLaunchReply,
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
import './transcript/mobile-agent-message-renderer.test-fixture'
|
||||
import { createElement } from 'react'
|
||||
import { act, create, type ReactTestRenderer } from 'react-test-renderer'
|
||||
import { afterEach, expect, it } from 'vitest'
|
||||
import { findAllByHostType } from '../../test-support/react-test-renderer-host-nodes'
|
||||
import { Transcript, textIn } from './transcript/mobile-native-chat-turn-diff.test-fixture'
|
||||
|
||||
let renderer: ReactTestRenderer | null = null
|
||||
afterEach(() => {
|
||||
act(() => renderer?.unmount())
|
||||
renderer = null
|
||||
})
|
||||
|
||||
it('shows finished-turn files outside folded work and opens a patch with one tap', () => {
|
||||
act(() => {
|
||||
renderer = create(createElement(Transcript, { working: true }))
|
||||
})
|
||||
expect(textIn(renderer!.root)).toContain('greeting.ts')
|
||||
act(() => {
|
||||
renderer!.update(createElement(Transcript))
|
||||
})
|
||||
expect(textIn(renderer!.root)).toContain('greeting.ts')
|
||||
expect(textIn(renderer!.root)).not.toContain('diagnostic-output')
|
||||
expect(textIn(renderer!.root)).not.toContain('helloNew()')
|
||||
const file = findAllByHostType(renderer!.root, 'Pressable').find(
|
||||
(node) => node.props.accessibilityLabel === '/repo/greeting.ts'
|
||||
)!
|
||||
act(() => file.props.onPress())
|
||||
expect(textIn(renderer!.root)).toContain('helloNew()')
|
||||
expect(textIn(renderer!.root)).not.toContain('statusNew()')
|
||||
act(() => renderer!.unmount())
|
||||
act(() => {
|
||||
renderer = create(createElement(Transcript))
|
||||
})
|
||||
expect(textIn(renderer!.root)).toContain('status.ts')
|
||||
})
|
||||
@@ -1,4 +1,4 @@
|
||||
import { MobileQueuedMessageComposerContext } from '../mobile-queued-message-composer-context'
|
||||
import { MobileQueuedMessageComposerContext } from './input/mobile-queued-message-composer-context'
|
||||
import { Activity, useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react'
|
||||
import { StyleSheet, View } from 'react-native'
|
||||
import { MobileNativeChatView, type MobileNativeChatInputLockReason } from './MobileNativeChatView'
|
||||
@@ -6,11 +6,11 @@ import { useMobileNativeChatProjection } from './transcript/use-mobile-native-ch
|
||||
import { nativeChatDockedTaskList } from '../../../../src/shared/native-chat/input/native-chat-task-list-state'
|
||||
import type { MobileNativeChatImageAttachments } from './composer/use-mobile-native-chat-image-attachments'
|
||||
import type { MobileNativeChatController } from './mobile-native-chat-controller-contract'
|
||||
import type { MobileNativeChatStructuredComposer } from './composer/MobileNativeChatComposer'
|
||||
import type { MobileNativeChatStructuredComposer } from './composer/mobile-native-chat-structured-composer'
|
||||
import { useMobileNativeChatComposerTray } from './composer/use-mobile-native-chat-composer-tray'
|
||||
import { useMobileNativeChatVisualRenderer } from './visual/MobileNativeChatVisual'
|
||||
import { MobileNativeChatVisualContext } from './visual/mobile-native-chat-visual-context'
|
||||
import { MobileNativeChatRootItemSourceContext } from './mobile-native-chat-item-read'
|
||||
import { MobileNativeChatRootItemSourceContext } from './transcript/mobile-native-chat-item-read'
|
||||
import { useMobileNativeChatMessageDetail } from './transcript/use-mobile-native-chat-message-detail'
|
||||
import {
|
||||
MobileNativeChatReplyRevealsContext,
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
import { MobileNativeChatRowOverlaysHost } from './transcript/MobileNativeChatRowOverlaysHost'
|
||||
import { nativeChatAskRequiresTerminal } from '../../../../src/shared/native-chat/native-chat-agent-support'
|
||||
import { tuiAgentDisplayName } from '../../../../src/shared/agent-launch/catalog/tui-agent-display-names'
|
||||
import { MobileNativeChatNoticeContext } from '../mobile-native-chat-notice-context'
|
||||
import { MobileNativeChatNoticeContext } from './transcript/mobile-native-chat-notice-context'
|
||||
import type { MobileNativeChatImageSource } from './visual/mobile-native-chat-image-preview'
|
||||
import type { MobileNativeChatHostOutage } from './mobile-native-chat-host-outage'
|
||||
import { useMobileNativeChatMarkdownLinks } from './use-mobile-native-chat-markdown-links'
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import {
|
||||
installChatViewHooks,
|
||||
assistantTurn,
|
||||
banners,
|
||||
bannerText,
|
||||
hostType,
|
||||
listIds,
|
||||
pressSend,
|
||||
render,
|
||||
root,
|
||||
update
|
||||
} from './MobileNativeChatView.harness.test-fixture'
|
||||
|
||||
@@ -51,35 +46,6 @@ vi.mock('./composer/MobileNativeChatComposer', async () => {
|
||||
describe('MobileNativeChatView: send and read failure banners', () => {
|
||||
installChatViewHooks()
|
||||
|
||||
it('leaves only the words of a read that failed for good, over a loaded transcript', async () => {
|
||||
const loaded = [assistantTurn('m1', 'earlier reply')]
|
||||
const words = 'This chat was saved by a newer Orca. Update Orca to open it.'
|
||||
const shown = (text: string) =>
|
||||
root().findAll((node) => hostType(node) === 'Text' && node.props.children === text)
|
||||
const composers = () => root().findAll((node) => hostType(node) === 'Composer')
|
||||
const lists = () => root().findAll((node) => hostType(node) === 'FlatList')
|
||||
const failure = {
|
||||
messages: loaded,
|
||||
folded: loaded,
|
||||
status: 'error' as const,
|
||||
error: words,
|
||||
canStop: true,
|
||||
permission: { title: 'Approve?', options: [{ label: 'Allow', send: '1' }] },
|
||||
sendErrorMessage: 'Message unconfirmed — check chat before retrying'
|
||||
}
|
||||
await render({ ...failure, readFailedFinally: true })
|
||||
expect(shown(words)).toHaveLength(1)
|
||||
expect(composers()).toHaveLength(0)
|
||||
expect(lists()).toHaveLength(0)
|
||||
expect(banners()).toHaveLength(0)
|
||||
expect(root().findAllByProps({ accessibilityLabel: 'Stop the agent' })).toHaveLength(0)
|
||||
|
||||
await update({ ...failure, error: "Orca couldn't open this chat's history right now." })
|
||||
expect(listIds()).toEqual(['m1'])
|
||||
expect(composers()).toHaveLength(1)
|
||||
expect(banners()).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('retires the previous banner before sending and preserves the new delivery notice', async () => {
|
||||
const onClearSendError = vi.fn()
|
||||
await render({
|
||||
@@ -99,6 +65,6 @@ describe('MobileNativeChatView: send and read failure banners', () => {
|
||||
})
|
||||
})
|
||||
|
||||
vi.mock('../MobileQueuedMessageComposer', () => ({
|
||||
vi.mock('./input/MobileQueuedMessageComposer', () => ({
|
||||
MobileQueuedMessageComposer: 'QueuedMessageComposer'
|
||||
}))
|
||||
|
||||
@@ -1,188 +0,0 @@
|
||||
import './MobileNativeChatView.harness.test-fixture'
|
||||
import { createElement, type ComponentProps } from 'react'
|
||||
import { act, create, type ReactTestRenderer } from 'react-test-renderer'
|
||||
import { Pressable } from 'react-native'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { MobileNativeChatView } from './MobileNativeChatView'
|
||||
import { useMobileNativeChatPromptPresentation } from './input/use-mobile-native-chat-prompt-presentation'
|
||||
import type { MobileChatPermission } from './input/mobile-native-chat-permission'
|
||||
import { setMobileNativeChatDraftText } from './composer/mobile-native-chat-draft-store'
|
||||
vi.mock('react-native', async () => {
|
||||
const React = await import('react')
|
||||
return {
|
||||
...(await import('../../test-support/react-native-motion-stub')).reactNativeMotionStub(),
|
||||
ActivityIndicator: 'ActivityIndicator',
|
||||
Image: 'Image',
|
||||
Platform: { OS: 'ios' },
|
||||
Keyboard: { dismiss: vi.fn() },
|
||||
FlatList: React.forwardRef((props, ref) => {
|
||||
React.useImperativeHandle(ref, () => ({ scrollToEnd: vi.fn(), scrollToOffset: vi.fn() }), [])
|
||||
return React.createElement('FlatList', props)
|
||||
}),
|
||||
Pressable: 'Pressable',
|
||||
ScrollView: 'ScrollView',
|
||||
TextInput: 'TextInput',
|
||||
StyleSheet: { create: (styles: unknown) => styles, hairlineWidth: 1 },
|
||||
Text: 'Text',
|
||||
View: 'View'
|
||||
}
|
||||
})
|
||||
vi.mock('react-native-safe-area-context', () => ({
|
||||
useSafeAreaInsets: () => ({ top: 0, bottom: 0, left: 0, right: 0 })
|
||||
}))
|
||||
vi.mock('react-native-gesture-handler', () => {
|
||||
type GestureChain = {
|
||||
runOnJS: () => GestureChain
|
||||
onStart: () => GestureChain
|
||||
onUpdate: () => GestureChain
|
||||
}
|
||||
const chain: GestureChain = { runOnJS: () => chain, onStart: () => chain, onUpdate: () => chain }
|
||||
return {
|
||||
Gesture: { Simultaneous: () => ({}), Native: () => ({}), Pinch: () => chain },
|
||||
GestureDetector: 'GestureDetector',
|
||||
GestureHandlerRootView: 'GestureHandlerRootView'
|
||||
}
|
||||
})
|
||||
vi.mock('lucide-react-native', () =>
|
||||
Object.fromEntries(
|
||||
[
|
||||
'ArrowDown',
|
||||
'ArrowUp',
|
||||
'ListEnd',
|
||||
'CornerDownRight',
|
||||
'ChevronDown',
|
||||
'ChevronUp',
|
||||
'ChevronsDownUp',
|
||||
'ChevronsUpDown',
|
||||
'ShieldQuestion',
|
||||
'ImagePlus',
|
||||
'Package',
|
||||
'Plus',
|
||||
'Mic',
|
||||
'Square',
|
||||
'X'
|
||||
].map((x) => [x, x])
|
||||
)
|
||||
)
|
||||
vi.mock('./transcript/MobileNativeChatMessage', () => ({
|
||||
MobileNativeChatMessage: 'ChatMessage'
|
||||
}))
|
||||
vi.mock('./transcript/MobileNativeChatLiveLine', () => ({
|
||||
MobileNativeChatLiveLine: 'LiveStatus'
|
||||
}))
|
||||
vi.mock('./input/MobileNativeChatAsk', () => ({ MobileNativeChatAsk: 'ChatAsk' }))
|
||||
vi.mock('./input/MobileNativeChatQuestion', () => ({
|
||||
MobileNativeChatQuestion: 'ChatQuestion'
|
||||
}))
|
||||
vi.mock('./input/MobileNativeChatSessionOptionPickers', () => ({
|
||||
MobileNativeChatSessionOptionPickers: 'SessionOptions'
|
||||
}))
|
||||
vi.mock('./composer/MobileNativeChatComposerMenu', () => ({
|
||||
MobileNativeChatComposerSuggestions: 'Suggestions'
|
||||
}))
|
||||
vi.mock('../../components/ActionSheetModal', () => ({ ActionSheetModal: 'ActionSheetModal' }))
|
||||
vi.mock('../../components/MobileMarkdown', () => ({ MobileMarkdown: 'Markdown' }))
|
||||
let tree: ReactTestRenderer | null = null
|
||||
setMobileNativeChatDraftText('terminal-1', 'no, do X instead')
|
||||
const props = {
|
||||
messages: [],
|
||||
folded: [],
|
||||
status: 'ready' as const,
|
||||
streaming: null,
|
||||
pending: [],
|
||||
onSend: vi.fn(async () => true),
|
||||
sendSurfaceId: 'terminal-1',
|
||||
getSendCompletionGeneration: () => 0,
|
||||
getComposerEditGeneration: () => 0,
|
||||
draftKey: 'terminal-1',
|
||||
onComposerTextChange: vi.fn()
|
||||
}
|
||||
const permission: MobileChatPermission = {
|
||||
title: 'Claude wants to use Bash',
|
||||
options: [{ label: 'Deny', send: String.fromCharCode(27) }]
|
||||
}
|
||||
type Overrides = Partial<ComponentProps<typeof MobileNativeChatView>> & {
|
||||
waitStartedAt?: number
|
||||
sessionKey?: string
|
||||
}
|
||||
function Harness(overrides: Overrides) {
|
||||
const shown = useMobileNativeChatPromptPresentation({
|
||||
permission: overrides.permission ?? null,
|
||||
waitStartedAt: overrides.waitStartedAt ?? 10,
|
||||
scopeKey: 'tab-1',
|
||||
sessionKey: overrides.sessionKey ?? 'session-1',
|
||||
observing: true,
|
||||
respondPermission: overrides.onRespondPermission ?? (async () => false)
|
||||
})
|
||||
return createElement(MobileNativeChatView, {
|
||||
...props,
|
||||
...overrides,
|
||||
permission: shown.permission,
|
||||
promptKey: shown.occurrenceKey,
|
||||
onRespondPermission: shown.respondPermission
|
||||
})
|
||||
}
|
||||
const render = async (overrides: Overrides) => {
|
||||
await act(async () => {
|
||||
const element = createElement(Harness, overrides)
|
||||
if (tree) {
|
||||
tree.update(element)
|
||||
} else {
|
||||
tree = create(element)
|
||||
}
|
||||
})
|
||||
}
|
||||
const sendButton = () => tree!.root.findByProps({ accessibilityLabel: 'Send message' })
|
||||
const approvalAction = () =>
|
||||
tree!.root.findByProps({ testID: 'native-chat-approval-actions' }).findByType(Pressable)
|
||||
afterEach(() => {
|
||||
act(() => tree?.unmount())
|
||||
tree = null
|
||||
vi.unstubAllGlobals()
|
||||
})
|
||||
describe('terminal prompt presentation with the production view, card and composer', () => {
|
||||
it('a late answer cannot reshow an answered replacement occurrence', async () => {
|
||||
let finishOld: (accepted: boolean) => void = () => {}
|
||||
const onRespondPermission = vi
|
||||
.fn<(send: string) => Promise<boolean>>()
|
||||
.mockReturnValueOnce(
|
||||
new Promise((resolve) => {
|
||||
finishOld = resolve
|
||||
})
|
||||
)
|
||||
.mockResolvedValueOnce(true)
|
||||
await render({ permission, onRespondPermission })
|
||||
act(() => {
|
||||
void approvalAction().props.onPress()
|
||||
})
|
||||
await render({ permission, onRespondPermission, waitStartedAt: 20 })
|
||||
await act(async () => {
|
||||
await approvalAction().props.onPress()
|
||||
})
|
||||
expect(sendButton().props.disabled).toBe(false)
|
||||
await act(async () => finishOld(true))
|
||||
expect(sendButton().props.disabled).toBe(false)
|
||||
})
|
||||
|
||||
it('a late answer cannot dismiss a replacement session', async () => {
|
||||
let finishOld: (accepted: boolean) => void = () => {}
|
||||
const onRespondPermission = vi.fn(
|
||||
() =>
|
||||
new Promise<boolean>((resolve) => {
|
||||
finishOld = resolve
|
||||
})
|
||||
)
|
||||
await render({ permission, onRespondPermission })
|
||||
act(() => {
|
||||
void approvalAction().props.onPress()
|
||||
})
|
||||
await render({ permission, onRespondPermission, sessionKey: 'session-2' })
|
||||
await act(async () => finishOld(true))
|
||||
expect(sendButton().props.disabled).toBe(true)
|
||||
expect(approvalAction().props.disabled).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
vi.mock('../MobileQueuedMessageComposer', () => ({
|
||||
MobileQueuedMessageComposer: 'QueuedMessageComposer'
|
||||
}))
|
||||
@@ -22,19 +22,19 @@ import { useMobileTranslation } from '../../i18n/use-mobile-translation'
|
||||
import { MobileNativeChatInputLockStatus } from './composer/MobileNativeChatInputLockStatus'
|
||||
import { useMobileColorScheme } from '../../theme/use-mobile-color-scheme'
|
||||
import { styles } from './mobile-native-chat-view-styles'
|
||||
import { MobileNativeChatEmptyStateView } from '../MobileNativeChatEmptyStateView'
|
||||
import { mobileNativeChatListFooter } from './mobile-native-chat-list-footer'
|
||||
import { mobileNativeChatListHeader } from './mobile-native-chat-list-header'
|
||||
import { MobileNativeChatEmptyStateView } from './transcript/MobileNativeChatEmptyStateView'
|
||||
import { mobileNativeChatListFooter } from './transcript/mobile-native-chat-list-footer'
|
||||
import { mobileNativeChatListHeader } from './transcript/mobile-native-chat-list-header'
|
||||
import {
|
||||
mobileNativeChatEmptyState,
|
||||
type MobileNativeChatPendingItem
|
||||
} from './mobile-native-chat-render-data'
|
||||
} from './transcript/mobile-native-chat-render-data'
|
||||
import { useMobileNativeChatTransientData } from './transcript/use-mobile-native-chat-transient-data'
|
||||
import { useMobileNativeChatRowKeys } from './transcript/mobile-native-chat-row-keys'
|
||||
import { useMobileNativeChatPinchGesture } from './transcript/use-mobile-native-chat-pinch-gesture'
|
||||
import { useMobileNativeChatTailFollow } from './transcript/use-mobile-native-chat-tail-follow'
|
||||
import { useMobileNativeChatTurnDisclosure } from './transcript/use-mobile-native-chat-turn-disclosure'
|
||||
import { mobileNativeChatComposerPlaceholder } from './use-mobile-native-chat-input-lease'
|
||||
import { mobileNativeChatComposerPlaceholder } from './composer/use-mobile-native-chat-input-lease'
|
||||
import { MobileNativeChatLiveLine } from './transcript/MobileNativeChatLiveLine'
|
||||
import { MobileNativeChatAwaitingInputRow } from './transcript/MobileNativeChatAwaitingInputRow'
|
||||
import type { NativeChatAwaitingInput } from '../../../../src/shared/native-chat/native-chat-terminal-turn'
|
||||
@@ -43,9 +43,9 @@ import type { PendingNativeChatImage } from './composer/mobile-native-chat-image
|
||||
import type { MobilePastedImages } from './composer/mobile-native-chat-composer-paste'
|
||||
import {
|
||||
MobileNativeChatDraftComposer,
|
||||
type MobileNativeChatSendProps,
|
||||
type MobileNativeChatStructuredComposer
|
||||
type MobileNativeChatSendProps
|
||||
} from './composer/MobileNativeChatComposer'
|
||||
import type { MobileNativeChatStructuredComposer } from './composer/mobile-native-chat-structured-composer'
|
||||
import { MobileNativeChatPromptCard } from './input/MobileNativeChatPromptCard'
|
||||
import type { MobileNativeChatMicProps } from './composer/MobileNativeChatComposerMic'
|
||||
import { useMobileNativeChatPromptInputOwner } from './input/use-mobile-native-chat-prompt-input-owner'
|
||||
@@ -54,11 +54,11 @@ import {
|
||||
type ComposerTrayProps
|
||||
} from './composer/use-mobile-native-chat-composer-tray'
|
||||
import type { MobileNativeChatSessionOptionPickersProps } from './input/MobileNativeChatSessionOptionPickers'
|
||||
import { MobileNativeChatScrollRootsBoundary } from '../MobileNativeChatScrollRootsBoundary'
|
||||
import { MobileNativeChatScrollRootsBoundary } from './transcript/MobileNativeChatScrollRootsBoundary'
|
||||
import { MobileNativeChatRowList } from './transcript/MobileNativeChatRowList'
|
||||
import { useMobileNativeChatRowRenderer } from './transcript/use-mobile-native-chat-row-renderer'
|
||||
import type { MobileNativeChatStatus } from './use-mobile-native-chat-session'
|
||||
import type { OlderPagePhase } from '../use-mobile-older-page-loader'
|
||||
import type { MobileNativeChatStatus } from './mobile-native-chat-session-status'
|
||||
import type { OlderPagePhase } from './transcript/use-mobile-older-page-loader'
|
||||
import { MobileNativeChatOpenFileContext } from './mobile-native-chat-open-file-context'
|
||||
import { MobileNativeChatLowerRegion } from './MobileNativeChatLowerRegion'
|
||||
import { MobileNativeChatOfflineQueue } from './input/MobileNativeChatOfflineQueue'
|
||||
|
||||
@@ -208,6 +208,6 @@ describe('MobileNativeChatView', () => {
|
||||
})
|
||||
})
|
||||
|
||||
vi.mock('../MobileQueuedMessageComposer', () => ({
|
||||
vi.mock('./input/MobileQueuedMessageComposer', () => ({
|
||||
MobileQueuedMessageComposer: 'QueuedMessageComposer'
|
||||
}))
|
||||
|
||||
+3
-3
@@ -2,9 +2,9 @@ import type {
|
||||
AgentSessionFailureCopyId,
|
||||
AgentSessionFailureCopyValues,
|
||||
AgentSessionFailureSay
|
||||
} from '../../../src/shared/agent-session/failures/agent-session-failure-copy'
|
||||
import { translate } from '../i18n/mobile-i18n'
|
||||
import { AGENT_SESSION_FAILURE_COPY } from '../../../src/shared/agent-session/failures/agent-session-failure-copy'
|
||||
} from '../../../../../src/shared/agent-session/failures/agent-session-failure-copy'
|
||||
import { translate } from '../../../i18n/mobile-i18n'
|
||||
import { AGENT_SESSION_FAILURE_COPY } from '../../../../../src/shared/agent-session/failures/agent-session-failure-copy'
|
||||
import { START_FAILURE_COPY } from './agent-session-start-failure-copy'
|
||||
import { SEND_FAILURE_COPY } from './agent-session-send-failure-copy'
|
||||
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
import { AGENT_SESSION_FAILURE_COPY } from '../../../src/shared/agent-session/failures/agent-session-failure-copy'
|
||||
import { AGENT_SESSION_FAILURE_COPY } from '../../../../../src/shared/agent-session/failures/agent-session-failure-copy'
|
||||
import type {
|
||||
AgentSessionFailureCopyId,
|
||||
AgentSessionFailureCopyValues
|
||||
} from '../../../src/shared/agent-session/failures/agent-session-failure-copy'
|
||||
import { translate } from '../i18n/mobile-i18n'
|
||||
} from '../../../../../src/shared/agent-session/failures/agent-session-failure-copy'
|
||||
import { translate } from '../../../i18n/mobile-i18n'
|
||||
|
||||
export const SEND_FAILURE_COPY = {
|
||||
unconfirmed: (values) =>
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import type {
|
||||
AgentSessionFailureCopyId,
|
||||
AgentSessionFailureCopyValues
|
||||
} from '../../../src/shared/agent-session/failures/agent-session-failure-copy'
|
||||
import { translate } from '../i18n/mobile-i18n'
|
||||
} from '../../../../../src/shared/agent-session/failures/agent-session-failure-copy'
|
||||
import { translate } from '../../../i18n/mobile-i18n'
|
||||
|
||||
export const START_FAILURE_COPY = {
|
||||
savedConversationMissing: (values) =>
|
||||
+4
-4
@@ -1,10 +1,10 @@
|
||||
import { expiredAttachmentsSentence } from '../../../src/shared/agent-session/failures/agent-session-attachment-failure-words'
|
||||
import { agentSessionFailureSentence } from '../../../src/shared/agent-session/failures/agent-session-failure-words'
|
||||
import { expiredAttachmentsSentence } from '../../../../../src/shared/agent-session/failures/agent-session-attachment-failure-words'
|
||||
import { agentSessionFailureSentence } from '../../../../../src/shared/agent-session/failures/agent-session-failure-words'
|
||||
import type {
|
||||
AgentSessionWriteNoticePart,
|
||||
AgentSessionWriteNoticeSentence
|
||||
} from '../../../src/shared/agent-session/failures/agent-session-write-notice-copy'
|
||||
import { translate } from '../i18n/mobile-i18n'
|
||||
} from '../../../../../src/shared/agent-session/failures/agent-session-write-notice-copy'
|
||||
import { translate } from '../../../i18n/mobile-i18n'
|
||||
import { sayMobileAgentSessionFailure } from './agent-session-failure-copy'
|
||||
|
||||
const SENTENCES: Record<AgentSessionWriteNoticeSentence, () => string> = {
|
||||
+6
-6
@@ -1,18 +1,18 @@
|
||||
import { useCallback, useRef } from 'react'
|
||||
import type { StructuredAgentSessionHostSupport } from './mobile-structured-agent-session-host-support'
|
||||
import type { AgentSessionCancelResult } from '../../../src/shared/agent-session/agent-session-wire'
|
||||
import type { StructuredAgentSessionState } from '../../../src/shared/agent-session/structured-agent-session-reducer'
|
||||
import { runningStructuredAgentSessionTurnId } from '../../../src/shared/agent-session/view/structured-agent-session-live-turn'
|
||||
import type { AgentSessionCancelResult } from '../../../../../src/shared/agent-session/agent-session-wire'
|
||||
import type { StructuredAgentSessionState } from '../../../../../src/shared/agent-session/structured-agent-session-reducer'
|
||||
import { runningStructuredAgentSessionTurnId } from '../../../../../src/shared/agent-session/view/structured-agent-session-live-turn'
|
||||
import {
|
||||
joinStructuredAgentSessionStop,
|
||||
structuredAgentSessionStopIsJoinable
|
||||
} from '../../../src/shared/agent-session/requests/structured-agent-session-stop-join'
|
||||
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
|
||||
} from '../../../../../src/shared/agent-session/requests/structured-agent-session-stop-join'
|
||||
import type { RpcClient } from '../../../transport/rpc/rpc-client-contract'
|
||||
import {
|
||||
requestStructuredAgentSessionMutation,
|
||||
type StructuredAgentSessionMutationCallResult
|
||||
} from './mobile-structured-agent-session-rpc'
|
||||
import { actionableStructuredPrompts } from './mobile-structured-actionable-prompt'
|
||||
import { actionableStructuredPrompts } from '../input/mobile-structured-actionable-prompt'
|
||||
|
||||
type PromptIdentity = { itemId: string; expectedRevision: number }
|
||||
|
||||
+23
-23
@@ -1,36 +1,36 @@
|
||||
import type { AgentSessionSlashCommand } from '../../../src/shared/agent-session/agent-session-wire'
|
||||
import type { NativeChatSendFollowUp } from '../../../src/shared/native-chat/input/native-chat-follow-up-behavior'
|
||||
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
|
||||
import type { AgentSessionSlashCommand } from '../../../../../src/shared/agent-session/agent-session-wire'
|
||||
import type { NativeChatSendFollowUp } from '../../../../../src/shared/native-chat/input/native-chat-follow-up-behavior'
|
||||
import type { RpcClient } from '../../../transport/rpc/rpc-client-contract'
|
||||
import type { StructuredAgentSessionHostSupport } from './mobile-structured-agent-session-host-support'
|
||||
import type {
|
||||
MobileNativeChatSendIntent,
|
||||
MobileNativeChatSendOutcome
|
||||
} from './native-chat/mobile-native-chat-send'
|
||||
import type { MobileNativeChatVisualSource } from './native-chat/visual/mobile-native-chat-visual-read'
|
||||
import type { MobileChatPermission } from './native-chat/input/mobile-native-chat-permission'
|
||||
import type { MobileChatQuestion } from './native-chat/input/mobile-native-chat-question'
|
||||
import type { MobileNativeChatSession } from './native-chat/use-mobile-native-chat-session'
|
||||
import type { NativeChatLiveTurnIndicator } from '../../../src/shared/native-chat/transcript/native-chat-turn-status'
|
||||
import type { NativeChatResolvedPrompt } from '../../../src/shared/native-chat/native-chat-resolution-receipt'
|
||||
import type { useMobileStructuredAgentOptions } from './use-mobile-structured-agent-options'
|
||||
import type { useMobileStructuredAgentTurnTiming } from './use-mobile-structured-agent-turn-timing'
|
||||
import type { StructuredMobileSendAttachment } from './use-mobile-structured-send-with-outcome'
|
||||
} from '../composer/mobile-native-chat-send'
|
||||
import type { MobileNativeChatVisualSource } from '../visual/mobile-native-chat-visual-read'
|
||||
import type { MobileChatPermission } from '../input/mobile-native-chat-permission'
|
||||
import type { MobileChatQuestion } from '../input/mobile-native-chat-question'
|
||||
import type { MobileNativeChatSession } from '../use-mobile-native-chat-session'
|
||||
import type { NativeChatLiveTurnIndicator } from '../../../../../src/shared/native-chat/transcript/native-chat-turn-status'
|
||||
import type { NativeChatResolvedPrompt } from '../../../../../src/shared/native-chat/native-chat-resolution-receipt'
|
||||
import type { useMobileStructuredAgentOptions } from '../input/use-mobile-structured-agent-options'
|
||||
import type { useMobileStructuredAgentTurnTiming } from '../transcript/use-mobile-structured-agent-turn-timing'
|
||||
import type { StructuredMobileSendAttachment } from '../composer/use-mobile-structured-send-with-outcome'
|
||||
import type {
|
||||
AgentJournalSkillRef,
|
||||
AgentJournalSubmission
|
||||
} from '../../../src/shared/agent-session/journal/agent-session-journal-types'
|
||||
} from '../../../../../src/shared/agent-session/journal/agent-session-journal-types'
|
||||
import type {
|
||||
MobileNativeChatCommandRefusalCauses,
|
||||
MobileNativeChatSendErrorReporter
|
||||
} from './native-chat/use-mobile-native-chat-send-error'
|
||||
import type { MobileStructuredQueuedMessageControls } from './use-mobile-structured-queued-message-controls'
|
||||
import type { MobileStructuredBackgroundTasks } from './use-mobile-structured-background-tasks'
|
||||
import type { NativeChatContextUsageSummary } from '../../../src/shared/native-chat/native-chat-context-usage-summary'
|
||||
import type { MobileStructuredInterruptedContinue } from './use-mobile-structured-interrupted-continue'
|
||||
import type { MobileStructuredThreadGoal } from './use-mobile-structured-thread-goal'
|
||||
import type { MobileStructuredSends } from './use-mobile-structured-sends'
|
||||
import type { AgentSessionRewindSurface } from '../../../src/shared/agent-session/lifecycle/agent-session-rewind-request'
|
||||
import type { MobileNativeChatUsageLimit } from './native-chat/use-mobile-native-chat-usage-limit'
|
||||
} from '../composer/use-mobile-native-chat-send-error'
|
||||
import type { MobileStructuredQueuedMessageControls } from '../input/use-mobile-structured-queued-message-controls'
|
||||
import type { MobileStructuredBackgroundTasks } from '../input/use-mobile-structured-background-tasks'
|
||||
import type { NativeChatContextUsageSummary } from '../../../../../src/shared/native-chat/native-chat-context-usage-summary'
|
||||
import type { MobileStructuredInterruptedContinue } from '../composer/use-mobile-structured-interrupted-continue'
|
||||
import type { MobileStructuredThreadGoal } from '../input/use-mobile-structured-thread-goal'
|
||||
import type { MobileStructuredSends } from '../composer/use-mobile-structured-sends'
|
||||
import type { AgentSessionRewindSurface } from '../../../../../src/shared/agent-session/lifecycle/agent-session-rewind-request'
|
||||
import type { MobileNativeChatUsageLimit } from '../use-mobile-native-chat-usage-limit'
|
||||
|
||||
export type StructuredMobileSession = Omit<
|
||||
ReturnType<typeof useMobileStructuredAgentOptions>,
|
||||
+8
-8
@@ -2,12 +2,12 @@ import {
|
||||
AGENT_SESSION_COMMANDS_ON_REQUEST_CAPABILITY,
|
||||
AGENT_SESSION_MODEL_EFFORT_DISCOVERY_CAPABILITY,
|
||||
AGENT_SESSION_COHERENT_MODEL_CATALOG_CAPABILITY
|
||||
} from '../../../src/shared/agent-session/structured-agent-session-surface-capabilities'
|
||||
} from '../../../../../src/shared/agent-session/structured-agent-session-surface-capabilities'
|
||||
import {
|
||||
AGENT_SESSION_CONVERSATION_STOP_RUNTIME_CAPABILITY,
|
||||
AGENT_SESSION_PROMPT_CANCEL_RUNTIME_CAPABILITY,
|
||||
AGENT_SESSION_REPEATED_STOP_RUNTIME_CAPABILITY
|
||||
} from '../../../src/shared/agent-session/lifecycle/agent-session-stop-capabilities'
|
||||
} from '../../../../../src/shared/agent-session/lifecycle/agent-session-stop-capabilities'
|
||||
import {
|
||||
AGENT_SESSION_ITEM_DETAIL_RUNTIME_CAPABILITY,
|
||||
AGENT_SESSION_SEND_RECORDED_RUNTIME_CAPABILITY,
|
||||
@@ -22,21 +22,21 @@ import {
|
||||
AGENT_SESSION_PHONE_REWIND_RUNTIME_CAPABILITY,
|
||||
AGENT_SESSION_PHONE_USAGE_LIMIT_CONTINUE_CANCEL_RUNTIME_CAPABILITY,
|
||||
AGENT_SESSION_QUEUED_MESSAGE_SKILLS_EDIT_RUNTIME_CAPABILITY
|
||||
} from '../../../src/shared/agent-session/agent-session-runtime-capabilities'
|
||||
import { AGENT_SESSION_STATUS_FEED_RUNTIME_CAPABILITY } from '../../../src/shared/agent-session/agent-session-attention-capabilities'
|
||||
} from '../../../../../src/shared/agent-session/agent-session-runtime-capabilities'
|
||||
import { AGENT_SESSION_STATUS_FEED_RUNTIME_CAPABILITY } from '../../../../../src/shared/agent-session/agent-session-attention-capabilities'
|
||||
import {
|
||||
AGENT_SESSION_SEND_SELECTION_RUNTIME_CAPABILITY,
|
||||
AGENT_SESSION_SEND_OPTIONS_RUNTIME_CAPABILITY,
|
||||
AGENT_SESSION_SEND_SKILLS_RUNTIME_CAPABILITY,
|
||||
AGENT_SESSION_SEND_USAGE_LIMIT_CONTINUATION_RUNTIME_CAPABILITY,
|
||||
AGENT_SESSION_USAGE_LIMIT_AUTO_CONTINUE_RUNTIME_CAPABILITY
|
||||
} from '../../../src/shared/agent-session/agent-session-create-capabilities'
|
||||
} from '../../../../../src/shared/agent-session/agent-session-create-capabilities'
|
||||
import {
|
||||
AGENT_SESSION_PERMISSION_MODES_RUNTIME_CAPABILITY,
|
||||
AGENT_SESSION_PERMISSION_OWN_RUNTIME_CAPABILITY
|
||||
} from '../../../src/shared/agent-session/agent-session-permission-modes-capability'
|
||||
import { SKILL_DISCOVER_WORKSPACE_CAPABILITY } from '../../../src/shared/skill-install-capability'
|
||||
import { AGENT_SESSION_PHONE_CONTINUE_INTERRUPTED_RUNTIME_CAPABILITY } from '../../../src/shared/agent-session/agent-session-continue-interrupted-capability'
|
||||
} from '../../../../../src/shared/agent-session/agent-session-permission-modes-capability'
|
||||
import { SKILL_DISCOVER_WORKSPACE_CAPABILITY } from '../../../../../src/shared/skill-install-capability'
|
||||
import { AGENT_SESSION_PHONE_CONTINUE_INTERRUPTED_RUNTIME_CAPABILITY } from '../../../../../src/shared/agent-session/agent-session-continue-interrupted-capability'
|
||||
|
||||
export type StructuredAgentSessionHostSupport = {
|
||||
commandsOnRequest?: boolean
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
|
||||
import { markRpcDeliveryUnknown } from '../transport/rpc/rpc-delivery-ambiguity'
|
||||
import type { RpcClient } from '../../../transport/rpc/rpc-client-contract'
|
||||
import { markRpcDeliveryUnknown } from '../../../transport/rpc/rpc-delivery-ambiguity'
|
||||
import { createMobileStructuredAgentSession } from './mobile-structured-agent-session-launch'
|
||||
import './mobile-created-structured-sessions'
|
||||
|
||||
+11
-11
@@ -1,30 +1,30 @@
|
||||
import { agentSessionForkSourceFailureWords } from '../../../src/shared/agent-session/failures/agent-session-failure-copy'
|
||||
import { agentSessionForkSourceFailureWords } from '../../../../../src/shared/agent-session/failures/agent-session-failure-copy'
|
||||
import { sayMobileAgentSessionFailure } from './agent-session-failure-copy'
|
||||
import type { TuiAgent } from '../../../src/shared/agent-launch/catalog/tui-agent'
|
||||
import type { TuiAgent } from '../../../../../src/shared/agent-launch/catalog/tui-agent'
|
||||
import type {
|
||||
AgentSessionAttachResult,
|
||||
AgentSessionMutationResult
|
||||
} from '../../../src/shared/agent-session/agent-session-wire'
|
||||
} from '../../../../../src/shared/agent-session/agent-session-wire'
|
||||
import {
|
||||
isDefinitiveAgentSessionCreateRefusal,
|
||||
isAgentSessionForkSourceAdmissionRefusal,
|
||||
isAgentSessionCreateAdmissionRefusal
|
||||
} from '../../../src/shared/agent-session/failures/agent-session-definitive-refusal'
|
||||
} from '../../../../../src/shared/agent-session/failures/agent-session-definitive-refusal'
|
||||
import {
|
||||
createStructuredAgentSessionId,
|
||||
structuredAgentSessionCreateParams,
|
||||
type StructuredAgentSessionCreateParams,
|
||||
type StructuredAgentSessionForkSource
|
||||
} from '../../../src/shared/agent-session/structured-agent-session-create'
|
||||
import type { StructuredAgentCreateSupportReply } from '../../../src/shared/agent-session/structured-agent-create-support-reply'
|
||||
import { TUI_AGENT_DISPLAY_NAMES } from '../../../src/shared/agent-launch/catalog/tui-agent-display-names'
|
||||
import { hasRuntimeRpcErrorCode } from '../../../src/shared/runtime-rpc-error-code'
|
||||
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
|
||||
} from '../../../../../src/shared/agent-session/structured-agent-session-create'
|
||||
import type { StructuredAgentCreateSupportReply } from '../../../../../src/shared/agent-session/structured-agent-create-support-reply'
|
||||
import { TUI_AGENT_DISPLAY_NAMES } from '../../../../../src/shared/agent-launch/catalog/tui-agent-display-names'
|
||||
import { hasRuntimeRpcErrorCode } from '../../../../../src/shared/runtime-rpc-error-code'
|
||||
import type { RpcClient } from '../../../transport/rpc/rpc-client-contract'
|
||||
import {
|
||||
structuredAgentSessionCreate,
|
||||
structuredAgentSupportProbe
|
||||
} from './native-chat/agent-session/mobile-structured-create-operations'
|
||||
import { randomV4Uuid } from '../platform/random-v4-uuid'
|
||||
} from './mobile-structured-create-operations'
|
||||
import { randomV4Uuid } from '../../../platform/random-v4-uuid'
|
||||
import { rememberMobileCreatedStructuredSession } from './mobile-created-structured-sessions'
|
||||
|
||||
// Partial: the reply is read before it is checked.
|
||||
+11
-11
@@ -1,11 +1,11 @@
|
||||
import type { AgentSessionMutationResult } from '../../../src/shared/agent-session/agent-session-wire'
|
||||
import type { AgentSessionMutationResult } from '../../../../../src/shared/agent-session/agent-session-wire'
|
||||
import type {
|
||||
AgentSessionWireRefusalCode,
|
||||
AgentSessionRefusalReference
|
||||
} from '../../../src/shared/agent-session/failures/agent-session-wire-refusals'
|
||||
import type { AgentJournalCursor } from '../../../src/shared/agent-session/journal/agent-session-journal-identity'
|
||||
import { structuredAgentSessionPayloadFingerprint } from '../../../src/shared/agent-session/lifecycle/structured-agent-session-mutation'
|
||||
import { agentSessionWriteNoticeParts } from '../../../src/shared/agent-session/failures/agent-session-refusal-notice'
|
||||
} from '../../../../../src/shared/agent-session/failures/agent-session-wire-refusals'
|
||||
import type { AgentJournalCursor } from '../../../../../src/shared/agent-session/journal/agent-session-journal-identity'
|
||||
import { structuredAgentSessionPayloadFingerprint } from '../../../../../src/shared/agent-session/lifecycle/structured-agent-session-mutation'
|
||||
import { agentSessionWriteNoticeParts } from '../../../../../src/shared/agent-session/failures/agent-session-refusal-notice'
|
||||
import {
|
||||
agentSessionRefusalFailure,
|
||||
agentSessionThrownFailure,
|
||||
@@ -13,14 +13,14 @@ import {
|
||||
readAgentSessionErrorRefusal,
|
||||
type AgentSessionWriteFailure,
|
||||
type AgentSessionWriteKind
|
||||
} from '../../../src/shared/agent-session/failures/agent-session-write-failure'
|
||||
} from '../../../../../src/shared/agent-session/failures/agent-session-write-failure'
|
||||
import { mobileAgentSessionWriteNoticeText } from './agent-session-write-notice-copy'
|
||||
import { structuredSessionOperationId } from './structured-session-operation-id'
|
||||
import { isRpcDeliveryUnknown } from '../transport/rpc/rpc-delivery-ambiguity'
|
||||
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
|
||||
import '../transport/connection/stable-logical-rpc-client'
|
||||
import { isLogicalClientCutoverError } from '../transport/connection/logical-client-cutover-error'
|
||||
import { MOBILE_NATIVE_CHAT_MIN_WRITE_TIMEOUT_MS } from './native-chat/mobile-native-chat-send'
|
||||
import { isRpcDeliveryUnknown } from '../../../transport/rpc/rpc-delivery-ambiguity'
|
||||
import type { RpcClient } from '../../../transport/rpc/rpc-client-contract'
|
||||
import '../../../transport/connection/stable-logical-rpc-client'
|
||||
import { isLogicalClientCutoverError } from '../../../transport/connection/logical-client-cutover-error'
|
||||
import { MOBILE_NATIVE_CHAT_MIN_WRITE_TIMEOUT_MS } from '../composer/mobile-native-chat-send'
|
||||
|
||||
export const STRUCTURED_SEND_TIMEOUT_MS = 15_000
|
||||
|
||||
+10
-10
@@ -1,21 +1,21 @@
|
||||
import type { AgentSessionSendResult } from '../../../src/shared/agent-session/agent-session-wire'
|
||||
import type { AgentJournalCursor } from '../../../src/shared/agent-session/journal/agent-session-journal-identity'
|
||||
import type { AgentJournalSkillRef } from '../../../src/shared/agent-session/journal/agent-session-journal-types'
|
||||
import type { AgentSessionSendResult } from '../../../../../src/shared/agent-session/agent-session-wire'
|
||||
import type { AgentJournalCursor } from '../../../../../src/shared/agent-session/journal/agent-session-journal-identity'
|
||||
import type { AgentJournalSkillRef } from '../../../../../src/shared/agent-session/journal/agent-session-journal-types'
|
||||
import {
|
||||
structuredAgentSessionSendBody,
|
||||
type StructuredAgentSessionAttachment
|
||||
} from '../../../src/shared/agent-session/requests/structured-agent-session-send-mutation'
|
||||
import { structuredAgentSessionBlocksTooLarge } from '../../../src/shared/rpc-contract/structured-agent-session-message-params'
|
||||
import { AGENT_SESSION_MESSAGE_TOO_LARGE_PARTS } from '../../../src/shared/agent-session/failures/agent-session-refusal-notice'
|
||||
} from '../../../../../src/shared/agent-session/requests/structured-agent-session-send-mutation'
|
||||
import { structuredAgentSessionBlocksTooLarge } from '../../../../../src/shared/rpc-contract/structured-agent-session-message-params'
|
||||
import { AGENT_SESSION_MESSAGE_TOO_LARGE_PARTS } from '../../../../../src/shared/agent-session/failures/agent-session-refusal-notice'
|
||||
import { mobileAgentSessionWriteNoticeText } from './agent-session-write-notice-copy'
|
||||
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
|
||||
import type { MobileNativeChatSendOutcome } from './native-chat/mobile-native-chat-send'
|
||||
import type { RpcClient } from '../../../transport/rpc/rpc-client-contract'
|
||||
import type { MobileNativeChatSendOutcome } from '../composer/mobile-native-chat-send'
|
||||
import {
|
||||
requestStructuredAgentSessionMutation,
|
||||
timeoutForDeadline
|
||||
} from './mobile-structured-agent-session-rpc'
|
||||
import { mobileStructuredSendDelivery } from './mobile-structured-send-delivery'
|
||||
import type { MobileNativeChatSendErrorReporter } from './native-chat/use-mobile-native-chat-send-error'
|
||||
import { mobileStructuredSendDelivery } from '../composer/mobile-structured-send-delivery'
|
||||
import type { MobileNativeChatSendErrorReporter } from '../composer/use-mobile-native-chat-send-error'
|
||||
|
||||
export async function sendMobileStructuredAgentSessionMessage(input: {
|
||||
client: RpcClient
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
import type { StructuredAgentSessionState } from '../../../src/shared/agent-session/structured-agent-session-reducer'
|
||||
import type { StructuredAgentSessionState } from '../../../../../src/shared/agent-session/structured-agent-session-reducer'
|
||||
import {
|
||||
runningStructuredAgentSessionTurnId,
|
||||
structuredAgentSessionHostSaysWorking
|
||||
} from '../../../src/shared/agent-session/view/structured-agent-session-live-turn'
|
||||
import { isStructuredAgentSessionMainAgentWorking } from '../../../src/shared/agent-session/view/structured-agent-session-main-agent-working'
|
||||
} from '../../../../../src/shared/agent-session/view/structured-agent-session-live-turn'
|
||||
import { isStructuredAgentSessionMainAgentWorking } from '../../../../../src/shared/agent-session/view/structured-agent-session-main-agent-working'
|
||||
|
||||
export function mobileStructuredAgentSessionWorking(state: StructuredAgentSessionState): boolean {
|
||||
return structuredAgentSessionHostSaysWorking(state.working, () =>
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import type { StructuredAgentHostClock } from '../../../src/shared/agent-session/structured-agent-session-reducer'
|
||||
import type { StructuredAgentHostClock } from '../../../../../src/shared/agent-session/structured-agent-session-reducer'
|
||||
|
||||
// Ignore delivery jitter below the precision of displayed clocks.
|
||||
const OFFSET_GRAIN_MS = 1_000
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
import { formatAgentTypeLabel } from '../../../src/shared/agent-status/presentation/agent-type-label'
|
||||
import type { StructuredSessionOpenFailure } from '../../../src/shared/open-structured-agent-session'
|
||||
import { translate } from '../i18n/mobile-i18n'
|
||||
import { formatAgentTypeLabel } from '../../../../../src/shared/agent-status/presentation/agent-type-label'
|
||||
import type { StructuredSessionOpenFailure } from '../../../../../src/shared/open-structured-agent-session'
|
||||
import { translate } from '../../../i18n/mobile-i18n'
|
||||
|
||||
export function mobileStructuredSessionOpenMessage(
|
||||
reason: StructuredSessionOpenFailure['reason'],
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
import * as z from 'zod'
|
||||
import { bindDeferredRpcOperation, defineRpcOperation } from '../transport/rpc/rpc-operation'
|
||||
import { rpcResultVariant } from '../transport/rpc/rpc-operation-result-reader'
|
||||
import type { RpcMethodName } from '../../../src/shared/rpc-contract/rpc-params-catalog.generated'
|
||||
import { bindDeferredRpcOperation, defineRpcOperation } from '../../../transport/rpc/rpc-operation'
|
||||
import { rpcResultVariant } from '../../../transport/rpc/rpc-operation-result-reader'
|
||||
import type { RpcMethodName } from '../../../../../src/shared/rpc-contract/rpc-params-catalog.generated'
|
||||
|
||||
function openingRead<Method extends RpcMethodName, Schema extends z.ZodType>(
|
||||
method: Method,
|
||||
+5
-5
@@ -1,10 +1,10 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { AgentSessionStatusSummary } from '../../../src/shared/agent-session/agent-session-wire'
|
||||
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
|
||||
import type { ConnectionState } from '../transport/connection/connection-state'
|
||||
import '../transport/connection/stable-logical-rpc-client'
|
||||
import type { AgentSessionStatusSummary } from '../../../../../src/shared/agent-session/agent-session-wire'
|
||||
import type { RpcClient } from '../../../transport/rpc/rpc-client-contract'
|
||||
import type { ConnectionState } from '../../../transport/connection/connection-state'
|
||||
import '../../../transport/connection/stable-logical-rpc-client'
|
||||
import { mobileStructuredSessionStatusFeed } from './mobile-structured-session-status-feed'
|
||||
import { stubRpcClient } from '../transport/rpc/rpc-client-test-stub'
|
||||
import { stubRpcClient } from '../../../transport/rpc/rpc-client-test-stub'
|
||||
|
||||
function summary(stopping: boolean): AgentSessionStatusSummary {
|
||||
return {
|
||||
+5
-5
@@ -5,14 +5,14 @@ import {
|
||||
foldAgentSessionStatusEvent,
|
||||
revokeAgentSessionStatusLive,
|
||||
type AgentSessionStatusSnapshot
|
||||
} from '../../../src/shared/agent-session/view/agent-session-status-snapshot-fold'
|
||||
import type { AgentSessionStatusEvent } from '../../../src/shared/agent-session/agent-session-wire'
|
||||
} from '../../../../../src/shared/agent-session/view/agent-session-status-snapshot-fold'
|
||||
import type { AgentSessionStatusEvent } from '../../../../../src/shared/agent-session/agent-session-wire'
|
||||
import {
|
||||
foldAgentSessionConversationNames,
|
||||
type AgentSessionConversationNames
|
||||
} from '../../../src/shared/agent-session/agent-session-conversation-names'
|
||||
import { isMobileMethodUnavailableError } from '../transport/rpc/mobile-method-unavailable'
|
||||
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
|
||||
} from '../../../../../src/shared/agent-session/agent-session-conversation-names'
|
||||
import { isMobileMethodUnavailableError } from '../../../transport/rpc/mobile-method-unavailable'
|
||||
import type { RpcClient } from '../../../transport/rpc/rpc-client-contract'
|
||||
|
||||
export type MobileStructuredSessionStatusFeed = {
|
||||
subscribe: (listener: () => void) => () => void
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
import type { AgentSessionSubscribeEvent } from '../../../src/shared/agent-session/agent-session-wire'
|
||||
import type { StructuredAgentSessionLiveSubscribe } from '../../../src/shared/agent-session/structured-agent-session-live-read'
|
||||
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
|
||||
import type { AgentSessionSubscribeEvent } from '../../../../../src/shared/agent-session/agent-session-wire'
|
||||
import type { StructuredAgentSessionLiveSubscribe } from '../../../../../src/shared/agent-session/structured-agent-session-live-read'
|
||||
import type { RpcClient } from '../../../transport/rpc/rpc-client-contract'
|
||||
|
||||
function isSubscribeEvent(value: unknown): value is AgentSessionSubscribeEvent {
|
||||
if (typeof value !== 'object' || value === null || !('type' in value)) {
|
||||
+5
-5
@@ -4,17 +4,17 @@ import {
|
||||
type StructuredSessionOpenSource,
|
||||
type StructuredSessionOpenTab,
|
||||
type StructuredSessionOpenTarget
|
||||
} from '../../../src/shared/open-structured-agent-session'
|
||||
import { isStructuredAgentId } from '../../../src/shared/agent-session/lifecycle/agent-session-provider-handle-encoding'
|
||||
import { structuredAgentSessionPaneKey } from '../../../src/shared/agent-session/view/structured-agent-session-projection'
|
||||
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
|
||||
} from '../../../../../src/shared/open-structured-agent-session'
|
||||
import { isStructuredAgentId } from '../../../../../src/shared/agent-session/lifecycle/agent-session-provider-handle-encoding'
|
||||
import { structuredAgentSessionPaneKey } from '../../../../../src/shared/agent-session/view/structured-agent-session-projection'
|
||||
import type { RpcClient } from '../../../transport/rpc/rpc-client-contract'
|
||||
import {
|
||||
structuredOpenLocation,
|
||||
structuredOpenParty,
|
||||
structuredOpenReveal,
|
||||
structuredOpenTabs
|
||||
} from './mobile-structured-session-open-rpc'
|
||||
import { sessionTabActivate } from './tabs/mobile-session-tab-write-operations'
|
||||
import { sessionTabActivate } from '../../tabs/mobile-session-tab-write-operations'
|
||||
|
||||
/** The workspace client already carries executionHost; a single budget includes connect waits. */
|
||||
export async function openMobileStructuredSession(args: {
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
// Keep id generation dependency-free so create/tasks callers do not pull in the native-chat write graph.
|
||||
|
||||
import { createStructuredAgentSessionOperationId } from '../../../src/shared/agent-session/lifecycle/structured-agent-session-mutation'
|
||||
import { randomV4Uuid } from '../platform/random-v4-uuid'
|
||||
import { createStructuredAgentSessionOperationId } from '../../../../../src/shared/agent-session/lifecycle/structured-agent-session-mutation'
|
||||
import { randomV4Uuid } from '../../../platform/random-v4-uuid'
|
||||
|
||||
export function structuredSessionOperationId(now: number = Date.now()): string {
|
||||
return createStructuredAgentSessionOperationId(randomV4Uuid, now)
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
import { useCallback } from 'react'
|
||||
import type { StructuredAgentSessionState } from '../../../src/shared/agent-session/structured-agent-session-reducer'
|
||||
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
|
||||
import type { StructuredAgentSessionState } from '../../../../../src/shared/agent-session/structured-agent-session-reducer'
|
||||
import type { RpcClient } from '../../../transport/rpc/rpc-client-contract'
|
||||
import {
|
||||
requestStructuredAgentSessionMutation,
|
||||
type StructuredAgentSessionMutationResult
|
||||
+14
-14
@@ -1,24 +1,24 @@
|
||||
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
|
||||
import { AGENT_SESSION_CONVERSATION_COMMAND_TIMEOUT_MS } from '../../../src/shared/agent-session/agent-session-conversation-command'
|
||||
import { AGENT_SESSION_PHONE_REWIND_RUNTIME_CAPABILITY } from '../../../src/shared/agent-session/agent-session-runtime-capabilities'
|
||||
import type { AgentSessionRewindResult } from '../../../src/shared/agent-session/lifecycle/agent-session-rewind'
|
||||
import { AGENT_SESSION_CONVERSATION_COMMAND_TIMEOUT_MS } from '../../../../../src/shared/agent-session/agent-session-conversation-command'
|
||||
import { AGENT_SESSION_PHONE_REWIND_RUNTIME_CAPABILITY } from '../../../../../src/shared/agent-session/agent-session-runtime-capabilities'
|
||||
import type { AgentSessionRewindResult } from '../../../../../src/shared/agent-session/lifecycle/agent-session-rewind'
|
||||
import {
|
||||
createAgentSessionRewindHook,
|
||||
type AgentSessionRewindInput,
|
||||
type AgentSessionRewindSendOutcome
|
||||
} from '../../../src/shared/agent-session/lifecycle/agent-session-rewind-request'
|
||||
import type { StructuredAgentSessionState } from '../../../src/shared/agent-session/structured-agent-session-reducer'
|
||||
import { actionableStructuredPrompts } from './mobile-structured-actionable-prompt'
|
||||
import { useRouteRelaysCapability } from '../worktree/workspace-server-context'
|
||||
import { sayMobileNativeChatRewind } from './native-chat/mobile-native-chat-rewind-copy'
|
||||
import type { MobileNativeChatSendOutcome } from './native-chat/mobile-native-chat-send'
|
||||
} from '../../../../../src/shared/agent-session/lifecycle/agent-session-rewind-request'
|
||||
import type { StructuredAgentSessionState } from '../../../../../src/shared/agent-session/structured-agent-session-reducer'
|
||||
import { actionableStructuredPrompts } from '../input/mobile-structured-actionable-prompt'
|
||||
import { useRouteRelaysCapability } from '../../../worktree/workspace-server-context'
|
||||
import { sayMobileNativeChatRewind } from '../mobile-native-chat-rewind-copy'
|
||||
import type { MobileNativeChatSendOutcome } from '../composer/mobile-native-chat-send'
|
||||
import { requestStructuredAgentSessionMutation } from './mobile-structured-agent-session-rpc'
|
||||
import { returnMobileNativeChatMessageToComposer } from './mobile-native-chat-message-hand-back'
|
||||
import type { useMobileStructuredAgentOptions } from './use-mobile-structured-agent-options'
|
||||
import { returnMobileNativeChatMessageToComposer } from '../composer/mobile-native-chat-message-hand-back'
|
||||
import type { useMobileStructuredAgentOptions } from '../input/use-mobile-structured-agent-options'
|
||||
import type { MobileStructuredAgentSessionArgs } from './mobile-structured-agent-session-contract'
|
||||
import type { MobileStructuredBackgroundTasks } from './use-mobile-structured-background-tasks'
|
||||
import type { MobileStructuredSendsOut } from './use-mobile-structured-stop-offer'
|
||||
import { tuiAgentDisplayName } from '../../../src/shared/agent-launch/catalog/tui-agent-display-names'
|
||||
import type { MobileStructuredBackgroundTasks } from '../input/use-mobile-structured-background-tasks'
|
||||
import type { MobileStructuredSendsOut } from '../composer/use-mobile-structured-stop-offer'
|
||||
import { tuiAgentDisplayName } from '../../../../../src/shared/agent-launch/catalog/tui-agent-display-names'
|
||||
|
||||
const useAgentSessionRewind = createAgentSessionRewindHook(
|
||||
{ useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState },
|
||||
+1
-1
@@ -8,7 +8,7 @@ import type {
|
||||
} from '../../../../../src/shared/agent-session/requests/agent-session-queued-message-wire'
|
||||
import type { AgentSessionSubscribeEvent } from '../../../../../src/shared/agent-session/agent-session-wire'
|
||||
import type { RpcResponse } from '../../../transport/rpc/rpc-wire-types'
|
||||
import type { StructuredAgentSessionHostSupport } from '../../mobile-structured-agent-session-host-support'
|
||||
import type { StructuredAgentSessionHostSupport } from './mobile-structured-agent-session-host-support'
|
||||
|
||||
export const SESSION_ID = 'session-1'
|
||||
|
||||
|
||||
+2
-2
@@ -7,8 +7,8 @@ import type { AgentSessionSubscribeEvent } from '../../../../../src/shared/agent
|
||||
import type { RpcClient } from '../../../transport/rpc/rpc-client-contract'
|
||||
import type { RpcResponse } from '../../../transport/rpc/rpc-wire-types'
|
||||
import { markRpcDeliveryUnknown } from '../../../transport/rpc/rpc-delivery-ambiguity'
|
||||
import type { StructuredAgentSessionHostSupport } from '../../mobile-structured-agent-session-host-support'
|
||||
import { useMobileStructuredAgentSession } from '../../use-mobile-structured-agent-session'
|
||||
import type { StructuredAgentSessionHostSupport } from './mobile-structured-agent-session-host-support'
|
||||
import { useMobileStructuredAgentSession } from './use-mobile-structured-agent-session'
|
||||
|
||||
import type { RpcClientContextValue } from '../../../transport/connection/rpc-client-context-contract'
|
||||
|
||||
|
||||
+1
-36
@@ -6,7 +6,7 @@ import type { AgentSessionSubscribeEvent } from '../../../../../src/shared/agent
|
||||
import { createWithQueryClient } from '../../../test-support/query-client-test-renderer'
|
||||
import type { RpcClient } from '../../../transport/rpc/rpc-client-contract'
|
||||
import type { RpcResponse } from '../../../transport/rpc/rpc-wire-types'
|
||||
import { useMobileStructuredAgentSession } from '../../use-mobile-structured-agent-session'
|
||||
import { useMobileStructuredAgentSession } from './use-mobile-structured-agent-session'
|
||||
import {
|
||||
SESSION_ID,
|
||||
mutationOk,
|
||||
@@ -29,25 +29,6 @@ const row = (
|
||||
observedAt: sequence,
|
||||
body: { kind: 'message', role, blocks: [{ type: 'text', text }] }
|
||||
})
|
||||
const divider = (sequence: number): AgentJournalRenderItem => ({
|
||||
...row(sequence, 'assistant', ''),
|
||||
body: {
|
||||
kind: 'status',
|
||||
text: 'Context cleared',
|
||||
presentation: 'context-cleared',
|
||||
contextClear: { operationId: `clear-${sequence}`, afterFence: 3, clearedAt: sequence }
|
||||
}
|
||||
})
|
||||
const dividerLands = (sequence: number): AgentSessionSubscribeEvent => ({
|
||||
type: 'batch',
|
||||
sessionId: SESSION_ID,
|
||||
batch: {
|
||||
cursor: { epoch: 'epoch-1', sequence },
|
||||
items: [divider(sequence)],
|
||||
removedItemIds: [],
|
||||
submissions: []
|
||||
}
|
||||
})
|
||||
|
||||
describe('useMobileStructuredAgentSession /clear', () => {
|
||||
let renderer: ReactTestRenderer | null = null
|
||||
@@ -132,22 +113,6 @@ describe('useMobileStructuredAgentSession /clear', () => {
|
||||
}
|
||||
}
|
||||
|
||||
it('hides the old transcript from the press until the divider lands', async () => {
|
||||
const chat = await mount()
|
||||
expect(chat.shown()).toEqual({ text: ['question', 'reply'], clearing: false })
|
||||
|
||||
const { outcome } = await chat.sendClear()
|
||||
expect(chat.shown()).toEqual({ text: [], clearing: true })
|
||||
|
||||
// The host's reply can reach the phone before the divider it already wrote.
|
||||
await chat.reply({ command: 'clear', state: 'completed' })
|
||||
await expect(outcome).resolves.toBe('accepted')
|
||||
expect(chat.shown()).toEqual({ text: [], clearing: true })
|
||||
|
||||
chat.push(dividerLands(3))
|
||||
expect(chat.shown()).toEqual({ text: ['Context cleared'], clearing: false })
|
||||
})
|
||||
|
||||
it('shows the old transcript again when the host refuses the /clear', async () => {
|
||||
const chat = await mount()
|
||||
const { outcome } = await chat.sendClear()
|
||||
|
||||
+2
-2
@@ -7,12 +7,12 @@ import { agentJournalItemKey } from '../../../../../src/shared/agent-session/jou
|
||||
import { AGENT_SESSION_PHONE_CONTINUE_INTERRUPTED_RUNTIME_CAPABILITY } from '../../../../../src/shared/agent-session/agent-session-continue-interrupted-capability'
|
||||
import type { RpcClient } from '../../../transport/rpc/rpc-client-contract'
|
||||
import type { RpcResponse } from '../../../transport/rpc/rpc-wire-types'
|
||||
import { structuredAgentSessionHostSupport } from '../../mobile-structured-agent-session-host-support'
|
||||
import { structuredAgentSessionHostSupport } from './mobile-structured-agent-session-host-support'
|
||||
import {
|
||||
snapshotEvent,
|
||||
SESSION_ID
|
||||
} from './use-mobile-structured-agent-session-queued.test-fixture'
|
||||
import { useMobileStructuredAgentSession } from '../../use-mobile-structured-agent-session'
|
||||
import { useMobileStructuredAgentSession } from './use-mobile-structured-agent-session'
|
||||
|
||||
vi.mock('@react-native-async-storage/async-storage', () => ({
|
||||
default: { getItem: vi.fn(async () => null), setItem: vi.fn(), removeItem: vi.fn() }
|
||||
|
||||
+6
-6
@@ -4,16 +4,16 @@ import {
|
||||
fieldsOf,
|
||||
mutationOk,
|
||||
ok
|
||||
} from './native-chat/agent-session/use-mobile-structured-agent-session-queued.test-fixture'
|
||||
} from './use-mobile-structured-agent-session-queued.test-fixture'
|
||||
import { act, type ReactTestRenderer } from 'react-test-renderer'
|
||||
import { createWithQueryClient } from '../test-support/query-client-test-renderer'
|
||||
import { createWithQueryClient } from '../../../test-support/query-client-test-renderer'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { AgentJournalRenderItem } from '../../../src/shared/agent-session/journal/agent-session-journal-types'
|
||||
import type { AgentJournalRenderItem } from '../../../../../src/shared/agent-session/journal/agent-session-journal-types'
|
||||
|
||||
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
|
||||
import type { ConnectionState } from '../transport/connection/connection-state'
|
||||
import type { RpcClient } from '../../../transport/rpc/rpc-client-contract'
|
||||
import type { ConnectionState } from '../../../transport/connection/connection-state'
|
||||
|
||||
import { structuredSendResultFixture } from './structured-agent-send-result.test-fixture'
|
||||
import { structuredSendResultFixture } from '../../structured-agent-send-result.test-fixture'
|
||||
import { useMobileStructuredAgentSession } from './use-mobile-structured-agent-session'
|
||||
|
||||
const asyncStorage = vi.hoisted(() => ({
|
||||
+28
-28
@@ -1,57 +1,57 @@
|
||||
import { asyncQuestionSourceScope as questionSourceScope } from '../../../src/shared/native-chat/input/native-chat-ask'
|
||||
import { structuredChatTranscriptIdentity } from './native-chat/mobile-native-chat-transcript-store'
|
||||
import { asyncQuestionSourceScope as questionSourceScope } from '../../../../../src/shared/native-chat/input/native-chat-ask'
|
||||
import { structuredChatTranscriptIdentity } from '../transcript/mobile-native-chat-transcript-store'
|
||||
import { useMemo, useRef } from 'react'
|
||||
import { tuiAgentDisplayName } from '../../../src/shared/agent-launch/catalog/tui-agent-display-names'
|
||||
import { tuiAgentDisplayName } from '../../../../../src/shared/agent-launch/catalog/tui-agent-display-names'
|
||||
import { mobileStructuredAgentSessionWorking } from './mobile-structured-agent-session-working'
|
||||
import { isFinalAgentSessionReadRefusal } from '../../../src/shared/agent-session/failures/structured-agent-session-read-refusal'
|
||||
import { isFinalAgentSessionReadRefusal } from '../../../../../src/shared/agent-session/failures/structured-agent-session-read-refusal'
|
||||
import {
|
||||
runningStructuredAgentSessionTurnId,
|
||||
structuredAgentSessionQueueSendsNext
|
||||
} from '../../../src/shared/agent-session/view/structured-agent-session-live-turn'
|
||||
} from '../../../../../src/shared/agent-session/view/structured-agent-session-live-turn'
|
||||
import {
|
||||
actionableStructuredApproval,
|
||||
actionableStructuredQuestion
|
||||
} from './mobile-structured-actionable-prompt'
|
||||
} from '../input/mobile-structured-actionable-prompt'
|
||||
import {
|
||||
projectStructuredPermission,
|
||||
projectStructuredQuestion
|
||||
} from './mobile-structured-agent-prompts'
|
||||
} from '../input/mobile-structured-agent-prompts'
|
||||
import type {
|
||||
MobileStructuredAgentSessionArgs,
|
||||
StructuredMobileSession
|
||||
} from './mobile-structured-agent-session-contract'
|
||||
import type { MobileNativeChatVisualSource } from './native-chat/visual/mobile-native-chat-visual-read'
|
||||
import type { MobileNativeChatVisualSource } from '../visual/mobile-native-chat-visual-read'
|
||||
import { useMobileStructuredAgentState } from './use-mobile-structured-agent-state'
|
||||
import { useMobileStructuredStopPress } from './use-mobile-structured-stop-press'
|
||||
import { useMobileStructuredStopPress } from '../composer/use-mobile-structured-stop-press'
|
||||
import { useMobileStructuredSessionHostStopping } from './use-mobile-structured-session-host-stopping'
|
||||
import { useMobileStructuredPromptResponses } from './use-mobile-structured-prompt-responses'
|
||||
import { useMobileStructuredAgentOptions } from './use-mobile-structured-agent-options'
|
||||
import { useHostModelCatalogCache } from './mobile-host-model-catalog-query'
|
||||
import { useMobileStructuredCommandController } from './use-mobile-structured-command-controller'
|
||||
import { useMobileStructuredSessionOptionStamp } from './use-mobile-structured-session-option-stamp'
|
||||
import { useMobileStructuredAgentTurnTiming } from './use-mobile-structured-agent-turn-timing'
|
||||
import { useMobileStructuredPromptResponses } from '../input/use-mobile-structured-prompt-responses'
|
||||
import { useMobileStructuredAgentOptions } from '../input/use-mobile-structured-agent-options'
|
||||
import { useHostModelCatalogCache } from '../input/mobile-host-model-catalog-query'
|
||||
import { useMobileStructuredCommandController } from '../composer/use-mobile-structured-command-controller'
|
||||
import { useMobileStructuredSessionOptionStamp } from '../input/use-mobile-structured-session-option-stamp'
|
||||
import { useMobileStructuredAgentTurnTiming } from '../transcript/use-mobile-structured-agent-turn-timing'
|
||||
import {
|
||||
pendingStructuredPromptIdentity,
|
||||
useMobileStructuredRequestCancel
|
||||
} from './mobile-structured-agent-session-cancel'
|
||||
import { useMobileStructuredAgentMutate } from './use-mobile-structured-agent-mutation'
|
||||
import { useMobileStructuredSendWithOutcome } from './use-mobile-structured-send-with-outcome'
|
||||
import { useMobileStructuredQueuedMessageControls } from './use-mobile-structured-queued-message-controls'
|
||||
import { useMobileStructuredBackgroundTasks } from './use-mobile-structured-background-tasks'
|
||||
import { useMobileStructuredSends } from './use-mobile-structured-sends'
|
||||
import { useMobileStructuredSendRecorded } from './mobile-structured-send-recorded-read'
|
||||
import { useMobileNativeChatQueueFollowUps as useQueueFollowUps } from './use-mobile-native-chat-queue-follow-ups'
|
||||
import { useMobileStructuredStopOffer } from './use-mobile-structured-stop-offer'
|
||||
import { useMobileStructuredTurnIndicator } from './use-mobile-structured-turn-indicator'
|
||||
import { useMobileStructuredContextUsage } from './use-mobile-structured-context-usage'
|
||||
import { useMobileStructuredInterruptedContinue } from './use-mobile-structured-interrupted-continue'
|
||||
import { useMobileStructuredSendWithOutcome } from '../composer/use-mobile-structured-send-with-outcome'
|
||||
import { useMobileStructuredQueuedMessageControls } from '../input/use-mobile-structured-queued-message-controls'
|
||||
import { useMobileStructuredBackgroundTasks } from '../input/use-mobile-structured-background-tasks'
|
||||
import { useMobileStructuredSends } from '../composer/use-mobile-structured-sends'
|
||||
import { useMobileStructuredSendRecorded } from '../composer/mobile-structured-send-recorded-read'
|
||||
import { useMobileNativeChatQueueFollowUps as useQueueFollowUps } from '../preferences/use-mobile-native-chat-queue-follow-ups'
|
||||
import { useMobileStructuredStopOffer } from '../composer/use-mobile-structured-stop-offer'
|
||||
import { useMobileStructuredTurnIndicator } from '../transcript/use-mobile-structured-turn-indicator'
|
||||
import { useMobileStructuredContextUsage } from '../composer/use-mobile-structured-context-usage'
|
||||
import { useMobileStructuredInterruptedContinue } from '../composer/use-mobile-structured-interrupted-continue'
|
||||
import {
|
||||
useMobileStructuredThreadGoal,
|
||||
useMobileStructuredThreadGoalSend
|
||||
} from './use-mobile-structured-thread-goal'
|
||||
import { useMobileStructuredTranscript } from './use-mobile-structured-transcript'
|
||||
} from '../input/use-mobile-structured-thread-goal'
|
||||
import { useMobileStructuredTranscript } from '../transcript/use-mobile-structured-transcript'
|
||||
import { useMobileStructuredAgentRewind } from './use-mobile-structured-agent-rewind'
|
||||
import { useMobileNativeChatUsageLimit } from './native-chat/use-mobile-native-chat-usage-limit'
|
||||
import { useMobileNativeChatUsageLimit } from '../use-mobile-native-chat-usage-limit'
|
||||
|
||||
export function useMobileStructuredAgentSession(
|
||||
args: MobileStructuredAgentSessionArgs
|
||||
+20
-17
@@ -1,45 +1,48 @@
|
||||
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||
import { isRootAgentJournalItem } from '../../../src/shared/agent-session/journal/agent-session-journal-producer'
|
||||
import { isRootAgentJournalItem } from '../../../../../src/shared/agent-session/journal/agent-session-journal-producer'
|
||||
import type {
|
||||
AgentSessionQueuedMessage,
|
||||
AgentSessionQueuePause
|
||||
} from '../../../src/shared/agent-session/requests/agent-session-queued-message-wire'
|
||||
} from '../../../../../src/shared/agent-session/requests/agent-session-queued-message-wire'
|
||||
import {
|
||||
type AgentSessionHistoryResult,
|
||||
AGENT_SESSION_HISTORY_MAX_LIMIT
|
||||
} from '../../../src/shared/agent-session/agent-session-wire'
|
||||
import { structuredAgentSessionHolderId } from '../../../src/shared/agent-session/view/structured-agent-session-holder'
|
||||
import { startStructuredAgentSessionLiveRead } from '../../../src/shared/agent-session/structured-agent-session-live-read'
|
||||
} from '../../../../../src/shared/agent-session/agent-session-wire'
|
||||
import { structuredAgentSessionHolderId } from '../../../../../src/shared/agent-session/view/structured-agent-session-holder'
|
||||
import { startStructuredAgentSessionLiveRead } from '../../../../../src/shared/agent-session/structured-agent-session-live-read'
|
||||
import {
|
||||
type AgentSessionTextAppendCapabilities,
|
||||
agentSessionTextAppendRequest
|
||||
} from '../../../src/shared/agent-session/agent-session-text-append'
|
||||
import { isFinalAgentSessionReadRefusal } from '../../../src/shared/agent-session/failures/structured-agent-session-read-refusal'
|
||||
} from '../../../../../src/shared/agent-session/agent-session-text-append'
|
||||
import { isFinalAgentSessionReadRefusal } from '../../../../../src/shared/agent-session/failures/structured-agent-session-read-refusal'
|
||||
import {
|
||||
EMPTY_STRUCTURED_AGENT_SESSION,
|
||||
oldestStructuredAgentSessionCursor,
|
||||
type StructuredAgentSessionAction,
|
||||
type StructuredAgentSessionState
|
||||
} from '../../../src/shared/agent-session/structured-agent-session-reducer'
|
||||
import { subscribeConnectionRevival } from '../diagnostics/connection/connection-revival-signal'
|
||||
} from '../../../../../src/shared/agent-session/structured-agent-session-reducer'
|
||||
import { subscribeConnectionRevival } from '../../../diagnostics/connection/connection-revival-signal'
|
||||
import {
|
||||
readRuntimeStatusProbe,
|
||||
recordRuntimeStatusProbe
|
||||
} from '../transport/connection/runtime-status-probe'
|
||||
import { decodeHostStatusReply, readHostStatusReply } from '../query/host-status-query'
|
||||
import { hostStatusSchema } from '../transport/hosts/host-status-reply-schema'
|
||||
} from '../../../transport/connection/runtime-status-probe'
|
||||
import { decodeHostStatusReply, readHostStatusReply } from '../../../query/host-status-query'
|
||||
import { hostStatusSchema } from '../../../transport/hosts/host-status-reply-schema'
|
||||
import {
|
||||
AGENT_SESSION_TEXT_APPEND_RUNTIME_CAPABILITY,
|
||||
AGENT_SESSION_TOOL_OUTPUT_APPEND_RUNTIME_CAPABILITY
|
||||
} from '../../../src/shared/agent-session/agent-session-runtime-capabilities'
|
||||
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
|
||||
} from '../../../../../src/shared/agent-session/agent-session-runtime-capabilities'
|
||||
import type { RpcClient } from '../../../transport/rpc/rpc-client-contract'
|
||||
import {
|
||||
agentSessionReadFailureRefusal,
|
||||
agentSessionReadRefusalText,
|
||||
callAgentSession
|
||||
} from './mobile-structured-agent-session-rpc'
|
||||
import { subscribeTranscriptAfterHold } from './mobile-structured-transcript-subscription'
|
||||
import { useMobileOlderPageLoader, type OlderPagePhase } from './use-mobile-older-page-loader'
|
||||
import {
|
||||
useMobileOlderPageLoader,
|
||||
type OlderPagePhase
|
||||
} from '../transcript/use-mobile-older-page-loader'
|
||||
import { mobileStructuredAgentSessionWorking } from './mobile-structured-agent-session-working'
|
||||
import {
|
||||
reduceStructuredChatState,
|
||||
@@ -47,8 +50,8 @@ import {
|
||||
storedStructuredSessionState,
|
||||
storedStructuredCopy,
|
||||
unconfirmedStructuredStateSavedAt
|
||||
} from './native-chat/mobile-native-chat-transcript-writer'
|
||||
import { useStoredChatTranscript } from './native-chat/use-stored-chat-transcript'
|
||||
} from '../transcript/mobile-native-chat-transcript-writer'
|
||||
import { useStoredChatTranscript } from '../transcript/use-stored-chat-transcript'
|
||||
|
||||
const MAX_RETAINED_SESSION_STATES = 32
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { useCallback, useSyncExternalStore } from 'react'
|
||||
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
|
||||
import type { RpcClient } from '../../../transport/rpc/rpc-client-contract'
|
||||
import { mobileStructuredSessionStatusFeed } from './mobile-structured-session-status-feed'
|
||||
|
||||
const noSubscription = (): (() => void) => () => {}
|
||||
@@ -7,17 +7,17 @@ import {
|
||||
updateMobileNativeChatDraftInputs
|
||||
} from './mobile-native-chat-draft-inputs'
|
||||
import './use-mobile-native-chat-drafts'
|
||||
import '../../use-mobile-structured-native-chat-send-bridge'
|
||||
import './use-mobile-structured-native-chat-send-bridge'
|
||||
import '../mobile-native-chat-scope-key'
|
||||
import '../../use-mobile-structured-agent-session'
|
||||
import '../agent-session/use-mobile-structured-agent-session'
|
||||
import '../agent-session/use-mobile-structured-agent-session-queued.test-fixture'
|
||||
import '../../structured-agent-send-result.test-fixture'
|
||||
import { findByHostType } from '../../../test-support/react-test-renderer-host-nodes'
|
||||
|
||||
import '../../mobile-structured-agent-session-host-support'
|
||||
import '../agent-session/mobile-structured-agent-session-host-support'
|
||||
import '../../../../../src/shared/agent-session/agent-session-runtime-capabilities'
|
||||
import '../../use-mobile-structured-agent-options'
|
||||
import '../../use-mobile-structured-agent-options.test-fixture'
|
||||
import '../input/use-mobile-structured-agent-options'
|
||||
import '../input/use-mobile-structured-agent-options.test-fixture'
|
||||
|
||||
import { createElement, type ComponentProps } from 'react'
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import { composerInputStyles as inputStyles } from '../../../components/composer
|
||||
import { MobileNativeChatComposerSendSlot } from './MobileNativeChatComposerSendSlot'
|
||||
import { MobileNativeChatEditActions } from './MobileNativeChatEditActions'
|
||||
import { useMobileNativeChatContextRing } from './MobileNativeChatContextUsageRing'
|
||||
import type { MobileNativeChatSendIntent } from '../mobile-native-chat-send'
|
||||
import type { MobileNativeChatSendIntent } from './mobile-native-chat-send'
|
||||
import { MobileNativeChatComposerMic } from './MobileNativeChatComposerMic'
|
||||
import type { MobileNativeChatMicProps } from './MobileNativeChatComposerMic'
|
||||
import { MobileNativeChatDictationLeading } from './MobileNativeChatDictationLeading'
|
||||
@@ -51,8 +51,6 @@ const NO_FILE_PATHS: string[] = []
|
||||
const NO_ATTACHMENTS: PendingNativeChatImage[] = []
|
||||
const NO_FILES: PendingNativeChatFile[] = []
|
||||
|
||||
export type { MobileNativeChatStructuredComposer } from './mobile-native-chat-structured-composer'
|
||||
|
||||
type Props = MobileNativeChatMicProps & {
|
||||
// Applies dictation's edit to the draft this composer shows; false when it can no longer take it.
|
||||
insertDictation?: (insert: (draft: string) => string) => boolean | void
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Plus } from 'lucide-react-native'
|
||||
import { colors } from '../../../theme/mobile-theme'
|
||||
import { useMobileTranslation } from '../../../i18n/use-mobile-translation'
|
||||
import { ActionSheetModal } from '../../../components/ActionSheetModal'
|
||||
import { mobileNativeChatAttachActions } from '../mobile-native-chat-attach-actions'
|
||||
import { mobileNativeChatAttachActions } from './mobile-native-chat-attach-actions'
|
||||
import {
|
||||
COMPOSER_CONTROL_HIT_SLOP,
|
||||
composerInputStyles as inputStyles
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { NativeChatSendFollowUp } from '../../../../../src/shared/native-ch
|
||||
import type { SessionOptionDescriptor } from '../../../../../src/shared/native-chat/input/native-chat-session-options'
|
||||
import { MobileNativeChatStopButton } from '../input/MobileNativeChatStopButton'
|
||||
import { MobileNativeChatControlSwap } from '../input/mobile-native-chat-control-swap'
|
||||
import type { MobileNativeChatSendIntent } from '../mobile-native-chat-send'
|
||||
import type { MobileNativeChatSendIntent } from './mobile-native-chat-send'
|
||||
import { mobileNativeChatComposerShowsStop } from './mobile-native-chat-composer-layout'
|
||||
import type { MobileNativeChatStructuredComposer } from './mobile-native-chat-structured-composer'
|
||||
import { readMobileNativeChatPickedSkills } from './mobile-native-chat-draft-store'
|
||||
|
||||
@@ -16,7 +16,7 @@ import { useMobileTranslation } from '../../../i18n/use-mobile-translation'
|
||||
import { useKeyboardPersistingTaps } from '../../../platform/keyboard-persisting-taps'
|
||||
import { colors } from '../../../theme/mobile-theme'
|
||||
import { useMobileColorScheme } from '../../../theme/use-mobile-color-scheme'
|
||||
import type { MobileNativeChatSendIntent } from '../mobile-native-chat-send'
|
||||
import type { MobileNativeChatSendIntent } from './mobile-native-chat-send'
|
||||
|
||||
const FOLLOW_UP_ICON = { queue: ListEnd, steer: CornerDownRight } as const
|
||||
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
import { AtSign, Image, Package, Paperclip, Terminal } from 'lucide-react-native'
|
||||
import type { ActionSheetAction } from '../../components/ActionSheetModal'
|
||||
import { translate } from '../../i18n/mobile-i18n'
|
||||
import type { ActionSheetAction } from '../../../components/ActionSheetModal'
|
||||
import { translate } from '../../../i18n/mobile-i18n'
|
||||
|
||||
// Dismiss the sheet before opening pickers because iOS cannot present them over its Modal.
|
||||
export function mobileNativeChatAttachActions(args: {
|
||||
@@ -19,7 +19,7 @@ import type {
|
||||
SlashCommandSuggestion
|
||||
} from '../../../../../src/shared/native-chat/input/native-chat-slash-commands'
|
||||
import { structuredSessionSlashCommands } from '../../../../../src/shared/agent-session/view/structured-agent-session-composer'
|
||||
import { getMobileNativeChatCommands } from '../mobile-native-chat-send-classification'
|
||||
import { getAgentAnsweredNativeChatCommands } from '../../../../../src/shared/native-chat/native-chat-agent-profiles'
|
||||
|
||||
// Why: the menu is a plain ScrollView right above a streaming transcript, so it mounts a bounded
|
||||
// number of rows; typing narrows the rest.
|
||||
@@ -66,7 +66,7 @@ export function mobileComposerCatalog({
|
||||
structured.compactInstructions,
|
||||
interactionModeSupported
|
||||
)
|
||||
: getMobileNativeChatCommands(agent)
|
||||
: getAgentAnsweredNativeChatCommands(agent)
|
||||
return {
|
||||
profile: getNativeChatAgentProfile(agent),
|
||||
commands: nativeChatPickerCommands(agent, commands, discovery.skills),
|
||||
|
||||
@@ -21,10 +21,6 @@ export type UnconfirmedSend = {
|
||||
deadline: ReturnType<typeof setTimeout> | null
|
||||
}
|
||||
|
||||
export function normalizedUserText(message: NativeChatMessage): string | null {
|
||||
return normalizedNativeChatUserMessageText(message)
|
||||
}
|
||||
|
||||
export type PendingImagePreviewEcho = Pick<
|
||||
NativeChatPendingSend,
|
||||
'id' | 'text' | 'sentAt' | 'afterMessageId' | 'matchingOccurrence'
|
||||
@@ -161,7 +157,7 @@ export function findLandedImagePreviewEchoes(
|
||||
return false
|
||||
}
|
||||
if (targetText) {
|
||||
const text = normalizedUserText(message)
|
||||
const text = normalizedNativeChatUserMessageText(message)
|
||||
if (text === null) {
|
||||
return false
|
||||
}
|
||||
@@ -199,7 +195,9 @@ export function findLandedUnconfirmedSends(
|
||||
if (message.role !== 'user') {
|
||||
continue
|
||||
}
|
||||
const key = isImageSourceUserTurn(message) ? '' : (normalizedUserText(message) ?? '')
|
||||
const key = isImageSourceUserTurn(message)
|
||||
? ''
|
||||
: (normalizedNativeChatUserMessageText(message) ?? '')
|
||||
const current = userMessagesByText.get(key) ?? []
|
||||
current.push({ id: message.id, index })
|
||||
userMessagesByText.set(key, current)
|
||||
|
||||
@@ -5,9 +5,9 @@ import {
|
||||
MOBILE_NATIVE_CHAT_MIN_WRITE_TIMEOUT_MS,
|
||||
openMobileNativeChatSendBudget,
|
||||
readMobileNativeChatInputClear
|
||||
} from '../mobile-native-chat-send'
|
||||
} from './mobile-native-chat-send'
|
||||
import { nativeChatTerminalWrite } from '../../../terminal/session/mobile-session-terminal-operations'
|
||||
import type { MobileNativeChatRpcSender } from '../mobile-native-chat-send'
|
||||
import type { MobileNativeChatRpcSender } from './mobile-native-chat-send'
|
||||
|
||||
// Wait for the TUI to register bracketed image attachments before text/Enter arrives.
|
||||
export const MOBILE_NATIVE_CHAT_IMAGE_SETTLE_MS = 300
|
||||
|
||||
@@ -5,8 +5,8 @@ import {
|
||||
updateMobileNativeChatDraftInputs
|
||||
} from './mobile-native-chat-draft-inputs'
|
||||
import type { PendingNativeChatFile } from './mobile-native-chat-file-attachment'
|
||||
import type { MobileNativeChatSendOrigin } from '../mobile-native-chat-pending-echo'
|
||||
import type { MobileNativeChatSendIntent } from '../mobile-native-chat-send'
|
||||
import type { MobileNativeChatSendOrigin } from '../transcript/mobile-native-chat-pending-echo'
|
||||
import type { MobileNativeChatSendIntent } from './mobile-native-chat-send'
|
||||
import { saveMobileNativeChatDraft } from './mobile-native-chat-draft-persistence'
|
||||
import type {
|
||||
MobileNativeChatInFlightSend,
|
||||
|
||||
+2
-2
@@ -5,12 +5,12 @@ import { returnMobileNativeChatMessageToComposer } from './mobile-native-chat-me
|
||||
import {
|
||||
readMobileNativeChatDraftInputs,
|
||||
updateMobileNativeChatDraftInputs
|
||||
} from './native-chat/composer/mobile-native-chat-draft-inputs'
|
||||
} from './mobile-native-chat-draft-inputs'
|
||||
import {
|
||||
resetMobileNativeChatDraftStoreForTests,
|
||||
setMobileNativeChatDraftText,
|
||||
useMobileNativeChatDraft
|
||||
} from './native-chat/composer/mobile-native-chat-draft-store'
|
||||
} from './mobile-native-chat-draft-store'
|
||||
|
||||
let renderer: ReactTestRenderer | null = null
|
||||
let text = ''
|
||||
+6
-6
@@ -1,12 +1,12 @@
|
||||
import type { AgentJournalMessageItem } from '../../../src/shared/agent-session/journal/agent-session-journal-types'
|
||||
import { queuedEditTextForKeptImages } from '../../../src/shared/queued-message-edit'
|
||||
import { appendReturnedDraftText } from '../../../src/shared/returned-draft-text'
|
||||
import { mobileDraftImageOfBlock } from './mobile-queued-message-edit-draft'
|
||||
import type { AgentJournalMessageItem } from '../../../../../src/shared/agent-session/journal/agent-session-journal-types'
|
||||
import { queuedEditTextForKeptImages } from '../../../../../src/shared/queued-message-edit'
|
||||
import { appendReturnedDraftText } from '../../../../../src/shared/returned-draft-text'
|
||||
import { mobileDraftImageOfBlock } from '../input/mobile-queued-message-edit-draft'
|
||||
import {
|
||||
readMobileNativeChatDraftInputs,
|
||||
updateMobileNativeChatDraftInputs
|
||||
} from './native-chat/composer/mobile-native-chat-draft-inputs'
|
||||
import { setMobileNativeChatDraftText } from './native-chat/composer/mobile-native-chat-draft-store'
|
||||
} from './mobile-native-chat-draft-inputs'
|
||||
import { setMobileNativeChatDraftText } from './mobile-native-chat-draft-store'
|
||||
|
||||
/** Append a sent message's text and images after what is typed; stable chip ids keep a repeat from doubling them. */
|
||||
export function returnMobileNativeChatMessageToComposer(
|
||||
+4
-8
@@ -3,17 +3,13 @@
|
||||
import {
|
||||
getAgentAnsweredNativeChatCommands,
|
||||
getNativeChatAgentProfile
|
||||
} from '../../../../src/shared/native-chat/native-chat-agent-profiles'
|
||||
} from '../../../../../src/shared/native-chat/native-chat-agent-profiles'
|
||||
import {
|
||||
classifyNativeChatSend,
|
||||
type NativeChatSendClassification,
|
||||
type SlashCommandSuggestion
|
||||
} from '../../../../src/shared/native-chat/input/native-chat-slash-commands'
|
||||
type NativeChatSendClassification
|
||||
} from '../../../../../src/shared/native-chat/input/native-chat-slash-commands'
|
||||
|
||||
// Terminal mobile chat lacks desktop-owned command answers and reply rows.
|
||||
export function getMobileNativeChatCommands(agent: string): readonly SlashCommandSuggestion[] {
|
||||
return getAgentAnsweredNativeChatCommands(agent)
|
||||
}
|
||||
|
||||
export function classifyMobileNativeChatSend(
|
||||
agent: string | null,
|
||||
@@ -26,7 +22,7 @@ export function classifyMobileNativeChatSend(
|
||||
const profile = getNativeChatAgentProfile(agent)
|
||||
return classifyNativeChatSend(
|
||||
text,
|
||||
getMobileNativeChatCommands(agent),
|
||||
getAgentAnsweredNativeChatCommands(agent),
|
||||
pickerSkillOriginToken,
|
||||
profile?.skillPrefix ?? null
|
||||
)
|
||||
+11
-11
@@ -1,22 +1,22 @@
|
||||
import type { RpcClient } from '../../transport/rpc/rpc-client-contract'
|
||||
import type { PendingNativeChatImage } from './composer/mobile-native-chat-image-attachment'
|
||||
import type { PendingNativeChatFile } from './composer/mobile-native-chat-file-attachment'
|
||||
import { isRpcDeliveryUnknown } from '../../transport/rpc/rpc-delivery-ambiguity'
|
||||
import '../../transport/connection/stable-logical-rpc-client'
|
||||
import { isLogicalClientCutoverError } from '../../transport/connection/logical-client-cutover-error'
|
||||
import type { RpcClient } from '../../../transport/rpc/rpc-client-contract'
|
||||
import type { PendingNativeChatImage } from './mobile-native-chat-image-attachment'
|
||||
import type { PendingNativeChatFile } from './mobile-native-chat-file-attachment'
|
||||
import { isRpcDeliveryUnknown } from '../../../transport/rpc/rpc-delivery-ambiguity'
|
||||
import '../../../transport/connection/stable-logical-rpc-client'
|
||||
import { isLogicalClientCutoverError } from '../../../transport/connection/logical-client-cutover-error'
|
||||
import {
|
||||
nativeChatTerminalWrite,
|
||||
nativeChatTerminalDraftRead
|
||||
} from '../../terminal/session/mobile-session-terminal-operations'
|
||||
import { typeAgentTuiCommand } from '../../../../src/shared/agent-launch/startup/agent-tui-command-typing'
|
||||
import { readTerminalSendAcknowledgment } from '../../../../src/shared/terminal/pty/lifecycle/terminal-send-acknowledgment'
|
||||
} from '../../../terminal/session/mobile-session-terminal-operations'
|
||||
import { typeAgentTuiCommand } from '../../../../../src/shared/agent-launch/startup/agent-tui-command-typing'
|
||||
import { readTerminalSendAcknowledgment } from '../../../../../src/shared/terminal/pty/lifecycle/terminal-send-acknowledgment'
|
||||
import {
|
||||
AGENT_TUI_CLEAR_MAX_LINES,
|
||||
countAgentTuiInputLines,
|
||||
buildAgentTuiClearInputForText
|
||||
} from '../../../../src/shared/agent-launch/startup/agent-tui-input-clear'
|
||||
} from '../../../../../src/shared/agent-launch/startup/agent-tui-input-clear'
|
||||
|
||||
import type { AgentJournalSkillRef } from '../../../../src/shared/agent-session/journal/agent-session-journal-types'
|
||||
import type { AgentJournalSkillRef } from '../../../../../src/shared/agent-session/journal/agent-session-journal-types'
|
||||
|
||||
export type MobileNativeChatRpcSender = Parameters<typeof nativeChatTerminalWrite.request>[0]
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { pasteMobileNativeChatImagePaths } from './composer/mobile-native-chat-image-send'
|
||||
import { pasteMobileNativeChatImagePaths } from './mobile-native-chat-image-send'
|
||||
import type { MobileNativeChatRpcSender } from './mobile-native-chat-send'
|
||||
|
||||
// The condition tracked here — a bracketed image paste left sitting on the agent's
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { MobileComposerStructuredCatalog } from './mobile-native-chat-composer-menu'
|
||||
import type { PendingNativeChatFile } from './mobile-native-chat-file-attachment'
|
||||
import type { MobileStructuredThreadGoal } from '../../use-mobile-structured-thread-goal'
|
||||
import type { MobileStructuredThreadGoal } from '../input/use-mobile-structured-thread-goal'
|
||||
|
||||
export type MobileNativeChatStructuredComposer = {
|
||||
catalog: MobileComposerStructuredCatalog
|
||||
|
||||
+11
-11
@@ -2,26 +2,26 @@ import {
|
||||
agentSessionConversationCommandFields,
|
||||
type AgentSessionConversationCommand,
|
||||
type AgentSessionConversationCommandResult
|
||||
} from '../../../src/shared/agent-session/agent-session-conversation-command'
|
||||
import type { AgentSessionFailureFact } from '../../../src/shared/agent-session/failures/agent-session-failure'
|
||||
} from '../../../../../src/shared/agent-session/agent-session-conversation-command'
|
||||
import type { AgentSessionFailureFact } from '../../../../../src/shared/agent-session/failures/agent-session-failure'
|
||||
import {
|
||||
dispatchStructuredAgentSessionComposerCommand,
|
||||
isStructuredAgentSessionHostCommand,
|
||||
type StructuredAgentSessionCommandRefusalCause,
|
||||
type StructuredAgentSessionComposerOptions
|
||||
} from '../../../src/shared/agent-session/view/structured-agent-session-composer'
|
||||
} from '../../../../../src/shared/agent-session/view/structured-agent-session-composer'
|
||||
import {
|
||||
conversationCommandReply,
|
||||
heldConversationCommandParts,
|
||||
structuredConversationCommandHold
|
||||
} from '../../../src/shared/structured-conversation-command-hold'
|
||||
import { mobileAgentSessionWriteNoticeText } from './agent-session-write-notice-copy'
|
||||
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
|
||||
import { translate } from '../i18n/mobile-i18n'
|
||||
import { sayMobileAgentSessionFailure } from './agent-session-failure-copy'
|
||||
import type { MobileNativeChatSendOutcome } from './native-chat/mobile-native-chat-send'
|
||||
import { requestStructuredAgentSessionMutation } from './mobile-structured-agent-session-rpc'
|
||||
import type { MobileNativeChatSendErrorReporter } from './native-chat/use-mobile-native-chat-send-error'
|
||||
} from '../../../../../src/shared/structured-conversation-command-hold'
|
||||
import { mobileAgentSessionWriteNoticeText } from '../agent-session/agent-session-write-notice-copy'
|
||||
import type { RpcClient } from '../../../transport/rpc/rpc-client-contract'
|
||||
import { translate } from '../../../i18n/mobile-i18n'
|
||||
import { sayMobileAgentSessionFailure } from '../agent-session/agent-session-failure-copy'
|
||||
import type { MobileNativeChatSendOutcome } from './mobile-native-chat-send'
|
||||
import { requestStructuredAgentSessionMutation } from '../agent-session/mobile-structured-agent-session-rpc'
|
||||
import type { MobileNativeChatSendErrorReporter } from './use-mobile-native-chat-send-error'
|
||||
|
||||
/** What the phone shows at keypress that holds a command; `background` also counts the strip mid-turn. */
|
||||
export type MobileStructuredCommandHolds = Readonly<
|
||||
+6
-6
@@ -1,9 +1,9 @@
|
||||
import type { AgentSessionSendResult } from '../../../src/shared/agent-session/agent-session-wire'
|
||||
import { agentSessionRefusalOperationState } from '../../../src/shared/agent-session/failures/agent-session-refusal-retry'
|
||||
import type { MobileNativeChatSendOutcome } from './native-chat/mobile-native-chat-send'
|
||||
import type { StructuredAgentSessionMutationCallResult } from './mobile-structured-agent-session-rpc'
|
||||
import { STRUCTURED_AGENT_SESSION_SUBMISSION_MISSING } from '../../../src/shared/agent-session/requests/structured-agent-session-send-evidence'
|
||||
import { translate } from '../i18n/mobile-i18n'
|
||||
import type { AgentSessionSendResult } from '../../../../../src/shared/agent-session/agent-session-wire'
|
||||
import { agentSessionRefusalOperationState } from '../../../../../src/shared/agent-session/failures/agent-session-refusal-retry'
|
||||
import type { MobileNativeChatSendOutcome } from './mobile-native-chat-send'
|
||||
import type { StructuredAgentSessionMutationCallResult } from '../agent-session/mobile-structured-agent-session-rpc'
|
||||
import { STRUCTURED_AGENT_SESSION_SUBMISSION_MISSING } from '../../../../../src/shared/agent-session/requests/structured-agent-session-send-evidence'
|
||||
import { translate } from '../../../i18n/mobile-i18n'
|
||||
|
||||
export type MobileStructuredSendDelivery = {
|
||||
outcome: MobileNativeChatSendOutcome
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
import { selectAgentSessionCurrentRequests } from '../../../src/shared/agent-session/requests/agent-session-current-requests'
|
||||
import type { StructuredAgentSessionState } from '../../../src/shared/agent-session/structured-agent-session-reducer'
|
||||
import { selectAgentSessionCurrentRequests } from '../../../../../src/shared/agent-session/requests/agent-session-current-requests'
|
||||
import type { StructuredAgentSessionState } from '../../../../../src/shared/agent-session/structured-agent-session-reducer'
|
||||
import {
|
||||
structuredAgentSessionFollowUpsQueue,
|
||||
structuredAgentSessionQueueEnabled
|
||||
} from '../../../src/shared/agent-session/view/structured-agent-session-queued-cards'
|
||||
} from '../../../../../src/shared/agent-session/view/structured-agent-session-queued-cards'
|
||||
|
||||
/** The desktop's rule: the alternate flips the setting first, then the queue's own rules decide. */
|
||||
export function mobileStructuredSendQueues(
|
||||
+4
-4
@@ -1,9 +1,9 @@
|
||||
import { useLayoutEffect, useMemo, useRef } from 'react'
|
||||
import * as z from 'zod'
|
||||
import { bindDeferredRpcOperation, defineRpcOperation } from '../transport/rpc/rpc-operation'
|
||||
import { rpcResultVariant } from '../transport/rpc/rpc-operation-result-reader'
|
||||
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
|
||||
import type { StructuredAgentSessionHostSupport } from './mobile-structured-agent-session-host-support'
|
||||
import { bindDeferredRpcOperation, defineRpcOperation } from '../../../transport/rpc/rpc-operation'
|
||||
import { rpcResultVariant } from '../../../transport/rpc/rpc-operation-result-reader'
|
||||
import type { RpcClient } from '../../../transport/rpc/rpc-client-contract'
|
||||
import type { StructuredAgentSessionHostSupport } from '../agent-session/mobile-structured-agent-session-host-support'
|
||||
|
||||
const sendRecordedRead = bindDeferredRpcOperation(
|
||||
defineRpcOperation({
|
||||
+2
-2
@@ -3,8 +3,8 @@ import { Goal } from 'lucide-react-native'
|
||||
import type { NativeChatSendFollowUp } from '../../../../../src/shared/native-chat/input/native-chat-follow-up-behavior'
|
||||
import { isBareStructuredAgentSessionGoalCommand } from '../../../../../src/shared/agent-session/view/structured-agent-session-composer'
|
||||
import { useMobileTranslation } from '../../../i18n/use-mobile-translation'
|
||||
import type { MobileStructuredThreadGoal } from '../../use-mobile-structured-thread-goal'
|
||||
import type { MobileNativeChatSendIntent } from '../mobile-native-chat-send'
|
||||
import type { MobileStructuredThreadGoal } from '../input/use-mobile-structured-thread-goal'
|
||||
import type { MobileNativeChatSendIntent } from './mobile-native-chat-send'
|
||||
import { MobileNativeChatThreadGoalStrip } from '../input/MobileNativeChatThreadGoalStrip'
|
||||
import { MobileNativeChatComposerModeChip } from './MobileNativeChatComposerModeChip'
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
mobileNativeChatChordHeadId,
|
||||
type MobileNativeChatQueuedMessagesProps
|
||||
} from '../input/MobileNativeChatQueuedMessages'
|
||||
import type { MobileStructuredBackgroundTasks } from '../../use-mobile-structured-background-tasks'
|
||||
import type { MobileStructuredBackgroundTasks } from '../input/use-mobile-structured-background-tasks'
|
||||
import { useMobileNativeChatQueuedEditFocus } from '../input/use-mobile-native-chat-queued-edit-focus'
|
||||
import { createMobileQueuedHeadLight } from '../input/mobile-queued-head-light'
|
||||
import {
|
||||
|
||||
+1
-50
@@ -2,7 +2,7 @@ import { createElement } from 'react'
|
||||
import { act, create } from 'react-test-renderer'
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import type { NativeChatMessage } from '../../../../../src/shared/native-chat/native-chat-types'
|
||||
import { buildMobileNativeChatTransientData } from '../mobile-native-chat-render-data'
|
||||
|
||||
import { useMobileNativeChatDrafts } from './use-mobile-native-chat-drafts'
|
||||
import {
|
||||
resetMobileNativeChatDraftStoreForTests,
|
||||
@@ -15,10 +15,6 @@ type TestRenderer = {
|
||||
update(element: ReturnType<typeof createElement>): void
|
||||
}
|
||||
|
||||
function userTurn(id: string, text: string, timestamp: number): NativeChatMessage {
|
||||
return { id, role: 'user', blocks: [{ type: 'text', text }], timestamp, source: 'transcript' }
|
||||
}
|
||||
|
||||
function assistantTurn(id: string, text: string, timestamp: number): NativeChatMessage {
|
||||
return {
|
||||
id,
|
||||
@@ -39,20 +35,6 @@ function imageTurn(id: string, path: string, timestamp: number): NativeChatMessa
|
||||
}
|
||||
}
|
||||
|
||||
function renderedPendingTexts(
|
||||
messages: NativeChatMessage[],
|
||||
state: DraftState | null
|
||||
): (string | undefined)[] {
|
||||
const { data } = buildMobileNativeChatTransientData({
|
||||
folded: messages,
|
||||
streaming: null,
|
||||
pending: state?.pending ?? []
|
||||
})
|
||||
return data
|
||||
.filter((message) => !messages.some((existing) => existing.id === message.id))
|
||||
.map((message) => message.blocks.find((block) => block.type === 'text')?.text)
|
||||
}
|
||||
|
||||
describe('useMobileNativeChatDrafts glued pending sends', () => {
|
||||
let renderer: TestRenderer | null = null
|
||||
let state: DraftState | null = null
|
||||
@@ -109,23 +91,6 @@ describe('useMobileNativeChatDrafts glued pending sends', () => {
|
||||
// Between the older history rows and the rows that land after a send, on the host's clock.
|
||||
const SENT_AT = 3000
|
||||
|
||||
function send(text: string): void {
|
||||
const origin = state?.captureSendOrigin(text, SENT_AT)
|
||||
if (origin) {
|
||||
state?.acceptSend(origin, text)
|
||||
}
|
||||
}
|
||||
|
||||
function rapidSend(first: string, second: string): void {
|
||||
act(() => {
|
||||
send(first)
|
||||
send(second)
|
||||
})
|
||||
}
|
||||
|
||||
const pendingTexts = (): (string | undefined)[] | undefined =>
|
||||
state?.pending.map((item) => item.text)
|
||||
|
||||
// Hydrating rows give no boundary, so these sends match only rows newer than their send time.
|
||||
describe('sends issued while the transcript is still hydrating', () => {
|
||||
// An image retires only by preview binding; excluding its own echo would strand both the photo and later glued sends.
|
||||
@@ -146,18 +111,4 @@ describe('useMobileNativeChatDrafts glued pending sends', () => {
|
||||
})
|
||||
|
||||
// Failed-read emptiness is unknown history, not an empty conversation; old rows must not claim sends against it.
|
||||
describe('sends issued before any read settled', () => {
|
||||
it('keeps both bubbles when the late read carries only an older glue-alike', async () => {
|
||||
await mount([], false, false)
|
||||
rapidSend('fix the', 'bug')
|
||||
|
||||
const olderIdentical = [
|
||||
userTurn('m1', 'fix the bug', 1000),
|
||||
assistantTurn('m2', 'fixed', 1100)
|
||||
]
|
||||
await update(olderIdentical)
|
||||
expect(pendingTexts()).toEqual(['fix the', 'bug'])
|
||||
expect(renderedPendingTexts(olderIdentical, state)).toEqual(['fix the', 'bug'])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
normalizeImageTranscriptMessages,
|
||||
normalizeNativeChatUserText as normalizeReconcileText
|
||||
} from '../../../../../src/shared/native-chat/transcript/native-chat-image-transcript-markers'
|
||||
import { useMobileNativeChatUnconfirmedSends } from '../use-mobile-native-chat-unconfirmed-sends'
|
||||
import { useMobileNativeChatUnconfirmedSends } from './use-mobile-native-chat-unconfirmed-sends'
|
||||
import {
|
||||
appendMobileNativeChatPending,
|
||||
combineMobileNativeChatPending,
|
||||
@@ -28,7 +28,7 @@ import {
|
||||
visibleMobileNativeChatPending,
|
||||
type MobileNativeChatPendingMessage,
|
||||
type MobileNativeChatSendOrigin
|
||||
} from '../mobile-native-chat-pending-echo'
|
||||
} from '../transcript/mobile-native-chat-pending-echo'
|
||||
import { mobileNativeChatScopeKey } from '../mobile-native-chat-scope-key'
|
||||
import { mobileNativeChatDraftDestination } from './mobile-native-chat-draft-inputs'
|
||||
import { useMobileNativeChatLaunchDraftSeed } from './use-mobile-native-chat-launch-draft-seed'
|
||||
|
||||
+2
-2
@@ -5,8 +5,8 @@ import '../../../../../src/shared/agent-launch/startup/agent-tui-input-clear'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { RpcClient } from '../../../transport/rpc/rpc-client-contract'
|
||||
import type { RpcResponse, RpcSuccess } from '../../../transport/rpc/rpc-wire-types'
|
||||
import { resetMobileNativeChatStaleInputForTests } from '../mobile-native-chat-stale-input'
|
||||
import { resetMobileNativeChatTerminalWritesForTests } from '../mobile-native-chat-terminal-write-lock'
|
||||
import { resetMobileNativeChatStaleInputForTests } from './mobile-native-chat-stale-input'
|
||||
import { resetMobileNativeChatTerminalWritesForTests } from './mobile-native-chat-terminal-write-lock'
|
||||
import { useMobileNativeChatImageAttachments } from './use-mobile-native-chat-image-attachments'
|
||||
|
||||
// Stub the media seam so direct Expo imports would expose unsupported Flow syntax and fail the transform.
|
||||
|
||||
@@ -21,20 +21,20 @@ import {
|
||||
openMobileNativeChatSendBudget,
|
||||
type MobileNativeChatSendIntent,
|
||||
type MobileNativeChatSendOutcome
|
||||
} from '../mobile-native-chat-send'
|
||||
} from './mobile-native-chat-send'
|
||||
import {
|
||||
clearMobileNativeChatInputStale,
|
||||
healMobileNativeChatStaleInput,
|
||||
isMobileNativeChatInputStale,
|
||||
markMobileNativeChatInputStale
|
||||
} from '../mobile-native-chat-stale-input'
|
||||
} from './mobile-native-chat-stale-input'
|
||||
import {
|
||||
acquireMobileNativeChatTerminalWrite,
|
||||
releaseMobileNativeChatTerminalWrite
|
||||
} from '../mobile-native-chat-terminal-write-lock'
|
||||
} from './mobile-native-chat-terminal-write-lock'
|
||||
import { useMobileNativeChatImageUpload } from './use-mobile-native-chat-image-upload'
|
||||
import type { PendingNativeChatFile } from './mobile-native-chat-file-attachment'
|
||||
import type { StructuredMobileSendAttachment } from '../../use-mobile-structured-send-with-outcome'
|
||||
import type { StructuredMobileSendAttachment } from './use-mobile-structured-send-with-outcome'
|
||||
|
||||
type CurrentRef<T> = { readonly current: T }
|
||||
type ShowToast = (message: string, durationMs?: number) => void
|
||||
|
||||
+2
-49
@@ -1,10 +1,7 @@
|
||||
import { createElement } from 'react'
|
||||
import { act, create, type ReactTestRenderer } from 'react-test-renderer'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import {
|
||||
useMobileNativeChatInputLease,
|
||||
useSettledMobileNativeChatInputLock
|
||||
} from './use-mobile-native-chat-input-lease'
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { useMobileNativeChatInputLease } from './use-mobile-native-chat-input-lease'
|
||||
|
||||
type Lease = ReturnType<typeof useMobileNativeChatInputLease>
|
||||
|
||||
@@ -65,47 +62,3 @@ describe('useMobileNativeChatInputLease', () => {
|
||||
expect(lease?.clear()).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('useSettledMobileNativeChatInputLock', () => {
|
||||
let renderer: ReactTestRenderer | null = null
|
||||
let settled: ReturnType<typeof useSettledMobileNativeChatInputLock> | undefined
|
||||
|
||||
afterEach(() => {
|
||||
act(() => renderer?.unmount())
|
||||
renderer = null
|
||||
vi.useRealTimers()
|
||||
})
|
||||
|
||||
function Harness({ reason }: { reason: 'waiting' | 'disconnected' | null }): null {
|
||||
settled = useSettledMobileNativeChatInputLock(reason)
|
||||
return null
|
||||
}
|
||||
|
||||
it('holds each edge until the lease has stopped flapping', () => {
|
||||
vi.useFakeTimers()
|
||||
act(() => {
|
||||
renderer = create(createElement(Harness, { reason: 'waiting' }))
|
||||
})
|
||||
expect(settled).toBeNull()
|
||||
act(() => {
|
||||
vi.advanceTimersByTime(600)
|
||||
})
|
||||
expect(settled).toBe('waiting')
|
||||
|
||||
act(() => renderer?.update(createElement(Harness, { reason: null })))
|
||||
act(() => {
|
||||
vi.advanceTimersByTime(300)
|
||||
})
|
||||
act(() => renderer?.update(createElement(Harness, { reason: 'disconnected' })))
|
||||
act(() => {
|
||||
vi.advanceTimersByTime(600)
|
||||
})
|
||||
expect(settled).toBe('disconnected')
|
||||
|
||||
act(() => renderer?.update(createElement(Harness, { reason: null })))
|
||||
act(() => {
|
||||
vi.advanceTimersByTime(600)
|
||||
})
|
||||
expect(settled).toBeNull()
|
||||
})
|
||||
})
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { nativeChatTurnStatusCopy } from './native-chat-turn-status-copy'
|
||||
import { translate, type Translate } from '../../i18n/mobile-i18n'
|
||||
import type { MobileNativeChatInputLockReason } from './MobileNativeChatView'
|
||||
import { nativeChatTurnStatusCopy } from '../transcript/native-chat-turn-status-copy'
|
||||
import { translate, type Translate } from '../../../i18n/mobile-i18n'
|
||||
import type { MobileNativeChatInputLockReason } from '../MobileNativeChatView'
|
||||
|
||||
export function useMobileNativeChatInputLease(args: {
|
||||
activeHandle: string | null
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
nativeChatLaunchDraftTurnBaseline,
|
||||
type NativeChatLaunchDraftTurnBaseline
|
||||
} from '../../../../../src/shared/native-chat/transcript/native-chat-launch-draft-resolution'
|
||||
import { normalizedUserText } from './mobile-native-chat-draft-reconcile'
|
||||
import { normalizedNativeChatUserMessageText } from '../../../../../src/shared/native-chat/transcript/native-chat-image-transcript-markers'
|
||||
import { mobileNativeChatLaunchDraftSeeds } from './mobile-native-chat-draft-store'
|
||||
import { mobileNativeChatDraftDestination } from './mobile-native-chat-draft-inputs'
|
||||
|
||||
@@ -22,7 +22,7 @@ function launchDraftResolved(
|
||||
): boolean {
|
||||
// Old hosts send no creation time, so any user turn retires the draft.
|
||||
if (createdAt === null) {
|
||||
return messages.some((message) => normalizedUserText(message) !== null)
|
||||
return messages.some((message) => normalizedNativeChatUserMessageText(message) !== null)
|
||||
}
|
||||
return launchDraftResolvedByTranscript({ createdAt }, messages, baseline)
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { createElement } from 'react'
|
||||
import { act, create, type ReactTestRenderer } from 'react-test-renderer'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { MobileNativeChatSendIntent } from '../mobile-native-chat-send'
|
||||
import type { MobileNativeChatSendIntent } from './mobile-native-chat-send'
|
||||
import type { MobileNativeChatInputLockReason } from '../MobileNativeChatView'
|
||||
import { resetMobileNativeChatDraftStoreForTests } from './mobile-native-chat-draft-store'
|
||||
import {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||
import { appendReturnedDraftText } from '../../../../../src/shared/returned-draft-text'
|
||||
import type { MobileNativeChatSendIntent } from '../mobile-native-chat-send'
|
||||
import type { MobileNativeChatSendIntent } from './mobile-native-chat-send'
|
||||
import type { MobileNativeChatInputLockReason } from '../MobileNativeChatView'
|
||||
import { useSettledMobileNativeChatInputLock } from '../use-mobile-native-chat-input-lease'
|
||||
import { useSettledMobileNativeChatInputLock } from './use-mobile-native-chat-input-lease'
|
||||
import {
|
||||
mobileNativeChatDraftDestination,
|
||||
readMobileNativeChatDraftInputs,
|
||||
|
||||
-57
@@ -100,54 +100,6 @@ describe('useMobileNativeChatSendError', () => {
|
||||
expect(api().message).toBe('Background tasks are still running.')
|
||||
})
|
||||
|
||||
it('holds a failure for four seconds, then drops it', async () => {
|
||||
await render()
|
||||
await act(async () => api().show('a'))
|
||||
expect(api().message).toBe('a')
|
||||
|
||||
await act(async () => {
|
||||
vi.advanceTimersByTime(3999)
|
||||
})
|
||||
expect(api().message).toBe('a')
|
||||
await act(async () => {
|
||||
vi.advanceTimersByTime(1)
|
||||
})
|
||||
expect(api().message).toBeNull()
|
||||
})
|
||||
|
||||
it('restarts the hold when a second failure lands mid-hold', async () => {
|
||||
await render()
|
||||
await act(async () => api().show('a'))
|
||||
await act(async () => {
|
||||
vi.advanceTimersByTime(3000)
|
||||
})
|
||||
await act(async () => api().show('b'))
|
||||
|
||||
await act(async () => {
|
||||
vi.advanceTimersByTime(3000)
|
||||
})
|
||||
expect(api().message).toBe('b')
|
||||
|
||||
await act(async () => {
|
||||
vi.advanceTimersByTime(1000)
|
||||
})
|
||||
expect(api().message).toBeNull()
|
||||
})
|
||||
|
||||
it('clears immediately and cancels the pending hold', async () => {
|
||||
await render()
|
||||
await act(async () => api().show('a'))
|
||||
await act(async () => api().clear())
|
||||
expect(api().message).toBeNull()
|
||||
|
||||
await act(async () => api().show('b'))
|
||||
await act(async () => api().clear())
|
||||
await act(async () => {
|
||||
vi.advanceTimersByTime(10_000)
|
||||
})
|
||||
expect(api().message).toBeNull()
|
||||
})
|
||||
|
||||
it('drops a held failure when the scope changes', async () => {
|
||||
await render('terminal-1')
|
||||
await act(async () => api().show('a'))
|
||||
@@ -210,13 +162,4 @@ describe('useMobileNativeChatSendError', () => {
|
||||
|
||||
expect(showToast).toHaveBeenCalledWith('Delivery unconfirmed', 1600)
|
||||
})
|
||||
|
||||
it('cancels the pending hold timer on unmount', async () => {
|
||||
await render()
|
||||
await act(async () => api().show('a'))
|
||||
expect(vi.getTimerCount()).toBe(1)
|
||||
act(() => renderer?.unmount())
|
||||
renderer = null
|
||||
expect(vi.getTimerCount()).toBe(0)
|
||||
})
|
||||
})
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { useCallback, useEffect, useRef, useState, type MutableRefObject } from 'react'
|
||||
import type { StructuredAgentSessionCommandRefusalCause } from '../../../../src/shared/agent-session/view/structured-agent-session-composer'
|
||||
import type { StructuredAgentSessionCommandRefusalCause } from '../../../../../src/shared/agent-session/view/structured-agent-session-composer'
|
||||
|
||||
// Keep command-refusal causes only while the chat still shows the work that caused them.
|
||||
export type MobileNativeChatSendErrorDetails = {
|
||||
+8
-8
@@ -1,13 +1,13 @@
|
||||
import { useCallback, useEffect, useRef, type MutableRefObject } from 'react'
|
||||
import { translate } from '../../i18n/mobile-i18n'
|
||||
import type { RpcClient } from '../../transport/rpc/rpc-client-contract'
|
||||
import { isRpcDeliveryUnknown } from '../../transport/rpc/rpc-delivery-ambiguity'
|
||||
import '../../transport/connection/stable-logical-rpc-client'
|
||||
import { isLogicalClientCutoverError } from '../../transport/connection/logical-client-cutover-error'
|
||||
import { nativeChatTerminalWrite } from '../../terminal/session/mobile-session-terminal-operations'
|
||||
import { translate } from '../../../i18n/mobile-i18n'
|
||||
import type { RpcClient } from '../../../transport/rpc/rpc-client-contract'
|
||||
import { isRpcDeliveryUnknown } from '../../../transport/rpc/rpc-delivery-ambiguity'
|
||||
import '../../../transport/connection/stable-logical-rpc-client'
|
||||
import { isLogicalClientCutoverError } from '../../../transport/connection/logical-client-cutover-error'
|
||||
import { nativeChatTerminalWrite } from '../../../terminal/session/mobile-session-terminal-operations'
|
||||
import { openMobileNativeChatSendBudget } from './mobile-native-chat-send'
|
||||
import { nativeChatStopSendsSecondEscape } from '../../../../src/shared/native-chat/native-chat-agent-support'
|
||||
import { NATIVE_CHAT_QUESTION_STEP_MS } from '../../../../src/shared/native-chat/input/native-chat-answer-stepping'
|
||||
import { nativeChatStopSendsSecondEscape } from '../../../../../src/shared/native-chat/native-chat-agent-support'
|
||||
import { NATIVE_CHAT_QUESTION_STEP_MS } from '../../../../../src/shared/native-chat/input/native-chat-answer-stepping'
|
||||
|
||||
// Resolves false only when no Escape could have landed, so the chat may offer Stop again.
|
||||
export function useMobileNativeChatStop(args: {
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
import { useMemo } from 'react'
|
||||
import type { AgentSessionConversationCommand } from '../../../../../src/shared/agent-session/agent-session-conversation-command'
|
||||
import type { MobileNativeChatStructuredComposer } from './MobileNativeChatComposer'
|
||||
import type { MobileNativeChatStructuredComposer } from './mobile-native-chat-structured-composer'
|
||||
import type { MobileNativeChatFileAttachments } from './use-mobile-native-chat-file-attachments'
|
||||
import type { useMobileStructuredSessionCommands } from '../../use-mobile-structured-session-commands'
|
||||
import type { MobileStructuredThreadGoal } from '../../use-mobile-structured-thread-goal'
|
||||
import type { useMobileStructuredSessionCommands } from './use-mobile-structured-session-commands'
|
||||
import type { MobileStructuredThreadGoal } from '../input/use-mobile-structured-thread-goal'
|
||||
|
||||
const NO_COMMANDS: readonly AgentSessionConversationCommand[] = []
|
||||
|
||||
|
||||
+5
-5
@@ -1,19 +1,19 @@
|
||||
// Lost acknowledgements may hide delivered sends: hold them quietly until the transcript confirms them, or hand them back at the deadline. Structured sends own a separate hold.
|
||||
|
||||
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||
import type { NativeChatMessage } from '../../../../src/shared/native-chat/native-chat-types'
|
||||
import type { NativeChatMessage } from '../../../../../src/shared/native-chat/native-chat-types'
|
||||
import {
|
||||
findLandedUnconfirmedSends,
|
||||
type UnconfirmedSend
|
||||
} from './composer/mobile-native-chat-draft-reconcile'
|
||||
import { returnMobileNativeChatInFlightSend } from './composer/mobile-native-chat-draft-store'
|
||||
} from './mobile-native-chat-draft-reconcile'
|
||||
import { returnMobileNativeChatInFlightSend } from './mobile-native-chat-draft-store'
|
||||
import {
|
||||
claimMobileNativeChatInFlightSends,
|
||||
releaseMobileNativeChatInFlightSends,
|
||||
settleMobileNativeChatInFlightSend,
|
||||
useMobileNativeChatSavedInFlightVersion
|
||||
} from './composer/mobile-native-chat-in-flight-sends'
|
||||
import type { MobileNativeChatSendOrigin } from './mobile-native-chat-pending-echo'
|
||||
} from './mobile-native-chat-in-flight-sends'
|
||||
import type { MobileNativeChatSendOrigin } from '../transcript/mobile-native-chat-pending-echo'
|
||||
import { createUnconfirmedSendDeadlines } from './unconfirmed-send-deadlines'
|
||||
|
||||
export const UNCONFIRMED_SEND_MESSAGE = 'Delivery unconfirmed — check chat before retrying'
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { RpcClient } from '../../../transport/rpc/rpc-client-contract'
|
||||
import type { StructuredAgentSessionHostSupport } from '../../mobile-structured-agent-session-host-support'
|
||||
import type { StructuredAgentSessionHostSupport } from '../agent-session/mobile-structured-agent-session-host-support'
|
||||
import { useMobileNativeChatFileSearch } from './use-mobile-native-chat-file-search'
|
||||
import { useMobileNativeChatSkills } from './use-mobile-native-chat-skills'
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { useMemo } from 'react'
|
||||
import type { useMobileStructuredAgentOptions } from './use-mobile-structured-agent-options'
|
||||
import type { useMobileStructuredAgentOptions } from '../input/use-mobile-structured-agent-options'
|
||||
|
||||
type MobileStructuredAgentOptions = ReturnType<typeof useMobileStructuredAgentOptions>
|
||||
|
||||
+4
-4
@@ -1,11 +1,11 @@
|
||||
import { useMemo } from 'react'
|
||||
import type { AgentJournalRenderItem } from '../../../src/shared/agent-session/journal/agent-session-journal-types'
|
||||
import type { AgentSessionOptionsResult } from '../../../src/shared/agent-session/options/agent-session-options-result'
|
||||
import { selectStructuredAgentSessionContextUsage } from '../../../src/shared/agent-session/structured-agent-session-context-usage'
|
||||
import type { AgentJournalRenderItem } from '../../../../../src/shared/agent-session/journal/agent-session-journal-types'
|
||||
import type { AgentSessionOptionsResult } from '../../../../../src/shared/agent-session/options/agent-session-options-result'
|
||||
import { selectStructuredAgentSessionContextUsage } from '../../../../../src/shared/agent-session/structured-agent-session-context-usage'
|
||||
import {
|
||||
summarizeContextUsage,
|
||||
type NativeChatContextUsageSummary
|
||||
} from '../../../src/shared/native-chat/native-chat-context-usage-summary'
|
||||
} from '../../../../../src/shared/native-chat/native-chat-context-usage-summary'
|
||||
|
||||
/** The composer ring's readout, from desktop's rule; an older host's missing answer leaves the loaded window's facts. */
|
||||
export function useMobileStructuredContextUsage(
|
||||
+8
-8
@@ -2,20 +2,20 @@ import { useCallback, useMemo, useState } from 'react'
|
||||
import type {
|
||||
AgentJournalRenderItem,
|
||||
AgentJournalSubmission
|
||||
} from '../../../src/shared/agent-session/journal/agent-session-journal-types'
|
||||
import { latestNativeChatOrcaStopCut } from '../../../src/shared/native-chat/native-chat-orca-stop-cut'
|
||||
} from '../../../../../src/shared/agent-session/journal/agent-session-journal-types'
|
||||
import { latestNativeChatOrcaStopCut } from '../../../../../src/shared/native-chat/native-chat-orca-stop-cut'
|
||||
import {
|
||||
failNativeChatInterruptedContinue,
|
||||
nativeChatInterruptedContinueState,
|
||||
NO_NATIVE_CHAT_INTERRUPTED_CONTINUE_ATTEMPT,
|
||||
nativeChatInterruptedContinueAccepted,
|
||||
type NativeChatInterruptedContinueAttempt
|
||||
} from '../../../src/shared/native-chat/native-chat-interrupted-continue'
|
||||
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
|
||||
import { callAgentSession } from './mobile-structured-agent-session-rpc'
|
||||
import { useRouteRelaysCapability } from '../worktree/workspace-server-context'
|
||||
import { AGENT_SESSION_PHONE_CONTINUE_INTERRUPTED_RUNTIME_CAPABILITY } from '../../../src/shared/agent-session/agent-session-continue-interrupted-capability'
|
||||
import type { StructuredAgentSessionHostSupport } from './mobile-structured-agent-session-host-support'
|
||||
} from '../../../../../src/shared/native-chat/native-chat-interrupted-continue'
|
||||
import type { RpcClient } from '../../../transport/rpc/rpc-client-contract'
|
||||
import { callAgentSession } from '../agent-session/mobile-structured-agent-session-rpc'
|
||||
import { useRouteRelaysCapability } from '../../../worktree/workspace-server-context'
|
||||
import { AGENT_SESSION_PHONE_CONTINUE_INTERRUPTED_RUNTIME_CAPABILITY } from '../../../../../src/shared/agent-session/agent-session-continue-interrupted-capability'
|
||||
import type { StructuredAgentSessionHostSupport } from '../agent-session/mobile-structured-agent-session-host-support'
|
||||
|
||||
export type MobileStructuredInterruptedContinue = {
|
||||
continueAvailable: boolean
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user