refactor(mobile): group host catalog credentials descriptors and connection history

This commit is contained in:
Neil
2026-11-10 02:20:11 -08:00
parent 7c01847447
commit f21236d64c
139 changed files with 233 additions and 583 deletions
@@ -560,21 +560,21 @@
"count": 1
},
{
"filePath": "mobile/src/transport/hosts/mobile-relay-host-overlay.ts",
"filePath": "mobile/src/host-catalog/mobile-relay-host-overlay.ts",
"kind": "object-property:message",
"text": "Expected exactly one endpoint for configured relay metadata",
"dynamic": false,
"count": 1
},
{
"filePath": "mobile/src/transport/hosts/mobile-relay-host-overlay.ts",
"filePath": "mobile/src/host-catalog/mobile-relay-host-overlay.ts",
"kind": "object-property:message",
"text": "Relay host identity mismatch",
"dynamic": false,
"count": 1
},
{
"filePath": "mobile/src/transport/hosts/mobile-relay-host-overlay.ts",
"filePath": "mobile/src/host-catalog/mobile-relay-host-overlay.ts",
"kind": "object-property:message",
"text": "Relay identity and endpoint must coexist",
"dynamic": false,
+1 -1
View File
@@ -27,7 +27,7 @@ import {
} from '../src/notifications/push-receive'
import { startPushTokenSync } from '../src/notifications/push-registration'
import { ensureDesktopNotificationChannel } from '../src/notifications/desktop-notification-channel'
import { loadHostCatalog } from '../src/transport/hosts/host-store'
import { loadHostCatalog } from '../src/host-catalog/host-store'
import { usePairingLinks } from '../src/navigation/use-pairing-links'
import { consumeInitialLaunchIntent } from '../src/navigation/initial-launch-intent'
import { recoverMobileRelayPairing } from '../src/pairing/mobile-relay-pairing-recovery'
+2 -2
View File
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useMemo, useState, useSyncExternalStore } from
import { View, Text, Pressable } from 'react-native'
import { useLocalSearchParams, useRouter } from 'expo-router'
import * as Clipboard from 'expo-clipboard'
import { loadHosts } from '../src/transport/hosts/host-store'
import { loadHosts } from '../src/host-catalog/host-store'
import { connectionLogStore } from '../src/diagnostics/connection/persisted-connection-log-store'
import { useRpcClientContext } from '../src/transport/connection/client-context'
import { useHostClient } from '../src/transport/connection/host-client-hooks'
@@ -22,7 +22,7 @@ import { connectionDiagnosticsScreenStyles as styles } from '../src/diagnostics/
import { useMobileColorScheme } from '../src/theme/use-mobile-color-scheme'
import { NATIVE_APP_LOG_ID } from '../src/diagnostics/native-render-log'
import type { ConnectionLogEntry } from '../src/diagnostics/connection/connection-log-types'
import type { HostProfile } from '../src/transport/hosts/host-profile'
import type { HostProfile } from '../src/host-catalog/host-profile'
import { pressedStyle } from '../src/theme/mobile-theme'
// Keep empty snapshot identity stable or useSyncExternalStore rerenders forever.
+4 -4
View File
@@ -18,7 +18,7 @@ import { NavBar } from '../../../src/components/nav-bar/NavBar'
import { NavBarButton } from '../../../src/components/nav-bar/NavBarButton'
import { themedStyleSheet } from '../../../src/theme/themed-styles'
import { useMobileColorScheme } from '../../../src/theme/use-mobile-color-scheme'
import { loadHosts, updateHostNameAndEndpoint } from '../../../src/transport/hosts/host-store'
import { loadHosts, updateHostNameAndEndpoint } from '../../../src/host-catalog/host-store'
import { displayHostEndpoint } from '../../../src/transport/hosts/host-endpoint'
import { resolveHostEndpointEdit } from '../../../src/transport/hosts/host-endpoint-edit'
import {
@@ -26,12 +26,12 @@ import {
usePrimeHosts,
useRefreshHostClient
} from '../../../src/transport/connection/host-client-hooks'
import { removeHostAndCloseClient } from '../../../src/transport/hosts/host-removal-lifecycle'
import { useHostDisplay } from '../../../src/transport/hosts/use-host-display'
import { removeHostAndCloseClient } from '../../../src/host-catalog/host-removal-lifecycle'
import { useHostDisplay } from '../../../src/host-descriptors/use-host-display'
import { leaveHostRoute } from '../../../src/host-route-exit'
import { ConfirmModal } from '../../../src/components/ConfirmModal'
import { ListGroup, ListRow } from '../../../src/components/list/ListGroup'
import type { HostProfile } from '../../../src/transport/hosts/host-profile'
import type { HostProfile } from '../../../src/host-catalog/host-profile'
import { hostOs } from '../../../src/platform/host-os'
import { translate } from '../../../src/i18n/mobile-i18n'
import { useMobileTranslation } from '../../../src/i18n/use-mobile-translation'
+2 -2
View File
@@ -12,8 +12,8 @@ import { colors, spacing } from '../src/theme/mobile-theme'
import { useMobileColorScheme } from '../src/theme/use-mobile-color-scheme'
import type { Translate } from '../src/i18n/mobile-i18n'
import { useMobileTranslation } from '../src/i18n/use-mobile-translation'
import { loadHosts, peekHosts } from '../src/transport/hosts/host-store'
import type { HostProfile } from '../src/transport/hosts/host-profile'
import { loadHosts, peekHosts } from '../src/host-catalog/host-store'
import type { HostProfile } from '../src/host-catalog/host-profile'
import { useFocusedSettingsHostClients } from '../src/settings/settings-host-client-connections'
import type { RpcClient } from '../src/transport/rpc/rpc-client-contract'
import { LIST_LEADING_INSET, ListRow } from '../src/components/list/ListGroup'
+2 -2
View File
@@ -1,7 +1,7 @@
import { useEffect, useMemo, useState } from 'react'
import { useRouter } from 'expo-router'
import { loadHosts, peekHosts } from '../src/transport/hosts/host-store'
import type { HostProfile } from '../src/transport/hosts/host-profile'
import { loadHosts, peekHosts } from '../src/host-catalog/host-store'
import type { HostProfile } from '../src/host-catalog/host-profile'
import { useFocusedSettingsHostClients } from '../src/settings/settings-host-client-connections'
import VoiceSettingsScreen from '../src/settings/voice-settings-screen'
import { nativeVoiceSettingsOperations } from '../src/settings/native-voice-settings-operations'
+1 -1
View File
@@ -3,7 +3,7 @@ import { View, Text, ScrollView, ActivityIndicator } from 'react-native'
import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context'
import { useFocusEffect, useLocalSearchParams } from 'expo-router'
import { ChevronLeft, RefreshCw, User } from 'lucide-react-native'
import { loadHosts, peekHosts } from '../transport/hosts/host-store'
import { loadHosts, peekHosts } from '../host-catalog/host-store'
import { useForceReconnect, useHostClient } from '../transport/connection/host-client-hooks'
import { useHostConnectionInputs } from '../transport/connection/client-context-connection-metrics'
import { classifyConnection, isConnectionOutage } from '../transport/connection/connection-health'
+2 -2
View File
@@ -12,8 +12,8 @@ import { triggerMediumImpact } from '../platform/haptics'
import { colors, spacing } from '../theme/mobile-theme'
import { themedStyleSheet } from '../theme/themed-styles'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import type { HostProfile } from '../transport/hosts/host-profile'
import { useHostDisplay } from '../transport/hosts/use-host-display'
import type { HostProfile } from '../host-catalog/host-profile'
import { useHostDisplay } from '../host-descriptors/use-host-display'
import { agentStateLabel, formatTimeAgo, type AgentDotState } from '../worktree/agent-row-display'
import { isDisclosureOpen, toggleDisclosure } from '../worktree/agent-child-disclosure'
import { areStructurallyEqual } from '../worktree/structural-equality'
@@ -6,7 +6,7 @@ import { TransientToast, useTransientToast } from '../components/TransientToast'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { useClipboardWriter } from '../platform/clipboard'
import { useOpenMobileSession } from '../session/use-open-mobile-session'
import type { HostProfile } from '../transport/hosts/host-profile'
import type { HostProfile } from '../host-catalog/host-profile'
import type { AgentActivityChange, AgentListRow } from './agent-list-rows'
import type { AgentListRowHandlers } from './MobileAgentListRows'
import type { AgentActivityFailure } from './use-agent-activity-writes'
@@ -9,8 +9,8 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context'
import { firstParam } from '../navigation/route-param-reader'
import { useRouteHandoff } from '../navigation/route-handoff'
import { useHostClient } from '../transport/connection/host-client-hooks'
import { useHostDisplay } from '../transport/hosts/use-host-display'
import { useHostProfile } from '../transport/hosts/use-host-profile'
import { useHostDisplay } from '../host-descriptors/use-host-display'
import { useHostProfile } from '../host-catalog/use-host-profile'
import { useHostProtocolGates } from '../components/host-protocol-gates-context'
import { NavBar, NavBarTitleButton } from '../components/nav-bar/NavBar'
import { NavBarButton } from '../components/nav-bar/NavBarButton'
@@ -62,9 +62,9 @@ vi.mock('../host-screen/host-list-queries', () => ({
(hostId && cachedRepos.get(hostId)) || null
}))
import '../transport/hosts/host-descriptor-store'
import '../host-descriptors/host-descriptor-store'
import { FakeSession } from '../transport/connection/mobile-endpoint-supervisor-test-fakes'
import { markRpcDeliveryUnknown } from '../transport/rpc/rpc-delivery-ambiguity'
import '../../../src/shared/execution-host'
import type { ExecutionHostId } from '../../../src/shared/execution-host'
@@ -231,72 +231,6 @@ describe('NewWorktreeModal project targets', () => {
expect(runTargetPicker(renderer).props.selectedId).toBe('runtime:env-1')
})
async function submitFromFolder(createReply: () => Promise<RpcResponse>) {
const serverRepo = { ...repos[0]!, path: '/srv/orca' }
const server = requestsOnly(
vi.fn((method: string) =>
method === 'repo.list'
? replied({ repos: [serverRepo] })
: method === 'worktree.create'
? createReply()
: Promise.reject(new Error(`unexpected ${method}`))
)
)
const settle = vi.fn()
await act(async () => {
renderer = create(
createElement(NewWorktreeModal, {
visible: true,
client: requestsOnly(() => new Promise<never>(() => {})),
serverClients: new Map<ExecutionHostId, RpcClient>([['runtime:env-1', server]]),
hostId: 'host-1',
onCreated: () => {},
onClose: () => {},
openExternalUrl: () => {},
folderLaunch: {
repoId: 'repo-1',
executionHostId: 'runtime:env-1',
name: 'payments',
parentWorkspace: 'folder:f-1',
submit: { begin: () => ({ settle }), presenting: () => true }
}
})
)
})
await flushUpdates()
const form = renderer.root.find((node) => typeof node.props.onCreate === 'function')
await act(async () => form.props.onCreate())
await flushUpdates()
const creates = vi
.mocked(server.sendRequest)
.mock.calls.filter(([method]) => method === 'worktree.create')
return { creates: creates.map(([, params]) => params), settle }
}
it('creates from a folder attached to that folder, on its host', async () => {
const { creates, settle } = await submitFromFolder(() =>
replied({ worktree: { id: 'repo-1::/srv/w/payments', displayName: 'payments' } })
)
expect(creates).toEqual([
expect.objectContaining({
repo: 'id:repo-1',
parentWorkspace: 'folder:f-1',
parentWorkspaceOrigin: 'manual'
})
])
expect(settle).toHaveBeenCalledWith('created')
})
it("doesn't try another name when a folder create's reply is lost", async () => {
const { creates, settle } = await submitFromFolder(() =>
Promise.reject(markRpcDeliveryUnknown(new Error('connection lost')))
)
expect(creates).toHaveLength(1)
expect(settle).toHaveBeenCalledWith('uncertain')
})
it('ignores a stale repo list after the client changes', async () => {
let resolveOldList: ((value: unknown) => void) | undefined
const oldList = new Promise((resolve) => {
+1 -1
View File
@@ -10,7 +10,7 @@ import { deriveRepoSlug, type PasteRepoCandidate } from '../tasks/smart-source-p
import { useMobileComposerSource } from '../tasks/use-mobile-composer-source'
import { useNewWorktreeRuntimeCapabilities } from '../tasks/worktree-create-capability'
import { useWorktreeCreateBasePrefetch } from '../tasks/use-worktree-create-base-prefetch'
import { useHostDescriptor } from '../transport/hosts/host-descriptor-store'
import { useHostDescriptor } from '../host-descriptors/host-descriptor-store'
import { isSameMobileWorkspaceRepo } from '../worktree/new-workspace-dialog-repo-selection'
import {
buildRetiredWorktreeNamesRefreshKey,
@@ -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 { HostProfile } from '../transport/hosts/host-profile'
import type { HostProfile } from '../host-catalog/host-profile'
import { useConnectedHostPicker } from './use-connected-host-picker'
function host(id: string, name: string, endpoint: string): HostProfile {
@@ -1,6 +1,6 @@
import { useRef, useState } from 'react'
import { hostEndpointLabel } from '../transport/hosts/host-endpoint-label'
import type { HostProfile } from '../transport/hosts/host-profile'
import type { HostProfile } from '../host-catalog/host-profile'
/** Picker rows for desktops, telling apart two that share a name and endpoint. */
export function hostPickerOptions(hosts: HostProfile[]) {
+2 -2
View File
@@ -7,11 +7,11 @@ import type { AESEncryptionKey } from 'expo-crypto'
import { Directory, Paths } from 'expo-file-system'
import { AppState } from 'react-native'
import { createExpoGenerationFileSystem } from '../mobile-web-shell/generation-store-file-system'
import { loadStoredHostProfiles } from '../transport/hosts/host-metadata-store'
import { loadStoredHostProfiles } from '../host-catalog/host-metadata-store'
import {
readPairingKeychainItem,
writePairingKeychainItem
} from '../transport/hosts/pairing-keychain'
} from '../host-credentials/pairing-keychain'
import {
createRootIndex,
DEVICE_STORE_CAPS,
@@ -5,7 +5,7 @@ import type {
MobileConnectionDiagnosticPath
} from './connection/connection-log-types'
import type { ConnectionState } from '../transport/connection/connection-state'
import { normalizeHostAppVersion } from '../transport/hosts/host-app-version'
import { normalizeHostAppVersion } from '../host-descriptors/host-app-version'
import { formatEndpoint } from './host-reachability'
import { diagnoseConnection } from './connection-diagnostics-analysis'
import { redactConnectionLogEntry, redactConnectionLogText } from './connection-log-redaction'
@@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest'
import { resolveDiagnosticsHostId } from './connection-diagnostics-screen-data'
import type { HostProfile } from '../transport/hosts/host-profile'
import type { HostProfile } from '../host-catalog/host-profile'
const host = (id: string): HostProfile => ({
id,
@@ -1,6 +1,6 @@
import type { ConnectionLogStore } from './connection/connection-log-buffer'
import type { ConnectionLogEntry } from './connection/connection-log-types'
import type { HostProfile } from '../transport/hosts/host-profile'
import type { HostProfile } from '../host-catalog/host-profile'
import type { RpcClientContextValue } from '../transport/connection/rpc-client-context-contract'
/** Route identity token: compared by reference to detect navigating away and back, never read. */
@@ -1,7 +1,7 @@
import { useEffect, useState } from 'react'
import { View, Text, Pressable, ActivityIndicator } from 'react-native'
import { Package } from 'lucide-react-native'
import { loadHosts } from '../transport/hosts/host-store'
import { loadHosts } from '../host-catalog/host-store'
import { colors } from '../theme/mobile-theme'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { troubleshootScreenStyles as styles } from './troubleshoot-screen-styles'
@@ -9,7 +9,7 @@ import {
useMobileWebBundleProbe,
type MobileWebBundleProbeState
} from './use-mobile-web-bundle-probe'
import type { HostProfile } from '../transport/hosts/host-profile'
import type { HostProfile } from '../host-catalog/host-profile'
import type { Translate } from '../i18n/mobile-i18n'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { ListGroup, ListRow } from '../components/list/ListGroup'
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'
import { Text, View } from 'react-native'
import type { MobileWebShellUpdateFailure } from '../mobile-web-shell/mobile-web-shell-update-failure'
import { processGenerationStore } from '../mobile-web-shell/process-generation-store'
import { loadHosts } from '../transport/hosts/host-store'
import { loadHosts } from '../host-catalog/host-store'
import { formatUpdateFailure } from './mobile-web-shell-update-failure-copy'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { troubleshootScreenStyles as styles } from './troubleshoot-screen-styles'
@@ -1,6 +1,6 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import type { ConnectionState } from '../transport/connection/connection-state'
import type { HostProfile } from '../transport/hosts/host-profile'
import type { HostProfile } from '../host-catalog/host-profile'
import { createNativeDiagnosticsOperations } from './native-diagnostics-operations'
const logStore = vi.hoisted(() => ({
@@ -1,6 +1,6 @@
import { Platform } from 'react-native'
import Constants from 'expo-constants'
import type { HostProfile } from '../transport/hosts/host-profile'
import type { HostProfile } from '../host-catalog/host-profile'
import type { RpcClientContextValue } from '../transport/connection/rpc-client-context-contract'
import { connectionLogStore } from './connection/persisted-connection-log-store'
import {
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'
import type { View } from 'react-native'
import { Platform } from 'react-native'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { loadHostCatalog, loadHosts } from '../transport/hosts/host-store'
import { loadHostCatalog, loadHosts } from '../host-catalog/host-store'
import {
startDiagnosticFetchTimeout,
type DiagnosticFetchTimeout
@@ -1,8 +1,8 @@
import { useCallback, useLayoutEffect, useMemo, useRef } from 'react'
import type { UseMobileDictationResult } from '../hooks/mobile-dictation-session-state'
import { useWorkspaceExecutionHost } from '../navigation/workspace-execution-host'
import { useHostDisplay } from '../transport/hosts/use-host-display'
import { useHostProfile } from '../transport/hosts/use-host-profile'
import { useHostDisplay } from '../host-descriptors/use-host-display'
import { useHostProfile } from '../host-catalog/use-host-profile'
import type { MobileDictationLive } from './mobile-dictation-live-context'
import { dictationFailureReason } from './mobile-dictation-controls-copy'
+1 -1
View File
@@ -2,7 +2,7 @@ import { memo } from 'react'
import type { AgentListRow } from '../agents/agent-list-rows'
import { MobileAgentListRows, type AgentListRowHandlers } from '../agents/MobileAgentListRows'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import type { HostProfile } from '../transport/hosts/host-profile'
import type { HostProfile } from '../host-catalog/host-profile'
import { areStructurallyEqual } from '../worktree/structural-equality'
import { MobileHomeSectionHeading } from './MobileHomeSectionHeading'
+2 -2
View File
@@ -6,10 +6,10 @@ import { statusDotColor } from '../components/StatusDot'
import type { ConnectionVerdict } from '../transport/connection/connection-health'
import { verdictDisplayLabel } from '../transport/connection/connection-health'
import { mobileConnectionPathAccessibilityLabel } from '../transport/connection/mobile-connection-path-label'
import { useHostDisplay } from '../transport/hosts/use-host-display'
import { useHostDisplay } from '../host-descriptors/use-host-display'
import type { MobileConnectionPath } from '../transport/connection/stable-logical-rpc-client'
import type { ConnectionState } from '../transport/connection/connection-state'
import type { HostCatalogEntry, HostProfile } from '../transport/hosts/host-profile'
import type { HostCatalogEntry, HostProfile } from '../host-catalog/host-profile'
import { colors } from '../theme/mobile-theme'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { homeHostWorktreeSummary, type HostWorktreeInfo } from '../worktree/home-worktree-info'
+1 -1
View File
@@ -7,7 +7,7 @@ import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { classifyConnection } from '../transport/connection/connection-health'
import { resolveHomeHostConnectionState } from '../transport/hosts/home-host-auto-connect'
import type { ConnectionState } from '../transport/connection/connection-state'
import type { HostCatalogEntry } from '../transport/hosts/host-profile'
import type { HostCatalogEntry } from '../host-catalog/host-profile'
import type { HostWorktreeInfo } from '../worktree/home-worktree-info'
import type { HomeHostConnections } from './home-host-connection-projection'
import { homeListStyles } from './home-list-styles'
+3 -3
View File
@@ -23,9 +23,9 @@ import {
} from '../transport/connection/host-client-hooks'
import { hostEndpointLabel } from '../transport/hosts/host-endpoint-label'
import { resolveHomeHostConnectionState } from '../transport/hosts/home-host-auto-connect'
import { removeHostAndCloseClient } from '../transport/hosts/host-removal-lifecycle'
import { loadHostCatalog } from '../transport/hosts/host-store'
import type { HostCatalogEntry, HostProfile } from '../transport/hosts/host-profile'
import { removeHostAndCloseClient } from '../host-catalog/host-removal-lifecycle'
import { loadHostCatalog } from '../host-catalog/host-store'
import type { HostCatalogEntry, HostProfile } from '../host-catalog/host-profile'
import { useOpenMobileHostEdit } from '../host-screen/use-open-mobile-host-edit'
import { mobileConnectionPathLabel } from '../transport/connection/mobile-connection-path-label'
import { newWorkspaceOverlayHref } from '../new-workspace/new-workspace-overlay-route'
+1 -1
View File
@@ -6,7 +6,7 @@ import { PickerModal } from '../components/PickerModal'
import { useConnectedHostPicker } from '../components/use-connected-host-picker'
import { colors } from '../theme/mobile-theme'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import type { HostProfile } from '../transport/hosts/host-profile'
import type { HostProfile } from '../host-catalog/host-profile'
import { homeListStyles as styles } from './home-list-styles'
type HomeHostSectionProps = {
@@ -1,6 +1,6 @@
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
import type { ConnectionState } from '../transport/connection/connection-state'
import type { HostCatalogEntry } from '../transport/hosts/host-profile'
import type { HostCatalogEntry } from '../host-catalog/host-profile'
export type MobileHomeClientEntry = {
hostId: string
@@ -7,8 +7,8 @@ import type { Translate } from '../../i18n/mobile-i18n'
import { useMobileTranslation } from '../../i18n/use-mobile-translation'
import { colors } from '../../theme/mobile-theme'
import { useMobileColorScheme } from '../../theme/use-mobile-color-scheme'
import type { HostProfile } from '../../transport/hosts/host-profile'
import { useHostDisplay } from '../../transport/hosts/use-host-display'
import type { HostProfile } from '../../host-catalog/host-profile'
import { useHostDisplay } from '../../host-descriptors/use-host-display'
import { MobileHomePill } from './MobileHomeHostPill'
const ALL_DESKTOPS = '__all__'
+2 -2
View File
@@ -29,8 +29,8 @@ import { useSerializedStoredState } from '../../storage/use-serialized-stored-st
import { colors, spacing } from '../../theme/mobile-theme'
import { themedStyleSheet } from '../../theme/themed-styles'
import { useMobileColorScheme } from '../../theme/use-mobile-color-scheme'
import type { HostProfile } from '../../transport/hosts/host-profile'
import { useHostDisplay } from '../../transport/hosts/use-host-display'
import type { HostProfile } from '../../host-catalog/host-profile'
import { useHostDisplay } from '../../host-descriptors/use-host-display'
import { formatTimeAgo } from '../../worktree/agent-row-display'
import { homeListStyles } from '../home-list-styles'
import { MobileHomeSectionHeading } from '../MobileHomeSectionHeading'
@@ -20,8 +20,8 @@ import { themedStyleSheet } from '../../theme/themed-styles'
import { useMobileColorScheme } from '../../theme/use-mobile-color-scheme'
import { useHostClient } from '../../transport/connection/host-client-hooks'
import type { ConnectionState } from '../../transport/connection/connection-state'
import type { HostProfile } from '../../transport/hosts/host-profile'
import { useHostDisplay } from '../../transport/hosts/use-host-display'
import type { HostProfile } from '../../host-catalog/host-profile'
import { useHostDisplay } from '../../host-descriptors/use-host-display'
import { homeListStyles as list } from '../home-list-styles'
import { MobileHomeSectionHeading } from '../MobileHomeSectionHeading'
import { MobileHomeAutomationRow, MobileHomeAutomationRunRow } from './MobileHomeAutomationRows'
+1 -1
View File
@@ -4,7 +4,7 @@ import { useResponsiveLayout } from '../../layout/responsive-layout'
import { spacing } from '../../theme/mobile-theme'
import { themedStyleSheet } from '../../theme/themed-styles'
import type { AgentListRowHandlers } from '../../agents/MobileAgentListRows'
import type { HostCatalogEntry } from '../../transport/hosts/host-profile'
import type { HostCatalogEntry } from '../../host-catalog/host-profile'
import { MobileHomeAppUpdateCard } from '../MobileHomeAppUpdateCard'
import { MobileHomeEmptyState } from '../MobileHomeEmptyState'
import { MobileHomeHostList } from '../MobileHomeHostList'
+2 -2
View File
@@ -10,8 +10,8 @@ import { colors, radii, spacing } from '../../theme/mobile-theme'
import { themedStyleSheet } from '../../theme/themed-styles'
import { useMobileColorScheme } from '../../theme/use-mobile-color-scheme'
import type { ConnectionState } from '../../transport/connection/connection-state'
import type { HostProfile } from '../../transport/hosts/host-profile'
import { useHostDisplay } from '../../transport/hosts/use-host-display'
import type { HostProfile } from '../../host-catalog/host-profile'
import { useHostDisplay } from '../../host-descriptors/use-host-display'
/** The desktop a per-desktop tab shows; it stays put until the user picks another or it is unpaired. */
export function useHomeTabHost(hosts: readonly HostProfile[], preferred: readonly HostProfile[]) {
+2 -2
View File
@@ -25,8 +25,8 @@ import '../../theme/themed-styles'
import { useMobileColorScheme } from '../../theme/use-mobile-color-scheme'
import { useHostClient } from '../../transport/connection/host-client-hooks'
import type { ConnectionState } from '../../transport/connection/connection-state'
import type { HostProfile } from '../../transport/hosts/host-profile'
import { useHostDisplay } from '../../transport/hosts/use-host-display'
import type { HostProfile } from '../../host-catalog/host-profile'
import { useHostDisplay } from '../../host-descriptors/use-host-display'
import { formatTimeAgo } from '../../worktree/agent-row-display'
import { homeListStyles } from '../home-list-styles'
import { MobileHomeSectionHeading } from '../MobileHomeSectionHeading'
+3 -3
View File
@@ -30,9 +30,9 @@ import {
import {
selectConnectableHostProfiles,
sortHostsByLastConnected
} from '../transport/hosts/host-catalog-selection'
import { loadHostCatalog } from '../transport/hosts/host-store'
import type { HostCatalogEntry } from '../transport/hosts/host-profile'
} from '../host-catalog/host-catalog-selection'
import { loadHostCatalog } from '../host-catalog/host-store'
import type { HostCatalogEntry } from '../host-catalog/host-profile'
import { hostObserverOptions, type HostQuery } from '../query/host-query'
import { isHostNotConnectedError } from '../query/host-query-errors'
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
@@ -12,7 +12,7 @@ import { usePrimeHosts } from '../transport/connection/host-client-hooks'
import { selectHomeAutoConnectHostIds } from '../transport/hosts/home-host-auto-connect'
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
import type { ConnectionState } from '../transport/connection/connection-state'
import type { HostCatalogEntry, HostProfile } from '../transport/hosts/host-profile'
import type { HostCatalogEntry, HostProfile } from '../host-catalog/host-profile'
import { useAllHostClients } from '../transport/connection/use-all-host-clients'
import {
readMobileHomeLastConnected,
@@ -1,4 +1,4 @@
import type { MobileRelayEndpoint } from '../../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import type { MobileRelayEndpoint } from '../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import type { HostListSnapshot } from './host-list-load-sharing'
import type { HostCatalogEntry, StoredHostProfile } from './host-profile'
@@ -0,0 +1,17 @@
import { mutateStoredHosts } from './host-list-mutation-queue'
export async function updateLastConnected(hostId: string): Promise<void> {
try {
await mutateStoredHosts((hosts) => {
const index = hosts.findIndex((h) => h.id === hostId)
if (index === -1) {
return hosts
}
const next = hosts.slice()
next[index] = { ...next[index]!, lastConnected: Date.now() }
return next
})
} catch {
// Swallow bookkeeping failures because void callers cannot catch them.
}
}
@@ -0,0 +1,2 @@
// Recency belongs to the native host list, which this page does not show.
export const updateLastConnected = (_hostId: string): Promise<void> => Promise.resolve()
@@ -25,7 +25,7 @@ vi.mock('react-native', () => ({
Platform: { OS: 'ios' }
}))
vi.mock('./host-credential-cleanup', () => ({
vi.mock('../host-credentials/host-credential-cleanup', () => ({
cancelPendingHostCredentialCleanup: vi.fn().mockResolvedValue(undefined),
recordHostCredentialCleanupIntent: vi.fn().mockResolvedValue(undefined),
scheduleHostCredentialCleanup: vi.fn().mockResolvedValue(undefined),
@@ -38,7 +38,7 @@ import {
savePairedHost,
updateHostNameAndEndpoint
} from './host-store'
import { updateHostDescriptor } from './host-descriptor-persistence'
import { updateHostDescriptor } from '../host-descriptors/host-descriptor-persistence'
import { resetMobileRelayHostOverlayStoreForTests } from './mobile-relay-host-overlay-store'
import { StoredHostProfileSchema, type StoredHostProfile } from './host-profile'
@@ -1,6 +1,6 @@
import { GENERATED_HOST_NAME_PATTERN, getNextHostNameFromHosts } from './host-names'
import type { StoredHostProfile } from './host-profile'
import { sameHostMachine, type HostMachine } from '../../../../src/shared/host-machine-line'
import { sameHostMachine, type HostMachine } from '../../../src/shared/host-machine-line'
// Resolve name identity inside host-store’s serialized mutation so display name and sources commit together; see withReportedDescriptor’s omission exception.
@@ -1,13 +1,13 @@
import { z } from 'zod'
import '../../../../src/shared/remote-runtime/pairing/mobile-relay-pairing-offer'
import '../../../src/shared/remote-runtime/pairing/mobile-relay-pairing-offer'
import {
MobileRelayEndpointSchema,
type MobileRelayEndpoint
} from '../../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import { NODE_PLATFORM_NAMES } from '../connection/mobile-runtime-host-platform'
import { salvagedOptional } from '../../../../src/shared/zod-salvage'
import type { HostMachine } from '../../../../src/shared/host-machine-line'
import { HostMachineSchema } from './host-status-reply-schema'
} from '../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import { NODE_PLATFORM_NAMES } from '../transport/connection/mobile-runtime-host-platform'
import { salvagedOptional } from '../../../src/shared/zod-salvage'
import type { HostMachine } from '../../../src/shared/host-machine-line'
import { HostMachineSchema } from '../transport/hosts/host-status-reply-schema'
export type HostProfile = {
id: string
@@ -1,12 +1,12 @@
import type { QueryClient } from '@tanstack/react-query'
import { wipeHostStore } from '../../device-store/device-store'
import { wipeHostStore } from '../device-store/device-store'
import {
deleteHostPageCache,
forgetHostUpdateFailures
} from '../../mobile-web-shell/removed-host-shell-cache'
import { unregisterPushForRemovedHost } from '../../notifications/push-registration'
import { forgetNativeHostQueries } from '../../query/native-query-persistence'
import { forgetHostDescriptor } from './host-descriptor-store'
} from '../mobile-web-shell/removed-host-shell-cache'
import { unregisterPushForRemovedHost } from '../notifications/push-registration'
import { forgetNativeHostQueries } from '../query/native-query-persistence'
import { forgetHostDescriptor } from '../host-descriptors/host-descriptor-store'
import { removeHost } from './host-store'
export async function removeHostAndCloseClient(
@@ -31,24 +31,14 @@ vi.mock('react-native', () => ({
Platform: platformMock
}))
vi.mock('./host-credential-cleanup', () => ({
vi.mock('../host-credentials/host-credential-cleanup', () => ({
cancelPendingHostCredentialCleanup: (...args: unknown[]) => cancelCleanupMock(...args),
recordHostCredentialCleanupIntent: (...args: unknown[]) => recordCleanupIntentMock(...args),
scheduleHostCredentialCleanup: (...args: unknown[]) => scheduleCleanupMock(...args),
retryPendingHostCredentialCleanups: vi.fn()
}))
import {
loadHostCatalog,
loadHosts,
RelayRoutingHostRemovedError,
removeHost,
resolvePairingHostIdentity,
resetHostStoreForTests,
savePairedHost,
setRelayRouting,
updateHostNameAndEndpoint
} from './host-store'
import { loadHostCatalog, loadHosts, resetHostStoreForTests, savePairedHost } from './host-store'
import { resetMobileRelayHostOverlayStoreForTests } from './mobile-relay-host-overlay-store'
const HOSTS_STORAGE_KEY = 'orca:hosts'
@@ -67,14 +57,6 @@ const HOST_TWO = {
publicKeyB64: 'key-2',
lastConnected: 0
}
const HOST_ONE_RELAY = {
v: 1 as const,
directorUrl: 'https://relay.onorca.dev',
cellUrl: 'https://relay-c1.onorca.dev',
assignmentEpoch: 7,
relayHostId: 'AbCdEf0123_-xyZ9',
e2eeFraming: 2 as const
}
describe('host-store list mutations', () => {
let storedHostsRaw: string
@@ -134,13 +116,6 @@ describe('host-store list mutations', () => {
expect(profiles.map(({ id }) => id)).toEqual([HOST_TWO.id])
})
it('fails closed when durable host identity storage is unreadable', async () => {
asyncStorageMock.getItem.mockRejectedValueOnce(new Error('storage unavailable'))
await expect(resolvePairingHostIdentity('key-new', 'host-new')).rejects.toThrow(/unreadable/)
expect(asyncStorageMock.setItem).not.toHaveBeenCalled()
})
it('serves a committed replacement token when same-key metadata persistence fails', async () => {
const duplicate = {
...HOST_TWO,
@@ -164,148 +139,6 @@ describe('host-store list mutations', () => {
loadHosts().then((hosts) => hosts.find(({ id }) => id === HOST_ONE.id)?.deviceToken)
).resolves.toBe('replacement-token')
})
it('refuses an early same-key token write without durable cleanup intent', async () => {
const replacement = {
...HOST_TWO,
id: 'host-replacement',
publicKeyB64: HOST_ONE.publicKeyB64,
deviceToken: 'replacement-token'
}
recordCleanupIntentMock.mockRejectedValueOnce(new Error('intent storage unavailable'))
await expect(savePairedHost(replacement)).rejects.toThrow('intent storage unavailable')
expect(JSON.parse(storedHostsRaw)).toEqual([HOST_ONE, HOST_TWO])
expect(secureStoreMock.setItemAsync).not.toHaveBeenCalled()
})
it('refuses to resurrect a removed host during relay upgrade publication', async () => {
storedHostsRaw = JSON.stringify([HOST_TWO])
await expect(setRelayRouting(HOST_ONE.id, HOST_ONE_RELAY)).rejects.toBeInstanceOf(
RelayRoutingHostRemovedError
)
expect(JSON.parse(storedHostsRaw)).toEqual([HOST_TWO])
expect(storedOverlayRaw).toBeNull()
expect(secureStoreMock.setItemAsync).not.toHaveBeenCalled()
})
it('applies concurrent rename and remove without clobbering either', async () => {
let releaseReads: (() => void) | undefined
const readsReleased = new Promise<void>((resolve) => {
releaseReads = resolve
})
let pendingReads = 0
asyncStorageMock.getItem.mockImplementation(async (key: string) => {
if (key !== HOSTS_STORAGE_KEY) {
return null
}
pendingReads += 1
if (pendingReads <= 2) {
await readsReleased
}
return storedHostsRaw
})
const rename = updateHostNameAndEndpoint(HOST_ONE.id, { personalName: 'Renamed Host' })
const remove = removeHost(HOST_TWO.id)
// Overlap writers behind one read gate to expose lost updates without serialization.
await vi.waitFor(() => {
expect(pendingReads).toBeGreaterThanOrEqual(1)
})
releaseReads?.()
await Promise.all([rename, remove])
expect(JSON.parse(storedHostsRaw)).toEqual([
{ ...HOST_ONE, name: 'Renamed Host', personalName: 'Renamed Host' }
])
})
it('does not wipe the host list when storage is unreadable during mutation', async () => {
storedHostsRaw = '{'
await expect(updateHostNameAndEndpoint(HOST_ONE.id, { personalName: 'Nope' })).rejects.toThrow(
/unreadable/
)
expect(asyncStorageMock.setItem).not.toHaveBeenCalled()
expect(storedHostsRaw).toBe('{')
})
// Park the slow keychain pass while a durable write invalidates it.
function gateKeychainReads(): () => void {
let release: () => void = () => {}
const gate = new Promise<void>((resolve) => {
release = resolve
})
secureStoreMock.getItemAsync.mockImplementation(async (key: string) => {
await gate
return key.endsWith(HOST_ONE.id) || key.endsWith(HOST_TWO.id) ? `token-${key.at(-1)}` : null
})
return release
}
it('does not serve a pre-removal snapshot to a load issued after the removal (#8791)', async () => {
const releaseKeychain = gateKeychainReads()
const parkedLoad = loadHosts()
await vi.waitFor(() => {
expect(secureStoreMock.getItemAsync).toHaveBeenCalled()
})
await removeHost(HOST_ONE.id)
const afterRemoval = loadHosts()
releaseKeychain()
await parkedLoad
await expect(afterRemoval.then((hosts) => hosts.map((host) => host.id))).resolves.toEqual([
HOST_TWO.id
])
})
it('does not serve a pre-rename snapshot to a load issued after the rename (#8791)', async () => {
const releaseKeychain = gateKeychainReads()
const parkedLoad = loadHosts()
await vi.waitFor(() => {
expect(secureStoreMock.getItemAsync).toHaveBeenCalled()
})
await updateHostNameAndEndpoint(HOST_ONE.id, { personalName: 'Living Room Mac' })
const afterRename = loadHosts()
releaseKeychain()
await parkedLoad
const hosts = await afterRename
expect(hosts.find((host) => host.id === HOST_ONE.id)?.name).toBe('Living Room Mac')
})
it('does not let a late pre-write token read poison the token cache', async () => {
const newHost = {
id: 'host-new',
name: 'New Host',
endpoint: 'ws://127.0.0.1:3',
publicKeyB64: 'key-new',
deviceToken: 'token-new',
lastConnected: 0
}
storedHostsRaw = JSON.stringify([{ ...newHost, deviceToken: undefined }])
let resolvePrewriteTokenRead: (token: string) => void = () => {}
secureStoreMock.getItemAsync.mockReturnValue(
new Promise<string>((resolve) => {
resolvePrewriteTokenRead = resolve
})
)
const parkedLoad = loadHosts()
await vi.waitFor(() => {
expect(secureStoreMock.getItemAsync).toHaveBeenCalled()
})
await savePairedHost(newHost)
resolvePrewriteTokenRead('token-old')
await parkedLoad
const hosts = await loadHosts()
expect(hosts.find((host) => host.id === newHost.id)?.deviceToken).toBe(newHost.deviceToken)
})
})
describe('host-store pairing save after an Android encryption rejection', () => {
@@ -1,4 +1,4 @@
import type { MobileRelayEndpoint } from '../../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import type { MobileRelayEndpoint } from '../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import { HostProfileSchema } from './host-profile'
import type { HostCatalogEntry, HostProfile, StoredHostProfile } from './host-profile'
@@ -6,27 +6,30 @@ import { getNextHostNameFromHosts } from './host-names'
import { mergeHostNameIdentity, withPersonalName } from './host-name-identity'
import * as hostListLoads from './host-list-load-sharing'
import { joinHostCatalogCredentials } from './host-catalog-credential-join'
import { resetPairingKeychainForTests } from './pairing-keychain'
import { readHostDeviceToken, writeHostDeviceToken } from './host-device-token-store'
import { resetPairingKeychainForTests } from '../host-credentials/pairing-keychain'
import {
readHostDeviceToken,
writeHostDeviceToken
} from '../host-credentials/host-device-token-store'
import {
cancelPendingHostCredentialCleanup,
recordHostCredentialCleanupIntent,
retryPendingHostCredentialCleanups,
scheduleHostCredentialCleanup
} from './host-credential-cleanup'
} from '../host-credentials/host-credential-cleanup'
import {
loadMobileRelayHostRoutingState,
removeMobileRelayHostRouting,
removeMobileRelayHostRoutings,
saveMobileRelayHostRouting
} from './mobile-relay-host-overlay-store'
import { scheduleOrphanedMobileRelayCleanup } from '../relay/mobile-relay-orphan-cleanup'
import { scheduleOrphanedMobileRelayCleanup } from '../transport/relay/mobile-relay-orphan-cleanup'
import {
getHostCredentialWriteRevision,
markHostCredentialWrite,
resetHostCredentialWriteRevisionsForTests
} from './host-credential-write-revision'
import { createUnpairedHostCredentialDeletion } from '../../pairing/unpaired-host-credential-deletion'
} from '../host-credentials/host-credential-write-revision'
import { createUnpairedHostCredentialDeletion } from '../pairing/unpaired-host-credential-deletion'
import {
loadStoredHostProfiles,
readStoredHostProfilesForMutation,
@@ -148,7 +151,7 @@ function removeOrphanOverlayIfUnpaired(hostId: string): Promise<void> {
})
}
import './host-descriptor-persistence'
import '../host-descriptors/host-descriptor-persistence'
export class RelayRoutingHostRemovedError extends Error {}
@@ -315,22 +318,6 @@ export async function updateHostNameAndEndpoint(
})
}
export async function updateLastConnected(hostId: string): Promise<void> {
try {
await mutateStoredHosts((hosts) => {
const index = hosts.findIndex((h) => h.id === hostId)
if (index === -1) {
return hosts
}
const next = hosts.slice()
next[index] = { ...next[index]!, lastConnected: Date.now() }
return next
})
} catch {
// Swallow bookkeeping failures because void callers cannot catch them.
}
}
export function resetHostStoreForTests(): void {
resetHostListMutationQueueForTests()
tokenCache.clear()
@@ -1,5 +1,5 @@
import { readPageHostProfile } from '../../mobile-web-shell/bridge/page-host-profile'
import type { MobileRelayEndpoint } from '../../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import { readPageHostProfile } from '../mobile-web-shell/bridge/page-host-profile'
import type { MobileRelayEndpoint } from '../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import type { HostCatalogEntry, HostProfile } from './host-profile'
// The page gets no device credential or public key; RPC uses the shell’s paired client.
@@ -26,9 +26,6 @@ export const setRelayRouting = (_hostId: string, _relay: MobileRelayEndpoint): P
export const removeHost = (_hostId: string): Promise<void> => Promise.resolve()
// Recency belongs to the native host list, which this page does not show.
export const updateLastConnected = (_hostId: string): Promise<void> => Promise.resolve()
export function updateHostNameAndEndpoint(
_hostId: string,
_updates: { personalName?: string | null; endpoint?: string }
@@ -74,22 +74,4 @@ describe('mobile relay host overlay store', () => {
await expect(saveMobileRelayHostRouting('host-1', RELAY)).resolves.toBe(true)
expect(JSON.parse(stored!)).toEqual([RELAY_ONLY_OVERLAY])
})
it('never overlays or resurrects a host whose legacy base was removed', async () => {
stored = JSON.stringify([LEGACY_OVERLAY])
await expect(loadMobileRelayHostRoutingState(new Set())).resolves.toEqual({
relays: new Map(),
orphanHostIds: ['host-1']
})
expect(asyncStorage.setItem).not.toHaveBeenCalled()
expect(JSON.parse(stored)).toEqual([LEGACY_OVERLAY])
})
it('refuses to overwrite unreadable overlay storage', async () => {
stored = '{'
await expect(saveMobileRelayHostRouting('host-1', RELAY)).rejects.toThrow(/unreadable/)
expect(asyncStorage.setItem).not.toHaveBeenCalled()
})
})
@@ -1,5 +1,5 @@
import AsyncStorage from '@react-native-async-storage/async-storage'
import type { MobileRelayEndpoint } from '../../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import type { MobileRelayEndpoint } from '../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import {
MobileRelayHostOverlaySchema,
toStoredMobileRelayHostOverlay,
@@ -2,8 +2,8 @@ import { z } from 'zod'
import {
MobileRelayEndpointSchema,
type MobileRelayEndpoint
} from '../../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import { relayConnectWebSocketUrl } from '../relay/mobile-relay-connect-url'
} from '../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import { relayConnectWebSocketUrl } from '../transport/relay/mobile-relay-connect-url'
const MobileAccessEndpointSchema = z
.object({
@@ -19,7 +19,7 @@ vi.mock('expo-secure-store', () => ({
vi.mock('react-native', () => ({ Platform: platform }))
import { promotePairingJournalCredential } from './mobile-relay-credential-bundle'
import type { MobileRelayPairingJournal } from '../../pairing/mobile-relay-pairing-journal'
import type { MobileRelayPairingJournal } from '../pairing/mobile-relay-pairing-journal'
import { resetPairingKeychainForTests } from './pairing-keychain'
const journal = {
@@ -1,7 +1,7 @@
import { Platform } from 'react-native'
import { z } from 'zod'
import type { DeviceCredentialInstalled } from '../../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import type { MobileRelayPairingJournal } from '../../pairing/mobile-relay-pairing-journal'
import type { DeviceCredentialInstalled } from '../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import type { MobileRelayPairingJournal } from '../pairing/mobile-relay-pairing-journal'
import {
deletePairingKeychainItem,
readPairingKeychainItem,
@@ -1,5 +1,8 @@
import { mutateStoredHosts } from './host-list-mutation-queue'
import { withReportedDescriptor, type ReportedHostDescriptor } from './host-name-identity'
import { mutateStoredHosts } from '../host-catalog/host-list-mutation-queue'
import {
withReportedDescriptor,
type ReportedHostDescriptor
} from '../host-catalog/host-name-identity'
// Keep authenticated descriptor upkeep best-effort; older hosts omitting both fields must not churn stored rows.
export async function updateHostDescriptor(
@@ -1,5 +1,5 @@
import '../../mobile-web-shell/bridge/page-host-profile'
import type { ReportedHostDescriptor } from './host-name-identity'
import '../mobile-web-shell/bridge/page-host-profile'
import type { ReportedHostDescriptor } from '../host-catalog/host-name-identity'
// Last-known descriptors belong to the native host list.
export function updateHostDescriptor(
@@ -1,7 +1,7 @@
import { recordHostDescriptor } from './host-descriptor-store'
import './host-store'
import '../host-catalog/host-store'
import { updateHostDescriptor } from './host-descriptor-persistence'
import type { HostStatusReply } from './host-status-reply-schema'
import type { HostStatusReply } from '../transport/hosts/host-status-reply-schema'
// Update live rows and persisted last-known descriptors together; best-effort bookkeeping must never gate connection.
export function recordHostDescriptorFromStatus(hostId: string, status: HostStatusReply): void {
@@ -1,5 +1,5 @@
import { useCallback, useSyncExternalStore } from 'react'
import { sameHostMachine, type HostMachine } from '../../../../src/shared/host-machine-line'
import { sameHostMachine, type HostMachine } from '../../../src/shared/host-machine-line'
export type HostMachineDescriptor = {
machineName: string | null
@@ -1,10 +1,10 @@
import {
resolveHostDisplay,
type HostDisplayResolution
} from '../../../../src/shared/host-display-resolution'
} from '../../../src/shared/host-display-resolution'
import { useHostDescriptor } from './host-descriptor-store'
import { classifyLegacyHostName } from './host-name-identity'
import type { HostMachine } from '../../../../src/shared/host-machine-line'
import { classifyLegacyHostName } from '../host-catalog/host-name-identity'
import type { HostMachine } from '../../../src/shared/host-machine-line'
export type HostDisplaySource = {
id: string
+1 -1
View File
@@ -1,7 +1,7 @@
import { Activity, Edit3, PowerOff, RefreshCw } from 'lucide-react-native'
import type { ActionSheetAction } from './components/ActionSheetModal'
import type { ConnectionState } from './transport/connection/connection-state'
import type { HostProfile } from './transport/hosts/host-profile'
import type { HostProfile } from './host-catalog/host-profile'
import { translate } from './i18n/mobile-i18n'
// Defer navigation and new drawers until this native Modal unmounts; presenting into a live one freezes iOS (#8791).
@@ -1,4 +1,4 @@
import type { HostProfile } from '../transport/hosts/host-profile'
import type { HostProfile } from '../host-catalog/host-profile'
import type { HostMachine } from '../../../src/shared/host-machine-line'
export type HostStoredDescriptor = {
@@ -1,5 +1,5 @@
import { useMemo } from 'react'
import { useHostDescriptor } from '../transport/hosts/host-descriptor-store'
import { useHostDescriptor } from '../host-descriptors/host-descriptor-store'
import type { ConnectionState } from '../transport/connection/connection-state'
import {
serverHostHealth,
@@ -28,7 +28,7 @@ import { useHostViewSettings } from './use-host-view-settings'
import { countActiveWorkspaceFilters } from '../../../src/shared/workspace-view/workspace-row-filters'
import { useHostWorktreeActions } from './use-host-worktree-actions'
import { useHostWorktreeCatalog } from './use-host-worktree-catalog'
import { useHostDisplay } from '../transport/hosts/use-host-display'
import { useHostDisplay } from '../host-descriptors/use-host-display'
import { classifyConnection } from '../transport/connection/connection-health'
export type HostScreenProps = {
@@ -3,8 +3,9 @@ import { useQueryClient } from '@tanstack/react-query'
import { translate } from '../i18n/mobile-i18n'
import { ORCA_SIDEBAR_INPUTS_IS_MAIN } from '../../../src/shared/sidebar-inputs-switch'
import { loadPinnedIds } from '../storage/preferences'
import { loadHosts, peekHosts, updateLastConnected } from '../transport/hosts/host-store'
import type { HostProfile } from '../transport/hosts/host-profile'
import { loadHosts, peekHosts } from '../host-catalog/host-store'
import { updateLastConnected } from '../host-catalog/host-connection-history'
import type { HostProfile } from '../host-catalog/host-profile'
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
import type { HostScreenState } from './use-host-screen-state'
import { storedHostDescriptor } from './host-stored-identity'
@@ -4,7 +4,7 @@ import type { ExecutionHostId } from '../../../src/shared/execution-host'
import type { ExecutionHostHealth } from '../../../src/shared/execution-host/execution-host-health'
import { storedHostDescriptor, type HostStoredDescriptor } from './host-stored-identity'
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
import type { HostProfile } from '../transport/hosts/host-profile'
import type { HostProfile } from '../host-catalog/host-profile'
import { INITIAL_MOBILE_VIEW, type MobileViewState } from '../worktree/workspace-view-settings'
import type { Worktree } from '../worktree/workspace-list-sections'
import type { ServedProjectSections } from '../worktree/project-sections-operations'
@@ -6,8 +6,8 @@ import { floatingWorkspaceSessionPath } from '../session/floating-workspace'
import { holdSessionLeave } from '../session/session-leave-guard'
import { savePinnedIds } from '../storage/preferences'
import type { useForgetHostClient } from '../transport/connection/host-client-hooks'
import { removeHostAndCloseClient } from '../transport/hosts/host-removal-lifecycle'
import { isPageHostRemovalUnavailable } from '../transport/hosts/page-host-removal-refusal'
import { removeHostAndCloseClient } from '../host-catalog/host-removal-lifecycle'
import { isPageHostRemovalUnavailable } from '../host-catalog/page-host-removal-refusal'
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
import {
rpcClientForExecutionHost,
@@ -1,4 +1,4 @@
import { useHostDisplay, type HostDisplaySource } from '../transport/hosts/use-host-display'
import { useHostDisplay, type HostDisplaySource } from '../host-descriptors/use-host-display'
import type { DownloadProgressFeed } from './download-progress-feed'
import { DownloadProgressBar, downloadedMegabytesCaption } from './DownloadProgressBar'
import type { MobileWebShellSessionState } from './mobile-web-shell-session-contract'
@@ -6,7 +6,7 @@ import { themedStyleSheet } from '../theme/themed-styles'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import type { Translate } from '../i18n/mobile-i18n'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import type { HostDisplaySource } from '../transport/hosts/use-host-display'
import type { HostDisplaySource } from '../host-descriptors/use-host-display'
import type { DownloadProgressFeed } from './download-progress-feed'
import type {
MobileWebShellFailureCause,
@@ -26,7 +26,7 @@ vi.mock('@react-native-async-storage/async-storage', () => ({
)
}
}))
vi.mock('../transport/hosts/host-store', () => ({
vi.mock('../host-catalog/host-store', () => ({
loadHosts: async () => [{ id: 'host-a', name: 'Host', endpoint: 'ws://h', lastConnected: 1 }]
}))
@@ -46,7 +46,7 @@ vi.mock('@react-native-async-storage/async-storage', () => ({
getItem: async (key: string) => doubles.store.get(key) ?? null
}
}))
vi.mock('../transport/hosts/host-store', () => ({
vi.mock('../host-catalog/host-store', () => ({
loadHosts: async () => {
if (doubles.hostsReject) {
throw new Error('the keychain would not answer')
@@ -1,5 +1,5 @@
import { useCallback, useEffect, useRef, useState } from 'react'
import { loadHosts } from '../transport/hosts/host-store'
import { loadHosts } from '../host-catalog/host-store'
import type { BridgeInitHost } from './bridge/bridge-envelope'
import {
hydrateMirroredStorage,
@@ -3,9 +3,9 @@ import { useRouter } from 'expo-router'
import { PickerModal } from '../components/PickerModal'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { hostPickerOptions } from '../components/use-connected-host-picker'
import { selectConnectableHostProfiles } from '../transport/hosts/host-catalog-selection'
import { loadHostCatalog } from '../transport/hosts/host-store'
import type { HostProfile } from '../transport/hosts/host-profile'
import { selectConnectableHostProfiles } from '../host-catalog/host-catalog-selection'
import { loadHostCatalog } from '../host-catalog/host-store'
import type { HostProfile } from '../host-catalog/host-profile'
// Keep picker and loading drawer in the overlay’s window so the load can start as selection leaves.
export function NewWorkspaceHostPicker({
@@ -4,7 +4,7 @@ import type { DismissNotificationEvent } from './desktop-notification-events'
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
import { waitForPushFallback } from './push-fallback'
import { getHostPushSupported, getHostPushSupportCompletion } from './push-registration'
import { loadHostCatalog } from '../transport/hosts/host-store'
import { loadHostCatalog } from '../host-catalog/host-store'
import { deriveHostFingerprint } from './push-host-fingerprint'
import { presentForegroundPush } from './android-foreground-push'
import {
@@ -1,7 +1,7 @@
import { parseExecutionHostId } from '../../../src/shared/execution-host'
import type { HostStackRouteTarget } from '../navigation/host-stack-navigation'
import { mobileSessionRouteTarget } from '../session/mobile-session-route'
import type { HostCredentialStatus } from '../transport/hosts/host-profile'
import type { HostCredentialStatus } from '../host-catalog/host-profile'
export type NotificationNavigationOptions = {
knownHostIds?: ReadonlySet<string>
@@ -1,6 +1,6 @@
import * as Notifications from 'expo-notifications'
import { pushMissedSinceRead, type MobilePushDismissalRpcSender } from './push-dismissal-operations'
import { loadHostCatalog } from '../transport/hosts/host-store'
import { loadHostCatalog } from '../host-catalog/host-store'
import { resolveHostIdForFingerprint } from './push-host-fingerprint'
import { readNativeNotificationData } from './native-notification-data'
import { readOrcaPushPayload, type OrcaPushPayload } from './push-payload'
@@ -4,8 +4,8 @@ import { setNotificationViewingWorkspace } from './notification-viewing-policy'
vi.mock('./push-tray-dismissal', () => ({ dismissPresentedPushNotification: vi.fn() }))
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { sha256 } from '@noble/hashes/sha256'
import { loadHostCatalog } from '../transport/hosts/host-store'
import type { HostCatalogEntry } from '../transport/hosts/host-profile'
import { loadHostCatalog } from '../host-catalog/host-store'
import type { HostCatalogEntry } from '../host-catalog/host-profile'
import {
foregroundNotificationBehavior,
@@ -19,7 +19,7 @@ async function shouldSuppressForegroundPush(data: unknown): Promise<boolean> {
}
vi.mock('react-native', () => ({ AppState: { currentState: 'background' } }))
vi.mock('../transport/hosts/host-store', () => ({ loadHostCatalog: vi.fn() }))
vi.mock('../host-catalog/host-store', () => ({ loadHostCatalog: vi.fn() }))
const storage = vi.hoisted(() => new Map<string, string>())
vi.mock('@react-native-async-storage/async-storage', () => ({
default: {
+1 -1
View File
@@ -2,7 +2,7 @@ import { wasPushDismissed } from './push-dismissal-watermarks'
import { dismissPresentedPushNotification } from './push-tray-dismissal'
import { shouldSuppressNotificationWhileViewing } from './notification-viewing-policy'
import { loadPushNotificationsEnabled } from '../storage/preferences'
import { loadHostCatalog } from '../transport/hosts/host-store'
import { loadHostCatalog } from '../host-catalog/host-store'
import { resolveHostIdForFingerprint } from './push-host-fingerprint'
import { readOrcaPushPayload, type OrcaPushPayload } from './push-payload'
import type { NotificationBehavior } from 'expo-notifications'
@@ -1,4 +1,4 @@
import { loadHostCatalog } from '../transport/hosts/host-store'
import { loadHostCatalog } from '../host-catalog/host-store'
import { deriveHostFingerprint } from './push-host-fingerprint'
import { dismissPresentedPushNotification } from './push-tray-dismissal'
import type { DismissNotificationEvent } from './desktop-notification-events'
@@ -1,5 +1,5 @@
import { useEffect, useRef, useState } from 'react'
import { loadHostCatalog } from '../transport/hosts/host-store'
import { loadHostCatalog } from '../host-catalog/host-store'
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
import { startRuntimeCapabilityProbe } from '../transport/connection/runtime-capability-probe'
import { useAllHostClients } from '../transport/connection/use-all-host-clients'
@@ -11,7 +11,7 @@ import {
readPairingKeychainItem,
resetPairingKeychainForTests,
writePairingKeychainItem
} from '../transport/hosts/pairing-keychain'
} from '../host-credentials/pairing-keychain'
const JOURNAL_STORAGE_KEY = 'orca:mobile-relay:pairing-journal:v1'
const JOURNAL_SECRET_KEY = 'orca.mobile-relay.pairing-journal.v1'
@@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import type { MobileRelayCredentialBundle } from '../transport/hosts/mobile-relay-credential-bundle'
import type { MobileRelayCredentialBundle } from '../host-credentials/mobile-relay-credential-bundle'
import { createMobileRelayPairingJournal } from './mobile-relay-pairing-journal'
import {
recoverMobileRelayPairing,
@@ -10,7 +10,7 @@ import type {
connectMobileRelayForPairing,
PairingCandidateClient
} from './mobile-relay-physical-client'
import type { HostProfile } from '../transport/hosts/host-profile'
import type { HostProfile } from '../host-catalog/host-profile'
import type { RpcResponse } from '../transport/rpc/rpc-wire-types'
import type { PairingOffer } from '../../../src/shared/remote-runtime/pairing/mobile-relay-pairing-offer'
@@ -4,13 +4,13 @@ import type {
PairingGetEndpointsResult
} from '../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import type { PairingRelay } from '../../../src/shared/remote-runtime/pairing/mobile-relay-pairing-offer'
import { loadHosts, savePairedHost } from '../transport/hosts/host-store'
import { loadHosts, savePairedHost } from '../host-catalog/host-store'
import {
promotePairingJournalCredential,
readMobileRelayCredentialBundle,
writeMobileRelayCredentialBundle,
type MobileRelayCredentialBundle
} from '../transport/hosts/mobile-relay-credential-bundle'
} from '../host-credentials/mobile-relay-credential-bundle'
import { resolvePairingInviteThroughDirector } from './mobile-relay-invite-director'
import type { MobileRelayPairingJournal } from './mobile-relay-pairing-journal'
import {
+1 -1
View File
@@ -3,7 +3,7 @@ import type {
MobileRelayEndpoint
} from '../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import type { MobileRelayPairingJournal } from './mobile-relay-pairing-journal'
import type { HostProfile } from '../transport/hosts/host-profile'
import type { HostProfile } from '../host-catalog/host-profile'
import type { PairingOffer } from '../../../src/shared/remote-runtime/pairing/mobile-relay-pairing-offer'
export function directHost(
+1 -1
View File
@@ -1,4 +1,4 @@
import '../transport/hosts/host-profile'
import '../host-catalog/host-profile'
import {
PairingOfferSchema,
type PairingOffer

Some files were not shown because too many files have changed in this diff Show More