diff --git a/mobile/src/session/agent-launch/mobile-runtime-repo-operations.ts b/mobile/src/session/agent-launch/mobile-runtime-repo-operations.ts index cb885ee3fc6..121c58461f1 100644 --- a/mobile/src/session/agent-launch/mobile-runtime-repo-operations.ts +++ b/mobile/src/session/agent-launch/mobile-runtime-repo-operations.ts @@ -1,3 +1,4 @@ +import type { RepoKind } from '../../../../src/shared/repo-types' import { bindDeferredRpcOperation, defineRpcOperation } from '../../transport/rpc/rpc-operation' import { rpcResultVariant } from '../../transport/rpc/rpc-operation-result-reader' import '../../terminal/terminal-reply-schema' @@ -11,6 +12,7 @@ import '../../terminal/quick-commands/mobile-quick-command-reply-schema' import '../../files/workspace-file-paths-reply-schema' export type MobileRuntimeRepoSummary = { + kind?: RepoKind id: string connectionId?: string | null executionHostId?: string | null diff --git a/mobile/src/session/mobile-review-action-rebase-check.ts b/mobile/src/session/mobile-review-action-rebase-check.ts index 31e703455c6..77cc58ffdc3 100644 --- a/mobile/src/session/mobile-review-action-rebase-check.ts +++ b/mobile/src/session/mobile-review-action-rebase-check.ts @@ -1,4 +1,6 @@ -import type { RpcOperationSender } from '../transport/rpc-operation-sender' +import type { RpcOperationSender } from '../transport/rpc/rpc-operation-sender' +import type { MobileRuntimeRepoSummary } from './agent-launch/mobile-runtime-repo-operations' +import { isFolderRepo } from '../../../src/shared/repo-kind' import { gitRebaseVerdictRead } from '../source-control/mobile-git-read-operations' import { translate } from '../i18n/mobile-i18n' import { workspaceKindForWorktreeId } from '../../../src/shared/workspace-launch-kind' @@ -11,9 +13,12 @@ export type MobileReviewActionAdmission = { ok: true } | { ok: false; message: s */ export async function confirmNoRebaseBeforeMobileReviewAction( client: RpcOperationSender, - worktreeId: string + worktreeId: string, + /** The repo the launch resolved for this workspace (host ambiguity already settled). */ + repo: Pick | null ): Promise { - if (workspaceKindForWorktreeId(worktreeId) !== 'git-worktree') { + // Folders, native or repo-backed, run no Git operation, so their review launches are unchanged. + if (workspaceKindForWorktreeId(worktreeId) !== 'git-worktree' || (repo && isFolderRepo(repo))) { return { ok: true } } let verdict: 'active' | 'none' | 'unverifiable' | undefined diff --git a/mobile/src/source-control/review/pr-ai-triage-launch.ts b/mobile/src/source-control/review/pr-ai-triage-launch.ts index 48cdb6d88e1..a79acd22c97 100644 --- a/mobile/src/source-control/review/pr-ai-triage-launch.ts +++ b/mobile/src/source-control/review/pr-ai-triage-launch.ts @@ -6,7 +6,8 @@ import { } from '../../session/agent-launch/mobile-existing-agent-launch' import { hostRefusesOtherRuntimeWorkspace, - loadMobileAgentLaunchContext + loadMobileAgentLaunchContext, + type MobileAgentLaunchContext } from '../../session/agent-launch/mobile-new-tab-agent-loader' import { resolveMobileSourceControlLaunchAgent } from './mobile-source-control-launch-agent' import { projectSourceControlActionLaunch } from '../../../../src/shared/source-control/ai/recipes/source-control-action-launch-preferences' @@ -41,7 +42,9 @@ export async function launchAgentWithPrompt(args: { prompt: string launchSource: string /** Runs after agent resolution so its owner-side check is fresh at launch; a refusal starts nothing. */ - admitLaunch?: () => Promise<{ ok: true } | { ok: false; message: string }> + admitLaunch?: ( + context: Pick + ) => Promise<{ ok: true } | { ok: false; message: string }> }): Promise { if (!supportsMobileExistingAgentLaunch(args.hostCapabilities)) { return { @@ -53,15 +56,14 @@ export async function launchAgentWithPrompt(args: { } } let resolved + let context: MobileAgentLaunchContext try { - resolved = resolveMobileSourceControlLaunchAgent( - await loadMobileAgentLaunchContext({ - client: args.client, - worktreeId: args.worktreeId, - hostRefusesOtherRuntime: hostRefusesOtherRuntimeWorkspace(args.hostCapabilities) - }), - args.actionId - ) + context = await loadMobileAgentLaunchContext({ + client: args.client, + worktreeId: args.worktreeId, + hostRefusesOtherRuntime: hostRefusesOtherRuntimeWorkspace(args.hostCapabilities) + }) + resolved = resolveMobileSourceControlLaunchAgent(context, args.actionId) } catch (error) { const message = error instanceof Error ? error.message.trim() : '' return { @@ -88,7 +90,7 @@ export async function launchAgentWithPrompt(args: { ) } } - const admission = args.admitLaunch ? await args.admitLaunch() : null + const admission = args.admitLaunch ? await args.admitLaunch(context) : null if (admission && !admission.ok) { return { kind: 'not-started', message: admission.message } } diff --git a/mobile/src/source-control/review/use-mobile-pr-ai-triage.ts b/mobile/src/source-control/review/use-mobile-pr-ai-triage.ts index 8133df8903d..c8fae90cf51 100644 --- a/mobile/src/source-control/review/use-mobile-pr-ai-triage.ts +++ b/mobile/src/source-control/review/use-mobile-pr-ai-triage.ts @@ -4,7 +4,7 @@ import type { RpcClient } from '../../transport/rpc/rpc-client-contract' import { triggerError, triggerSuccess } from '../../platform/haptics' import { useMobileTranslation } from '../../i18n/use-mobile-translation' import { launchAgentWithPrompt, promptedLaunchNotice } from './pr-ai-triage-launch' -import { confirmNoRebaseBeforeMobileReviewAction } from './mobile-review-action-rebase-check' +import { confirmNoRebaseBeforeMobileReviewAction } from '../../session/mobile-review-action-rebase-check' import { resolveMobileAgentLaunchAvailability, type MobileAgentLaunchAvailability @@ -102,7 +102,10 @@ export function useMobilePrAiTriage(input: Input) { ...TRIAGE_LAUNCH[key], // Review actions need the desktop rule: no launch while the owner is rebasing. ...(scope === 'review' - ? { admitLaunch: () => confirmNoRebaseBeforeMobileReviewAction(client, worktreeId) } + ? { + admitLaunch: ({ repo }) => + confirmNoRebaseBeforeMobileReviewAction(client, worktreeId, repo) + } : {}) }) const notice = promptedLaunchNotice(result, workspaceLabel)