+
+
+ {t('auto.components.settings.cloudApi.secret.title', 'Copy your new key')}
+
+
+ {t(
+ 'auto.components.settings.cloudApi.secret.description',
+ '“{{value0}}” is ready to use.',
+ {
+ value0: created.key.name
+ }
+ )}
+
+
+
+
+
+
+
+ {t(
+ 'auto.components.settings.cloudApi.secret.onceTitle',
+ 'This is the only time Orca shows this key.'
+ )}
+ {' '}
+ {t(
+ 'auto.components.settings.cloudApi.secret.onceBody',
+ 'Store it in a password manager or your CI secrets now. If you lose it, revoke it and create a new one.'
+ )}
+
+ {draft.postResults === 'comment'
+ ? t(
+ 'auto.components.settings.cloudRoutines.editor.postCommentHint',
+ 'Posts a summary on the PR or issue that triggered it.'
+ )
+ : draft.postResults === 'pr'
+ ? t(
+ 'auto.components.settings.cloudRoutines.editor.postPrHint',
+ 'Pushes the agent’s changes to a branch and opens a pull request.'
+ )
+ : t(
+ 'auto.components.settings.cloudRoutines.editor.postNoneHint',
+ 'Results stay in the run history and the workspace.'
+ )}
+
+ {t(
+ 'auto.components.settings.cloudRoutines.editor.webhookNew',
+ 'After you save, Orca shows a secret URL once. Send a POST to it from CI, Zapier or any script to start a run; the JSON body is passed to the agent.'
+ )}
+
+ {t(
+ 'auto.components.settings.cloudRoutines.editor.webhookExisting',
+ 'POST to this routine’s secret URL to start a run. Orca never shows the full URL again; rotate it if you lost it or it leaked.'
+ )}
+
+
+ {t(
+ 'auto.components.settings.cloudRoutines.webhook.once',
+ 'Copy this URL now. Orca will not show it again, and anyone who has it can start this routine.'
+ )}
+
+
+
+ {t('auto.components.settings.cloudRoutines.webhook.title', 'Routine created')}
+
+
+ {t(
+ 'auto.components.settings.cloudRoutines.webhook.description',
+ 'Send a POST request to this URL to start a run. The request body is passed to the agent.'
+ )}
+
+
+
+
+ {CURL_EXAMPLE}
+
+
+
+
+
+ )
+}
diff --git a/src/renderer/src/components/settings/cloud-api/cloud-api-copy.ts b/src/renderer/src/components/settings/cloud-api/cloud-api-copy.ts
new file mode 100644
index 00000000000..a529a771afb
--- /dev/null
+++ b/src/renderer/src/components/settings/cloud-api/cloud-api-copy.ts
@@ -0,0 +1,170 @@
+// Wording for Orca Cloud API results: error codes from main become sentences people can act on.
+import { translate } from '@/i18n/i18n'
+import type { Translate } from '@/i18n/use-translate'
+import type {
+ CloudApiErrorCode,
+ CloudApiScope,
+ RoutineRunStatus,
+ RoutineRunTrigger
+} from '../../../../../shared/cloud-api/cloud-api-types'
+
+export function cloudApiErrorCopy(
+ error: CloudApiErrorCode,
+ t: Translate = translate,
+ options: { detail?: string; retryAfterSeconds?: number } = {}
+): string {
+ switch (error) {
+ case 'unconfigured':
+ return t(
+ 'auto.components.settings.cloudApi.error.unconfigured',
+ 'Orca Cloud is not available in this build.'
+ )
+ case 'signed-out':
+ return t(
+ 'auto.components.settings.cloudApi.error.signedOut',
+ 'Sign in to Orca to manage Orca Cloud access.'
+ )
+ case 'admin-required':
+ return t(
+ 'auto.components.settings.cloudApi.error.adminRequired',
+ 'Only an org owner or admin can do this.'
+ )
+ case 'forbidden':
+ return t(
+ 'auto.components.settings.cloudApi.error.forbidden',
+ 'Your account does not have permission to do this.'
+ )
+ case 'not-found':
+ return t(
+ 'auto.components.settings.cloudApi.error.notFound',
+ 'It no longer exists. Refresh to see the latest.'
+ )
+ case 'not-available':
+ return t(
+ 'auto.components.settings.cloudApi.error.notAvailable',
+ 'Orca Cloud does not offer this yet. Try again after the next update.'
+ )
+ case 'invalid-request':
+ return options.detail
+ ? t(
+ 'auto.components.settings.cloudApi.error.invalidWithDetail',
+ 'Orca Cloud rejected that: {{value0}}',
+ { value0: options.detail }
+ )
+ : t(
+ 'auto.components.settings.cloudApi.error.invalid',
+ 'Orca Cloud rejected that request. Check the fields and try again.'
+ )
+ case 'rate-limited':
+ return options.retryAfterSeconds
+ ? t(
+ 'auto.components.settings.cloudApi.error.rateLimitedFor',
+ 'Too many requests. Try again in {{value0}} seconds.',
+ { value0: String(options.retryAfterSeconds) }
+ )
+ : t(
+ 'auto.components.settings.cloudApi.error.rateLimited',
+ 'Too many requests. Try again in a minute.'
+ )
+ case 'network':
+ return t(
+ 'auto.components.settings.cloudApi.error.network',
+ 'Could not reach Orca Cloud. Check your connection and try again.'
+ )
+ case 'invalid-response':
+ return t(
+ 'auto.components.settings.cloudApi.error.invalidResponse',
+ 'Orca Cloud sent an answer this version of Orca does not understand. Update Orca and try again.'
+ )
+ case 'server':
+ return t(
+ 'auto.components.settings.cloudApi.error.server',
+ 'Orca Cloud had a problem. Try again in a moment.'
+ )
+ }
+}
+
+export function cloudApiScopeDescription(scope: CloudApiScope, t: Translate = translate): string {
+ switch (scope) {
+ case 'workspaces:read':
+ return t(
+ 'auto.components.settings.cloudApi.scope.workspacesRead',
+ 'List and inspect workspaces'
+ )
+ case 'workspaces:write':
+ return t(
+ 'auto.components.settings.cloudApi.scope.workspacesWrite',
+ 'Create, wake, sleep and delete workspaces'
+ )
+ case 'messages:write':
+ return t('auto.components.settings.cloudApi.scope.messagesWrite', 'Send prompts to agents')
+ case 'projects:read':
+ return t('auto.components.settings.cloudApi.scope.projectsRead', 'List projects')
+ case 'projects:write':
+ return t('auto.components.settings.cloudApi.scope.projectsWrite', 'Create and edit projects')
+ case 'routines:read':
+ return t(
+ 'auto.components.settings.cloudApi.scope.routinesRead',
+ 'List routines and their runs'
+ )
+ case 'routines:write':
+ return t(
+ 'auto.components.settings.cloudApi.scope.routinesWrite',
+ 'Create, edit and run routines'
+ )
+ case 'audit:read':
+ return t('auto.components.settings.cloudApi.scope.auditRead', 'Read the org audit log')
+ }
+}
+
+export function routineRunStatusLabel(status: RoutineRunStatus, t: Translate = translate): string {
+ switch (status) {
+ case 'queued':
+ return t('auto.components.settings.cloudRoutines.status.queued', 'Queued')
+ case 'starting':
+ return t('auto.components.settings.cloudRoutines.status.starting', 'Starting')
+ case 'running':
+ return t('auto.components.settings.cloudRoutines.status.running', 'Running')
+ case 'posting':
+ return t('auto.components.settings.cloudRoutines.status.posting', 'Posting results')
+ case 'succeeded':
+ return t('auto.components.settings.cloudRoutines.status.succeeded', 'Succeeded')
+ case 'failed':
+ return t('auto.components.settings.cloudRoutines.status.failed', 'Failed')
+ case 'cancelled':
+ return t('auto.components.settings.cloudRoutines.status.cancelled', 'Cancelled')
+ case 'timed_out':
+ return t('auto.components.settings.cloudRoutines.status.timedOut', 'Timed out')
+ }
+}
+
+export type RoutineRunTone = 'active' | 'success' | 'failure' | 'neutral'
+
+export function routineRunTone(status: RoutineRunStatus): RoutineRunTone {
+ if (status === 'succeeded') {
+ return 'success'
+ }
+ if (status === 'failed' || status === 'timed_out') {
+ return 'failure'
+ }
+ if (status === 'cancelled') {
+ return 'neutral'
+ }
+ return 'active'
+}
+
+export function routineRunTriggerLabel(
+ trigger: RoutineRunTrigger,
+ t: Translate = translate
+): string {
+ switch (trigger) {
+ case 'schedule':
+ return t('auto.components.settings.cloudRoutines.runTrigger.schedule', 'Schedule')
+ case 'github':
+ return t('auto.components.settings.cloudRoutines.runTrigger.github', 'GitHub')
+ case 'webhook':
+ return t('auto.components.settings.cloudRoutines.runTrigger.webhook', 'Webhook')
+ case 'manual':
+ return t('auto.components.settings.cloudRoutines.runTrigger.manual', 'Manual')
+ }
+}
diff --git a/src/renderer/src/components/settings/cloud-api/cloud-api-format.test.ts b/src/renderer/src/components/settings/cloud-api/cloud-api-format.test.ts
new file mode 100644
index 00000000000..5d5c88c81ae
--- /dev/null
+++ b/src/renderer/src/components/settings/cloud-api/cloud-api-format.test.ts
@@ -0,0 +1,85 @@
+import { describe, expect, it } from 'vitest'
+import { CLOUD_API_SCOPES } from '../../../../../shared/cloud-api/cloud-api-types'
+import { cloudApiErrorCopy, routineRunTone } from './cloud-api-copy'
+import {
+ describeRoutineTrigger,
+ formatCountdown,
+ formatKeyPrefix,
+ formatRunDuration,
+ presetForScopes,
+ scopesForPreset,
+ timeZoneOptions
+} from './cloud-api-format'
+
+const MEMBER = CLOUD_API_SCOPES.filter((scope) => scope !== 'audit:read')
+
+describe('scope presets', () => {
+ it('read only is every read scope the viewer may grant, never admin-only ones', () => {
+ expect(scopesForPreset('read', CLOUD_API_SCOPES)).toEqual([
+ 'workspaces:read',
+ 'projects:read',
+ 'routines:read'
+ ])
+ expect(scopesForPreset('full', MEMBER)).not.toContain('audit:read')
+ })
+
+ it('recognises presets from a scope list', () => {
+ expect(presetForScopes(['routines:read', 'workspaces:read', 'projects:read'], MEMBER)).toBe(
+ 'read'
+ )
+ expect(presetForScopes(MEMBER, MEMBER)).toBe('full')
+ expect(presetForScopes(['workspaces:read'], MEMBER)).toBe('custom')
+ })
+})
+
+describe('formatting', () => {
+ it('marks a key prefix as truncated', () => {
+ expect(formatKeyPrefix('orca_sk_Ab3x')).toBe('orca_sk_Ab3x…')
+ })
+
+ it('formats run durations and countdowns', () => {
+ expect(formatRunDuration(null)).toBe('—')
+ expect(formatRunDuration(38_000)).toBe('38s')
+ expect(formatRunDuration(252_000)).toBe('4m 12s')
+ expect(formatRunDuration(3_900_000)).toBe('1h 5m')
+ expect(formatCountdown(582_000)).toBe('9:42')
+ expect(formatCountdown(-5)).toBe('0:00')
+ })
+
+ it('summarises triggers', () => {
+ expect(describeRoutineTrigger({ kind: 'webhook', urlHint: null })).toBe('Webhook')
+ expect(
+ describeRoutineTrigger({ kind: 'github', events: ['pull_request.labeled'], labels: ['orca'] })
+ ).toBe('GitHub: PR labeled `orca`')
+ expect(
+ describeRoutineTrigger({
+ kind: 'schedule',
+ cron: '0 9 * * 1-5',
+ timezone: 'America/New_York'
+ })
+ ).toMatch(/^Weekdays at 9:00.*\(America\/New_York\)$/)
+ })
+
+ it('offers the local zone first', () => {
+ const zones = timeZoneOptions('Asia/Tokyo')
+ expect(zones[0]).toBe('Asia/Tokyo')
+ expect(zones).toContain('UTC')
+ })
+})
+
+describe('copy', () => {
+ it('words every error code and keeps server detail for validation errors', () => {
+ expect(cloudApiErrorCopy('admin-required')).toMatch(/owner or admin/)
+ expect(
+ cloudApiErrorCopy('invalid-request', undefined, { detail: 'name: Too small' })
+ ).toContain('name: Too small')
+ expect(cloudApiErrorCopy('rate-limited', undefined, { retryAfterSeconds: 7 })).toContain('7')
+ })
+
+ it('tones run statuses', () => {
+ expect(routineRunTone('succeeded')).toBe('success')
+ expect(routineRunTone('timed_out')).toBe('failure')
+ expect(routineRunTone('posting')).toBe('active')
+ expect(routineRunTone('cancelled')).toBe('neutral')
+ })
+})
diff --git a/src/renderer/src/components/settings/cloud-api/cloud-api-format.ts b/src/renderer/src/components/settings/cloud-api/cloud-api-format.ts
new file mode 100644
index 00000000000..26f77050e28
--- /dev/null
+++ b/src/renderer/src/components/settings/cloud-api/cloud-api-format.ts
@@ -0,0 +1,156 @@
+import { translate } from '@/i18n/i18n'
+import type { Translate } from '@/i18n/use-translate'
+import { formatUiRelativeTime } from '@/i18n/relative-time-format'
+import { formatUiAutomationSchedule } from '@/components/automations/automation-schedule-label'
+import {
+ CLOUD_API_ADMIN_SCOPES,
+ CLOUD_API_READ_SCOPES,
+ type CloudApiScope,
+ type RoutineGithubEvent,
+ type RoutineTrigger
+} from '../../../../../shared/cloud-api/cloud-api-types'
+
+export type ScopePreset = 'read' | 'full' | 'custom'
+
+/** Read only = every *:read scope the viewer may grant; Full = everything they may grant. */
+export function scopesForPreset(
+ preset: Exclude,
+ available: readonly CloudApiScope[]
+): CloudApiScope[] {
+ if (preset === 'full') {
+ return [...available]
+ }
+ return available.filter((scope) => CLOUD_API_READ_SCOPES.includes(scope))
+}
+
+export function presetForScopes(
+ scopes: readonly CloudApiScope[],
+ available: readonly CloudApiScope[]
+): ScopePreset {
+ const set = new Set(scopes)
+ const same = (other: readonly CloudApiScope[]): boolean =>
+ other.length === set.size && other.every((scope) => set.has(scope))
+ if (same(scopesForPreset('full', available))) {
+ return 'full'
+ }
+ if (same(scopesForPreset('read', available))) {
+ return 'read'
+ }
+ return 'custom'
+}
+
+export function isAdminScope(scope: CloudApiScope): boolean {
+ return CLOUD_API_ADMIN_SCOPES.includes(scope)
+}
+
+/** "orca_sk_Ab3x…" — the stored prefix plus an ellipsis so nobody mistakes it for the secret. */
+export function formatKeyPrefix(prefix: string): string {
+ return `${prefix}…`
+}
+
+export function formatRelativeFromNow(timestamp: number, now: number, intlLocale?: string): string {
+ return formatUiRelativeTime(timestamp - now, intlLocale)
+}
+
+export function formatAbsoluteTime(timestamp: number, intlLocale?: string): string {
+ return new Intl.DateTimeFormat(intlLocale, { dateStyle: 'medium', timeStyle: 'short' }).format(
+ timestamp
+ )
+}
+
+export function formatRunDuration(ms: number | null, t: Translate = translate): string {
+ if (ms === null) {
+ return '—'
+ }
+ const seconds = Math.round(ms / 1000)
+ if (seconds < 60) {
+ return t('auto.components.settings.cloudRoutines.duration.seconds', '{{value0}}s', {
+ value0: String(seconds)
+ })
+ }
+ const minutes = Math.floor(seconds / 60)
+ if (minutes < 60) {
+ return t('auto.components.settings.cloudRoutines.duration.minutes', '{{value0}}m {{value1}}s', {
+ value0: String(minutes),
+ value1: String(seconds % 60)
+ })
+ }
+ return t('auto.components.settings.cloudRoutines.duration.hours', '{{value0}}h {{value1}}m', {
+ value0: String(Math.floor(minutes / 60)),
+ value1: String(minutes % 60)
+ })
+}
+
+export function githubEventLabel(event: RoutineGithubEvent, t: Translate = translate): string {
+ switch (event) {
+ case 'pull_request.opened':
+ return t('auto.components.settings.cloudRoutines.event.prOpened', 'PR opened')
+ case 'pull_request.labeled':
+ return t('auto.components.settings.cloudRoutines.event.prLabeled', 'PR labeled')
+ case 'pull_request.synchronize':
+ return t('auto.components.settings.cloudRoutines.event.prPushed', 'PR updated (new commits)')
+ case 'issues.opened':
+ return t('auto.components.settings.cloudRoutines.event.issueOpened', 'Issue opened')
+ case 'issues.labeled':
+ return t('auto.components.settings.cloudRoutines.event.issueLabeled', 'Issue labeled')
+ case 'issue_comment.created':
+ return t('auto.components.settings.cloudRoutines.event.comment', 'New comment')
+ }
+}
+
+/** One-line summary for lists: "Weekdays at 9:00 AM (America/New_York)", "GitHub: PR labeled `orca`". */
+export function describeRoutineTrigger(
+ trigger: RoutineTrigger,
+ t: Translate = translate,
+ intlLocale?: string
+): string {
+ if (trigger.kind === 'schedule') {
+ return t(
+ 'auto.components.settings.cloudRoutines.trigger.scheduleSummary',
+ '{{value0}} ({{value1}})',
+ {
+ value0: formatUiAutomationSchedule(trigger.cron, t, intlLocale),
+ value1: trigger.timezone
+ }
+ )
+ }
+ if (trigger.kind === 'webhook') {
+ return t('auto.components.settings.cloudRoutines.trigger.webhook', 'Webhook')
+ }
+ const events = trigger.events.map((event) => githubEventLabel(event, t)).join(', ')
+ const labels = trigger.labels?.length
+ ? ` ${trigger.labels.map((label) => `\`${label}\``).join(', ')}`
+ : ''
+ return t('auto.components.settings.cloudRoutines.trigger.githubSummary', 'GitHub: {{value0}}', {
+ value0: `${events}${labels}`
+ })
+}
+
+export function localTimeZone(): string {
+ try {
+ return Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC'
+ } catch {
+ return 'UTC'
+ }
+}
+
+/** Every zone the runtime knows, with the local zone and UTC guaranteed present. */
+export function timeZoneOptions(local: string = localTimeZone()): string[] {
+ let zones: string[] = []
+ try {
+ zones =
+ (Intl as unknown as { supportedValuesOf?: (key: string) => string[] }).supportedValuesOf?.(
+ 'timeZone'
+ ) ?? []
+ } catch {
+ zones = []
+ }
+ const all = new Set([local, 'UTC', ...zones])
+ return [...all].sort((a, b) => (a === local ? -1 : b === local ? 1 : a.localeCompare(b)))
+}
+
+/** "9:42" — minutes and seconds left, never negative. */
+export function formatCountdown(ms: number): string {
+ const total = Math.max(0, Math.ceil(ms / 1000))
+ return `${Math.floor(total / 60)}:${String(total % 60).padStart(2, '0')}`
+}
diff --git a/src/renderer/src/components/settings/cloud-api/cloud-api-parts.tsx b/src/renderer/src/components/settings/cloud-api/cloud-api-parts.tsx
new file mode 100644
index 00000000000..201b7424c55
--- /dev/null
+++ b/src/renderer/src/components/settings/cloud-api/cloud-api-parts.tsx
@@ -0,0 +1,257 @@
+import { useEffect, useRef, useState } from 'react'
+import { AlertCircle, Check, Copy, RefreshCw } from 'lucide-react'
+import { Button } from '@/components/ui/button'
+import { Label } from '@/components/ui/label'
+import { useTranslate } from '@/i18n/use-translate'
+import { cn } from '@/lib/utils'
+import type { RoutineRunStatus } from '../../../../../shared/cloud-api/cloud-api-types'
+import { routineRunStatusLabel, routineRunTone, type RoutineRunTone } from './cloud-api-copy'
+
+const COPIED_RESET_MS = 2000
+
+async function writeClipboard(value: string): Promise {
+ if (window.api?.ui?.writeClipboardText) {
+ await window.api.ui.writeClipboardText(value)
+ return
+ }
+ await navigator.clipboard.writeText(value)
+}
+
+/** Copy with a visible + announced "Copied" state; the label names what is copied for screen readers. */
+export function CopyValueButton({
+ value,
+ label,
+ variant = 'outline',
+ size = 'xs',
+ className,
+ onCopied
+}: {
+ value: string
+ /** e.g. "Copy MCP URL". */
+ label: string
+ variant?: 'outline' | 'ghost' | 'default'
+ size?: 'xs' | 'sm'
+ className?: string
+ onCopied?: () => void
+}): React.JSX.Element {
+ const t = useTranslate()
+ const [state, setState] = useState<'idle' | 'copied' | 'failed'>('idle')
+ const timer = useRef | null>(null)
+ useEffect(
+ () => () => {
+ if (timer.current) {
+ clearTimeout(timer.current)
+ }
+ },
+ []
+ )
+ const copy = async (): Promise => {
+ try {
+ await writeClipboard(value)
+ setState('copied')
+ onCopied?.()
+ } catch {
+ setState('failed')
+ }
+ if (timer.current) {
+ clearTimeout(timer.current)
+ }
+ timer.current = setTimeout(() => setState('idle'), COPIED_RESET_MS)
+ }
+ return (
+ <>
+
+
+ {state === 'copied'
+ ? t('auto.components.settings.cloudApi.copiedAnnouncement', 'Copied to clipboard')
+ : state === 'failed'
+ ? t('auto.components.settings.cloudApi.copyFailedAnnouncement', 'Could not copy')
+ : ''}
+
+ >
+ )
+}
+
+export function CloudApiErrorNotice({
+ message,
+ onRetry,
+ className
+}: {
+ message: string
+ onRetry?: () => void
+ className?: string
+}): React.JSX.Element {
+ const t = useTranslate()
+ return (
+
+
+
{message}
+ {onRetry ? (
+
+ ) : null}
+
+ )
+}
+
+/** Placeholder rows while a list loads; static under reduced motion. */
+export function CloudApiSkeletonRows({
+ rows = 3,
+ label
+}: {
+ rows?: number
+ label: string
+}): React.JSX.Element {
+ return (
+