refactor: organize provider and repository settings owners (#40059)

* refactor: organize provider and repository settings owners

* refactor: define repository action recipe specialization once
This commit is contained in:
Neil
2026-11-08 17:49:14 -08:00
committed by GitHub
parent 7d5e5dc2ac
commit 60df70e7cd
102 changed files with 1124 additions and 1161 deletions
+1 -1
View File
@@ -7,7 +7,7 @@
1 src/renderer/src/components/settings/browser/profiles/BrowserSessionCookiesSection.tsx
1 src/renderer/src/components/settings/browser/routing/BrowserSshWorkspaceRoutingSetting.tsx
1 src/renderer/src/components/settings/quick-commands/QuickCommandsToolbar.tsx
1 src/renderer/src/components/settings/repository/execution/RepositoryHostSetupsSection.tsx
1 src/renderer/src/components/settings/repository/hosts/RepositoryHostSetupsSection.tsx
1 src/renderer/src/components/sidebar/host-admission/ssh/AddRemoteHostSshConfigPicker.tsx
4 src/renderer/src/components/status-bar/SshStatusSegment.tsx
1 src/renderer/src/components/status-bar/resource-usage-popover-body.tsx
+4 -4
View File
@@ -422,11 +422,11 @@
1 src/renderer/src/components/settings/privacy/PrivacyPane.tsx
1 src/renderer/src/components/settings/quick-commands/QuickCommandsPane.tsx
1 src/renderer/src/components/settings/repository/RepositoryFormatterSection.tsx
2 src/renderer/src/components/settings/repository/RepositoryGitHubAccountSection.tsx
2 src/renderer/src/components/settings/repository/source-control/RepositoryGitHubAccountSection.tsx
3 src/renderer/src/components/settings/repository/RepositoryJiraProjectSection.tsx
2 src/renderer/src/components/settings/repository/execution/RepositoryForkSyncSection.tsx
3 src/renderer/src/components/settings/repository/execution/RepositoryHostSetupActions.tsx
2 src/renderer/src/components/settings/repository/execution/SparsePresetSettingsSection.tsx
2 src/renderer/src/components/settings/repository/source-control/RepositoryForkSyncSection.tsx
3 src/renderer/src/components/settings/repository/hosts/RepositoryHostSetupActions.tsx
2 src/renderer/src/components/settings/repository/worktrees/SparsePresetSettingsSection.tsx
2 src/renderer/src/components/settings/repository/identity/RepositoryIconPicker.tsx
1 src/renderer/src/components/settings/repository/mcp/McpConfigSection.tsx
9 src/renderer/src/components/settings/repository/source-control/repository-source-control-ai-global-ux.ts
@@ -5606,7 +5606,7 @@
"src/renderer/src/components/settings/form-controls/SettingsFormControls.segmented-control.test.tsx": 730,
"src/renderer/src/components/settings/shortcuts/ShortcutFilterRail.test.ts": 273,
"src/renderer/src/components/settings/shortcuts/ShortcutsPane.provenance.test.tsx": 2302,
"src/renderer/src/components/settings/repository/execution/SparsePresetSettingsSection.test.tsx": 744,
"src/renderer/src/components/settings/repository/worktrees/SparsePresetSettingsSection.test.tsx": 744,
"src/renderer/src/components/settings/ssh/server-actions/SshHostDeltaMoveDialog.test.tsx": 438,
"src/renderer/src/components/settings/ssh/server-actions/SshHostRecoverServerAction.test.tsx": 669,
"src/renderer/src/components/settings/ssh/SshPane.test.tsx": 1699,
@@ -5636,8 +5636,8 @@
"src/renderer/src/components/settings/notifications/notification-host-pending-save.test.tsx": 2029,
"src/renderer/src/components/settings/repository/RepositoryJiraProjectSection.test.tsx": 463,
"src/renderer/src/components/settings/repository/RepositoryPaneDraftInput.test.tsx": 314,
"src/renderer/src/components/settings/repository/execution/RepositoryHostSetupsSection.settings-entry.test.tsx": 2007,
"src/renderer/src/components/settings/repository/execution/RepositoryWorktreeDefaultsSection.test.tsx": 495,
"src/renderer/src/components/settings/repository/hosts/RepositoryHostSetupsSection.settings-entry.test.tsx": 2007,
"src/renderer/src/components/settings/repository/worktrees/RepositoryWorktreeDefaultsSection.test.tsx": 495,
"src/renderer/src/components/settings/repository/identity/RepositoryIconPicker.github-avatar-refresh.test.tsx": 615,
"src/renderer/src/components/settings/runtime-environments/pairing/runtime-share-computer-button.test.tsx": 2092,
"src/renderer/src/components/settings/navigation/settings-project-list.test.ts": 99,
@@ -5648,7 +5648,7 @@
"src/renderer/src/components/integrations/task-trackers/linear-integration-card.test.tsx": 1414,
"src/renderer/src/components/settings/appearance/themes/use-catalog-app-themes.test.ts": 2159,
"src/renderer/src/components/settings/form-controls/use-debounced-settings-text-draft.test.ts": 308,
"src/renderer/src/components/settings/repository/execution/use-repository-hook-settings-draft.test.tsx": 586,
"src/renderer/src/components/settings/repository/hooks/use-repository-hook-settings-draft.test.tsx": 586,
"src/renderer/src/components/settings/repository/hooks/use-repository-issue-command-wsl-stopped.test.ts": 523,
"src/renderer/src/components/settings/runtime-environments/catalog/use-runtime-environment-catalog.test.tsx": 2252,
"src/renderer/src/components/settings/runtime-environments/catalog/use-runtime-environment-mutation-actions.test.tsx": 2069,
@@ -27,7 +27,7 @@ import { AgentDefaultArgsInput } from './launch-settings/AgentLaunchDefaultsEdit
import { NativeChatSessionOptionRows } from '../native-chat/session/options/controls/NativeChatSessionOptionRows'
import { Collapsible, CollapsibleTrigger, CollapsibleContent } from '@/components/ui/collapsible'
import type { SessionOptionDescriptor } from '../../../../shared/native-chat/input/native-chat-session-options'
import { AgentPermissionMenu } from './launch-settings/AgentPermissionChoiceControls'
import { AgentPermissionMenu } from './launch-settings/AgentPermissionMenu'
import {
AgentLaunchSetupFooter,
agentLaunchSetupArgumentsNote,
@@ -0,0 +1,125 @@
import type { Ref } from 'react'
import { X } from 'lucide-react'
import { useTranslate } from '../../../i18n/use-translate'
import { Tooltip, TooltipContent, TooltipTrigger } from '../../ui/tooltip'
import type { AgentArgsChoice } from './agent-args-choice'
function AgentArgsChoiceChip({
label,
flag,
onRemove,
disabled,
chipRef,
buttonRef,
choiceKey,
source
}: {
label: string
flag: string
onRemove: () => void
disabled?: boolean
chipRef?: Ref<HTMLSpanElement>
buttonRef?: Ref<HTMLButtonElement>
choiceKey: string
source?: 'arguments'
}): React.JSX.Element {
const t = useTranslate()
return (
<Tooltip>
<TooltipTrigger asChild>
<span
ref={chipRef}
className="flex h-5 min-w-0 max-w-full items-center gap-1 rounded bg-muted px-1.5 font-mono text-xs leading-5 text-foreground/80 focus-within:ring-2 focus-within:ring-ring"
>
<span className="truncate">{flag}</span>
<button
ref={buttonRef}
type="button"
disabled={disabled}
onClick={onRemove}
onKeyDown={(event) => {
if (event.key === 'Backspace') {
event.preventDefault()
if (
!disabled &&
!event.repeat &&
!event.altKey &&
!event.ctrlKey &&
!event.metaKey
) {
onRemove()
}
}
}}
aria-label={
source === 'arguments' || choiceKey !== 'permissionMode'
? t('settings.agents.choiceChipRemove', 'Remove {{flag}}', { flag })
: t(
'settings.agents.permissionChipRemove',
"Remove {{flag}} and use {{agent}}'s own settings",
{ flag, agent: label }
)
}
className="rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50"
>
<X className="size-3" />
</button>
</span>
</TooltipTrigger>
<TooltipContent>
{source === 'arguments'
? t('agentPicker.argumentsHint', 'Applies only to CLI launches.')
: choiceKey !== 'permissionMode'
? t(
'settings.agents.choiceChipTooltip',
'Added by {{choice}}. Remove it to use the default.',
{
choice:
choiceKey === 'model'
? t('settings.sourceControl.actionModel.model', 'Model')
: t('settings.sourceControl.actionModel.effort', 'Effort')
}
)
: t(
'settings.agents.permissionChipTooltip',
'Added by Permissions. Remove it to use {{agent}}’s own settings.',
{ agent: label }
)}
</TooltipContent>
</Tooltip>
)
}
export function AgentArgsChoiceChips({
chips,
disabled,
chipRef,
buttonRef,
onRemove
}: {
chips: readonly AgentArgsChoice[]
disabled?: boolean
chipRef?: Ref<HTMLSpanElement>
buttonRef?: Ref<HTMLButtonElement>
onRemove: (chip: AgentArgsChoice) => void
}): React.JSX.Element {
return (
<span
ref={chipRef}
className="relative z-10 -mb-5 flex h-5 w-fit max-w-full items-center gap-1"
>
{chips.map((chip, index) => (
<AgentArgsChoiceChip
key={chip.key}
choiceKey={chip.key}
label={chip.label}
flag={chip.flag}
source={chip.source}
disabled={disabled}
buttonRef={index === chips.length - 1 ? buttonRef : undefined}
onRemove={() => onRemove(chip)}
/>
))}
</span>
)
}
@@ -4,15 +4,13 @@ import { useTranslate } from '@/i18n/use-translate'
import { antigravityChatSignInRunning } from '@/runtime/provider-accounts/sign-in/antigravity-chat-sign-in-status'
import { useManagedRuntimeInstall } from '@/runtime/hosts/installation/use-managed-runtime-install'
import { ManagedRuntimeInstallRow } from '../../managed-runtime/ManagedRuntimeInstallRow'
import { useAntigravityChatSignIn } from '../../provider-accounts/AntigravityChatSignInRow'
import {
AntigravityProviderSignInArea,
antigravityProviderSignInShown
} from '../../provider-accounts/AntigravityProviderSignInArea'
import { useAntigravityChatSignIn } from '../../provider-accounts/use-antigravity-chat-sign-in'
import { AntigravityProviderSignInArea } from '../../provider-accounts/AntigravityProviderSignInArea'
import { antigravityProviderSignInShown } from '../../provider-accounts/antigravity-chat-runtime-sign-in-policy'
import {
getHostRuntimeLabel,
getRuntimeSentenceLabel
} from '../../settings/accounts/scope/accounts-pane-runtime'
} from '../../../lib/provider-accounts/account-runtime-label'
import type { AgentOpensAs } from '../../../lib/agent-session/launch/native-chat-provider-choice'
import { SettingsSegmentedControl } from '../../settings/form-controls/SettingsFormControls'
import { structuredChatUnavailableOnPlatform } from '../../../../../shared/agent-session/structured-chat-platform-support'
@@ -2,13 +2,11 @@ import type {
AgentChoicePatch,
AgentDedicatedChoices
} from '../../../../../shared/agent-launch/choices/agent-launch-choices'
import { reconcileAgentChoiceArgs } from '../../../../../shared/agent-launch/choices/agent-choice-reconciliation'
import {
findCatalogModel,
getAgentSessionOptionLaunchCatalog
} from '../../../../../shared/agent-session/options/agent-session-option-catalog'
import {
sourceControlActionAgentPicksModel,
sourceControlActionOptions
@@ -16,7 +14,7 @@ import {
import { encodeCatalogOptionValue } from '../../../../../shared/agent-session/options/structured-agent-session-option-codec'
import type { TuiAgent } from '../../../../../shared/agent-launch/catalog/tui-agent'
import { AgentChoiceMenu } from './AgentChoiceMenu'
import { sourceControlActionRouteHint } from './AgentChoiceOptionField'
import { sourceControlActionRouteHint } from './agent-choice-route-hint'
import { useTranslate } from '@/i18n/use-translate'
const AGENT_DEFAULT_VALUE = '__agent_default__'
@@ -2,9 +2,6 @@ import type { ReactNode } from 'react'
import { Label } from '../../ui/label'
import { SelectTrigger, SelectValue } from '../../ui/select'
import { Tooltip, TooltipContent, TooltipTrigger } from '../../ui/tooltip'
import { translate } from '@/i18n/i18n'
import type { Translate } from '@/i18n/use-translate'
import type { SourceControlActionChoiceRoute } from '../../../../../shared/source-control/ai/recipes/source-control-action-options'
export function SourceControlActionOptionField({
label,
@@ -24,18 +21,6 @@ export function SourceControlActionOptionField({
)
}
/** Says which launches a saved choice reaches when it is not both. */
export function sourceControlActionRouteHint(
route: SourceControlActionChoiceRoute,
t: Translate = translate
): string | null {
return route === 'chats'
? t('settings.sourceControl.actionModel.chatsOnly', 'Applies to chats only')
: route === 'terminals'
? t('settings.sourceControl.actionModel.terminalsOnly', 'Applies to terminals only')
: null
}
export function SourceControlActionOptionTrigger({
label,
disabled
@@ -5,13 +5,12 @@ import {
type AgentChoicePatch
} from '../../../../../shared/agent-launch/choices/agent-launch-choices'
import { AgentDefaultArgsInput } from './AgentLaunchDefaultsEditor'
import { AgentPermissionMenu, type AgentPermissionChoiceRow } from './AgentPermissionChoiceControls'
import { AgentPermissionMenu } from './AgentPermissionMenu'
import type { AgentPermissionChoiceRow } from './agent-permission-choice-row'
import { agentModelChoiceChips } from './agent-model-choice-chips'
import { useAgentLaunchFieldWrite } from './use-agent-launch-field-write'
import { reconcileAgentChoiceArgs } from '../../../../../shared/agent-launch/choices/agent-choice-reconciliation'
import type { TuiAgent } from '../../../../../shared/agent-launch/catalog/tui-agent'
import { useTranslate } from '@/i18n/use-translate'
import { AgentChoiceFields } from './AgentChoiceControls'
@@ -9,7 +9,8 @@ import {
type AgentDefaultEnvDraftInvalidReason
} from './agent-default-env-draft'
import { useAgentLaunchFieldWrite } from './use-agent-launch-field-write'
import { AgentArgsChoiceChips, type AgentArgsChoice } from './AgentPermissionChoiceControls'
import { AgentArgsChoiceChips } from './AgentArgsChoiceChips'
import type { AgentArgsChoice } from './agent-args-choice'
export function AgentCommandOverrideInput({
defaultCmd,
@@ -1,386 +0,0 @@
import { AgentPermissionMenuOptions } from './AgentPermissionMenuOptions'
import { ChevronDown, X } from 'lucide-react'
import type { Ref } from 'react'
import type { AgentChatPermissionMode } from '../../../../../shared/agent-launch/permissions/agent-chat-permission-mode'
import type { AgentPermissionChoice } from '../../../../../shared/agent-launch/permissions/tui-agent-permission-choice'
import { translate } from '@/i18n/i18n'
import { useTranslate } from '@/i18n/use-translate'
import type { Translate } from '@/i18n/use-translate'
import { cn } from '@/lib/utils'
import { Button } from '../../ui/button'
import { Label } from '../../ui/label'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuRadioGroup,
DropdownMenuTrigger
} from '../../ui/dropdown-menu'
import { Tooltip, TooltipContent, TooltipTrigger } from '../../ui/tooltip'
import { nativeChatPermissionModeLabel } from '../../native-chat/session/options/controls/native-chat-permission-mode-labels'
import { AgentPermissionChoiceItems, AgentPermissionChoiceName } from './AgentPermissionChoiceItems'
/** Use chat-mode wording; own names the agent when available. */
export function agentPermissionChoiceLabel(
choice: AgentPermissionChoice,
agentLabel: string | null,
t: Translate = translate
): string {
if (choice !== 'own') {
return nativeChatPermissionModeLabel(choice, t)
}
return agentLabel
? t('settings.agents.permissionOwnAgent', "Use {{agent}}'s own settings", {
agent: agentLabel
})
: t('settings.agents.permissionOwnAll', "Agents' own settings")
}
export function AllAgentsPermissionSetting({
chatOwnSupported = false,
choice,
withoutAutoChoice,
onChange,
onChangeWithoutAuto
}: {
chatOwnSupported?: boolean
choice: AgentPermissionChoice | null
/** What the agents without Approve for me share; null when they differ. */
withoutAutoChoice: AgentPermissionChoice | null
onChange: (choice: AgentPermissionChoice) => void
onChangeWithoutAuto: (choice: AgentPermissionChoice) => void
}): React.JSX.Element {
const t = useTranslate()
const title = t('settings.agents.permissionsTitle', 'Permissions')
const ownLabel = t('settings.agents.permissionEachOwn', "Each agent's own settings")
const withoutAutoTitle = t(
'settings.agents.otherAgentsPermissionsLabel',
'Permissions for other agents'
)
return (
<section className="space-y-1">
<div className="flex flex-wrap items-center gap-x-3 gap-y-1">
<h3 className="text-sm font-semibold">{title}</h3>
<DropdownMenu>
<DropdownMenuTrigger asChild disabled={choice === null}>
<Button
type="button"
variant="outline"
size="xs"
aria-label={title}
className="w-48 max-w-full justify-between"
>
{choice === null ? (
<span className="h-4" />
) : (
<AgentPermissionChoiceName choice={choice} ownLabel={ownLabel} truncate />
)}
<ChevronDown className="size-3 shrink-0" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="start" collisionPadding={8} className="w-72">
<DropdownMenuRadioGroup aria-label={title} value={choice ?? ''}>
<AgentPermissionChoiceItems
choices={['ask', 'auto', 'full-access', 'own']}
ownLabel={ownLabel}
chatOwnSupported={chatOwnSupported}
onSelect={onChange}
/>
</DropdownMenuRadioGroup>
</DropdownMenuContent>
</DropdownMenu>
</div>
<p className="text-xs text-muted-foreground">
{t(
'settings.agents.permissionsChoiceExplanation',
'What every agent may do without asking. You can set one agent differently below.'
)}
</p>
<div className="min-h-6">
{choice === 'auto' ? (
<div className="flex items-center gap-2">
<span className="text-xs text-muted-foreground">
{t('settings.agents.permissionWithoutAuto', 'Agents without Approve for me')}
</span>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
type="button"
variant="outline"
size="xs"
aria-label={withoutAutoTitle}
className="min-w-0 max-w-full"
>
{withoutAutoChoice === null ? (
<span className="truncate">
{t('settings.agents.permissionMixed', 'Mixed')}
</span>
) : (
<AgentPermissionChoiceName
choice={withoutAutoChoice}
ownLabel={ownLabel}
truncate
/>
)}
<ChevronDown className="size-3 shrink-0" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="start" collisionPadding={8} className="w-72">
<DropdownMenuRadioGroup
aria-label={withoutAutoTitle}
value={withoutAutoChoice ?? ''}
>
<AgentPermissionChoiceItems
choices={['full-access', 'own']}
ownLabel={ownLabel}
chatOwnSupported={chatOwnSupported}
onSelect={onChangeWithoutAuto}
/>
</DropdownMenuRadioGroup>
</DropdownMenuContent>
</DropdownMenu>
</div>
) : null}
</div>
</section>
)
}
export type AgentPermissionChoiceRow = {
chatOwnSupported?: boolean
choices: readonly AgentPermissionChoice[]
choice: AgentPermissionChoice
source: 'agent' | 'all'
terminalChoice?: AgentPermissionChoice
chatChoice?: AgentChatPermissionMode | null
/** What this agent gets from the all-agents choice. */
defaultChoice: AgentPermissionChoice
onSelect: (choice: AgentPermissionChoice | 'default') => void
/** The flag terminals add, shown as a chip in Arguments; empty when none. */
flag: string
/** The agent's own Arguments set permissions, so terminals use those instead. */
argsSetPermission: boolean
}
export function AgentPermissionMenu({
agentId,
label,
permission,
inheritLabel,
onOpenChange,
disabled,
size = 'xs',
layout = 'inline',
showInherited = true,
rawValue
}: {
agentId: string
label: string
permission: AgentPermissionChoiceRow
inheritLabel?: string
onOpenChange?: (open: boolean) => void
disabled?: boolean
size?: 'xs' | 'sm'
/** Row: muted label left and the menu right, like the chat composer's option rows. */
layout?: 'inline' | 'stacked' | 'row'
showInherited?: boolean
rawValue?: string
}): React.JSX.Element {
const t = useTranslate()
const followAll = inheritLabel ?? t('settings.agents.permissionSameAsAll', 'Same as all agents')
const ownLabel = agentPermissionChoiceLabel('own', label, t)
return (
<div
className={cn(
'flex min-w-0',
layout === 'stacked'
? 'flex-col items-stretch gap-2'
: layout === 'row'
? 'min-h-7 items-center justify-between gap-3'
: 'flex-wrap items-center gap-x-3 gap-y-1'
)}
>
{layout === 'row' ? (
<span className="text-xs text-muted-foreground">
{t('settings.agents.rowPermissions', 'Permissions')}
</span>
) : layout === 'stacked' ? (
<Label variant="settings">{t('settings.agents.rowPermissions', 'Permissions')}</Label>
) : (
<span className="text-xs font-medium">
{t('settings.agents.rowPermissions', 'Permissions')}
</span>
)}
<DropdownMenu onOpenChange={onOpenChange}>
<DropdownMenuTrigger asChild disabled={disabled}>
<Button
type="button"
variant="outline"
size={size}
aria-label={t('settings.agents.rowPermissionsLabel', '{{agent}} permissions', {
agent: label
})}
className={cn('min-w-0 max-w-full', layout === 'stacked' && 'w-full justify-between')}
>
<span className="flex min-w-0 items-center gap-1.5 text-xs">
{permission.source === 'all' ? <span className="shrink-0">{followAll} ·</span> : null}
<AgentPermissionChoiceName
choice={rawValue ? 'own' : permission.choice}
ownLabel={rawValue ?? ownLabel}
truncate
/>
</span>
<ChevronDown className="size-3 shrink-0" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="start" collisionPadding={8} className="w-80">
<AgentPermissionMenuOptions
agentId={agentId}
permission={permission}
disabled={disabled}
rawValue={rawValue}
showInherited={showInherited}
followAll={followAll}
ownLabel={ownLabel}
/>
</DropdownMenuContent>
</DropdownMenu>
{permission.terminalChoice === 'own' && permission.chatChoice ? (
<span className="text-xs text-muted-foreground">
{t(
'settings.agents.permissionSurfaceDifference',
'Terminals use the agent’s own settings; new chats use {{mode}}.',
{ mode: nativeChatPermissionModeLabel(permission.chatChoice, t) }
)}
</span>
) : null}
</div>
)
}
function AgentArgsChoiceChip({
label,
flag,
onRemove,
disabled,
chipRef,
buttonRef,
choiceKey,
source
}: {
label: string
flag: string
onRemove: () => void
disabled?: boolean
chipRef?: Ref<HTMLSpanElement>
buttonRef?: Ref<HTMLButtonElement>
choiceKey: string
source?: 'arguments'
}): React.JSX.Element {
const t = useTranslate()
return (
<Tooltip>
<TooltipTrigger asChild>
<span
ref={chipRef}
className="flex h-5 min-w-0 max-w-full items-center gap-1 rounded bg-muted px-1.5 font-mono text-xs leading-5 text-foreground/80 focus-within:ring-2 focus-within:ring-ring"
>
<span className="truncate">{flag}</span>
<button
ref={buttonRef}
type="button"
disabled={disabled}
onClick={onRemove}
onKeyDown={(event) => {
if (event.key === 'Backspace') {
event.preventDefault()
if (
!disabled &&
!event.repeat &&
!event.altKey &&
!event.ctrlKey &&
!event.metaKey
) {
onRemove()
}
}
}}
aria-label={
source === 'arguments' || choiceKey !== 'permissionMode'
? t('settings.agents.choiceChipRemove', 'Remove {{flag}}', { flag })
: t(
'settings.agents.permissionChipRemove',
"Remove {{flag}} and use {{agent}}'s own settings",
{ flag, agent: label }
)
}
className="rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50"
>
<X className="size-3" />
</button>
</span>
</TooltipTrigger>
<TooltipContent>
{source === 'arguments'
? t('agentPicker.argumentsHint', 'Applies only to CLI launches.')
: choiceKey !== 'permissionMode'
? t(
'settings.agents.choiceChipTooltip',
'Added by {{choice}}. Remove it to use the default.',
{
choice:
choiceKey === 'model'
? t('settings.sourceControl.actionModel.model', 'Model')
: t('settings.sourceControl.actionModel.effort', 'Effort')
}
)
: t(
'settings.agents.permissionChipTooltip',
'Added by Permissions. Remove it to use {{agent}}’s own settings.',
{ agent: label }
)}
</TooltipContent>
</Tooltip>
)
}
export type AgentArgsChoice = {
key: string
label: string
flag: string
onRemove: (text: string) => string
source?: 'arguments'
}
export function AgentArgsChoiceChips({
chips,
disabled,
chipRef,
buttonRef,
onRemove
}: {
chips: readonly AgentArgsChoice[]
disabled?: boolean
chipRef?: Ref<HTMLSpanElement>
buttonRef?: Ref<HTMLButtonElement>
onRemove: (chip: AgentArgsChoice) => void
}): React.JSX.Element {
return (
<span
ref={chipRef}
className="relative z-10 -mb-5 flex h-5 w-fit max-w-full items-center gap-1"
>
{chips.map((chip, index) => (
<AgentArgsChoiceChip
key={chip.key}
choiceKey={chip.key}
label={chip.label}
flag={chip.flag}
source={chip.source}
disabled={disabled}
buttonRef={index === chips.length - 1 ? buttonRef : undefined}
onRemove={() => onRemove(chip)}
/>
))}
</span>
)
}
@@ -0,0 +1,107 @@
import { useTranslate } from '../../../i18n/use-translate'
import { cn } from '../../../lib/utils'
import { ChevronDown } from 'lucide-react'
import { Button } from '../../ui/button'
import { Label } from '../../ui/label'
import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from '../../ui/dropdown-menu'
import { nativeChatPermissionModeLabel } from '../../native-chat/session/options/controls/native-chat-permission-mode-labels'
import { AgentPermissionChoiceName } from './AgentPermissionChoiceItems'
import { AgentPermissionMenuOptions } from './AgentPermissionMenuOptions'
import type { AgentPermissionChoiceRow } from './agent-permission-choice-row'
import { agentPermissionChoiceLabel } from './agent-permission-choice-label'
export function AgentPermissionMenu({
agentId,
label,
permission,
inheritLabel,
onOpenChange,
disabled,
size = 'xs',
layout = 'inline',
showInherited = true,
rawValue
}: {
agentId: string
label: string
permission: AgentPermissionChoiceRow
inheritLabel?: string
onOpenChange?: (open: boolean) => void
disabled?: boolean
size?: 'xs' | 'sm'
/** Row: muted label left and the menu right, like the chat composer's option rows. */
layout?: 'inline' | 'stacked' | 'row'
showInherited?: boolean
rawValue?: string
}): React.JSX.Element {
const t = useTranslate()
const followAll = inheritLabel ?? t('settings.agents.permissionSameAsAll', 'Same as all agents')
const ownLabel = agentPermissionChoiceLabel('own', label, t)
return (
<div
className={cn(
'flex min-w-0',
layout === 'stacked'
? 'flex-col items-stretch gap-2'
: layout === 'row'
? 'min-h-7 items-center justify-between gap-3'
: 'flex-wrap items-center gap-x-3 gap-y-1'
)}
>
{layout === 'row' ? (
<span className="text-xs text-muted-foreground">
{t('settings.agents.rowPermissions', 'Permissions')}
</span>
) : layout === 'stacked' ? (
<Label variant="settings">{t('settings.agents.rowPermissions', 'Permissions')}</Label>
) : (
<span className="text-xs font-medium">
{t('settings.agents.rowPermissions', 'Permissions')}
</span>
)}
<DropdownMenu onOpenChange={onOpenChange}>
<DropdownMenuTrigger asChild disabled={disabled}>
<Button
type="button"
variant="outline"
size={size}
aria-label={t('settings.agents.rowPermissionsLabel', '{{agent}} permissions', {
agent: label
})}
className={cn('min-w-0 max-w-full', layout === 'stacked' && 'w-full justify-between')}
>
<span className="flex min-w-0 items-center gap-1.5 text-xs">
{permission.source === 'all' ? <span className="shrink-0">{followAll} ·</span> : null}
<AgentPermissionChoiceName
choice={rawValue ? 'own' : permission.choice}
ownLabel={rawValue ?? ownLabel}
truncate
/>
</span>
<ChevronDown className="size-3 shrink-0" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="start" collisionPadding={8} className="w-80">
<AgentPermissionMenuOptions
agentId={agentId}
permission={permission}
disabled={disabled}
rawValue={rawValue}
showInherited={showInherited}
followAll={followAll}
ownLabel={ownLabel}
/>
</DropdownMenuContent>
</DropdownMenu>
{permission.terminalChoice === 'own' && permission.chatChoice ? (
<span className="text-xs text-muted-foreground">
{t(
'settings.agents.permissionSurfaceDifference',
'Terminals use the agent’s own settings; new chats use {{mode}}.',
{ mode: nativeChatPermissionModeLabel(permission.chatChoice, t) }
)}
</span>
) : null}
</div>
)
}
@@ -1,4 +1,4 @@
import type { AgentPermissionChoiceRow } from './AgentPermissionChoiceControls'
import type { AgentPermissionChoiceRow } from './agent-permission-choice-row'
import { AgentPermissionChoiceItems, AgentPermissionChoiceName } from './AgentPermissionChoiceItems'
import {
DropdownMenuRadioGroup,
@@ -0,0 +1,7 @@
export type AgentArgsChoice = {
key: string
label: string
flag: string
onRemove: (text: string) => string
source?: 'arguments'
}
@@ -0,0 +1,15 @@
import { translate } from '../../../i18n/i18n'
import type { Translate } from '../../../i18n/use-translate'
import type { SourceControlActionChoiceRoute } from '../../../../../shared/source-control/ai/recipes/source-control-action-options'
/** Says which launches a saved choice reaches when it is not both. */
export function sourceControlActionRouteHint(
route: SourceControlActionChoiceRoute,
t: Translate = translate
): string | null {
return route === 'chats'
? t('settings.sourceControl.actionModel.chatsOnly', 'Applies to chats only')
: route === 'terminals'
? t('settings.sourceControl.actionModel.terminalsOnly', 'Applies to terminals only')
: null
}
@@ -10,7 +10,7 @@ import type {
} from '../../../../../shared/agent-launch/choices/agent-launch-choices'
import type { AgentArgsProjectionContext } from '../../../../../shared/agent-launch/picker/agent-launch-picker-arguments'
import type { TuiAgent } from '../../../../../shared/agent-launch/catalog/tui-agent'
import type { AgentArgsChoice } from './AgentPermissionChoiceControls'
import type { AgentArgsChoice } from './agent-args-choice'
export function agentModelChoiceChips(
agent: TuiAgent | null | undefined,
@@ -0,0 +1,20 @@
import type { AgentPermissionChoice } from '../../../../../shared/agent-launch/permissions/tui-agent-permission-choice'
import { translate } from '../../../i18n/i18n'
import type { Translate } from '../../../i18n/use-translate'
import { nativeChatPermissionModeLabel } from '../../native-chat/session/options/controls/native-chat-permission-mode-labels'
/** Use chat-mode wording; own names the agent when available. */
export function agentPermissionChoiceLabel(
choice: AgentPermissionChoice,
agentLabel: string | null,
t: Translate = translate
): string {
if (choice !== 'own') {
return nativeChatPermissionModeLabel(choice, t)
}
return agentLabel
? t('settings.agents.permissionOwnAgent', "Use {{agent}}'s own settings", {
agent: agentLabel
})
: t('settings.agents.permissionOwnAll', "Agents' own settings")
}
@@ -0,0 +1,18 @@
import type { AgentChatPermissionMode } from '../../../../../shared/agent-launch/permissions/agent-chat-permission-mode'
import type { AgentPermissionChoice } from '../../../../../shared/agent-launch/permissions/tui-agent-permission-choice'
export type AgentPermissionChoiceRow = {
chatOwnSupported?: boolean
choices: readonly AgentPermissionChoice[]
choice: AgentPermissionChoice
source: 'agent' | 'all'
terminalChoice?: AgentPermissionChoice
chatChoice?: AgentChatPermissionMode | null
/** What this agent gets from the all-agents choice. */
defaultChoice: AgentPermissionChoice
onSelect: (choice: AgentPermissionChoice | 'default') => void
/** The flag terminals add, shown as a chip in Arguments; empty when none. */
flag: string
/** The agent's own Arguments set permissions, so terminals use those instead. */
argsSetPermission: boolean
}
@@ -16,7 +16,7 @@ import {
type AntigravityChatAuthConfig
} from '../../../../shared/antigravity-chat-auth-config'
import { Input } from '../ui/input'
import { SettingRow } from './AntigravityChatAuthSettingRow'
import { AntigravityChatAuthSettingRow } from './AntigravityChatAuthSettingRow'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/select'
export type AntigravityChatAuthAction = {
@@ -296,7 +296,7 @@ function AuthForm({
{heading}
{!unavailable && (
<div className="space-y-3">
<SettingRow
<AntigravityChatAuthSettingRow
htmlFor={`${id}-method`}
label={t('accounts.antigravity.authMethod', 'Sign in with')}
description={
@@ -332,10 +332,10 @@ function AuthForm({
<SelectItem value="oauth-business">{methodLabel('oauth-business', t)}</SelectItem>
</SelectContent>
</Select>
</SettingRow>
</AntigravityChatAuthSettingRow>
{method === 'oauth-business' && (
<>
<SettingRow
<AntigravityChatAuthSettingRow
htmlFor={`${id}-project`}
label={t('accounts.antigravity.gcpProject', 'Google Cloud project')}
>
@@ -352,8 +352,8 @@ function AuthForm({
onBlur={commitText}
onKeyDown={commitOnEnter}
/>
</SettingRow>
<SettingRow
</AntigravityChatAuthSettingRow>
<AntigravityChatAuthSettingRow
htmlFor={`${id}-location`}
label={t('accounts.antigravity.gcpLocation', 'Google Cloud location')}
>
@@ -370,7 +370,7 @@ function AuthForm({
onBlur={commitText}
onKeyDown={commitOnEnter}
/>
</SettingRow>
</AntigravityChatAuthSettingRow>
</>
)}
</div>
@@ -2,7 +2,7 @@ import type { ReactNode } from 'react'
import { Label } from '../ui/label'
/** Label and short description on the left, its control on the right. */
export function SettingRow(props: {
export function AntigravityChatAuthSettingRow(props: {
htmlFor: string
label: string
description?: string | null
@@ -8,7 +8,7 @@ import { Badge } from '../ui/badge'
import { Button } from '../ui/button'
import { Input } from '../ui/input'
import type { AntigravityChatAuthAction } from './AntigravityChatAuthForm'
import type { AntigravityChatSignInControls } from './AntigravityChatSignInRow'
import type { AntigravityChatSignInControls } from './use-antigravity-chat-sign-in'
export function AntigravityChatSignInBadge({
signIn
@@ -1,185 +1,12 @@
import { AntigravityChatAuthForm } from './AntigravityChatAuthForm'
import { useEffect, useState, useSyncExternalStore, type ReactNode } from 'react'
import { translate } from '@/i18n/i18n'
import { useTranslate, type Translate } from '@/i18n/use-translate'
import { useClipboardTextCopyFeedback } from '@/hooks/use-clipboard-text-copy-feedback'
import {
antigravityChatSignInRunning as running,
cancelAntigravityChatSignIn,
completeAntigravityChatSignIn,
observeAntigravityChatSignIn,
readAntigravityChatSignIn,
startAntigravityChatSignIn,
subscribeAntigravityChatSignIns,
type AntigravityChatSignInView
} from '@/runtime/provider-accounts/sign-in/antigravity-chat-sign-in-status'
import type { ReactNode } from 'react'
import { useTranslate } from '../../i18n/use-translate'
import type { RuntimeClientTarget } from '../../../../shared/runtime-client-target'
import type {
AntigravityChatAuth,
AntigravityChatSignInState
} from '../../../../shared/antigravity-account-types'
import type { ManagedRuntimeInstallObservation } from '@/runtime/hosts/installation/use-managed-runtime-install'
import {
AntigravityChatSignInAction,
AntigravityChatSignInBadge
} from './AntigravityChatSignInAction'
type Flow = AntigravityChatSignInState
/** A running flow another client started: the host tells only its starter the id. */
const otherClients = (flow: Flow | null): boolean => running(flow) && flow.flowId === null
/** Progress of a sign-in flow; signed-in or signed-out state shows in the status badge instead. */
function chatSignInLine(
flow: Flow | null,
auth: AntigravityChatAuth,
openFailed: boolean,
t: Translate = translate
): string | null {
if (otherClients(flow)) {
return t('accounts.antigravity.chatOtherClient', 'Sign-in is in progress in another client.')
}
switch (flow?.phase) {
case 'starting':
return t('accounts.antigravity.chatStarting', 'Starting sign-in…')
case 'waiting':
return openFailed
? t('accounts.antigravity.chatOpenFailed', 'Copy the link and open it in your browser.')
: t('accounts.antigravity.chatWaiting', 'Finish signing in in your browser.')
case 'verifying':
return t('accounts.antigravity.chatVerifying', 'Finishing sign-in…')
// A settled flow only stands in until the host answers whether it is signed in.
case 'cancelled':
return auth === 'unknown'
? t('accounts.antigravity.chatCancelled', 'Sign-in cancelled.')
: null
case 'expired':
return auth === 'unknown'
? t('accounts.antigravity.chatExpired', 'Sign-in timed out. Try again.')
: null
case 'failed':
case 'signedIn':
case undefined:
return null
}
}
type SignInAction = 'retry' | 'changeAccount' | 'signIn'
function signInAction(
flow: Flow | null,
auth: AntigravityChatAuth,
error: string | null
): SignInAction {
if (
error ||
flow?.phase === 'failed' ||
flow?.phase === 'cancelled' ||
flow?.phase === 'expired'
) {
return 'retry'
}
return auth === 'signedIn' ? 'changeAccount' : 'signIn'
}
const SETTLED_OPERATION_PHASES = new Set(['succeeded', 'failed', 'cancelled'])
/** Sign-in needs an installed server and no removal; updates keep the old copy usable, while unreported status defers to the host. */
export function antigravityChatSignInBlocked(
install: Extract<ManagedRuntimeInstallObservation, { kind: 'active' }>
): boolean {
const { snapshot } = install
if (snapshot.kind !== 'known') {
return snapshot.kind === 'unknown'
}
const { source, operation } = snapshot.state
return !source || (operation?.kind === 'remove' && !SETTLED_OPERATION_PHASES.has(operation.phase))
}
const NOT_FOLLOWED: AntigravityChatSignInView = {
status: 'unknown',
flow: null,
auth: 'unknown',
error: null,
openFailed: false
}
export function useAntigravityChatSignIn(
owner: RuntimeClientTarget | null
): AntigravityChatSignInView {
const shown = owner !== null
const environmentId = owner?.kind === 'environment' ? owner.environmentId : null
useEffect(
() =>
shown
? observeAntigravityChatSignIn(
environmentId === null ? { kind: 'local' } : { kind: 'environment', environmentId }
)
: undefined,
[shown, environmentId]
)
const read = (): AntigravityChatSignInView =>
owner ? readAntigravityChatSignIn(owner) : NOT_FOLLOWED
return useSyncExternalStore(subscribeAntigravityChatSignIns, read, read)
}
/** Share host auth across Settings layouts; auth stays unknown until a chat or sign-in asks the host. */
export type AntigravityChatSignInControls = ReturnType<typeof useAntigravityChatSignInControls>
export function useAntigravityChatSignInControls(props: {
owner: RuntimeClientTarget
label: string
disabled: boolean
}) {
const t = useTranslate()
const { owner, label } = props
const { status, flow, auth, openFailed, ...view } = useAntigravityChatSignIn(owner)
const [pending, setPending] = useState(false)
const act = (request: () => Promise<void>): void => {
setPending(true)
void request().finally(() => setPending(false))
}
const copy = useClipboardTextCopyFeedback(flow?.url ?? '')
const failed = t('accounts.antigravity.chatFailed', 'Sign-in failed. Try again.')
const error = view.error === null ? null : view.error || failed
const copyFailed = t('accounts.antigravity.chatCopyFailed', 'Could not copy the link.')
const readFailed = t(
'accounts.antigravity.chatReadFailed',
'Could not check the sign-in on {{host}}.',
{ host: label }
)
const ownFlow = running(flow) && flow.flowId !== null
const action = signInAction(flow, auth, error)
const line = status === 'known' ? chatSignInLine(flow, auth, openFailed, t) : null
return {
flow,
auth: status === 'known' ? auth : 'unknown',
signingIn: running(flow),
ownFlow,
url: ownFlow && flow?.phase === 'waiting' ? (flow.url ?? null) : null,
line,
alert:
error ??
(status === 'readFailed' ? readFailed : null) ??
(flow?.phase === 'failed' ? (flow.error ?? failed) : null) ??
(copy.status === 'failed' ? copyFailed : null),
action,
pending,
copy,
copyLabel: t('accounts.antigravity.chatCopyLink', 'Copy sign-in link'),
signInDisabled: props.disabled || pending || status !== 'known' || otherClients(flow),
recoveryDisabled: props.disabled || pending || otherClients(flow),
start: () => act(() => startAntigravityChatSignIn(owner)),
cancel: () => act(() => cancelAntigravityChatSignIn(owner)),
send: (callbackUrl: string, refused: (message: string) => void) =>
act(async () => {
const refusal = await completeAntigravityChatSignIn(owner, callbackUrl)
if (refusal !== null) {
refused(refusal || failed)
}
})
}
}
import { useAntigravityChatSignInControls } from './use-antigravity-chat-sign-in'
/** All rows for an execution host share its server’s sign-in, including running flows. */
export function AntigravityChatSignInRow(props: {
@@ -6,25 +6,11 @@ import {
AntigravityChatSignInAction,
AntigravityChatSignInBadge
} from './AntigravityChatSignInAction'
import {
antigravityChatSignInBlocked,
useAntigravityChatSignInControls
} from './AntigravityChatSignInRow'
import { antigravityChatSignInBlocked } from './antigravity-chat-runtime-sign-in-policy'
import { useAntigravityChatSignInControls } from './use-antigravity-chat-sign-in'
type ActiveInstall = Extract<ManagedRuntimeInstallObservation, { kind: 'active' }>
const CHANGING_PHASES = new Set(['downloading', 'extracting', 'verifying', 'removing'])
/** Require an installed server outside install/removal; retain space while host status is unknown. */
export function antigravityProviderSignInShown(install: ActiveInstall): boolean {
const { snapshot } = install
if (snapshot.kind !== 'known') {
return true
}
const { source, operation } = snapshot.state
return source !== null && !(operation && CHANGING_PHASES.has(operation.phase))
}
export function AntigravityProviderSignInArea(props: {
owner: RuntimeClientTarget
label: string
@@ -0,0 +1,29 @@
import type { ManagedRuntimeInstallObservation } from '../../runtime/hosts/installation/use-managed-runtime-install'
const SETTLED_OPERATION_PHASES = new Set(['succeeded', 'failed', 'cancelled'])
/** Sign-in needs an installed server and no removal; updates keep the old copy usable, while unreported status defers to the host. */
export function antigravityChatSignInBlocked(
install: Extract<ManagedRuntimeInstallObservation, { kind: 'active' }>
): boolean {
const { snapshot } = install
if (snapshot.kind !== 'known') {
return snapshot.kind === 'unknown'
}
const { source, operation } = snapshot.state
return !source || (operation?.kind === 'remove' && !SETTLED_OPERATION_PHASES.has(operation.phase))
}
const CHANGING_PHASES = new Set(['downloading', 'extracting', 'verifying', 'removing'])
/** Require an installed server outside install/removal; retain space while host status is unknown. */
export function antigravityProviderSignInShown(
install: Extract<ManagedRuntimeInstallObservation, { kind: 'active' }>
): boolean {
const { snapshot } = install
if (snapshot.kind !== 'known') {
return true
}
const { source, operation } = snapshot.state
return source !== null && !(operation && CHANGING_PHASES.has(operation.phase))
}
@@ -0,0 +1,161 @@
import { useEffect, useState, useSyncExternalStore } from 'react'
import { translate } from '../../i18n/i18n'
import { useTranslate, type Translate } from '../../i18n/use-translate'
import { useClipboardTextCopyFeedback } from '../../hooks/use-clipboard-text-copy-feedback'
import {
antigravityChatSignInRunning as running,
cancelAntigravityChatSignIn,
completeAntigravityChatSignIn,
observeAntigravityChatSignIn,
readAntigravityChatSignIn,
startAntigravityChatSignIn,
subscribeAntigravityChatSignIns,
type AntigravityChatSignInView
} from '../../runtime/provider-accounts/sign-in/antigravity-chat-sign-in-status'
import type { RuntimeClientTarget } from '../../../../shared/runtime-client-target'
import type {
AntigravityChatAuth,
AntigravityChatSignInState
} from '../../../../shared/antigravity-account-types'
/** A running flow another client started: the host tells only its starter the id. */
const otherClients = (flow: AntigravityChatSignInState | null): boolean =>
running(flow) && flow.flowId === null
/** Progress of a sign-in flow; signed-in or signed-out state shows in the status badge instead. */
function chatSignInLine(
flow: AntigravityChatSignInState | null,
auth: AntigravityChatAuth,
openFailed: boolean,
t: Translate = translate
): string | null {
if (otherClients(flow)) {
return t('accounts.antigravity.chatOtherClient', 'Sign-in is in progress in another client.')
}
switch (flow?.phase) {
case 'starting':
return t('accounts.antigravity.chatStarting', 'Starting sign-in…')
case 'waiting':
return openFailed
? t('accounts.antigravity.chatOpenFailed', 'Copy the link and open it in your browser.')
: t('accounts.antigravity.chatWaiting', 'Finish signing in in your browser.')
case 'verifying':
return t('accounts.antigravity.chatVerifying', 'Finishing sign-in…')
// A settled flow only stands in until the host answers whether it is signed in.
case 'cancelled':
return auth === 'unknown'
? t('accounts.antigravity.chatCancelled', 'Sign-in cancelled.')
: null
case 'expired':
return auth === 'unknown'
? t('accounts.antigravity.chatExpired', 'Sign-in timed out. Try again.')
: null
case 'failed':
case 'signedIn':
case undefined:
return null
}
}
type SignInAction = 'retry' | 'changeAccount' | 'signIn'
function signInAction(
flow: AntigravityChatSignInState | null,
auth: AntigravityChatAuth,
error: string | null
): SignInAction {
if (
error ||
flow?.phase === 'failed' ||
flow?.phase === 'cancelled' ||
flow?.phase === 'expired'
) {
return 'retry'
}
return auth === 'signedIn' ? 'changeAccount' : 'signIn'
}
const NOT_FOLLOWED: AntigravityChatSignInView = {
status: 'unknown',
flow: null,
auth: 'unknown',
error: null,
openFailed: false
}
export function useAntigravityChatSignIn(
owner: RuntimeClientTarget | null
): AntigravityChatSignInView {
const shown = owner !== null
const environmentId = owner?.kind === 'environment' ? owner.environmentId : null
useEffect(
() =>
shown
? observeAntigravityChatSignIn(
environmentId === null ? { kind: 'local' } : { kind: 'environment', environmentId }
)
: undefined,
[shown, environmentId]
)
const read = (): AntigravityChatSignInView =>
owner ? readAntigravityChatSignIn(owner) : NOT_FOLLOWED
return useSyncExternalStore(subscribeAntigravityChatSignIns, read, read)
}
/** Share host auth across Settings layouts; auth stays unknown until a chat or sign-in asks the host. */
export type AntigravityChatSignInControls = ReturnType<typeof useAntigravityChatSignInControls>
export function useAntigravityChatSignInControls(props: {
owner: RuntimeClientTarget
label: string
disabled: boolean
}) {
const t = useTranslate()
const { owner, label } = props
const { status, flow, auth, openFailed, ...view } = useAntigravityChatSignIn(owner)
const [pending, setPending] = useState(false)
const act = (request: () => Promise<void>): void => {
setPending(true)
void request().finally(() => setPending(false))
}
const copy = useClipboardTextCopyFeedback(flow?.url ?? '')
const failed = t('accounts.antigravity.chatFailed', 'Sign-in failed. Try again.')
const error = view.error === null ? null : view.error || failed
const copyFailed = t('accounts.antigravity.chatCopyFailed', 'Could not copy the link.')
const readFailed = t(
'accounts.antigravity.chatReadFailed',
'Could not check the sign-in on {{host}}.',
{ host: label }
)
const ownFlow = running(flow) && flow.flowId !== null
const action = signInAction(flow, auth, error)
const line = status === 'known' ? chatSignInLine(flow, auth, openFailed, t) : null
return {
flow,
auth: status === 'known' ? auth : 'unknown',
signingIn: running(flow),
ownFlow,
url: ownFlow && flow?.phase === 'waiting' ? (flow.url ?? null) : null,
line,
alert:
error ??
(status === 'readFailed' ? readFailed : null) ??
(flow?.phase === 'failed' ? (flow.error ?? failed) : null) ??
(copy.status === 'failed' ? copyFailed : null),
action,
pending,
copy,
copyLabel: t('accounts.antigravity.chatCopyLink', 'Copy sign-in link'),
signInDisabled: props.disabled || pending || status !== 'known' || otherClients(flow),
recoveryDisabled: props.disabled || pending || otherClients(flow),
start: () => act(() => startAntigravityChatSignIn(owner)),
cancel: () => act(() => cancelAntigravityChatSignIn(owner)),
send: (callbackUrl: string, refused: (message: string) => void) =>
act(async () => {
const refusal = await completeAntigravityChatSignIn(owner, callbackUrl)
if (refusal !== null) {
refused(refusal || failed)
}
})
}
}
@@ -11,8 +11,8 @@ import {
import { sourceControlActionSelectedPreferences } from '../../../../../../shared/source-control/ai/recipes/source-control-action-launch-preferences'
import { translate } from '@/i18n/i18n'
import { AGENT_CATALOG } from '@/lib/agent-catalog'
import { agentPermissionChoiceLabel } from '../../../agent/launch-settings/AgentPermissionChoiceControls'
import { sourceControlActionRouteHint } from '../../../agent/launch-settings/AgentChoiceOptionField'
import { agentPermissionChoiceLabel } from '../../../agent/launch-settings/agent-permission-choice-label'
import { sourceControlActionRouteHint } from '../../../agent/launch-settings/agent-choice-route-hint'
/** Describes the saved choices and which launches they reach. */
export function describeSourceControlActionModel(
@@ -47,15 +47,11 @@ import { ZcodePlanAccountsSection } from './usage/ZcodePlanAccountsSection'
import type {
AccountsPaneProps,
AccountsPaneSectionModel,
ClaudeAccountAction,
CodexAccountAction,
ProviderAccountAction,
RemoveAccountTarget
} from './accounts-pane-types'
import {
EMPTY_WSL_DISTROS,
getRuntimeSentenceLabel,
getSelectedAccountRuntime
} from './scope/accounts-pane-runtime'
import { EMPTY_WSL_DISTROS, getSelectedAccountRuntime } from './scope/accounts-pane-runtime'
import { getRuntimeSentenceLabel } from '../../../lib/provider-accounts/account-runtime-label'
import { watchCodexConfigSyncStatus } from '../../../runtime/provider-accounts/codex-config-sync-observer'
import {
createClaudeAccountActionRunner,
@@ -64,10 +60,8 @@ import {
import { renderAccountsLocationSection } from './scope/accounts-pane-location-section'
import { renderClaudeAccountsSection } from './claude/accounts-pane-claude-section'
import { renderCodexAccountsSection } from './codex/accounts-pane-codex-section'
import {
renderGeminiAccountsSection,
renderOpenCodeAccountsSection
} from './providers/accounts-pane-provider-setting-sections'
import { renderGeminiAccountsSection } from './providers/accounts-pane-gemini-section'
import { renderOpenCodeAccountsSection } from './providers/accounts-pane-opencode-section'
import { MiniMaxAccountsSection } from './usage/MiniMaxAccountsSection'
import { useUsageHostSettings } from './usage/use-usage-host-settings'
import { ManagedDataAccountsSection } from './providers/ManagedDataAccountsSection'
@@ -148,10 +142,10 @@ export function AccountsPane({
const [codexAccounts, setCodexAccounts] =
useState<CodexRateLimitAccountsState>(emptyCodexAccountsState)
const [codexAccountsLoaded, setCodexAccountsLoaded] = useState(false)
const [codexAction, setCodexAction] = useState<CodexAccountAction>('idle')
const [codexAction, setCodexAction] = useState<ProviderAccountAction>('idle')
const [claudeAccounts, setClaudeAccounts] =
useState<ClaudeRateLimitAccountsState>(emptyClaudeAccountsState)
const [claudeAction, setClaudeAction] = useState<ClaudeAccountAction>('idle')
const [claudeAction, setClaudeAction] = useState<ProviderAccountAction>('idle')
// Capture runtime slots at dialog opening; roster updates could remove the slot needed for restart diffs.
const [removeCodexTarget, setRemoveCodexTarget] = useState<RemoveAccountTarget | null>(null)
const [removeClaudeTarget, setRemoveClaudeTarget] = useState<RemoveAccountTarget | null>(null)
@@ -17,18 +17,17 @@ import {
getProviderAccountRuntime
} from '../../provider-accounts/provider-account-visibility'
import type {
ClaudeAccountAction,
ProviderAccountAction,
ClaudeAccountActionRunner,
CodexAccountAction,
CodexAccountActionRunner,
LocalAccountRuntime
CodexAccountActionRunner
} from './accounts-pane-types'
import type { LocalAccountRuntime } from '../../../lib/provider-accounts/account-runtime-label'
import {
getClaudeAccountErrorDescription,
getCodexAccountErrorDescription,
isClaudeAccountCancellation,
isCodexAccountCancellation
} from './accounts-pane-action-errors'
} from '../../../lib/provider-accounts/provider-account-action-errors'
import { getClaudeAccountLabel } from '@/lib/claude-account-label'
import { handleRunningClaudeSessionsAfterSwitch } from '@/lib/claude-account-switch-sessions'
@@ -41,7 +40,7 @@ type CodexActionContext = {
codexAccounts: CodexRateLimitAccountsState
setCodexAccounts: Dispatch<SetStateAction<CodexRateLimitAccountsState>>
setCodexAccountsLoaded: Dispatch<SetStateAction<boolean>>
setCodexAction: Dispatch<SetStateAction<CodexAccountAction>>
setCodexAction: Dispatch<SetStateAction<ProviderAccountAction>>
fetchSettings: () => Promise<void>
recordFeatureInteraction: (featureId: FeatureInteractionId) => void
/** False once the pane shows a different account owner than this action targeted. */
@@ -147,7 +146,7 @@ type ClaudeActionContext = {
isRemoteAccountScope: boolean
claudeAccounts: ClaudeRateLimitAccountsState
setClaudeAccounts: Dispatch<SetStateAction<ClaudeRateLimitAccountsState>>
setClaudeAction: Dispatch<SetStateAction<ClaudeAccountAction>>
setClaudeAction: Dispatch<SetStateAction<ProviderAccountAction>>
fetchSettings: () => Promise<void>
recordFeatureInteraction: (featureId: FeatureInteractionId) => void
/** False once the pane shows a different account owner than this action targeted. */
@@ -13,6 +13,7 @@ import type { FeatureInteractionId } from '../../../../../shared/feature-interac
import type { ProviderAccountRuntimeView } from '../../provider-accounts/provider-account-visibility'
import type { RuntimeClientTarget } from '../../../../../shared/runtime-client-target'
import type { SettingsHostScope } from '../host-scope/settings-host-scope'
import type { LocalAccountRuntime } from '../../../lib/provider-accounts/account-runtime-label'
export type AccountsPaneProps = {
settings: GlobalSettings
@@ -30,21 +31,13 @@ export type AccountsPaneProps = {
wslHostDistro?: string | null
}
export type LocalAccountRuntime = {
runtime: 'host' | 'wsl'
wslDistro?: string | null
label: string
}
export type CodexAccountAction =
export type ProviderAccountAction =
| 'idle'
| 'adding'
| `reauth:${string}`
| `remove:${string}`
| `select:${string}`
export type ClaudeAccountAction = CodexAccountAction
export type RemoveAccountTarget = {
id: string
runtime: ProviderAccountRuntimeView
@@ -56,13 +49,13 @@ export type ProviderAccountVisibilityOptions = {
}
export type CodexAccountActionRunner = (
action: CodexAccountAction,
action: ProviderAccountAction,
operation: () => Promise<CodexRateLimitAccountsState>,
actionRuntime?: ProviderAccountRuntimeView
) => Promise<void>
export type ClaudeAccountActionRunner = (
action: ClaudeAccountAction,
action: ProviderAccountAction,
operation: () => Promise<ClaudeRateLimitAccountsState>,
actionRuntime?: ProviderAccountRuntimeView
) => Promise<void>
@@ -90,13 +83,13 @@ export type AccountsPaneSectionModel = {
accountRuntimeUnavailable: boolean
accountVisibilityOptions: ProviderAccountVisibilityOptions
claudeAccounts: ClaudeRateLimitAccountsState
claudeAction: ClaudeAccountAction
claudeAction: ProviderAccountAction
visibleClaudeAccounts: ClaudeRateLimitAccountsState['accounts']
systemClaudeActive: boolean
setRemoveClaudeTarget: Dispatch<SetStateAction<RemoveAccountTarget | null>>
runClaudeAccountAction: ClaudeAccountActionRunner
codexAccounts: CodexRateLimitAccountsState
codexAction: CodexAccountAction
codexAction: ProviderAccountAction
visibleCodexAccounts: CodexRateLimitAccountsState['accounts']
systemCodexActive: boolean
systemCodexNeedsSignIn: boolean
@@ -17,11 +17,9 @@ import { Button } from '../../../ui/button'
import { Badge } from '../../../ui/badge'
import { ManagedRuntimeInstallRow } from '../../../managed-runtime/ManagedRuntimeInstallRow'
import { antigravityChatSignInRunning } from '@/runtime/provider-accounts/sign-in/antigravity-chat-sign-in-status'
import {
AntigravityChatSignInRow,
antigravityChatSignInBlocked,
useAntigravityChatSignIn
} from '../../../provider-accounts/AntigravityChatSignInRow'
import { AntigravityChatSignInRow } from '../../../provider-accounts/AntigravityChatSignInRow'
import { antigravityChatSignInBlocked } from '../../../provider-accounts/antigravity-chat-runtime-sign-in-policy'
import { useAntigravityChatSignIn } from '../../../provider-accounts/use-antigravity-chat-sign-in'
import { openAppHttpLinkFromAnchor } from '@/lib/browser/navigation/app-http-link-open'
import { formatTimeAgo } from '../../../status-bar/tooltip'
import { ChatUnavailableOnWindowsNote } from '../../../agent/launch-settings/AgentChatChoiceControls'
@@ -0,0 +1,82 @@
import { translate } from '../../../../i18n/i18n'
import type { Translate } from '../../../../i18n/use-translate'
import { Label } from '../../../ui/label'
import { Switch } from '../../../ui/switch'
import { GeminiIcon } from '../../../status-bar/icons'
import { SearchableSetting } from '../../section-layout/SearchableSetting'
import { SettingsGroup } from '../../section-layout/SettingsGroup'
import type { AccountsPaneSectionModel } from '../accounts-pane-types'
export function renderGeminiAccountsSection(
model: AccountsPaneSectionModel,
t: Translate = translate
): React.JSX.Element {
const { localAccountRuntimeSentenceLabel, recordFeatureInteraction, settings, updateSettings } =
model
return (
<div key="gemini" id="accounts-gemini" className="scroll-mt-6">
<SettingsGroup
title={
<span className="flex items-center gap-2">
<GeminiIcon size={16} />
{t('auto.components.settings.AccountsPane.0c64dc2a64', 'Gemini CLI (legacy)')}
</span>
}
description={t(
'auto.components.settings.AccountsPane.973741a871',
'Keep existing Gemini CLI sessions available. Gemini credentials do not sign you into Antigravity.'
)}
>
<SearchableSetting
title={t(
'auto.components.settings.AccountsPane.0c7f915b01',
'Use Gemini CLI credentials'
)}
description={t(
'auto.components.settings.AccountsPane.d676c41fc6',
'Extracts OAuth credentials from your local Gemini CLI installation to authenticate with Google. This uses credentials issued to the Gemini CLI app, not Orca. May break if Google updates the CLI. Use at your own risk.'
)}
keywords={[
'gemini',
'cli',
'oauth',
'credentials',
'experimental',
'rate limit',
'status bar'
]}
className="flex items-center justify-between gap-4 py-3"
>
<div className="space-y-0.5">
<Label>
{t(
'auto.components.settings.AccountsPane.96f3649526',
'Use Gemini CLI credentials (experimental)'
)}
</Label>
<p className="text-xs text-muted-foreground">
{t(
'auto.components.settings.AccountsPane.c2aee76420',
'Extracts OAuth credentials from your local Gemini CLI installation to authenticate with Google for {{value0}}. This uses credentials issued to the Gemini CLI app, not Orca. May break if Google updates the CLI. Use at your own risk.',
{ value0: localAccountRuntimeSentenceLabel }
)}
</p>
</div>
<Switch
aria-label={t(
'auto.components.settings.AccountsPane.96f3649526',
'Use Gemini CLI credentials (experimental)'
)}
checked={settings.geminiCliOAuthEnabled}
onCheckedChange={(checked) => {
recordFeatureInteraction('usage-tracking')
updateSettings({
geminiCliOAuthEnabled: checked
})
}}
/>
</SearchableSetting>
</SettingsGroup>
</div>
)
}
@@ -1,88 +1,13 @@
import { translate } from '@/i18n/i18n'
import type { Translate } from '@/i18n/use-translate'
import { translate } from '../../../../i18n/i18n'
import type { Translate } from '../../../../i18n/use-translate'
import { Button } from '../../../ui/button'
import { Label } from '../../../ui/label'
import { Switch } from '../../../ui/switch'
import { GeminiIcon, OpenCodeGoIcon } from '../../../status-bar/icons'
import { OpenCodeGoIcon } from '../../../status-bar/icons'
import { SearchableSetting } from '../../section-layout/SearchableSetting'
import { SettingsGroup } from '../../section-layout/SettingsGroup'
import { DebouncedSettingsTextInput } from '../../form-controls/DebouncedSettingsTextInput'
import type { AccountsPaneSectionModel } from '../accounts-pane-types'
import { OpenCodeGoCredentials } from '../usage/accounts-pane-opencode-credentials'
import { DebouncedSettingsTextInput } from '../../form-controls/DebouncedSettingsTextInput'
import { SettingsGroup } from '../../section-layout/SettingsGroup'
export function renderGeminiAccountsSection(
model: AccountsPaneSectionModel,
t: Translate = translate
): React.JSX.Element {
const { localAccountRuntimeSentenceLabel, recordFeatureInteraction, settings, updateSettings } =
model
return (
<div key="gemini" id="accounts-gemini" className="scroll-mt-6">
<SettingsGroup
title={
<span className="flex items-center gap-2">
<GeminiIcon size={16} />
{t('auto.components.settings.AccountsPane.0c64dc2a64', 'Gemini CLI (legacy)')}
</span>
}
description={t(
'auto.components.settings.AccountsPane.973741a871',
'Keep existing Gemini CLI sessions available. Gemini credentials do not sign you into Antigravity.'
)}
>
<SearchableSetting
title={t(
'auto.components.settings.AccountsPane.0c7f915b01',
'Use Gemini CLI credentials'
)}
description={t(
'auto.components.settings.AccountsPane.d676c41fc6',
'Extracts OAuth credentials from your local Gemini CLI installation to authenticate with Google. This uses credentials issued to the Gemini CLI app, not Orca. May break if Google updates the CLI. Use at your own risk.'
)}
keywords={[
'gemini',
'cli',
'oauth',
'credentials',
'experimental',
'rate limit',
'status bar'
]}
className="flex items-center justify-between gap-4 py-3"
>
<div className="space-y-0.5">
<Label>
{t(
'auto.components.settings.AccountsPane.96f3649526',
'Use Gemini CLI credentials (experimental)'
)}
</Label>
<p className="text-xs text-muted-foreground">
{t(
'auto.components.settings.AccountsPane.c2aee76420',
'Extracts OAuth credentials from your local Gemini CLI installation to authenticate with Google for {{value0}}. This uses credentials issued to the Gemini CLI app, not Orca. May break if Google updates the CLI. Use at your own risk.',
{ value0: localAccountRuntimeSentenceLabel }
)}
</p>
</div>
<Switch
aria-label={t(
'auto.components.settings.AccountsPane.96f3649526',
'Use Gemini CLI credentials (experimental)'
)}
checked={settings.geminiCliOAuthEnabled}
onCheckedChange={(checked) => {
recordFeatureInteraction('usage-tracking')
updateSettings({
geminiCliOAuthEnabled: checked
})
}}
/>
</SearchableSetting>
</SettingsGroup>
</div>
)
}
export function renderOpenCodeAccountsSection(
model: AccountsPaneSectionModel,
@@ -4,7 +4,7 @@ import type { Translate } from '@/i18n/use-translate'
import { SearchableSetting } from '../../section-layout/SearchableSetting'
import { SettingsRow, SettingsSegmentedControl } from '../../form-controls/SettingsFormControls'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../../../ui/select'
import { getHostRuntimeLabel } from './accounts-pane-runtime'
import { getHostRuntimeLabel } from '../../../../lib/provider-accounts/account-runtime-label'
import { WSL_DEFAULT_DISTRO_KEY } from '../../../provider-accounts/provider-account-visibility'
import type { GlobalSettings } from '../../../../../../shared/global-settings-types'
import type { AccountsPaneSectionModel } from '../accounts-pane-types'
@@ -8,16 +8,13 @@ import { resolveLocalAccountRuntimeTarget } from '../../../../../../shared/local
import { getRendererAppPlatform } from '../../../../lib/renderer-app-platform'
import { getIntlLocale, translate } from '@/i18n/i18n'
import type { Translate } from '@/i18n/use-translate'
import type { LocalAccountRuntime } from '../accounts-pane-types'
import {
type LocalAccountRuntime,
getHostRuntimeLabel
} from '../../../../lib/provider-accounts/account-runtime-label'
export const EMPTY_WSL_DISTROS: string[] = []
export function getHostRuntimeLabel(t: Translate = translate): string {
return navigator.userAgent.includes('Windows')
? 'Windows'
: t('auto.components.settings.AccountsPane.9baf45d071', 'This device')
}
// System default has no saved identity; show live host login or custom-provider detail, falling back when signed out.
export function getCodexSystemDefaultSubtitle(
identity: CodexSystemDefaultIdentity | undefined,
@@ -98,13 +95,6 @@ export function getSelectedAccountRuntime(
return { runtime: 'host', label: getHostRuntimeLabel(t) }
}
// Standalone runtime labels need sentence casing when interpolated into prose.
export function getRuntimeSentenceLabel(runtime: LocalAccountRuntime): string {
return runtime.runtime === 'host' && !navigator.userAgent.includes('Windows')
? `${runtime.label.charAt(0).toLocaleLowerCase()}${runtime.label.slice(1)}`
: runtime.label
}
export function formatAccountTimestamp(
timestamp: number,
intlLocale: string = getIntlLocale()
@@ -1,6 +1,6 @@
import { getDefaultSettings } from '../../../../../shared/constants'
import { defineFixture } from '../../../component-fixtures/component-fixture'
import { AgentWorkspaceTrustSetting } from './AgentsPane'
import { AgentWorkspaceTrustSetting } from './behavior/AgentWorkspaceTrustSetting'
export const on = defineFixture({
width: 640,
@@ -1,79 +0,0 @@
import { describe, expect, it, vi } from 'vitest'
import { getDefaultSettings } from '../../../../../shared/constants'
import type { GlobalSettings } from '../../../../../shared/global-settings-types'
import { useAppStore } from '../../../store/index'
import { createAgentAvailabilityUpdateQueue } from '../../../lib/agent-session/launch/agent-settings-update-queue'
type Deferred = {
promise: Promise<void>
resolve: () => void
}
function createDeferred(): Deferred {
let resolve!: () => void
const promise = new Promise<void>((next) => {
resolve = next
})
return { promise, resolve }
}
async function flushPromiseQueue(): Promise<void> {
await Promise.resolve()
await Promise.resolve()
}
describe('AgentsPane', () => {
it('serializes rapid availability writes against the latest settings snapshot', async () => {
const queueAvailabilityUpdate = createAgentAvailabilityUpdateQueue()
const settings: GlobalSettings = {
...getDefaultSettings('/tmp'),
defaultTuiAgent: null,
disabledTuiAgents: []
}
const writes: Deferred[] = []
const updates: Partial<GlobalSettings>[] = []
useAppStore.setState({ settings })
const updateSettings = vi.fn((update: Partial<GlobalSettings>) => {
updates.push(update)
const nextSettings = {
...(useAppStore.getState().settings ?? settings),
...update
}
const write = createDeferred()
writes.push(write)
return write.promise.then(() => {
useAppStore.setState({ settings: nextSettings })
})
})
const firstWrite = queueAvailabilityUpdate({
getSettings: () => useAppStore.getState().settings,
fallbackSettings: settings,
updateSettings,
agentId: 'claude',
enabled: false
})
const secondWrite = queueAvailabilityUpdate({
getSettings: () => useAppStore.getState().settings,
fallbackSettings: settings,
updateSettings,
agentId: 'codex',
enabled: false
})
await flushPromiseQueue()
expect(updateSettings).toHaveBeenCalledTimes(1)
expect(updates[0]).toMatchObject({ disabledTuiAgents: ['claude'] })
writes[0].resolve()
await firstWrite
await flushPromiseQueue()
expect(updateSettings).toHaveBeenCalledTimes(2)
expect(updates[1]).toMatchObject({ disabledTuiAgents: ['claude', 'codex'] })
writes[1].resolve()
await secondWrite
})
})
@@ -18,13 +18,8 @@ import {
getAgentStatusHooksDescription,
getAgentStatusHooksTitle
} from './behavior/agent-status-hooks-copy'
import {
getAgentWorkspaceTrustDescription,
getAgentWorkspaceTrustTitle
} from './behavior/agent-workspace-trust-copy'
import { SettingsSwitchRow } from '../form-controls/SettingsFormControls'
import { isPairedWebClientWindow } from '@/lib/desktop-window-chrome'
import { AgentLaunchSettingsSection } from './launch/AgentLaunchSettingsSection'
import {
AgentPermissionsSetting,
@@ -33,6 +28,7 @@ import {
import type { SettingsHostScope } from '../host-scope/settings-host-scope'
import { SettingsGroup } from '../section-layout/SettingsGroup'
import { useTranslate } from '@/i18n/use-translate'
import { AgentWorkspaceTrustSetting } from './behavior/AgentWorkspaceTrustSetting'
type AgentSettingProps = {
settings: GlobalSettings
@@ -120,7 +116,7 @@ function renderAgentPermissions(props: AgentPermissionsSettingProps): React.Reac
return <AgentPermissionsSetting {...props} />
}
export function AgentStatusHooksSetting({ settings, updateSettings }: AgentSettingProps) {
function AgentStatusHooksSetting({ settings, updateSettings }: AgentSettingProps) {
const t = useTranslate()
const enabled = settings.agentStatusHooksEnabled !== false
return (
@@ -134,21 +130,7 @@ export function AgentStatusHooksSetting({ settings, updateSettings }: AgentSetti
)
}
export function AgentWorkspaceTrustSetting({ settings, updateSettings }: AgentSettingProps) {
const t = useTranslate()
const enabled = settings.agentWorkspaceTrustEnabled !== false
return (
<SettingsSwitchRow
label={getAgentWorkspaceTrustTitle(t)}
description={getAgentWorkspaceTrustDescription(t)}
checked={enabled}
onChange={() => updateSettings({ agentWorkspaceTrustEnabled: !enabled })}
ariaLabel={getAgentWorkspaceTrustTitle(t)}
/>
)
}
export function AgentGeneratedTabTitlesSetting({ settings, updateSettings }: AgentSettingProps) {
function AgentGeneratedTabTitlesSetting({ settings, updateSettings }: AgentSettingProps) {
const t = useTranslate()
const enabled = settings.tabAutoGenerateTitle === true
return (
@@ -0,0 +1,27 @@
import type { GlobalSettings } from '../../../../../../shared/global-settings-types'
import { useTranslate } from '../../../../i18n/use-translate'
import { SettingsSwitchRow } from '../../form-controls/SettingsFormControls'
import {
getAgentWorkspaceTrustTitle,
getAgentWorkspaceTrustDescription
} from './agent-workspace-trust-copy'
export function AgentWorkspaceTrustSetting({
settings,
updateSettings
}: {
settings: GlobalSettings
updateSettings: (updates: Partial<GlobalSettings>) => void | Promise<void>
}) {
const t = useTranslate()
const enabled = settings.agentWorkspaceTrustEnabled !== false
return (
<SettingsSwitchRow
label={getAgentWorkspaceTrustTitle(t)}
description={getAgentWorkspaceTrustDescription(t)}
checked={enabled}
onChange={() => updateSettings({ agentWorkspaceTrustEnabled: !enabled })}
ariaLabel={getAgentWorkspaceTrustTitle(t)}
/>
)
}
@@ -6,7 +6,6 @@ import { cn } from '@/lib/utils'
import { useTranslate } from '@/i18n/use-translate'
import { Button } from '../../../ui/button'
import { SettingsBadge, SettingsSegmentedControl } from '../../form-controls/SettingsFormControls'
import {
type AgentSessionSourceHomeControl,
AgentSessionSourceHomeInput
@@ -24,11 +23,9 @@ import {
AgentDefaultArgsInput,
AgentDefaultEnvInput
} from '../../../agent/launch-settings/AgentLaunchDefaultsEditor'
import {
agentPermissionChoiceLabel,
AgentPermissionMenu,
type AgentPermissionChoiceRow
} from '../../../agent/launch-settings/AgentPermissionChoiceControls'
import { agentPermissionChoiceLabel } from '../../../agent/launch-settings/agent-permission-choice-label'
import { AgentPermissionMenu } from '../../../agent/launch-settings/AgentPermissionMenu'
import type { AgentPermissionChoiceRow } from '../../../agent/launch-settings/agent-permission-choice-row'
import { openAppHttpLinkFromAnchor } from '@/lib/browser/navigation/app-http-link-open'
import type { AgentOpensAs } from '../../../../lib/agent-session/launch/native-chat-provider-choice'
import { AgentOpensAsControl } from '../../../agent/launch-settings/AgentChatChoiceControls'
@@ -23,11 +23,9 @@ import {
} from '../../../../../../shared/agent-launch/permissions/tui-agent-permission-choice'
import { agentArgsSetPermission } from '../../../../../../shared/agent-launch/permissions/agent-permission-args'
import { liftAgentPermissionArgs } from '../../../../../../shared/agent-launch/permissions/tui-agent-permission-lift'
import {
agentPermissionChoiceLabel,
AllAgentsPermissionSetting,
type AgentPermissionChoiceRow
} from '@/components/agent/launch-settings/AgentPermissionChoiceControls'
import { agentPermissionChoiceLabel } from '../../../agent/launch-settings/agent-permission-choice-label'
import { AllAgentsPermissionSetting } from '../permissions/AllAgentsPermissionSetting'
import type { AgentPermissionChoiceRow } from '../../../agent/launch-settings/agent-permission-choice-row'
import type { AgentPermissionsSettingProps } from '@/components/settings/agents/permissions/AgentPermissionsSetting'
import {
buildAgentRowPermissions,
@@ -1,6 +1,6 @@
import { useTranslate } from '@/i18n/use-translate'
import { AgentDefaultSetting } from './AgentDefaultSetting'
import { AllAgentsPermissionSetting } from '../../../agent/launch-settings/AgentPermissionChoiceControls'
import { AllAgentsPermissionSetting } from '../permissions/AllAgentsPermissionSetting'
export function AgentLaunchSettingsLoading(): React.JSX.Element {
const t = useTranslate()
@@ -0,0 +1,124 @@
import { useTranslate } from '../../../../i18n/use-translate'
import type { AgentPermissionChoice } from '../../../../../../shared/agent-launch/permissions/tui-agent-permission-choice'
import { ChevronDown } from 'lucide-react'
import { Button } from '../../../ui/button'
import {
DropdownMenu,
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuRadioGroup
} from '../../../ui/dropdown-menu'
import {
AgentPermissionChoiceItems,
AgentPermissionChoiceName
} from '../../../agent/launch-settings/AgentPermissionChoiceItems'
export function AllAgentsPermissionSetting({
chatOwnSupported = false,
choice,
withoutAutoChoice,
onChange,
onChangeWithoutAuto
}: {
chatOwnSupported?: boolean
choice: AgentPermissionChoice | null
/** What the agents without Approve for me share; null when they differ. */
withoutAutoChoice: AgentPermissionChoice | null
onChange: (choice: AgentPermissionChoice) => void
onChangeWithoutAuto: (choice: AgentPermissionChoice) => void
}): React.JSX.Element {
const t = useTranslate()
const title = t('settings.agents.permissionsTitle', 'Permissions')
const ownLabel = t('settings.agents.permissionEachOwn', "Each agent's own settings")
const withoutAutoTitle = t(
'settings.agents.otherAgentsPermissionsLabel',
'Permissions for other agents'
)
return (
<section className="space-y-1">
<div className="flex flex-wrap items-center gap-x-3 gap-y-1">
<h3 className="text-sm font-semibold">{title}</h3>
<DropdownMenu>
<DropdownMenuTrigger asChild disabled={choice === null}>
<Button
type="button"
variant="outline"
size="xs"
aria-label={title}
className="w-48 max-w-full justify-between"
>
{choice === null ? (
<span className="h-4" />
) : (
<AgentPermissionChoiceName choice={choice} ownLabel={ownLabel} truncate />
)}
<ChevronDown className="size-3 shrink-0" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="start" collisionPadding={8} className="w-72">
<DropdownMenuRadioGroup aria-label={title} value={choice ?? ''}>
<AgentPermissionChoiceItems
choices={['ask', 'auto', 'full-access', 'own']}
ownLabel={ownLabel}
chatOwnSupported={chatOwnSupported}
onSelect={onChange}
/>
</DropdownMenuRadioGroup>
</DropdownMenuContent>
</DropdownMenu>
</div>
<p className="text-xs text-muted-foreground">
{t(
'settings.agents.permissionsChoiceExplanation',
'What every agent may do without asking. You can set one agent differently below.'
)}
</p>
<div className="min-h-6">
{choice === 'auto' ? (
<div className="flex items-center gap-2">
<span className="text-xs text-muted-foreground">
{t('settings.agents.permissionWithoutAuto', 'Agents without Approve for me')}
</span>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
type="button"
variant="outline"
size="xs"
aria-label={withoutAutoTitle}
className="min-w-0 max-w-full"
>
{withoutAutoChoice === null ? (
<span className="truncate">
{t('settings.agents.permissionMixed', 'Mixed')}
</span>
) : (
<AgentPermissionChoiceName
choice={withoutAutoChoice}
ownLabel={ownLabel}
truncate
/>
)}
<ChevronDown className="size-3 shrink-0" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="start" collisionPadding={8} className="w-72">
<DropdownMenuRadioGroup
aria-label={withoutAutoTitle}
value={withoutAutoChoice ?? ''}
>
<AgentPermissionChoiceItems
choices={['full-access', 'own']}
ownLabel={ownLabel}
chatOwnSupported={chatOwnSupported}
onSelect={onChangeWithoutAuto}
/>
</DropdownMenuRadioGroup>
</DropdownMenuContent>
</DropdownMenu>
</div>
) : null}
</div>
</section>
)
}
@@ -1,5 +1,5 @@
import type { AgentPermissionMode } from '../../../../../../shared/agent-launch/permissions/tui-agent-permissions'
import { agentPermissionChoiceLabel } from '../../../agent/launch-settings/AgentPermissionChoiceControls'
import { agentPermissionChoiceLabel } from '../../../agent/launch-settings/agent-permission-choice-label'
import type { Translate } from '../../../../i18n/use-translate'
export function agentPermissionModeChoice(mode: Exclude<AgentPermissionMode, 'mixed'>) {
@@ -8,10 +8,10 @@ import { getRepoKindLabel, isFolderRepo } from '../../../../../shared/repo-kind'
import { getRepoExecutionHostId, type ExecutionHostId } from '../../../../../shared/execution-host'
import { Label } from '../../ui/label'
import { useShallow } from 'zustand/react/shallow'
import { RepositoryHooksSection } from './execution/RepositoryHooksSection'
import { RepositoryHooksSection } from './hooks/RepositoryHooksSection'
import { McpConfigSection } from './mcp/McpConfigSection'
import { WorktreeSymlinksSection } from './execution/WorktreeSymlinksSection'
import { SparsePresetSettingsSection } from './execution/SparsePresetSettingsSection'
import { WorktreeSymlinksSection } from './worktrees/WorktreeSymlinksSection'
import { SparsePresetSettingsSection } from './worktrees/SparsePresetSettingsSection'
import { RepositorySourceControlAiSection } from './source-control/RepositorySourceControlAiSection'
import { SearchableSetting } from '../section-layout/SearchableSetting'
import { SettingsGroup } from '../section-layout/SettingsGroup'
@@ -22,20 +22,20 @@ import { useAppStore } from '@/store/index'
import { getRepositoryIconSectionId } from './repository-settings-targets'
import { RepositoryIconPicker } from './identity/RepositoryIconPicker'
import { getRepositoryPaneSearchEntries } from './repository-search'
import { RepositoryHostSetupsSection } from './execution/RepositoryHostSetupsSection'
import { RepositoryHostSetupsSection } from './hosts/RepositoryHostSetupsSection'
import { RepoSettingsDraftInput } from './RepositorySettingsDraftInput'
import { RepositoryForkSyncSection } from './execution/RepositoryForkSyncSection'
import { RepositoryForkSyncSection } from './source-control/RepositoryForkSyncSection'
import {
getRepositoryAgentTrustSearchEntry,
RepositoryAgentTrustSection
} from './RepositoryAgentTrustSection'
import { RepositoryGitHubAccountSection } from './RepositoryGitHubAccountSection'
import { RepositoryGitHubAccountSection } from './source-control/RepositoryGitHubAccountSection'
import { useTranslate } from '@/i18n/use-translate'
import { RepositoryWindowsRuntimeSection } from './execution/RepositoryWindowsRuntimeSection'
import { RepositoryWindowsRuntimeSection } from './runtime/RepositoryWindowsRuntimeSection'
import { matchesRepositoryIdentitySearch } from './identity/repository-identity-search'
import { RepositoryWorktreeDefaultsSection } from './execution/RepositoryWorktreeDefaultsSection'
import { RepositoryWorktreeDefaultsSection } from './worktrees/RepositoryWorktreeDefaultsSection'
import { RepositoryJiraProjectSection } from './RepositoryJiraProjectSection'
import { getProjectRuntimeSessionSummary } from './execution/repository-runtime-session-summary'
import { getProjectRuntimeSessionSummary } from './runtime/repository-runtime-session-summary'
import { getRepoOwnerWorktreeVisibilityDefaults } from '../../../store/slices/worktrees/listing/worktree-visibility-defaults-by-host'
import {
RepositoryFormatterSection,
@@ -1,31 +0,0 @@
import type { SparsePresetDirectoryParseResult } from '@/lib/sparse-preset-draft'
import { SparsePresetInlineEditor } from '../../../sparse/SparsePresetInlineEditor'
import type { SparsePresetDraft } from '../../../sparse/SparseCheckoutPresetDraftForm'
type SparsePresetDraftEditorProps = {
draft: SparsePresetDraft
setDraft: (draft: SparsePresetDraft | null) => void
nameError: string | null
parsedDirectories: SparsePresetDirectoryParseResult | null
canSaveDraft: boolean
submitting: boolean
onSave: () => void
operationError?: string | null
repoRootPath?: string
repoConnectionId?: string
}
export function SparsePresetDraftEditor({
setDraft,
canSaveDraft,
...props
}: SparsePresetDraftEditorProps): React.JSX.Element {
return (
<SparsePresetInlineEditor
{...props}
onDraftChange={setDraft}
canSave={canSaveDraft}
onCancel={() => setDraft(null)}
/>
)
}
@@ -13,7 +13,7 @@ vi.mock('@/runtime/repo-hooks/runtime-hooks-client', () => ({
}))
vi.mock('sonner', () => ({ toast: { error: vi.fn() } }))
import { useRepositoryIssueCommand } from '../execution/use-repository-issue-command'
import { useRepositoryIssueCommand } from './use-repository-issue-command'
const distroRunningListeners = new Set<(distro: string) => void>()
const REFUSED = {
@@ -0,0 +1,45 @@
import type { Repo } from '../../../../../../shared/repo-types'
import type { SettingsSearchEntry } from '../../search/settings-search'
import { translate } from '@/i18n/i18n'
import type { Translate } from '@/i18n/use-translate'
import { searchKeywordTranslator } from '../../search/settings-search-keywords'
export function getRepositoryMcpConfigSearchEntries(
repo: Repo,
t: Translate = translate
): SettingsSearchEntry[] {
const translateSearchKeyword = searchKeywordTranslator(t)
return [
{
title: t('auto.components.settings.repository.search.31bd0a2420', 'MCP Configs'),
description: t(
'auto.components.settings.repository.search.3c31801626',
'Inspect project-level MCP server config files.'
),
keywords: [
repo.displayName,
...translateSearchKeyword('auto.components.settings.repository.search.343f0a508c', 'mcp'),
...translateSearchKeyword(
'auto.components.settings.repository.search.16dc7a4637',
'model context protocol'
),
...translateSearchKeyword(
'auto.components.settings.repository.search.e760e3fae7',
'.mcp.json'
),
...translateSearchKeyword(
'auto.components.settings.repository.search.26f42fe773',
'.cursor/mcp.json'
),
...translateSearchKeyword(
'auto.components.settings.repository.search.db11b337c4',
'.claude.json'
),
...translateSearchKeyword(
'auto.components.settings.repository.search.d73fb47b45',
'.claude/mcp.json'
)
]
}
]
}
@@ -8,9 +8,10 @@ import type { SettingsSearchEntry } from '../search/settings-search'
import { translate } from '@/i18n/i18n'
import type { Translate } from '@/i18n/use-translate'
import { searchKeywordTranslator } from '../search/settings-search-keywords'
import { getRepositoryGitAuthorSearchEntries } from './repository-git-author-search-entries'
import { getRepositoryGitHooksSearchEntries } from './execution/repository-git-hooks-search-entries'
import { getRepositoryGitWorktreeSearchEntries } from './execution/repository-git-worktree-search-entries'
import { getRepositoryGitAuthorSearchEntries } from './source-control/repository-git-author-search-entries'
import { getRepositoryMcpConfigSearchEntries } from './mcp/mcp-config-search'
import { getRepositoryGitHooksSearchEntries } from './hooks/repository-git-hooks-search-entries'
import { getRepositoryGitWorktreeSearchEntries } from './worktrees/repository-git-worktree-search-entries'
import { getRepositoryFormatterSearchEntry } from './RepositoryFormatterSection'
import { getRepositoryAgentTrustSearchEntry } from './RepositoryAgentTrustSection'
@@ -249,6 +250,7 @@ export function getRepositoryPaneSearchEntries(
? []
: [
...getRepositoryGitAuthorSearchEntries(repo, t),
...getRepositoryMcpConfigSearchEntries(repo, t),
...getRepositoryGitHooksSearchEntries(repo, t)
])
]
@@ -1,21 +1,24 @@
import { useCallback, useEffect, useId, useMemo, useRef, useState } from 'react'
import { RefreshCw } from 'lucide-react'
import type { GhAccountBinding } from '../../../../../shared/github/account-binding'
import type { Repo } from '../../../../../shared/repo-types'
import type { GhAccountBindingInventory } from '../../../../../shared/github/auth-types'
import { Button } from '../../ui/button'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../../ui/select'
import { SearchableSetting } from '../section-layout/SearchableSetting'
import type { GhAccountBinding } from '../../../../../../shared/github/account-binding'
import type { Repo } from '../../../../../../shared/repo-types'
import type { GhAccountBindingInventory } from '../../../../../../shared/github/auth-types'
import { Button } from '../../../ui/button'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../../../ui/select'
import { SearchableSetting } from '../../section-layout/SearchableSetting'
import { useAppStore } from '@/store/index'
import { runtimeTargetForOwnerEnvironment } from '@/runtime/rpc/targets/runtime-client-target'
import { getRepoExecutionHostId, parseExecutionHostId } from '../../../../../shared/execution-host'
import {
getRepoExecutionHostId,
parseExecutionHostId
} from '../../../../../../shared/execution-host'
import { useTranslate } from '@/i18n/use-translate'
import { searchKeywords } from '../search/settings-search-keywords'
import { searchKeywords } from '../../search/settings-search-keywords'
import {
isGhAccountBindingEnforced,
listRepositoryGhBindableAccounts,
validateRepositoryGhAccountBinding
} from '../../../runtime/repository-github/repository-github-account'
} from '../../../../runtime/repository-github/repository-github-account'
type RepositoryGitHubAccountSectionProps = {
repo: Repo
@@ -23,11 +23,12 @@ import { isCustomAgentId } from '../../../../../../shared/source-control/ai/gene
import {
type SourceControlActionId,
SOURCE_CONTROL_ACTION_IDS,
SOURCE_CONTROL_ACTION_LABELS
SOURCE_CONTROL_ACTION_LABELS,
resolveSourceControlActionCommandTemplate
} from '../../../../../../shared/source-control/ai/recipes/source-control-ai-actions'
import { Input } from '../../../ui/input'
import { Label } from '../../../ui/label'
import { RepositorySourceControlAiActionSaveControls } from '../../source-control/RepositorySourceControlAiActionSaveControls'
import { RepositorySourceControlAiActionSaveControls } from './RepositorySourceControlAiActionSaveControls'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../../../ui/select'
import { SourceControlActionVariableChips } from '../../../source-control/SourceControlActionVariableChips'
import {
@@ -45,7 +46,6 @@ import {
agentArgsStateLabel,
commandTemplateStateLabel,
readInheritedAgentArgs,
readInheritedCommandTemplate,
resolveAgentArgsPlaceholderAgent
} from './repository-source-control-ai-labels'
import { getRepositorySourceControlAiActionRecipeSectionId } from '../repository-settings-targets'
@@ -129,7 +129,10 @@ const SelectedRepositoryActionRows = memo(
{SOURCE_CONTROL_ACTION_IDS.map((actionId) => {
const hasOverride = hasOwnActionOverride(repoAi.actionOverrides, actionId)
const override = repoAi.actionOverrides?.[actionId]
const inheritedTemplate = readInheritedCommandTemplate(source, actionId)
const inheritedTemplate = resolveSourceControlActionCommandTemplate(
source.actions,
actionId
)
const inheritedAgentArgs = readInheritedAgentArgs(source, actionId)
const templateValue =
hasOverride && typeof override?.commandInputTemplate === 'string'
@@ -1,4 +1,4 @@
import { Button } from '../../ui/button'
import { Button } from '../../../ui/button'
import { useTranslate } from '@/i18n/use-translate'
type RepositorySourceControlAiActionSaveControlsProps = {
@@ -1,8 +1,8 @@
import type { Repo } from '../../../../../shared/repo-types'
import type { SettingsSearchEntry } from '../search/settings-search'
import type { Repo } from '../../../../../../shared/repo-types'
import type { SettingsSearchEntry } from '../../search/settings-search'
import { translate } from '@/i18n/i18n'
import type { Translate } from '@/i18n/use-translate'
import { searchKeywordTranslator } from '../search/settings-search-keywords'
import { searchKeywordTranslator } from '../../search/settings-search-keywords'
export function getRepositoryGitAuthorSearchEntries(
repo: Repo,
@@ -43,37 +43,6 @@ export function getRepositoryGitAuthorSearchEntries(
...translateSearchKeyword('auto.components.settings.repository.search.fa3131f223', 'model'),
...translateSearchKeyword('auto.components.settings.repository.search.fff8834983', 'prompt')
]
},
{
title: t('auto.components.settings.repository.search.31bd0a2420', 'MCP Configs'),
description: t(
'auto.components.settings.repository.search.3c31801626',
'Inspect project-level MCP server config files.'
),
keywords: [
repo.displayName,
...translateSearchKeyword('auto.components.settings.repository.search.343f0a508c', 'mcp'),
...translateSearchKeyword(
'auto.components.settings.repository.search.16dc7a4637',
'model context protocol'
),
...translateSearchKeyword(
'auto.components.settings.repository.search.e760e3fae7',
'.mcp.json'
),
...translateSearchKeyword(
'auto.components.settings.repository.search.26f42fe773',
'.cursor/mcp.json'
),
...translateSearchKeyword(
'auto.components.settings.repository.search.db11b337c4',
'.claude.json'
),
...translateSearchKeyword(
'auto.components.settings.repository.search.d73fb47b45',
'.claude/mcp.json'
)
]
}
]
}
@@ -1,3 +1,7 @@
import {
readCompleteRecipeForDraft,
type RepoActionRecipe
} from './repository-source-control-ai-recipe-completion'
import {
readActionRecipeTextDraft,
sameDraftLaunchPreferences,
@@ -6,7 +10,6 @@ import {
} from './repository-source-control-ai-recipe-text'
import { normalizeRepoSourceControlAiOverrides } from '../../../../../../shared/source-control/ai/settings/source-control-ai-repo-settings'
import { resolveSourceControlActionRecipe } from '../../../../../../shared/source-control/ai/source-control-ai-operation-policy'
import {
SOURCE_CONTROL_ACTION_IDS,
SOURCE_CONTROL_TEXT_ACTION_IDS,
@@ -15,13 +18,8 @@ import {
import type { RepoSourceControlAiOverrides } from '../../../../../../shared/source-control/ai/settings/source-control-ai-settings-types'
import { withRepoTextModelEdits } from '../../source-control/text-actions/source-control-text-action-model-replay'
import type { GlobalSettings } from '../../../../../../shared/global-settings-types'
import { completeRepoActionRecipe } from './repository-source-control-ai-labels'
import { SOURCE_CONTROL_TEXT_ACTION_ID_SET } from '../../source-control/source-control-action-recipe-options'
type RepoActionRecipe = NonNullable<
NonNullable<RepoSourceControlAiOverrides['actionOverrides']>[SourceControlActionId]
>
export function hasOwnActionOverride(
overrides: RepoSourceControlAiOverrides['actionOverrides'],
actionId: SourceControlActionId
@@ -61,22 +59,6 @@ export function dropRepoLegacyInstructionForAction(
}
}
/** The action an edit starts from: the complete recipe it resolves to, owned or partial, keeping a
* saved explicit args clear and never the agent only detected to run a default selection. */
export function readCompleteRecipeForDraft(
current: RepoSourceControlAiOverrides,
settings: Pick<GlobalSettings, 'sourceControlAi' | 'commitMessageAi' | 'defaultTuiAgent'> | null,
actionId: SourceControlActionId
): RepoActionRecipe {
const recipe = resolveSourceControlActionRecipe({
settings,
repo: { sourceControlAi: current },
actionId
})
const cleared = current.actionOverrides?.[actionId]?.agentArgs === null
return { ...completeRepoActionRecipe(recipe, actionId), ...(cleared ? { agentArgs: null } : {}) }
}
export function setActionOverride(
current: RepoSourceControlAiOverrides,
actionId: SourceControlActionId,
@@ -1,3 +1,4 @@
import { readCompleteRecipeForDraft } from './repository-source-control-ai-recipe-completion'
import type {
HostedReviewDefaultKey,
UseRepositorySourceControlAiGlobalUxArgs
@@ -19,7 +20,6 @@ import {
composeDisplayRepoAi,
computeActionDirtyById,
hasOwnActionOverride,
readCompleteRecipeForDraft,
retainCustomCommandDraft,
retainDivergentActionTextDrafts,
withRepoAiActionMode,
@@ -1,7 +1,4 @@
import {
lowerActionArgumentChoices,
demoteActionArgumentChoices
} from '../../../../../../shared/source-control/ai/recipes/source-control-action-argument-document'
import { lowerActionArgumentChoices } from '../../../../../../shared/source-control/ai/recipes/source-control-action-argument-document'
import {
sourceControlActionSelectedPreferences,
sourceControlActionExecutionArgs
@@ -10,7 +7,6 @@ import type { TuiAgent } from '../../../../../../shared/agent-launch/catalog/tui
import { readActionModelSelection } from '../../../../../../shared/source-control/ai/recipes/source-control-action-model-selection'
import {
DEFAULT_SOURCE_CONTROL_ACTION_COMMAND_TEMPLATES,
resolveSourceControlActionCommandTemplate,
type SourceControlActionId,
type SourceControlActionRecipe
} from '../../../../../../shared/source-control/ai/recipes/source-control-ai-actions'
@@ -27,13 +23,6 @@ export const DEFAULT_AGENT_VALUE = '__default_agent__'
export const CUSTOM_COMMAND_MODE_INHERIT = 'inherit'
export const CUSTOM_COMMAND_MODE_REPO = 'repo'
export function readInheritedCommandTemplate(
source: SourceControlAiSettings,
actionId: SourceControlActionId
): string {
return resolveSourceControlActionCommandTemplate(source.actions, actionId)
}
export function readInheritedAgentArgs(
source: SourceControlAiSettings,
actionId: SourceControlActionId
@@ -60,29 +49,6 @@ export function resolveAgentArgsPlaceholderAgent(
return defaultTuiAgent && defaultTuiAgent !== 'blank' ? defaultTuiAgent : null
}
export function completeRepoActionRecipe(
recipe: SourceControlActionRecipe,
actionId: SourceControlActionId
): NonNullable<
NonNullable<RepoSourceControlAiOverrides['actionOverrides']>[SourceControlActionId]
> {
if (recipe.argumentChoices && recipe.argumentChoices.syntaxAgent !== recipe.agentId) {
recipe = demoteActionArgumentChoices(recipe)
}
const commandInputTemplate =
typeof recipe.commandInputTemplate === 'string'
? recipe.commandInputTemplate
: DEFAULT_SOURCE_CONTROL_ACTION_COMMAND_TEMPLATES[actionId]
return {
agentId: recipe.agentId ?? null,
commandInputTemplate,
...(typeof recipe.agentArgs === 'string' ? { agentArgs: recipe.agentArgs } : {}),
...(recipe.argumentChoices ? { argumentChoices: recipe.argumentChoices } : {}),
...(recipe.launchPreferences ? { launchPreferences: recipe.launchPreferences } : {}),
...(recipe.surface ? { surface: recipe.surface } : {})
}
}
export function actionScopeLabel(hasOverride: boolean): string {
return hasOverride ? 'Customized for this repository' : 'Using global settings'
}
@@ -0,0 +1,52 @@
import { demoteActionArgumentChoices } from '../../../../../../shared/source-control/ai/recipes/source-control-action-argument-document'
import { resolveSourceControlActionRecipe } from '../../../../../../shared/source-control/ai/source-control-ai-operation-policy'
import {
DEFAULT_SOURCE_CONTROL_ACTION_COMMAND_TEMPLATES,
type SourceControlActionRecipe,
type SourceControlActionId
} from '../../../../../../shared/source-control/ai/recipes/source-control-ai-actions'
import type { RepoSourceControlAiOverrides } from '../../../../../../shared/source-control/ai/settings/source-control-ai-settings-types'
import type { GlobalSettings } from '../../../../../../shared/global-settings-types'
export type RepoActionRecipe = NonNullable<
NonNullable<RepoSourceControlAiOverrides['actionOverrides']>[SourceControlActionId]
>
function completeRepoActionRecipe(
recipe: SourceControlActionRecipe,
actionId: SourceControlActionId
): NonNullable<
NonNullable<RepoSourceControlAiOverrides['actionOverrides']>[SourceControlActionId]
> {
if (recipe.argumentChoices && recipe.argumentChoices.syntaxAgent !== recipe.agentId) {
recipe = demoteActionArgumentChoices(recipe)
}
const commandInputTemplate =
typeof recipe.commandInputTemplate === 'string'
? recipe.commandInputTemplate
: DEFAULT_SOURCE_CONTROL_ACTION_COMMAND_TEMPLATES[actionId]
return {
agentId: recipe.agentId ?? null,
commandInputTemplate,
...(typeof recipe.agentArgs === 'string' ? { agentArgs: recipe.agentArgs } : {}),
...(recipe.argumentChoices ? { argumentChoices: recipe.argumentChoices } : {}),
...(recipe.launchPreferences ? { launchPreferences: recipe.launchPreferences } : {}),
...(recipe.surface ? { surface: recipe.surface } : {})
}
}
/** The action an edit starts from: the complete recipe it resolves to, owned or partial, keeping a
* saved explicit args clear and never the agent only detected to run a default selection. */
export function readCompleteRecipeForDraft(
current: RepoSourceControlAiOverrides,
settings: Pick<GlobalSettings, 'sourceControlAi' | 'commitMessageAi' | 'defaultTuiAgent'> | null,
actionId: SourceControlActionId
): RepoActionRecipe {
const recipe = resolveSourceControlActionRecipe({
settings,
repo: { sourceControlAi: current },
actionId
})
const cleared = current.actionOverrides?.[actionId]?.agentArgs === null
return { ...completeRepoActionRecipe(recipe, actionId), ...(cleared ? { agentArgs: null } : {}) }
}
@@ -21,7 +21,7 @@ import {
type ActionRecipeTextDraft
} from './repository-source-control-ai-recipe-text'
import { retireActionLaunchPreferences } from '../../source-control/source-control-ai-action-recipe-draft'
import { readInheritedCommandTemplate } from './repository-source-control-ai-labels'
import { resolveSourceControlActionCommandTemplate } from '../../../../../../shared/source-control/ai/recipes/source-control-ai-actions'
export function resetActionDraftLaunchPreferences(
current: Partial<Record<SourceControlActionId, ActionRecipeTextDraft>>,
@@ -136,7 +136,8 @@ export function createRepoActionTextDraftEditors(
const draft =
current[actionId] ?? readActionRecipeTextDraft(immediateRepoAiRef.current, actionId)
const currentTemplate =
draft.commandInputTemplate || readInheritedCommandTemplate(source, actionId)
draft.commandInputTemplate ||
resolveSourceControlActionCommandTemplate(source.actions, actionId)
const separator = currentTemplate.endsWith('\n') || currentTemplate.length === 0 ? '' : ' '
return patchActionTextDraft(current, immediateRepoAiRef.current, actionId, {
commandInputTemplate: `${currentTemplate}${separator}{${variable}}`
@@ -6,7 +6,7 @@ import { parseSparsePresetDirectories, validateSparsePresetName } from '@/lib/sp
import { useMountedRef } from '@/hooks/useMountedRef'
import { Button } from '../../../ui/button'
import { getSparsePresetOperationErrorMessage } from './sparse-preset-operation-error'
import { SparsePresetDraftEditor } from './sparse-preset-draft-editor'
import { SparsePresetInlineEditor } from '../../../sparse/SparsePresetInlineEditor'
import type { SparsePresetDraft } from '../../../sparse/SparseCheckoutPresetDraftForm'
import { SparsePresetSettingsRow } from './sparse-preset-settings-row'
import { useTranslate } from '@/i18n/use-translate'
@@ -183,10 +183,10 @@ export function SparsePresetSettingsSection({
}
const draftEditor = draft ? (
<SparsePresetDraftEditor
<SparsePresetInlineEditor
draft={draft}
operationError={operationError}
setDraft={(nextDraft) => {
onDraftChange={(nextDraft) => {
if (nextDraft) {
setDraft(nextDraft)
} else {
@@ -195,7 +195,8 @@ export function SparsePresetSettingsSection({
}}
nameError={nameError}
parsedDirectories={parsedDirectories}
canSaveDraft={canSaveDraft}
canSave={canSaveDraft}
onCancel={closeDraft}
submitting={submitting}
onSave={() => void handleSaveDraft()}
repoRootPath={repo?.path}
@@ -43,17 +43,7 @@ type PickerProps = {
onPick: (agent: TuiAgent | null, choice: Pick<SourceControlActionRecipe, 'surface'>) => void
}
export function SourceControlActionAgentPicker(
props: PickerProps | { text: ComponentProps<typeof AgentLaunchPicker> }
) {
return 'text' in props ? (
<AgentLaunchPicker {...props.text} />
) : (
<ObservedSourceControlActionAgentPicker {...props} />
)
}
function ObservedSourceControlActionAgentPicker(props: PickerProps) {
export function SourceControlActionAgentPicker(props: PickerProps) {
const repo = useAppStore((state) => state.repos.find((repo) => repo.id === props.repoId) ?? null)
const rows = props.repoId
? sourceControlRepoAgentRows(repo)
@@ -27,7 +27,7 @@ import type { TuiAgent } from '../../../../../shared/agent-launch/catalog/tui-ag
import { useAppStore } from '@/store/index'
import { useTranslate } from '@/i18n/use-translate'
import { AgentDefaultArgsInput } from '../../agent/launch-settings/AgentLaunchDefaultsEditor'
import { AgentPermissionMenu } from '../../agent/launch-settings/AgentPermissionChoiceControls'
import { AgentPermissionMenu } from '../../agent/launch-settings/AgentPermissionMenu'
export function SourceControlActionArguments({
agent,
@@ -43,7 +43,7 @@ import {
type AgentPickerEntry,
type AgentPickerDraft
} from '../../../../../../shared/agent-launch/picker/agent-launch-picker'
import { SourceControlActionAgentPicker } from '../SourceControlActionAgentPicker'
import { AgentLaunchPicker } from '@/components/agent/AgentLaunchPicker'
import { getAgentCatalogForAction } from '../source-control-action-recipe-options'
import { DropdownMenuItem } from '../../../ui/dropdown-menu'
@@ -308,8 +308,8 @@ const TextActionPicker = memo(
.filter(Boolean)
.join(' · ')
return (
<SourceControlActionAgentPicker
text={{
<AgentLaunchPicker
{...{
draftScope: props.draftScope,
agent: activeAgent,
disabled: props.disabled || !settings || Boolean(props.repoId && (!repo || !host)),
@@ -1,24 +1,8 @@
import { useState } from 'react'
import { JiraConnectDialog } from '@/components/jira-connect-dialog'
import { Button } from '@/components/ui/button'
import { TaskSourceShowInTasksStep } from './TaskSourceShowInTasksStep'
import { TaskSourceStepRow } from './TaskSourceStepRow'
import { useTranslate } from '@/i18n/use-translate'
type ConnectStepProps = {
visible: boolean
canHide: boolean
onToggleVisible: () => void
connected: boolean
checking: boolean
}
function getConnectStepState(props: ConnectStepProps): 'in-progress' | 'done' | 'pending' {
if (props.checking) {
return 'in-progress'
}
return props.connected ? 'done' : 'pending'
}
import { getConnectStepState, type ConnectStepProps } from './task-source-setup-state'
export function CodeHostSetupSteps(
props: ConnectStepProps & {
@@ -78,50 +62,3 @@ export function CodeHostSetupSteps(
</ol>
)
}
export function JiraSetupSteps(
props: ConnectStepProps & { onConnected: () => void; onOpenIntegrations: () => void }
): React.JSX.Element {
const t = useTranslate()
const [dialogOpen, setDialogOpen] = useState(false)
return (
<>
<ol className="divide-y divide-border/50">
<TaskSourceStepRow
index={1}
state={getConnectStepState(props)}
title={t('auto.components.settings.TasksPane.connectJiraTitle', 'Connect Jira')}
description={t(
'auto.components.settings.TasksPane.connectJiraDescription',
'Add a Jira Cloud site or self-hosted instance with an API token or PAT.'
)}
action={
<Button
type="button"
size="sm"
variant={props.connected ? 'outline' : 'default'}
onClick={props.connected ? props.onOpenIntegrations : () => setDialogOpen(true)}
>
{props.connected
? t('auto.components.settings.TasksPane.manageJira', 'Manage keys')
: t('auto.components.settings.TasksPane.addJira', 'Add Jira access')}
</Button>
}
/>
<TaskSourceShowInTasksStep
index={2}
providerLabel={t('auto.components.settings.TasksPane.6b23a34f6d', 'Jira')}
visible={props.visible}
canHide={props.canHide}
onToggleVisible={props.onToggleVisible}
/>
</ol>
<JiraConnectDialog
open={dialogOpen}
onOpenChange={setDialogOpen}
onConnected={props.onConnected}
/>
</>
)
}
@@ -0,0 +1,54 @@
import { useState } from 'react'
import { JiraConnectDialog } from '@/components/jira-connect-dialog'
import { Button } from '@/components/ui/button'
import { TaskSourceShowInTasksStep } from './TaskSourceShowInTasksStep'
import { TaskSourceStepRow } from './TaskSourceStepRow'
import { useTranslate } from '@/i18n/use-translate'
import { getConnectStepState, type ConnectStepProps } from './task-source-setup-state'
export function JiraSetupSteps(
props: ConnectStepProps & { onConnected: () => void; onOpenIntegrations: () => void }
): React.JSX.Element {
const t = useTranslate()
const [dialogOpen, setDialogOpen] = useState(false)
return (
<>
<ol className="divide-y divide-border/50">
<TaskSourceStepRow
index={1}
state={getConnectStepState(props)}
title={t('auto.components.settings.TasksPane.connectJiraTitle', 'Connect Jira')}
description={t(
'auto.components.settings.TasksPane.connectJiraDescription',
'Add a Jira Cloud site or self-hosted instance with an API token or PAT.'
)}
action={
<Button
type="button"
size="sm"
variant={props.connected ? 'outline' : 'default'}
onClick={props.connected ? props.onOpenIntegrations : () => setDialogOpen(true)}
>
{props.connected
? t('auto.components.settings.TasksPane.manageJira', 'Manage keys')
: t('auto.components.settings.TasksPane.addJira', 'Add Jira access')}
</Button>
}
/>
<TaskSourceShowInTasksStep
index={2}
providerLabel={t('auto.components.settings.TasksPane.6b23a34f6d', 'Jira')}
visible={props.visible}
canHide={props.canHide}
onToggleVisible={props.onToggleVisible}
/>
</ol>
<JiraConnectDialog
open={dialogOpen}
onOpenChange={setDialogOpen}
onConnected={props.onConnected}
/>
</>
)
}
@@ -1,43 +0,0 @@
// @vitest-environment happy-dom
import { cleanup, fireEvent, render } from '@testing-library/react'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { JiraSetupSteps } from './TaskSourceSimpleSetup'
const mocks = vi.hoisted(() => ({
dialogOpen: [] as boolean[]
}))
vi.mock('@/components/jira-connect-dialog', () => ({
JiraConnectDialog: ({ open }: { open: boolean }) => {
mocks.dialogOpen.push(open)
return null
}
}))
afterEach(() => {
cleanup()
mocks.dialogOpen = []
})
describe('JiraSetupSteps', () => {
it('routes connected credential management to Integrations', () => {
const onOpenIntegrations = vi.fn()
const rendered = render(
<JiraSetupSteps
connected
checking={false}
visible
canHide
onToggleVisible={vi.fn()}
onConnected={vi.fn()}
onOpenIntegrations={onOpenIntegrations}
/>
)
fireEvent.click(rendered.getByRole('button', { name: 'Manage keys' }))
expect(onOpenIntegrations).toHaveBeenCalledOnce()
expect(mocks.dialogOpen.at(-1)).toBe(false)
})
})
@@ -13,7 +13,8 @@ import { LinearIcon } from '@/components/icons/LinearIcon'
import { Button } from '@/components/ui/button'
import { useAppStore } from '@/store/index'
import { SearchableSetting } from '../section-layout/SearchableSetting'
import { CodeHostSetupSteps, JiraSetupSteps } from './TaskSourceSimpleSetup'
import { CodeHostSetupSteps } from './TaskSourceCodeHostSetup'
import { JiraSetupSteps } from './TaskSourceJiraSetup'
import { TaskSourceLinearSetup } from './TaskSourceLinearSetup'
import { TaskSourceProviderCard } from './TaskSourceProviderCard'
import {
@@ -145,3 +145,18 @@ export function resolveStickyAutoExpandedTaskProvider({
}): TaskProvider | null {
return previousAutoExpanded ?? getAutoExpandedTaskProvider(providers, readinessByProvider)
}
export type ConnectStepProps = {
visible: boolean
canHide: boolean
onToggleVisible: () => void
connected: boolean
checking: boolean
}
export function getConnectStepState(props: ConnectStepProps): 'in-progress' | 'done' | 'pending' {
if (props.checking) {
return 'in-progress'
}
return props.connected ? 'done' : 'pending'
}
@@ -11,7 +11,7 @@ import {
emptyClaudeAccountsState
} from '@/runtime/provider-accounts/observations/runtime-provider-accounts-client'
import { toast } from 'sonner'
import { getClaudeAccountErrorDescription } from '../settings/accounts/accounts-pane-action-errors'
import { getClaudeAccountErrorDescription } from '../../lib/provider-accounts/provider-account-action-errors'
import { useTranslate } from '@/i18n/use-translate'
import {
getWindowsTerminalCapabilityOwnerKey,
@@ -3,7 +3,7 @@ import type { RateLimitRuntimeTarget } from '../../../../shared/rate-limit-types
import { resolveLocalAccountRuntimeTarget } from '../../../../shared/local-account-runtime'
import { getRendererAppPlatform } from '../../lib/renderer-app-platform'
import { translate } from '@/i18n/i18n'
import { getHostRuntimeLabel } from '../settings/accounts/scope/accounts-pane-runtime'
import { getHostRuntimeLabel } from '../../lib/provider-accounts/account-runtime-label'
export type CodexStatusRuntimeTarget = {
runtime: 'host' | 'wsl'
@@ -1,6 +1,7 @@
import { describe, expect, it, vi } from 'vitest'
import { getDefaultSettings } from '../../../../../shared/constants'
import type { GlobalSettings } from '../../../../../shared/global-settings-types'
import { useAppStore } from '../../../store/index'
import { createAgentAvailabilityUpdateQueue } from './agent-settings-update-queue'
describe('agent availability settings', () => {
@@ -40,3 +41,77 @@ describe('agent availability settings', () => {
expect(updateSettings.mock.calls[1][0]).toMatchObject({ disabledTuiAgents: ['codex'] })
})
})
type Deferred = {
promise: Promise<void>
resolve: () => void
}
function createDeferred(): Deferred {
let resolve!: () => void
const promise = new Promise<void>((next) => {
resolve = next
})
return { promise, resolve }
}
async function flushPromiseQueue(): Promise<void> {
await Promise.resolve()
await Promise.resolve()
}
describe('AgentsPane', () => {
it('serializes rapid availability writes against the latest settings snapshot', async () => {
const queueAvailabilityUpdate = createAgentAvailabilityUpdateQueue()
const settings: GlobalSettings = {
...getDefaultSettings('/tmp'),
defaultTuiAgent: null,
disabledTuiAgents: []
}
const writes: Deferred[] = []
const updates: Partial<GlobalSettings>[] = []
useAppStore.setState({ settings })
const updateSettings = vi.fn((update: Partial<GlobalSettings>) => {
updates.push(update)
const nextSettings = {
...(useAppStore.getState().settings ?? settings),
...update
}
const write = createDeferred()
writes.push(write)
return write.promise.then(() => {
useAppStore.setState({ settings: nextSettings })
})
})
const firstWrite = queueAvailabilityUpdate({
getSettings: () => useAppStore.getState().settings,
fallbackSettings: settings,
updateSettings,
agentId: 'claude',
enabled: false
})
const secondWrite = queueAvailabilityUpdate({
getSettings: () => useAppStore.getState().settings,
fallbackSettings: settings,
updateSettings,
agentId: 'codex',
enabled: false
})
await flushPromiseQueue()
expect(updateSettings).toHaveBeenCalledTimes(1)
expect(updates[0]).toMatchObject({ disabledTuiAgents: ['claude'] })
writes[0].resolve()
await firstWrite
await flushPromiseQueue()
expect(updateSettings).toHaveBeenCalledTimes(2)
expect(updates[1]).toMatchObject({ disabledTuiAgents: ['claude', 'codex'] })
writes[1].resolve()
await secondWrite
})
})
@@ -79,7 +79,7 @@ vi.mock('@/runtime/hosts/installation/managed-runtime-install-status', async (im
vi.mock('@/runtime/hosts/installation/use-managed-runtime-install', () => ({
useManagedRuntimeInstall: () => runtime.current
}))
vi.mock('../../../components/provider-accounts/AntigravityChatSignInRow', () => ({
vi.mock('../../../components/provider-accounts/use-antigravity-chat-sign-in', () => ({
useAntigravityChatSignIn: () => ({ flow: null })
}))
vi.mock(
@@ -4,7 +4,7 @@ import { useAppStore } from '@/store'
import {
getClaudeAccountErrorDescription,
isClaudeAccountCancellation
} from '@/components/settings/accounts/accounts-pane-action-errors'
} from './provider-accounts/provider-account-action-errors'
/** Sign in again via hidden claude auth login in the account folder; toast failures and keep cancellation silent. */
export async function signInToClaudeAccount(accountId: string): Promise<boolean> {

Some files were not shown because too many files have changed in this diff Show More