refactor(mobile): ask these call sites for a request port, not a whole client

The migration widened seven files from `Pick<RpcClient, 'sendRequest'>` to the
full `RpcClient` for no reason: a bound operation's `request` takes
`UnvalidatedRpcRequestPort`, which is structurally that same single member.
Name the port instead, so the signature says what each function actually needs
and a caller holding only a port still satisfies it.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
This commit is contained in:
Jinwoo-H
2026-09-14 21:05:25 -04:00
parent 82d77103e0
commit 16c9c232fc
7 changed files with 25 additions and 18 deletions
@@ -16,7 +16,7 @@ import { ChevronLeft, RefreshCw } from 'lucide-react-native'
import { colors } from '../theme/mobile-theme'
import { useHostClient } from '../transport/client-context'
import type { RpcSuccess } from '../transport/types'
import type { RpcClient } from '../transport/rpc-client'
import type { UnvalidatedRpcRequestPort } from '../transport/unvalidated-rpc-request-port'
import { readMobileRuntimeHostPlatform } from '../transport/mobile-runtime-host-platform'
import { getWorktreeLabel } from '../session/worktree-label'
import {
@@ -369,7 +369,7 @@ export function MobileAgentSessionHistoryPanel({
const EMPTY_SESSIONS: AiVaultSession[] = []
const EMPTY_ISSUES: { agent: AiVaultSession['agent']; path: string; message: string }[] = []
async function loadMobileResumeMetadata(client: RpcClient): Promise<{
async function loadMobileResumeMetadata(client: UnvalidatedRpcRequestPort): Promise<{
repos: MobileAiVaultResumeRepo[]
folderWorkspaces: MobileAiVaultResumeFolderWorkspace[]
projectGroups: MobileAiVaultResumeProjectGroup[]
+11 -6
View File
@@ -1,5 +1,5 @@
import type { RuntimeSpeechSetupState } from '../../../src/shared/runtime-types'
import type { RpcClient } from '../transport/rpc-client'
import type { UnvalidatedRpcRequestPort } from '../transport/unvalidated-rpc-request-port'
import type { RpcResponse } from '../transport/types'
import { interpretOrThrowRefusalMessage } from '../transport/rpc-refusal-message'
import { LogicalClientCutoverError } from '../transport/stable-logical-rpc-client'
@@ -40,7 +40,9 @@ export function isDictationSetupRequiredError(message: string): boolean {
return SETUP_REQUIRED_CODES.has(message) || message.startsWith('voice_model_not_ready:')
}
export async function fetchDictationSetup(client: RpcClient): Promise<MobileSpeechSetup> {
export async function fetchDictationSetup(
client: UnvalidatedRpcRequestPort
): Promise<MobileSpeechSetup> {
const reply = await requestDictationSetupReply(client)
if (isLegacyDesktopSpeechSetupReply(reply)) {
throw new Error(LEGACY_DESKTOP_SPEECH_SETUP_MESSAGE)
@@ -52,7 +54,7 @@ export async function fetchDictationSetup(client: RpcClient): Promise<MobileSpee
) as MobileSpeechSetup
}
async function requestDictationSetupReply(client: RpcClient): Promise<RpcResponse> {
async function requestDictationSetupReply(client: UnvalidatedRpcRequestPort): Promise<RpcResponse> {
try {
return await dictationSetupRead.request(client, null)
} catch (error) {
@@ -65,7 +67,10 @@ async function requestDictationSetupReply(client: RpcClient): Promise<RpcRespons
}
}
export async function downloadDictationModel(client: RpcClient, modelId: string): Promise<void> {
export async function downloadDictationModel(
client: UnvalidatedRpcRequestPort,
modelId: string
): Promise<void> {
const reply = await dictationModelDownload.request(client, { modelId })
interpretOrThrowRefusalMessage(
() => dictationModelDownload.interpret(reply),
@@ -74,7 +79,7 @@ export async function downloadDictationModel(client: RpcClient, modelId: string)
}
export async function deleteDictationModel(
client: RpcClient,
client: UnvalidatedRpcRequestPort,
modelId: string
): Promise<MobileSpeechSetup> {
const reply = await dictationModelDelete.request(client, { modelId })
@@ -86,7 +91,7 @@ export async function deleteDictationModel(
}
export async function setDictationConfig(
client: RpcClient,
client: UnvalidatedRpcRequestPort,
params: { enabled?: boolean; modelId?: string; dictationMode?: 'toggle' | 'hold' }
): Promise<MobileSpeechSetup> {
const reply = await dictationConfigWrite.request(client, params)
@@ -13,7 +13,7 @@ import type {
MobilePushRegisterResult
} from '../../../src/shared/mobile-push-contract'
import { NOTIFICATIONS_REMOTE_PUSH_RUNTIME_CAPABILITY } from '../../../src/shared/protocol-version'
import type { RpcClient } from '../transport/rpc-client'
import type { UnvalidatedRpcRequestPort } from '../transport/unvalidated-rpc-request-port'
import { startRuntimeCapabilityProbe } from '../transport/runtime-capability-probe'
import { pushRouteRegister, pushRouteUnregister } from './mobile-push-registration-operations'
import {
@@ -26,7 +26,7 @@ import { addPushTokenListener, getDevicePushToken, type MobilePushToken } from '
export const NOTIFICATIONS_REMOTE_PUSH_CAPABILITY = NOTIFICATIONS_REMOTE_PUSH_RUNTIME_CAPABILITY
type PushClient = RpcClient
type PushClient = UnvalidatedRpcRequestPort
const REQUEST_TIMEOUT_MS = 5_000
const REMOVAL_TIMEOUT_MS = 2_000
@@ -1,4 +1,4 @@
import type { RpcClient } from '../transport/rpc-client'
import type { UnvalidatedRpcRequestPort } from '../transport/unvalidated-rpc-request-port'
import {
fetchDictationSetup,
setDictationConfig,
@@ -7,7 +7,9 @@ import {
} from '../dictation/mobile-dictation-setup'
import type { VoiceSettingsOperations } from './voice-settings-operations'
export function nativeVoiceSettingsOperations(client: RpcClient): VoiceSettingsOperations {
export function nativeVoiceSettingsOperations(
client: UnvalidatedRpcRequestPort
): VoiceSettingsOperations {
return {
load: () => fetchDictationSetup(client),
configure: (params) => setDictationConfig(client, params),
@@ -1,5 +1,5 @@
import { isTerminalQueryReply } from '../../../src/shared/terminal-query-reply'
import type { RpcClient } from '../transport/rpc-client'
import type { UnvalidatedRpcRequestPort } from '../transport/unvalidated-rpc-request-port'
import { terminalInputSend } from './mobile-terminal-operations'
type TerminalSubscriptionRegistry = {
@@ -8,7 +8,7 @@ type TerminalSubscriptionRegistry = {
type MobileTerminalQueryReplyOptions = {
bytes: string
client: RpcClient | null
client: UnvalidatedRpcRequestPort | null
clientId: string | null
connected: boolean
handle: string
@@ -2,11 +2,11 @@ import { reportWorkerTerminalUserInput } from './worker-terminal-takeover-report
import { getTerminalLiveAccessoryRawSendTarget } from './terminal-live-accessory-raw-send-target'
import { buildTerminalSendParams, TERMINAL_INPUT_SEND_OPTIONS } from './terminal-send-request'
import { terminalInputSend } from './mobile-terminal-operations'
import type { RpcClient } from '../transport/rpc-client'
import type { UnvalidatedRpcRequestPort } from '../transport/unvalidated-rpc-request-port'
import type { ConnectionState } from '../transport/types'
type TerminalLiveAccessoryRawSendArgs = {
readonly client: RpcClient | null
readonly client: UnvalidatedRpcRequestPort | null
readonly targetHandle: string
readonly activeHandle: string | null
readonly activeSessionTabType: string | null
@@ -1,7 +1,7 @@
import type { RpcClient } from '../transport/rpc-client'
import type { UnvalidatedRpcRequestPort } from '../transport/unvalidated-rpc-request-port'
import { workerTerminalTakeoverReport } from './mobile-terminal-operations'
type ReportClient = RpcClient
type ReportClient = UnvalidatedRpcRequestPort
const REPORT_INTERVAL_MS = 30_000
const REPORT_RETRY_DELAY_MS = 250
let reportsByClient = new WeakMap<ReportClient, Map<string, number>>()