Files
orca/mobile/src/session/mobile-session-quick-command-launch.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

44 lines
1.5 KiB
TypeScript

import { buildMobileQuickCommandLaunch } from '../terminal/quick-commands'
import type { MobileQuickCommandLaunch } from '../terminal/quick-commands'
import { triggerError } from '../platform/haptics'
import type { TerminalQuickCommand } from '../../../src/shared/terminal-quick-command-types'
import type { MobileNewTabAgentOption } from './mobile-new-tab-agent-options'
import type { MobileSessionAttachmentsModel } from './use-mobile-session-attachments'
/** Runs a saved quick command through the session's ordinary terminal creator. */
export function launchMobileSessionQuickCommand(
scope: Pick<
MobileSessionAttachmentsModel,
| 'client'
| 'connState'
| 'creatingTerminalRef'
| 'creatingBrowser'
| 'creatingMarkdown'
| 'showToast'
>,
createTerminal: (
agent?: MobileNewTabAgentOption['agent'],
options?: MobileQuickCommandLaunch['options'] & { errorToast?: string }
) => Promise<unknown>,
command: TerminalQuickCommand
): boolean {
if (
!scope.client ||
scope.connState !== 'connected' ||
scope.creatingTerminalRef.current ||
scope.creatingBrowser ||
scope.creatingMarkdown
) {
return false
}
const launch = buildMobileQuickCommandLaunch(command)
if (!launch) {
triggerError()
scope.showToast('Edit this quick command before running it', 1800)
return false
}
const label = command.label.trim() || 'Quick command'
void createTerminal(launch.agent, { ...launch.options, errorToast: `Couldn't run ${label}` })
return true
}