From 5cbbadfb2b84a5478762cd50afa55b6c3d8da294 Mon Sep 17 00:00:00 2001 From: Jinwoo-H Date: Wed, 9 Sep 2026 03:12:13 -0400 Subject: [PATCH] refactor(mobile): drop the five adapter methods with no live caller - HostSessionNativeChatOperations sendMessage, respond and attachImage. Every shipped send path calls sendMobileNativeChatMessageWithOutcome or typeMobileNativeChatCommandWithOutcome directly, as on main. - HostWorkspaceCreationOperations createBlankWorkspace and createWorkspaceFromSource. use-new-workspace-create-submit imports createBlankWorkspace from the source module instead. With those two gone the native creation factory only spread the RPC operations and RpcWorkspaceCreationOperations only excluded them, so both collapse. The arg and result types that existed solely for the five methods go with them, as does the dead SessionTabsResult re-export. Each name was grepped against non-test, non-adapter callers before and after. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb --- .../host-session-native-chat-operations.ts | 23 ------------ .../session/host-session-tab-operations.ts | 4 --- .../mobile-session-route-parity.test.ts | 4 +-- ...ive-host-session-native-chat-operations.ts | 19 ---------- .../host-workspace-creation-operations.ts | 35 +------------------ ...tive-host-workspace-creation-operations.ts | 20 +---------- .../rpc-workspace-creation-operations.ts | 12 ++----- 7 files changed, 7 insertions(+), 110 deletions(-) diff --git a/mobile/src/session/host-session-native-chat-operations.ts b/mobile/src/session/host-session-native-chat-operations.ts index 419ee0307b3..cad0d769f85 100644 --- a/mobile/src/session/host-session-native-chat-operations.ts +++ b/mobile/src/session/host-session-native-chat-operations.ts @@ -4,7 +4,6 @@ import type { } from '../../../src/shared/native-chat-types' import type { MobileNativeChatSendOutcome } from './mobile-native-chat-send' import type { MobileNativeChatStreamFrame } from './mobile-native-chat-stream-frame' -import type { MobileImageSource } from './mobile-image-source-picker' export type HostSessionNativeChatTarget = { workspaceId: string @@ -29,10 +28,6 @@ export type HostSessionNativeChatImageAttachment = { previewUri: string } -export type HostSessionNativeChatImageAttachResult = - | { status: 'accepted'; attachment: HostSessionNativeChatImageAttachment } - | { status: 'cancelled' | 'permission-denied' | 'too-large' } - export type HostSessionNativeChatOperations = { /** Whether the serving host can read this workspace's agent transcripts. */ readability(workspaceId: string): Promise @@ -48,25 +43,7 @@ export type HostSessionNativeChatOperations = { limit: number, beforeOffset?: number ): Promise - sendMessage( - target: HostSessionNativeChatTarget, - text: string, - deadline?: number, - clearInputFirst?: boolean, - resolvedLaunchDraft?: { text: string; createdAt: number }, - typeCommand?: boolean - ): Promise - respond( - target: HostSessionNativeChatTarget, - text: string, - enter: boolean, - deadline?: number - ): Promise stop(target: HostSessionNativeChatTarget, deadline?: number): Promise - attachImage?( - target: HostSessionNativeChatTarget, - source: MobileImageSource - ): Promise pasteImages?( target: HostSessionNativeChatTarget, references: readonly string[], diff --git a/mobile/src/session/host-session-tab-operations.ts b/mobile/src/session/host-session-tab-operations.ts index b55c24c89a1..f755758af53 100644 --- a/mobile/src/session/host-session-tab-operations.ts +++ b/mobile/src/session/host-session-tab-operations.ts @@ -1,5 +1,3 @@ -import type { SessionTabsResult } from './mobile-session-route-types' - export type HostSessionTabCloseResult = | { outcome: 'closed' } | { outcome: 'refused'; reason: string | null } @@ -8,5 +6,3 @@ export type HostSessionTabOperations = { createBrowser(workspaceId: string, url: string): Promise<{ browserPageId?: string }> close(workspaceId: string, tabId: string): Promise } - -export type { SessionTabsResult } diff --git a/mobile/src/session/mobile-session-route-parity.test.ts b/mobile/src/session/mobile-session-route-parity.test.ts index 83cd257b671..3487cdc9627 100644 --- a/mobile/src/session/mobile-session-route-parity.test.ts +++ b/mobile/src/session/mobile-session-route-parity.test.ts @@ -79,7 +79,7 @@ const HEAD_TIMER_CREATION_SHA256 = '1a31b625e2174c3db77272249843196d2b6b06ab1e654a96d8f7858e3082e66b' const HEAD_TIMER_CLEANUP_SHA256 = 'c73f1d1c2cc89642f3d727d6f3b6b81860a9d6f34234541a2065ec3d1a8cd116' const HEAD_RUNTIME_STRING_SHA256 = - '390b26467725abc0514fdbbee2cba3ded2586d471438cea0b113182465484d5b' + 'f7ab0549d15dfa0b830bf916844816fa317581a129ace4e99917ddf9cfb3771e' const HEAD_HOST_JSX_SHA256 = '390405926b1695fa3a33686f0bc192b432f5468d8576499d7cafbb4922defbb5' const HEAD_LEAF_JSX_SHA256 = 'd5f1ef0db57c63eb3e4ee7c98e8483bc21882a151ce0ca24e42c7d1234e1dace' const HEAD_STYLE_REFERENCE_SHA256 = @@ -517,7 +517,7 @@ describe('mobile session route extraction parity', () => { it('preserves runtime strings, styles, and the expanded JSX tree', () => { const strings = readRuntimeStrings() - expect(strings).toHaveLength(593) + expect(strings).toHaveLength(592) expect(hash(strings)).toBe(HEAD_RUNTIME_STRING_SHA256) const jsx = readJsxFacts(readDefinitions()) expect(jsx.host).toHaveLength(124) diff --git a/mobile/src/session/native-host-session-native-chat-operations.ts b/mobile/src/session/native-host-session-native-chat-operations.ts index 9828df79fb1..0c02bef274b 100644 --- a/mobile/src/session/native-host-session-native-chat-operations.ts +++ b/mobile/src/session/native-host-session-native-chat-operations.ts @@ -4,7 +4,6 @@ import { isFloatingWorkspaceWorktreeId } from './floating-workspace' import { isMobileNativeChatTranscriptReadable } from './mobile-native-chat-eligibility' import { sendMobileNativeChatMessageWithOutcome, - typeMobileNativeChatCommandWithOutcome, type MobileNativeChatSendOutcome } from './mobile-native-chat-send' import { rankSuggestions } from './mobile-native-chat-autocomplete' @@ -63,24 +62,6 @@ export function nativeHostSessionNativeChatOperations( return { error: 'Transcript read failed' } } }, - sendMessage(target, text, deadline, clearInputFirst, resolvedLaunchDraft, typeCommand) { - if (typeCommand && target.terminalId) { - return typeMobileNativeChatCommandWithOutcome({ - client, - terminal: target.terminalId, - command: text, - resolvedLaunchDraft, - deadline, - ...(target.clientId - ? { mobileClient: { id: target.clientId, type: 'mobile' as const } } - : {}) - }) - } - return sendNative(target, text, true, client, deadline, clearInputFirst, resolvedLaunchDraft) - }, - respond(target, text, enter, deadline) { - return sendNative(target, text, enter, client, deadline) - }, stop(target, deadline) { // Escape must not carry Return: the extra newline submits whatever the agent // had parked on its input line. diff --git a/mobile/src/worktree/host-workspace-creation-operations.ts b/mobile/src/worktree/host-workspace-creation-operations.ts index 1780c009d70..c2a4434b561 100644 --- a/mobile/src/worktree/host-workspace-creation-operations.ts +++ b/mobile/src/worktree/host-workspace-creation-operations.ts @@ -8,20 +8,13 @@ import type { SparsePreset } from '../../../src/shared/worktree/create-types' import type { GitHubPrStartPoint } from '../../../src/shared/worktree/types' import type { RepoSlug } from '../../../src/shared/new-workspace/github-links' import type { SshConnectionState } from '../../../src/shared/ssh-types' -import type { WorktreeCreateResult } from '../tasks/worktree-create-retry' -import type { WorktreeCreateIdempotencyProbe } from '../tasks/worktree-create-idempotency-policy' import type { NewWorktreeRuntimeCapabilities } from '../tasks/worktree-create-capability' -import type { - MrStateFilter, - MobileComposerCreateSelection -} from '../tasks/mobile-composer-source-types' +import type { MrStateFilter } from '../tasks/mobile-composer-source-types' import type { ComposerHostedBase, ResolveComposerMrBaseArgs, ResolveComposerPrBaseArgs } from '../tasks/composer-source-base-resolve' -import type { WorkspaceAgentChoice } from '../tasks/workspace-agent-selection' -import type { WorkspaceCreateSetupDecision } from '../tasks/workspace-create-params' import type { SetupHookTrust } from '../tasks/setup-hook-trust' import type { ExecutionHostId } from '../../../src/shared/execution-host' import type { GitRemoteIdentity } from '../../../src/shared/git-remote-identity' @@ -56,28 +49,6 @@ export type NewWorkspaceRepoHooks = { setupTrust?: SetupHookTrust } -export type CreateBlankWorkspaceOperationArgs = { - repoId: string - baseName: string - agentChoice: WorkspaceAgentChoice - nameWasGenerated: boolean - comment: string | undefined - setupDecision: WorkspaceCreateSetupDecision - worktreeCreateIdempotency: WorktreeCreateIdempotencyProbe -} - -export type CreateWorkspaceFromSourceOperationArgs = { - selection: MobileComposerCreateSelection - targetRepoId: string - setupDecision: WorkspaceCreateSetupDecision - agentChoice: WorkspaceAgentChoice - workspaceName: string | undefined - note: string | undefined - sparseCheckout?: { directories: string[]; presetId?: string } - nameIsAutoManaged?: boolean - worktreeCreateIdempotency: WorktreeCreateIdempotencyProbe -} - export type HostWorkspaceCreationOperations = { listRepositories(): Promise readRetiredWorktreeNames(repoId: string): Promise @@ -129,8 +100,4 @@ export type HostWorkspaceCreationOperations = { }): Promise resolvePrBase(args: Omit): Promise resolveMrBase(args: Omit): Promise - createBlankWorkspace(args: CreateBlankWorkspaceOperationArgs): Promise - createWorkspaceFromSource( - args: CreateWorkspaceFromSourceOperationArgs - ): Promise } diff --git a/mobile/src/worktree/native-host-workspace-creation-operations.ts b/mobile/src/worktree/native-host-workspace-creation-operations.ts index 3f76cb4e8d1..97155e36f54 100644 --- a/mobile/src/worktree/native-host-workspace-creation-operations.ts +++ b/mobile/src/worktree/native-host-workspace-creation-operations.ts @@ -1,27 +1,9 @@ import type { RpcClient } from '../transport/rpc-client' -import { createBlankWorkspace } from '../tasks/blank-workspace-create' -import { createWorkspaceFromComposerSource } from '../tasks/source-workspace-create' import type { HostWorkspaceCreationOperations } from './host-workspace-creation-operations' import { rpcWorkspaceCreationOperations } from './rpc-workspace-creation-operations' export function nativeHostWorkspaceCreationOperations( client: RpcClient ): HostWorkspaceCreationOperations { - return { - ...rpcWorkspaceCreationOperations(client), - async createBlankWorkspace(args) { - return createBlankWorkspace({ - client, - ...args, - createdWithAgentId: args.agentChoice === 'blank' ? undefined : args.agentChoice - }) - }, - async createWorkspaceFromSource(args) { - return createWorkspaceFromComposerSource({ - client, - ...args, - agent: { choice: args.agentChoice } - }) - } - } + return rpcWorkspaceCreationOperations(client) } diff --git a/mobile/src/worktree/rpc-workspace-creation-operations.ts b/mobile/src/worktree/rpc-workspace-creation-operations.ts index 051deca5ba1..1b8e5f4e260 100644 --- a/mobile/src/worktree/rpc-workspace-creation-operations.ts +++ b/mobile/src/worktree/rpc-workspace-creation-operations.ts @@ -4,17 +4,11 @@ import type { HostWorkspaceCreationOperations } from './host-workspace-creation- import { nativeHostWorkspaceCreationReadOperations } from './native-host-workspace-creation-read-operations' import { nativeHostWorkspaceCreationSourceOperations } from './native-host-workspace-creation-source-operations' -export type RpcWorkspaceCreationOperations = Omit< - HostWorkspaceCreationOperations, - 'createBlankWorkspace' | 'createWorkspaceFromSource' -> - -/** Every workspace-creation call that is a plain desktop request, written against a bare request - * sender so any non-socket provider can supply one without a second copy. Creation itself is - * excluded: it needs connection state for its retry, which a sender cannot report. */ +/** Every workspace-creation call the screens make, written against a bare request sender so any + * non-socket provider can supply one without a second copy. */ export function rpcWorkspaceCreationOperations( client: RpcRequestSender -): RpcWorkspaceCreationOperations { +): HostWorkspaceCreationOperations { return { ...nativeHostWorkspaceCreationReadOperations(client), ...nativeHostWorkspaceCreationSourceOperations(client),