From 808e433b82da14d290ad62c54167cd47ffc50464 Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Wed, 4 Nov 2026 00:12:34 -0800 Subject: [PATCH] fix(mobile): let folder repo review actions launch without a Git verdict Repo-backed folder workspaces have repo::path ids, so the mobile review-action gate sent git.status for them and refused the launch. The gate now reuses the repo the launch context already resolved and, like desktop's isFolderRepo check, skips the verdict for folder repos; Git workspaces still need a fresh 'none'. --- .../mobile-runtime-repo-operations.ts | 2 ++ .../mobile-review-action-rebase-check.ts | 11 ++++++--- .../review/pr-ai-triage-launch.ts | 24 ++++++++++--------- .../review/use-mobile-pr-ai-triage.ts | 7 ++++-- 4 files changed, 28 insertions(+), 16 deletions(-) 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)