Files
orca/mobile/src/session/mobile-chat-fork-create-feedback.ts
T
Brennan Benson 64e544a442 feat(mobile): Resume in New CLI from a phone chat tab (#29783)
* feat(mobile): Resume in New CLI from a phone chat tab

A chat tab on the phone had only Close in its long-press menu, so a chat
that would not load left no way to reach its conversation. The phone now
offers Resume in New CLI, like the desktop tab menu: the chat's host
prepares the conversation and the phone opens a copy in a new terminal tab.

The resume and fork startup builders move to src/shared so the desktop and
the phone build the same command.

* test(mobile): type the fake terminal create instead of casting its calls

* fix(mobile): pass the host's fork source as is; match the quoted args in the test

* test(mobile): give the fake host client the untyped mock the other client fakes use

* style: format the shared resume builder and phone fork files

* Fix mobile chat CLI fork creation on owning host

* Fix mobile chat fork lint and split create owner helpers

* Keep chat fork beside phone anchor across tab groups

* Combine mobile terminal runtime type imports

* Repair mobile create CI contracts after chat fork extraction

* Classify chat fork preflight refusals and preserve mobile create recordings

* Keep route-owned create cleanup quiet after unmount

* Preserve typed runtime repair refusal in chat fork preflight

* Preserve checked store through mobile chat fork preflight

* Register mobile chat fork runtime fixture before test setup

* Remove unused mobile create recording value

* style(mobile): format the chat fork create files; move fork reply messages into the fork feedback module

Formatting pushed the create hook past its line limit, so the fork-only reply message, partial-success warning and host capability check now live beside the other fork messages. Same order and copy as before.

* Keep quick command mutation aligned with formatted request

* Keep mobile chat CLI forks in terminal view

* Pass mobile chat resolution its existing controller arguments

* Match the mobile create fixture mock layout

* Keep mobile chat CLI forks open when placement is unavailable

* Brace placement contract fixture checks

* test(mobile): keep the prompt controller mock under its line limit after the main merge

* Expose pane admission in the runtime test fixture type

* Complete the chat fork contract controller fixture
2026-10-16 18:10:24 -07:00

49 lines
2.5 KiB
TypeScript

import { isRpcDeliveryUnknown } from '../transport/rpc-delivery-ambiguity'
import { isLogicalClientCutoverError } from '../transport/stable-logical-rpc-client'
import { RpcIncompatibleReplyError } from '../transport/rpc-incompatible-reply-error'
import { PROJECT_RUNTIME_REPAIR_REQUIRED_CODE } from '../../../src/shared/project-runtime-repair-message'
import { SESSION_TABS_CHAT_FORK_CLI_RUNTIME_CAPABILITY } from '../../../src/shared/session-tabs-runtime-capabilities'
import type { RpcResponse } from '../transport/types'
import { createdTerminalDesktopWarning } from './session-write-reply-schema'
export function hostSupportsMobileChatFork(
hostCapabilities: readonly string[] | undefined
): boolean {
return hostCapabilities?.includes(SESSION_TABS_CHAT_FORK_CLI_RUNTIME_CAPABILITY) === true
}
/** A chat fork's create reply: why the host refused it, a partial-success warning, or nothing. */
export function mobileChatForkCreateReplyMessage(
agentName: string,
response: RpcResponse
): string | null {
if (!response.ok) {
return mobileChatForkRefusalMessage(agentName, response.error.code)
}
return createdTerminalDesktopWarning(response.result)
? `${agentName} opened in a CLI, but its desktop tab could not be shown. Check open tabs on the host before retrying.`
: null
}
export function mobileChatForkRefusalMessage(agentName: string, code: string): string {
const guidance =
code === 'chat_fork_anchor_changed'
? 'Select a tab and try again.'
: code === 'chat_fork_runtime_incompatible'
? 'Open the chat in a native workspace on its host and try again.'
: code === 'chat_fork_source_unavailable'
? "Check that the chat has a saved conversation and review the agent's command and settings on the host, then try again."
: code === PROJECT_RUNTIME_REPAIR_REQUIRED_CODE
? 'Review Project Runtime settings on the host and restore native Windows execution for this chat, then try again.'
: 'Reconnect and check open tabs on the host before retrying.'
return `Could not open ${agentName} in a new CLI. ${guidance}`
}
export function mobileChatForkRequestFailureMessage(agentName: string, error: unknown): string {
return isRpcDeliveryUnknown(error) ||
isLogicalClientCutoverError(error) ||
error instanceof RpcIncompatibleReplyError
? `${agentName} may have opened. Reconnect and check open tabs on the host before retrying.`
: `Could not open ${agentName} in a new CLI. Check the chat and host settings, then try again.`
}