From 60df70e7cd8af083887fbaa5b73542cdad752ef5 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sun, 8 Nov 2026 17:49:14 -0800 Subject: [PATCH] refactor: organize provider and repository settings owners (#40059) * refactor: organize provider and repository settings owners * refactor: define repository action recipe specialization once --- config/host-list-render-baseline.txt | 2 +- config/react-compiler-bailout-baseline.txt | 8 +- .../scripts/ci/sharding/ci-shard-timings.json | 8 +- .../agent/AgentLaunchSetupPanel.tsx | 2 +- .../launch-settings/AgentArgsChoiceChips.tsx | 125 ++++++ .../AgentChatChoiceControls.tsx | 10 +- .../launch-settings/AgentChoiceControls.tsx | 4 +- .../AgentChoiceOptionField.tsx | 15 - .../AgentLaunchChoiceEditor.tsx | 5 +- .../AgentLaunchDefaultsEditor.tsx | 3 +- .../AgentPermissionChoiceControls.tsx | 386 ------------------ .../launch-settings/AgentPermissionMenu.tsx | 107 +++++ .../AgentPermissionMenuOptions.tsx | 2 +- .../launch-settings/agent-args-choice.ts | 7 + .../agent-choice-route-hint.ts | 15 + .../agent-model-choice-chips.ts | 2 +- .../agent-permission-choice-label.ts | 20 + .../agent-permission-choice-row.ts | 18 + .../AntigravityChatAuthForm.tsx | 14 +- .../AntigravityChatAuthSettingRow.tsx | 2 +- .../AntigravityChatSignInAction.tsx | 2 +- .../AntigravityChatSignInRow.tsx | 179 +------- .../AntigravityProviderSignInArea.tsx | 18 +- ...antigravity-chat-runtime-sign-in-policy.ts | 29 ++ .../use-antigravity-chat-sign-in.ts | 161 ++++++++ .../ai/source-control-action-model-copy.ts | 4 +- .../settings/accounts/AccountsPane.tsx | 20 +- .../accounts/accounts-pane-account-actions.ts | 13 +- .../settings/accounts/accounts-pane-types.ts | 19 +- .../providers/AntigravityAccountsSection.tsx | 8 +- .../accounts-pane-gemini-section.tsx | 82 ++++ ...tsx => accounts-pane-opencode-section.tsx} | 85 +--- .../scope/accounts-pane-location-section.tsx | 2 +- .../accounts/scope/accounts-pane-runtime.ts | 18 +- .../AgentWorkspaceTrustSetting.fixture.tsx | 2 +- .../settings/agents/AgentsPane.test.tsx | 79 ---- .../components/settings/agents/AgentsPane.tsx | 24 +- .../behavior/AgentWorkspaceTrustSetting.tsx | 27 ++ .../agents/launch/AgentCatalogRow.tsx | 9 +- .../launch/AgentLaunchSettingsCatalog.tsx | 8 +- .../launch/AgentLaunchSettingsLoading.tsx | 2 +- .../AllAgentsPermissionSetting.tsx | 124 ++++++ .../agent-permission-mode-label.ts | 2 +- .../settings/repository/RepositoryPane.tsx | 18 +- .../execution/sparse-preset-draft-editor.tsx | 31 -- .../RepositoryHookPolicySettings.tsx | 0 .../RepositoryHookScriptSetting.tsx | 0 .../RepositoryHooksSection.tsx | 0 .../RepositoryHooksYamlStatus.tsx | 0 .../RepositoryIssueCommandSetting.tsx | 0 .../repository-git-hooks-search-entries.ts | 0 .../repository-hook-defaults.ts | 0 .../repository-hook-settings-draft.ts | 0 ...se-repository-hook-settings-draft.test.tsx | 0 .../use-repository-hook-settings-draft.ts | 0 ...pository-issue-command-wsl-stopped.test.ts | 2 +- .../use-repository-issue-command.ts | 0 .../RepositoryHostSetupActions.tsx | 0 ...yHostSetupsSection.settings-entry.test.tsx | 0 .../RepositoryHostSetupsSection.tsx | 0 .../repository-host-add-project-steps.tsx | 0 .../repository-host-setup-options.ts | 0 .../repository/mcp/mcp-config-search.ts | 45 ++ .../settings/repository/repository-search.ts | 8 +- .../ProjectWindowsRuntimeSetting.tsx | 0 .../RepositoryWindowsRuntimeSection.tsx | 0 .../repository-runtime-session-summary.ts | 0 .../RepositoryForkSyncSection.tsx | 0 .../RepositoryGitHubAccountSection.tsx | 21 +- .../RepositorySourceControlAiActionRows.tsx | 11 +- ...itorySourceControlAiActionSaveControls.tsx | 2 +- .../repository-git-author-search-entries.ts | 37 +- .../repository-source-control-ai-draft.ts | 26 +- .../repository-source-control-ai-global-ux.ts | 2 +- .../repository-source-control-ai-labels.ts | 36 +- ...ory-source-control-ai-recipe-completion.ts | 52 +++ ...repository-source-control-ai-text-draft.ts | 5 +- ...RepositoryWorktreeDefaultsSection.test.tsx | 0 .../RepositoryWorktreeDefaultsSection.tsx | 0 .../SparsePresetSettingsSection.test.tsx | 0 .../SparsePresetSettingsSection.tsx | 9 +- .../WorktreeSymlinksSection.tsx | 0 .../repository-git-worktree-search-entries.ts | 0 .../sparse-preset-date.ts | 0 .../sparse-preset-directory-preview.tsx | 0 .../sparse-preset-operation-error.ts | 0 .../sparse-preset-settings-row.tsx | 0 .../SourceControlActionAgentPicker.tsx | 12 +- .../SourceControlActionArguments.tsx | 2 +- .../SourceControlTextActionAgentPicker.tsx | 6 +- ...eSetup.tsx => TaskSourceCodeHostSetup.tsx} | 65 +-- .../settings/tasks/TaskSourceJiraSetup.tsx | 54 +++ .../tasks/TaskSourceSimpleSetup.test.tsx | 43 -- .../components/settings/tasks/TasksPane.tsx | 3 +- .../settings/tasks/task-source-setup-state.ts | 15 + .../status-bar/ClaudeSwitcherForOwner.tsx | 2 +- .../status-bar/status-bar-runtime-targets.ts | 2 +- .../agent-settings-update-queue.test.ts | 75 ++++ .../native-chat-provider-choice.test.tsx | 2 +- .../src/lib/claude-account-sign-in.ts | 2 +- .../account-runtime-label.ts | 21 + .../provider-account-action-errors.ts} | 4 +- 102 files changed, 1124 insertions(+), 1161 deletions(-) create mode 100644 src/renderer/src/components/agent/launch-settings/AgentArgsChoiceChips.tsx delete mode 100644 src/renderer/src/components/agent/launch-settings/AgentPermissionChoiceControls.tsx create mode 100644 src/renderer/src/components/agent/launch-settings/AgentPermissionMenu.tsx create mode 100644 src/renderer/src/components/agent/launch-settings/agent-args-choice.ts create mode 100644 src/renderer/src/components/agent/launch-settings/agent-choice-route-hint.ts create mode 100644 src/renderer/src/components/agent/launch-settings/agent-permission-choice-label.ts create mode 100644 src/renderer/src/components/agent/launch-settings/agent-permission-choice-row.ts create mode 100644 src/renderer/src/components/provider-accounts/antigravity-chat-runtime-sign-in-policy.ts create mode 100644 src/renderer/src/components/provider-accounts/use-antigravity-chat-sign-in.ts create mode 100644 src/renderer/src/components/settings/accounts/providers/accounts-pane-gemini-section.tsx rename src/renderer/src/components/settings/accounts/providers/{accounts-pane-provider-setting-sections.tsx => accounts-pane-opencode-section.tsx} (66%) delete mode 100644 src/renderer/src/components/settings/agents/AgentsPane.test.tsx create mode 100644 src/renderer/src/components/settings/agents/behavior/AgentWorkspaceTrustSetting.tsx create mode 100644 src/renderer/src/components/settings/agents/permissions/AllAgentsPermissionSetting.tsx delete mode 100644 src/renderer/src/components/settings/repository/execution/sparse-preset-draft-editor.tsx rename src/renderer/src/components/settings/repository/{execution => hooks}/RepositoryHookPolicySettings.tsx (100%) rename src/renderer/src/components/settings/repository/{execution => hooks}/RepositoryHookScriptSetting.tsx (100%) rename src/renderer/src/components/settings/repository/{execution => hooks}/RepositoryHooksSection.tsx (100%) rename src/renderer/src/components/settings/repository/{execution => hooks}/RepositoryHooksYamlStatus.tsx (100%) rename src/renderer/src/components/settings/repository/{execution => hooks}/RepositoryIssueCommandSetting.tsx (100%) rename src/renderer/src/components/settings/repository/{execution => hooks}/repository-git-hooks-search-entries.ts (100%) rename src/renderer/src/components/settings/repository/{execution => hooks}/repository-hook-defaults.ts (100%) rename src/renderer/src/components/settings/repository/{execution => hooks}/repository-hook-settings-draft.ts (100%) rename src/renderer/src/components/settings/repository/{execution => hooks}/use-repository-hook-settings-draft.test.tsx (100%) rename src/renderer/src/components/settings/repository/{execution => hooks}/use-repository-hook-settings-draft.ts (100%) rename src/renderer/src/components/settings/repository/{execution => hooks}/use-repository-issue-command.ts (100%) rename src/renderer/src/components/settings/repository/{execution => hosts}/RepositoryHostSetupActions.tsx (100%) rename src/renderer/src/components/settings/repository/{execution => hosts}/RepositoryHostSetupsSection.settings-entry.test.tsx (100%) rename src/renderer/src/components/settings/repository/{execution => hosts}/RepositoryHostSetupsSection.tsx (100%) rename src/renderer/src/components/settings/repository/{execution => hosts}/repository-host-add-project-steps.tsx (100%) rename src/renderer/src/components/settings/repository/{execution => hosts}/repository-host-setup-options.ts (100%) create mode 100644 src/renderer/src/components/settings/repository/mcp/mcp-config-search.ts rename src/renderer/src/components/settings/repository/{execution => runtime}/ProjectWindowsRuntimeSetting.tsx (100%) rename src/renderer/src/components/settings/repository/{execution => runtime}/RepositoryWindowsRuntimeSection.tsx (100%) rename src/renderer/src/components/settings/repository/{execution => runtime}/repository-runtime-session-summary.ts (100%) rename src/renderer/src/components/settings/repository/{execution => source-control}/RepositoryForkSyncSection.tsx (100%) rename src/renderer/src/components/settings/repository/{ => source-control}/RepositoryGitHubAccountSection.tsx (94%) rename src/renderer/src/components/settings/{ => repository}/source-control/RepositorySourceControlAiActionSaveControls.tsx (97%) rename src/renderer/src/components/settings/repository/{ => source-control}/repository-git-author-search-entries.ts (56%) create mode 100644 src/renderer/src/components/settings/repository/source-control/repository-source-control-ai-recipe-completion.ts rename src/renderer/src/components/settings/repository/{execution => worktrees}/RepositoryWorktreeDefaultsSection.test.tsx (100%) rename src/renderer/src/components/settings/repository/{execution => worktrees}/RepositoryWorktreeDefaultsSection.tsx (100%) rename src/renderer/src/components/settings/repository/{execution => worktrees}/SparsePresetSettingsSection.test.tsx (100%) rename src/renderer/src/components/settings/repository/{execution => worktrees}/SparsePresetSettingsSection.tsx (98%) rename src/renderer/src/components/settings/repository/{execution => worktrees}/WorktreeSymlinksSection.tsx (100%) rename src/renderer/src/components/settings/repository/{execution => worktrees}/repository-git-worktree-search-entries.ts (100%) rename src/renderer/src/components/settings/repository/{execution => worktrees}/sparse-preset-date.ts (100%) rename src/renderer/src/components/settings/repository/{execution => worktrees}/sparse-preset-directory-preview.tsx (100%) rename src/renderer/src/components/settings/repository/{execution => worktrees}/sparse-preset-operation-error.ts (100%) rename src/renderer/src/components/settings/repository/{execution => worktrees}/sparse-preset-settings-row.tsx (100%) rename src/renderer/src/components/settings/tasks/{TaskSourceSimpleSetup.tsx => TaskSourceCodeHostSetup.tsx} (51%) create mode 100644 src/renderer/src/components/settings/tasks/TaskSourceJiraSetup.tsx delete mode 100644 src/renderer/src/components/settings/tasks/TaskSourceSimpleSetup.test.tsx create mode 100644 src/renderer/src/lib/provider-accounts/account-runtime-label.ts rename src/renderer/src/{components/settings/accounts/accounts-pane-action-errors.ts => lib/provider-accounts/provider-account-action-errors.ts} (92%) diff --git a/config/host-list-render-baseline.txt b/config/host-list-render-baseline.txt index b1a39632401..09d3a029300 100644 --- a/config/host-list-render-baseline.txt +++ b/config/host-list-render-baseline.txt @@ -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 diff --git a/config/react-compiler-bailout-baseline.txt b/config/react-compiler-bailout-baseline.txt index 7ba46d39928..c4cd51da520 100644 --- a/config/react-compiler-bailout-baseline.txt +++ b/config/react-compiler-bailout-baseline.txt @@ -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 diff --git a/config/scripts/ci/sharding/ci-shard-timings.json b/config/scripts/ci/sharding/ci-shard-timings.json index 1c66127fe10..da79a66c8cf 100644 --- a/config/scripts/ci/sharding/ci-shard-timings.json +++ b/config/scripts/ci/sharding/ci-shard-timings.json @@ -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, diff --git a/src/renderer/src/components/agent/AgentLaunchSetupPanel.tsx b/src/renderer/src/components/agent/AgentLaunchSetupPanel.tsx index 7e420a90701..f1674e82ec5 100644 --- a/src/renderer/src/components/agent/AgentLaunchSetupPanel.tsx +++ b/src/renderer/src/components/agent/AgentLaunchSetupPanel.tsx @@ -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, diff --git a/src/renderer/src/components/agent/launch-settings/AgentArgsChoiceChips.tsx b/src/renderer/src/components/agent/launch-settings/AgentArgsChoiceChips.tsx new file mode 100644 index 00000000000..e5ea2e81420 --- /dev/null +++ b/src/renderer/src/components/agent/launch-settings/AgentArgsChoiceChips.tsx @@ -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 + buttonRef?: Ref + choiceKey: string + source?: 'arguments' +}): React.JSX.Element { + const t = useTranslate() + return ( + + + + {flag} + + + + + {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 } + )} + + + ) +} + +export function AgentArgsChoiceChips({ + chips, + disabled, + chipRef, + buttonRef, + onRemove +}: { + chips: readonly AgentArgsChoice[] + disabled?: boolean + chipRef?: Ref + buttonRef?: Ref + onRemove: (chip: AgentArgsChoice) => void +}): React.JSX.Element { + return ( + + {chips.map((chip, index) => ( + onRemove(chip)} + /> + ))} + + ) +} diff --git a/src/renderer/src/components/agent/launch-settings/AgentChatChoiceControls.tsx b/src/renderer/src/components/agent/launch-settings/AgentChatChoiceControls.tsx index 8d325ff20ec..10c739f54dd 100644 --- a/src/renderer/src/components/agent/launch-settings/AgentChatChoiceControls.tsx +++ b/src/renderer/src/components/agent/launch-settings/AgentChatChoiceControls.tsx @@ -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' diff --git a/src/renderer/src/components/agent/launch-settings/AgentChoiceControls.tsx b/src/renderer/src/components/agent/launch-settings/AgentChoiceControls.tsx index 0f5d09aecd0..f79f0fc0178 100644 --- a/src/renderer/src/components/agent/launch-settings/AgentChoiceControls.tsx +++ b/src/renderer/src/components/agent/launch-settings/AgentChoiceControls.tsx @@ -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__' diff --git a/src/renderer/src/components/agent/launch-settings/AgentChoiceOptionField.tsx b/src/renderer/src/components/agent/launch-settings/AgentChoiceOptionField.tsx index 6d1c2c9a4f3..476815e0c6b 100644 --- a/src/renderer/src/components/agent/launch-settings/AgentChoiceOptionField.tsx +++ b/src/renderer/src/components/agent/launch-settings/AgentChoiceOptionField.tsx @@ -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 diff --git a/src/renderer/src/components/agent/launch-settings/AgentLaunchChoiceEditor.tsx b/src/renderer/src/components/agent/launch-settings/AgentLaunchChoiceEditor.tsx index 578f84149b1..6e95245b19c 100644 --- a/src/renderer/src/components/agent/launch-settings/AgentLaunchChoiceEditor.tsx +++ b/src/renderer/src/components/agent/launch-settings/AgentLaunchChoiceEditor.tsx @@ -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' diff --git a/src/renderer/src/components/agent/launch-settings/AgentLaunchDefaultsEditor.tsx b/src/renderer/src/components/agent/launch-settings/AgentLaunchDefaultsEditor.tsx index f6ec4790271..2880c1a64ed 100644 --- a/src/renderer/src/components/agent/launch-settings/AgentLaunchDefaultsEditor.tsx +++ b/src/renderer/src/components/agent/launch-settings/AgentLaunchDefaultsEditor.tsx @@ -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, diff --git a/src/renderer/src/components/agent/launch-settings/AgentPermissionChoiceControls.tsx b/src/renderer/src/components/agent/launch-settings/AgentPermissionChoiceControls.tsx deleted file mode 100644 index e0e630ca7cb..00000000000 --- a/src/renderer/src/components/agent/launch-settings/AgentPermissionChoiceControls.tsx +++ /dev/null @@ -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 ( -
-
-

{title}

- - - - - - - - - - -
-

- {t( - 'settings.agents.permissionsChoiceExplanation', - 'What every agent may do without asking. You can set one agent differently below.' - )} -

-
- {choice === 'auto' ? ( -
- - {t('settings.agents.permissionWithoutAuto', 'Agents without Approve for me')} - - - - - - - - - - - -
- ) : null} -
-
- ) -} - -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 ( -
- {layout === 'row' ? ( - - {t('settings.agents.rowPermissions', 'Permissions')} - - ) : layout === 'stacked' ? ( - - ) : ( - - {t('settings.agents.rowPermissions', 'Permissions')} - - )} - - - - - - - - - {permission.terminalChoice === 'own' && permission.chatChoice ? ( - - {t( - 'settings.agents.permissionSurfaceDifference', - 'Terminals use the agent’s own settings; new chats use {{mode}}.', - { mode: nativeChatPermissionModeLabel(permission.chatChoice, t) } - )} - - ) : null} -
- ) -} - -function AgentArgsChoiceChip({ - label, - flag, - onRemove, - disabled, - chipRef, - buttonRef, - choiceKey, - source -}: { - label: string - flag: string - onRemove: () => void - disabled?: boolean - chipRef?: Ref - buttonRef?: Ref - choiceKey: string - source?: 'arguments' -}): React.JSX.Element { - const t = useTranslate() - return ( - - - - {flag} - - - - - {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 } - )} - - - ) -} - -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 - buttonRef?: Ref - onRemove: (chip: AgentArgsChoice) => void -}): React.JSX.Element { - return ( - - {chips.map((chip, index) => ( - onRemove(chip)} - /> - ))} - - ) -} diff --git a/src/renderer/src/components/agent/launch-settings/AgentPermissionMenu.tsx b/src/renderer/src/components/agent/launch-settings/AgentPermissionMenu.tsx new file mode 100644 index 00000000000..5755c37a089 --- /dev/null +++ b/src/renderer/src/components/agent/launch-settings/AgentPermissionMenu.tsx @@ -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 ( +
+ {layout === 'row' ? ( + + {t('settings.agents.rowPermissions', 'Permissions')} + + ) : layout === 'stacked' ? ( + + ) : ( + + {t('settings.agents.rowPermissions', 'Permissions')} + + )} + + + + + + + + + {permission.terminalChoice === 'own' && permission.chatChoice ? ( + + {t( + 'settings.agents.permissionSurfaceDifference', + 'Terminals use the agent’s own settings; new chats use {{mode}}.', + { mode: nativeChatPermissionModeLabel(permission.chatChoice, t) } + )} + + ) : null} +
+ ) +} diff --git a/src/renderer/src/components/agent/launch-settings/AgentPermissionMenuOptions.tsx b/src/renderer/src/components/agent/launch-settings/AgentPermissionMenuOptions.tsx index 952fcc138b4..c5469c2802a 100644 --- a/src/renderer/src/components/agent/launch-settings/AgentPermissionMenuOptions.tsx +++ b/src/renderer/src/components/agent/launch-settings/AgentPermissionMenuOptions.tsx @@ -1,4 +1,4 @@ -import type { AgentPermissionChoiceRow } from './AgentPermissionChoiceControls' +import type { AgentPermissionChoiceRow } from './agent-permission-choice-row' import { AgentPermissionChoiceItems, AgentPermissionChoiceName } from './AgentPermissionChoiceItems' import { DropdownMenuRadioGroup, diff --git a/src/renderer/src/components/agent/launch-settings/agent-args-choice.ts b/src/renderer/src/components/agent/launch-settings/agent-args-choice.ts new file mode 100644 index 00000000000..1ce39193b46 --- /dev/null +++ b/src/renderer/src/components/agent/launch-settings/agent-args-choice.ts @@ -0,0 +1,7 @@ +export type AgentArgsChoice = { + key: string + label: string + flag: string + onRemove: (text: string) => string + source?: 'arguments' +} diff --git a/src/renderer/src/components/agent/launch-settings/agent-choice-route-hint.ts b/src/renderer/src/components/agent/launch-settings/agent-choice-route-hint.ts new file mode 100644 index 00000000000..bbdb0704342 --- /dev/null +++ b/src/renderer/src/components/agent/launch-settings/agent-choice-route-hint.ts @@ -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 +} diff --git a/src/renderer/src/components/agent/launch-settings/agent-model-choice-chips.ts b/src/renderer/src/components/agent/launch-settings/agent-model-choice-chips.ts index b3b66c6a36a..6a7f68d79bf 100644 --- a/src/renderer/src/components/agent/launch-settings/agent-model-choice-chips.ts +++ b/src/renderer/src/components/agent/launch-settings/agent-model-choice-chips.ts @@ -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, diff --git a/src/renderer/src/components/agent/launch-settings/agent-permission-choice-label.ts b/src/renderer/src/components/agent/launch-settings/agent-permission-choice-label.ts new file mode 100644 index 00000000000..5ebe2a5a566 --- /dev/null +++ b/src/renderer/src/components/agent/launch-settings/agent-permission-choice-label.ts @@ -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") +} diff --git a/src/renderer/src/components/agent/launch-settings/agent-permission-choice-row.ts b/src/renderer/src/components/agent/launch-settings/agent-permission-choice-row.ts new file mode 100644 index 00000000000..9e282eb6f39 --- /dev/null +++ b/src/renderer/src/components/agent/launch-settings/agent-permission-choice-row.ts @@ -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 +} diff --git a/src/renderer/src/components/provider-accounts/AntigravityChatAuthForm.tsx b/src/renderer/src/components/provider-accounts/AntigravityChatAuthForm.tsx index 2ad72f75cb7..8da4de826dc 100644 --- a/src/renderer/src/components/provider-accounts/AntigravityChatAuthForm.tsx +++ b/src/renderer/src/components/provider-accounts/AntigravityChatAuthForm.tsx @@ -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 && (
- {methodLabel('oauth-business', t)} - + {method === 'oauth-business' && ( <> - @@ -352,8 +352,8 @@ function AuthForm({ onBlur={commitText} onKeyDown={commitOnEnter} /> - - + @@ -370,7 +370,7 @@ function AuthForm({ onBlur={commitText} onKeyDown={commitOnEnter} /> - + )}
diff --git a/src/renderer/src/components/provider-accounts/AntigravityChatAuthSettingRow.tsx b/src/renderer/src/components/provider-accounts/AntigravityChatAuthSettingRow.tsx index be70802fde1..8ee426a34ff 100644 --- a/src/renderer/src/components/provider-accounts/AntigravityChatAuthSettingRow.tsx +++ b/src/renderer/src/components/provider-accounts/AntigravityChatAuthSettingRow.tsx @@ -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 diff --git a/src/renderer/src/components/provider-accounts/AntigravityChatSignInAction.tsx b/src/renderer/src/components/provider-accounts/AntigravityChatSignInAction.tsx index 116ff387d3c..2b257e8d745 100644 --- a/src/renderer/src/components/provider-accounts/AntigravityChatSignInAction.tsx +++ b/src/renderer/src/components/provider-accounts/AntigravityChatSignInAction.tsx @@ -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 diff --git a/src/renderer/src/components/provider-accounts/AntigravityChatSignInRow.tsx b/src/renderer/src/components/provider-accounts/AntigravityChatSignInRow.tsx index d9da2125f18..48da9809e04 100644 --- a/src/renderer/src/components/provider-accounts/AntigravityChatSignInRow.tsx +++ b/src/renderer/src/components/provider-accounts/AntigravityChatSignInRow.tsx @@ -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 -): 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 - -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 => { - 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: { diff --git a/src/renderer/src/components/provider-accounts/AntigravityProviderSignInArea.tsx b/src/renderer/src/components/provider-accounts/AntigravityProviderSignInArea.tsx index 43c45978528..7d467b96505 100644 --- a/src/renderer/src/components/provider-accounts/AntigravityProviderSignInArea.tsx +++ b/src/renderer/src/components/provider-accounts/AntigravityProviderSignInArea.tsx @@ -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 -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 diff --git a/src/renderer/src/components/provider-accounts/antigravity-chat-runtime-sign-in-policy.ts b/src/renderer/src/components/provider-accounts/antigravity-chat-runtime-sign-in-policy.ts new file mode 100644 index 00000000000..6acc801a8f3 --- /dev/null +++ b/src/renderer/src/components/provider-accounts/antigravity-chat-runtime-sign-in-policy.ts @@ -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 +): 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 +): boolean { + const { snapshot } = install + if (snapshot.kind !== 'known') { + return true + } + const { source, operation } = snapshot.state + return source !== null && !(operation && CHANGING_PHASES.has(operation.phase)) +} diff --git a/src/renderer/src/components/provider-accounts/use-antigravity-chat-sign-in.ts b/src/renderer/src/components/provider-accounts/use-antigravity-chat-sign-in.ts new file mode 100644 index 00000000000..a476f14331a --- /dev/null +++ b/src/renderer/src/components/provider-accounts/use-antigravity-chat-sign-in.ts @@ -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 + +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 => { + 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) + } + }) + } +} diff --git a/src/renderer/src/components/right-sidebar/source-control/ai/source-control-action-model-copy.ts b/src/renderer/src/components/right-sidebar/source-control/ai/source-control-action-model-copy.ts index a64a2eb3ff2..0e7636a2b6e 100644 --- a/src/renderer/src/components/right-sidebar/source-control/ai/source-control-action-model-copy.ts +++ b/src/renderer/src/components/right-sidebar/source-control/ai/source-control-action-model-copy.ts @@ -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( diff --git a/src/renderer/src/components/settings/accounts/AccountsPane.tsx b/src/renderer/src/components/settings/accounts/AccountsPane.tsx index be9aa57d2b7..09131bc6fb5 100644 --- a/src/renderer/src/components/settings/accounts/AccountsPane.tsx +++ b/src/renderer/src/components/settings/accounts/AccountsPane.tsx @@ -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(emptyCodexAccountsState) const [codexAccountsLoaded, setCodexAccountsLoaded] = useState(false) - const [codexAction, setCodexAction] = useState('idle') + const [codexAction, setCodexAction] = useState('idle') const [claudeAccounts, setClaudeAccounts] = useState(emptyClaudeAccountsState) - const [claudeAction, setClaudeAction] = useState('idle') + const [claudeAction, setClaudeAction] = useState('idle') // Capture runtime slots at dialog opening; roster updates could remove the slot needed for restart diffs. const [removeCodexTarget, setRemoveCodexTarget] = useState(null) const [removeClaudeTarget, setRemoveClaudeTarget] = useState(null) diff --git a/src/renderer/src/components/settings/accounts/accounts-pane-account-actions.ts b/src/renderer/src/components/settings/accounts/accounts-pane-account-actions.ts index e6cc3880eef..b7956134520 100644 --- a/src/renderer/src/components/settings/accounts/accounts-pane-account-actions.ts +++ b/src/renderer/src/components/settings/accounts/accounts-pane-account-actions.ts @@ -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> setCodexAccountsLoaded: Dispatch> - setCodexAction: Dispatch> + setCodexAction: Dispatch> fetchSettings: () => Promise 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> - setClaudeAction: Dispatch> + setClaudeAction: Dispatch> fetchSettings: () => Promise recordFeatureInteraction: (featureId: FeatureInteractionId) => void /** False once the pane shows a different account owner than this action targeted. */ diff --git a/src/renderer/src/components/settings/accounts/accounts-pane-types.ts b/src/renderer/src/components/settings/accounts/accounts-pane-types.ts index dd37ec0d132..2456c828c47 100644 --- a/src/renderer/src/components/settings/accounts/accounts-pane-types.ts +++ b/src/renderer/src/components/settings/accounts/accounts-pane-types.ts @@ -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, actionRuntime?: ProviderAccountRuntimeView ) => Promise export type ClaudeAccountActionRunner = ( - action: ClaudeAccountAction, + action: ProviderAccountAction, operation: () => Promise, actionRuntime?: ProviderAccountRuntimeView ) => Promise @@ -90,13 +83,13 @@ export type AccountsPaneSectionModel = { accountRuntimeUnavailable: boolean accountVisibilityOptions: ProviderAccountVisibilityOptions claudeAccounts: ClaudeRateLimitAccountsState - claudeAction: ClaudeAccountAction + claudeAction: ProviderAccountAction visibleClaudeAccounts: ClaudeRateLimitAccountsState['accounts'] systemClaudeActive: boolean setRemoveClaudeTarget: Dispatch> runClaudeAccountAction: ClaudeAccountActionRunner codexAccounts: CodexRateLimitAccountsState - codexAction: CodexAccountAction + codexAction: ProviderAccountAction visibleCodexAccounts: CodexRateLimitAccountsState['accounts'] systemCodexActive: boolean systemCodexNeedsSignIn: boolean diff --git a/src/renderer/src/components/settings/accounts/providers/AntigravityAccountsSection.tsx b/src/renderer/src/components/settings/accounts/providers/AntigravityAccountsSection.tsx index 6a08f0d9675..0b963470af2 100644 --- a/src/renderer/src/components/settings/accounts/providers/AntigravityAccountsSection.tsx +++ b/src/renderer/src/components/settings/accounts/providers/AntigravityAccountsSection.tsx @@ -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' diff --git a/src/renderer/src/components/settings/accounts/providers/accounts-pane-gemini-section.tsx b/src/renderer/src/components/settings/accounts/providers/accounts-pane-gemini-section.tsx new file mode 100644 index 00000000000..7f3125d44ee --- /dev/null +++ b/src/renderer/src/components/settings/accounts/providers/accounts-pane-gemini-section.tsx @@ -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 ( +
+ + + {t('auto.components.settings.AccountsPane.0c64dc2a64', 'Gemini CLI (legacy)')} + + } + description={t( + 'auto.components.settings.AccountsPane.973741a871', + 'Keep existing Gemini CLI sessions available. Gemini credentials do not sign you into Antigravity.' + )} + > + +
+ +

+ {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 } + )} +

+
+ { + recordFeatureInteraction('usage-tracking') + updateSettings({ + geminiCliOAuthEnabled: checked + }) + }} + /> +
+
+
+ ) +} diff --git a/src/renderer/src/components/settings/accounts/providers/accounts-pane-provider-setting-sections.tsx b/src/renderer/src/components/settings/accounts/providers/accounts-pane-opencode-section.tsx similarity index 66% rename from src/renderer/src/components/settings/accounts/providers/accounts-pane-provider-setting-sections.tsx rename to src/renderer/src/components/settings/accounts/providers/accounts-pane-opencode-section.tsx index 3b5c99a6b22..3c166ba7143 100644 --- a/src/renderer/src/components/settings/accounts/providers/accounts-pane-provider-setting-sections.tsx +++ b/src/renderer/src/components/settings/accounts/providers/accounts-pane-opencode-section.tsx @@ -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 ( -
- - - {t('auto.components.settings.AccountsPane.0c64dc2a64', 'Gemini CLI (legacy)')} - - } - description={t( - 'auto.components.settings.AccountsPane.973741a871', - 'Keep existing Gemini CLI sessions available. Gemini credentials do not sign you into Antigravity.' - )} - > - -
- -

- {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 } - )} -

-
- { - recordFeatureInteraction('usage-tracking') - updateSettings({ - geminiCliOAuthEnabled: checked - }) - }} - /> -
-
-
- ) -} export function renderOpenCodeAccountsSection( model: AccountsPaneSectionModel, diff --git a/src/renderer/src/components/settings/accounts/scope/accounts-pane-location-section.tsx b/src/renderer/src/components/settings/accounts/scope/accounts-pane-location-section.tsx index 087f9dd9b2a..965cfe923c9 100644 --- a/src/renderer/src/components/settings/accounts/scope/accounts-pane-location-section.tsx +++ b/src/renderer/src/components/settings/accounts/scope/accounts-pane-location-section.tsx @@ -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' diff --git a/src/renderer/src/components/settings/accounts/scope/accounts-pane-runtime.ts b/src/renderer/src/components/settings/accounts/scope/accounts-pane-runtime.ts index 8d0fee372f0..363eaf415dc 100644 --- a/src/renderer/src/components/settings/accounts/scope/accounts-pane-runtime.ts +++ b/src/renderer/src/components/settings/accounts/scope/accounts-pane-runtime.ts @@ -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() diff --git a/src/renderer/src/components/settings/agents/AgentWorkspaceTrustSetting.fixture.tsx b/src/renderer/src/components/settings/agents/AgentWorkspaceTrustSetting.fixture.tsx index 35f2f8019fa..23bd8b64870 100644 --- a/src/renderer/src/components/settings/agents/AgentWorkspaceTrustSetting.fixture.tsx +++ b/src/renderer/src/components/settings/agents/AgentWorkspaceTrustSetting.fixture.tsx @@ -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, diff --git a/src/renderer/src/components/settings/agents/AgentsPane.test.tsx b/src/renderer/src/components/settings/agents/AgentsPane.test.tsx deleted file mode 100644 index de70d9e9a3b..00000000000 --- a/src/renderer/src/components/settings/agents/AgentsPane.test.tsx +++ /dev/null @@ -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 - resolve: () => void -} - -function createDeferred(): Deferred { - let resolve!: () => void - const promise = new Promise((next) => { - resolve = next - }) - return { promise, resolve } -} - -async function flushPromiseQueue(): Promise { - 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[] = [] - - useAppStore.setState({ settings }) - const updateSettings = vi.fn((update: Partial) => { - 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 - }) -}) diff --git a/src/renderer/src/components/settings/agents/AgentsPane.tsx b/src/renderer/src/components/settings/agents/AgentsPane.tsx index 300cb30f862..906f6307b86 100644 --- a/src/renderer/src/components/settings/agents/AgentsPane.tsx +++ b/src/renderer/src/components/settings/agents/AgentsPane.tsx @@ -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 } -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 ( - 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 ( diff --git a/src/renderer/src/components/settings/agents/behavior/AgentWorkspaceTrustSetting.tsx b/src/renderer/src/components/settings/agents/behavior/AgentWorkspaceTrustSetting.tsx new file mode 100644 index 00000000000..b0cb3692c2f --- /dev/null +++ b/src/renderer/src/components/settings/agents/behavior/AgentWorkspaceTrustSetting.tsx @@ -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) => void | Promise +}) { + const t = useTranslate() + const enabled = settings.agentWorkspaceTrustEnabled !== false + return ( + updateSettings({ agentWorkspaceTrustEnabled: !enabled })} + ariaLabel={getAgentWorkspaceTrustTitle(t)} + /> + ) +} diff --git a/src/renderer/src/components/settings/agents/launch/AgentCatalogRow.tsx b/src/renderer/src/components/settings/agents/launch/AgentCatalogRow.tsx index 0f8cfa8ce07..414878167e2 100644 --- a/src/renderer/src/components/settings/agents/launch/AgentCatalogRow.tsx +++ b/src/renderer/src/components/settings/agents/launch/AgentCatalogRow.tsx @@ -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' diff --git a/src/renderer/src/components/settings/agents/launch/AgentLaunchSettingsCatalog.tsx b/src/renderer/src/components/settings/agents/launch/AgentLaunchSettingsCatalog.tsx index a889724094f..ec8218f5abe 100644 --- a/src/renderer/src/components/settings/agents/launch/AgentLaunchSettingsCatalog.tsx +++ b/src/renderer/src/components/settings/agents/launch/AgentLaunchSettingsCatalog.tsx @@ -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, diff --git a/src/renderer/src/components/settings/agents/launch/AgentLaunchSettingsLoading.tsx b/src/renderer/src/components/settings/agents/launch/AgentLaunchSettingsLoading.tsx index 8af60e1f1c2..994faf53d0b 100644 --- a/src/renderer/src/components/settings/agents/launch/AgentLaunchSettingsLoading.tsx +++ b/src/renderer/src/components/settings/agents/launch/AgentLaunchSettingsLoading.tsx @@ -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() diff --git a/src/renderer/src/components/settings/agents/permissions/AllAgentsPermissionSetting.tsx b/src/renderer/src/components/settings/agents/permissions/AllAgentsPermissionSetting.tsx new file mode 100644 index 00000000000..639f376e960 --- /dev/null +++ b/src/renderer/src/components/settings/agents/permissions/AllAgentsPermissionSetting.tsx @@ -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 ( +
+
+

{title}

+ + + + + + + + + + +
+

+ {t( + 'settings.agents.permissionsChoiceExplanation', + 'What every agent may do without asking. You can set one agent differently below.' + )} +

+
+ {choice === 'auto' ? ( +
+ + {t('settings.agents.permissionWithoutAuto', 'Agents without Approve for me')} + + + + + + + + + + + +
+ ) : null} +
+
+ ) +} diff --git a/src/renderer/src/components/settings/agents/permissions/agent-permission-mode-label.ts b/src/renderer/src/components/settings/agents/permissions/agent-permission-mode-label.ts index 6960cd5e03a..9411eff69d9 100644 --- a/src/renderer/src/components/settings/agents/permissions/agent-permission-mode-label.ts +++ b/src/renderer/src/components/settings/agents/permissions/agent-permission-mode-label.ts @@ -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) { diff --git a/src/renderer/src/components/settings/repository/RepositoryPane.tsx b/src/renderer/src/components/settings/repository/RepositoryPane.tsx index 50871a8077f..0cdad62a893 100644 --- a/src/renderer/src/components/settings/repository/RepositoryPane.tsx +++ b/src/renderer/src/components/settings/repository/RepositoryPane.tsx @@ -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, diff --git a/src/renderer/src/components/settings/repository/execution/sparse-preset-draft-editor.tsx b/src/renderer/src/components/settings/repository/execution/sparse-preset-draft-editor.tsx deleted file mode 100644 index 87e00d40473..00000000000 --- a/src/renderer/src/components/settings/repository/execution/sparse-preset-draft-editor.tsx +++ /dev/null @@ -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 ( - setDraft(null)} - /> - ) -} diff --git a/src/renderer/src/components/settings/repository/execution/RepositoryHookPolicySettings.tsx b/src/renderer/src/components/settings/repository/hooks/RepositoryHookPolicySettings.tsx similarity index 100% rename from src/renderer/src/components/settings/repository/execution/RepositoryHookPolicySettings.tsx rename to src/renderer/src/components/settings/repository/hooks/RepositoryHookPolicySettings.tsx diff --git a/src/renderer/src/components/settings/repository/execution/RepositoryHookScriptSetting.tsx b/src/renderer/src/components/settings/repository/hooks/RepositoryHookScriptSetting.tsx similarity index 100% rename from src/renderer/src/components/settings/repository/execution/RepositoryHookScriptSetting.tsx rename to src/renderer/src/components/settings/repository/hooks/RepositoryHookScriptSetting.tsx diff --git a/src/renderer/src/components/settings/repository/execution/RepositoryHooksSection.tsx b/src/renderer/src/components/settings/repository/hooks/RepositoryHooksSection.tsx similarity index 100% rename from src/renderer/src/components/settings/repository/execution/RepositoryHooksSection.tsx rename to src/renderer/src/components/settings/repository/hooks/RepositoryHooksSection.tsx diff --git a/src/renderer/src/components/settings/repository/execution/RepositoryHooksYamlStatus.tsx b/src/renderer/src/components/settings/repository/hooks/RepositoryHooksYamlStatus.tsx similarity index 100% rename from src/renderer/src/components/settings/repository/execution/RepositoryHooksYamlStatus.tsx rename to src/renderer/src/components/settings/repository/hooks/RepositoryHooksYamlStatus.tsx diff --git a/src/renderer/src/components/settings/repository/execution/RepositoryIssueCommandSetting.tsx b/src/renderer/src/components/settings/repository/hooks/RepositoryIssueCommandSetting.tsx similarity index 100% rename from src/renderer/src/components/settings/repository/execution/RepositoryIssueCommandSetting.tsx rename to src/renderer/src/components/settings/repository/hooks/RepositoryIssueCommandSetting.tsx diff --git a/src/renderer/src/components/settings/repository/execution/repository-git-hooks-search-entries.ts b/src/renderer/src/components/settings/repository/hooks/repository-git-hooks-search-entries.ts similarity index 100% rename from src/renderer/src/components/settings/repository/execution/repository-git-hooks-search-entries.ts rename to src/renderer/src/components/settings/repository/hooks/repository-git-hooks-search-entries.ts diff --git a/src/renderer/src/components/settings/repository/execution/repository-hook-defaults.ts b/src/renderer/src/components/settings/repository/hooks/repository-hook-defaults.ts similarity index 100% rename from src/renderer/src/components/settings/repository/execution/repository-hook-defaults.ts rename to src/renderer/src/components/settings/repository/hooks/repository-hook-defaults.ts diff --git a/src/renderer/src/components/settings/repository/execution/repository-hook-settings-draft.ts b/src/renderer/src/components/settings/repository/hooks/repository-hook-settings-draft.ts similarity index 100% rename from src/renderer/src/components/settings/repository/execution/repository-hook-settings-draft.ts rename to src/renderer/src/components/settings/repository/hooks/repository-hook-settings-draft.ts diff --git a/src/renderer/src/components/settings/repository/execution/use-repository-hook-settings-draft.test.tsx b/src/renderer/src/components/settings/repository/hooks/use-repository-hook-settings-draft.test.tsx similarity index 100% rename from src/renderer/src/components/settings/repository/execution/use-repository-hook-settings-draft.test.tsx rename to src/renderer/src/components/settings/repository/hooks/use-repository-hook-settings-draft.test.tsx diff --git a/src/renderer/src/components/settings/repository/execution/use-repository-hook-settings-draft.ts b/src/renderer/src/components/settings/repository/hooks/use-repository-hook-settings-draft.ts similarity index 100% rename from src/renderer/src/components/settings/repository/execution/use-repository-hook-settings-draft.ts rename to src/renderer/src/components/settings/repository/hooks/use-repository-hook-settings-draft.ts diff --git a/src/renderer/src/components/settings/repository/hooks/use-repository-issue-command-wsl-stopped.test.ts b/src/renderer/src/components/settings/repository/hooks/use-repository-issue-command-wsl-stopped.test.ts index ed19fd07680..9ee0c301bb8 100644 --- a/src/renderer/src/components/settings/repository/hooks/use-repository-issue-command-wsl-stopped.test.ts +++ b/src/renderer/src/components/settings/repository/hooks/use-repository-issue-command-wsl-stopped.test.ts @@ -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 = { diff --git a/src/renderer/src/components/settings/repository/execution/use-repository-issue-command.ts b/src/renderer/src/components/settings/repository/hooks/use-repository-issue-command.ts similarity index 100% rename from src/renderer/src/components/settings/repository/execution/use-repository-issue-command.ts rename to src/renderer/src/components/settings/repository/hooks/use-repository-issue-command.ts diff --git a/src/renderer/src/components/settings/repository/execution/RepositoryHostSetupActions.tsx b/src/renderer/src/components/settings/repository/hosts/RepositoryHostSetupActions.tsx similarity index 100% rename from src/renderer/src/components/settings/repository/execution/RepositoryHostSetupActions.tsx rename to src/renderer/src/components/settings/repository/hosts/RepositoryHostSetupActions.tsx diff --git a/src/renderer/src/components/settings/repository/execution/RepositoryHostSetupsSection.settings-entry.test.tsx b/src/renderer/src/components/settings/repository/hosts/RepositoryHostSetupsSection.settings-entry.test.tsx similarity index 100% rename from src/renderer/src/components/settings/repository/execution/RepositoryHostSetupsSection.settings-entry.test.tsx rename to src/renderer/src/components/settings/repository/hosts/RepositoryHostSetupsSection.settings-entry.test.tsx diff --git a/src/renderer/src/components/settings/repository/execution/RepositoryHostSetupsSection.tsx b/src/renderer/src/components/settings/repository/hosts/RepositoryHostSetupsSection.tsx similarity index 100% rename from src/renderer/src/components/settings/repository/execution/RepositoryHostSetupsSection.tsx rename to src/renderer/src/components/settings/repository/hosts/RepositoryHostSetupsSection.tsx diff --git a/src/renderer/src/components/settings/repository/execution/repository-host-add-project-steps.tsx b/src/renderer/src/components/settings/repository/hosts/repository-host-add-project-steps.tsx similarity index 100% rename from src/renderer/src/components/settings/repository/execution/repository-host-add-project-steps.tsx rename to src/renderer/src/components/settings/repository/hosts/repository-host-add-project-steps.tsx diff --git a/src/renderer/src/components/settings/repository/execution/repository-host-setup-options.ts b/src/renderer/src/components/settings/repository/hosts/repository-host-setup-options.ts similarity index 100% rename from src/renderer/src/components/settings/repository/execution/repository-host-setup-options.ts rename to src/renderer/src/components/settings/repository/hosts/repository-host-setup-options.ts diff --git a/src/renderer/src/components/settings/repository/mcp/mcp-config-search.ts b/src/renderer/src/components/settings/repository/mcp/mcp-config-search.ts new file mode 100644 index 00000000000..32b25bc9e79 --- /dev/null +++ b/src/renderer/src/components/settings/repository/mcp/mcp-config-search.ts @@ -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' + ) + ] + } + ] +} diff --git a/src/renderer/src/components/settings/repository/repository-search.ts b/src/renderer/src/components/settings/repository/repository-search.ts index 4e47547207f..03b9a313d47 100644 --- a/src/renderer/src/components/settings/repository/repository-search.ts +++ b/src/renderer/src/components/settings/repository/repository-search.ts @@ -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) ]) ] diff --git a/src/renderer/src/components/settings/repository/execution/ProjectWindowsRuntimeSetting.tsx b/src/renderer/src/components/settings/repository/runtime/ProjectWindowsRuntimeSetting.tsx similarity index 100% rename from src/renderer/src/components/settings/repository/execution/ProjectWindowsRuntimeSetting.tsx rename to src/renderer/src/components/settings/repository/runtime/ProjectWindowsRuntimeSetting.tsx diff --git a/src/renderer/src/components/settings/repository/execution/RepositoryWindowsRuntimeSection.tsx b/src/renderer/src/components/settings/repository/runtime/RepositoryWindowsRuntimeSection.tsx similarity index 100% rename from src/renderer/src/components/settings/repository/execution/RepositoryWindowsRuntimeSection.tsx rename to src/renderer/src/components/settings/repository/runtime/RepositoryWindowsRuntimeSection.tsx diff --git a/src/renderer/src/components/settings/repository/execution/repository-runtime-session-summary.ts b/src/renderer/src/components/settings/repository/runtime/repository-runtime-session-summary.ts similarity index 100% rename from src/renderer/src/components/settings/repository/execution/repository-runtime-session-summary.ts rename to src/renderer/src/components/settings/repository/runtime/repository-runtime-session-summary.ts diff --git a/src/renderer/src/components/settings/repository/execution/RepositoryForkSyncSection.tsx b/src/renderer/src/components/settings/repository/source-control/RepositoryForkSyncSection.tsx similarity index 100% rename from src/renderer/src/components/settings/repository/execution/RepositoryForkSyncSection.tsx rename to src/renderer/src/components/settings/repository/source-control/RepositoryForkSyncSection.tsx diff --git a/src/renderer/src/components/settings/repository/RepositoryGitHubAccountSection.tsx b/src/renderer/src/components/settings/repository/source-control/RepositoryGitHubAccountSection.tsx similarity index 94% rename from src/renderer/src/components/settings/repository/RepositoryGitHubAccountSection.tsx rename to src/renderer/src/components/settings/repository/source-control/RepositoryGitHubAccountSection.tsx index b7a26640f98..a12d6e8256b 100644 --- a/src/renderer/src/components/settings/repository/RepositoryGitHubAccountSection.tsx +++ b/src/renderer/src/components/settings/repository/source-control/RepositoryGitHubAccountSection.tsx @@ -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 diff --git a/src/renderer/src/components/settings/repository/source-control/RepositorySourceControlAiActionRows.tsx b/src/renderer/src/components/settings/repository/source-control/RepositorySourceControlAiActionRows.tsx index a2454cb8c50..c79cdf6c962 100644 --- a/src/renderer/src/components/settings/repository/source-control/RepositorySourceControlAiActionRows.tsx +++ b/src/renderer/src/components/settings/repository/source-control/RepositorySourceControlAiActionRows.tsx @@ -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' diff --git a/src/renderer/src/components/settings/source-control/RepositorySourceControlAiActionSaveControls.tsx b/src/renderer/src/components/settings/repository/source-control/RepositorySourceControlAiActionSaveControls.tsx similarity index 97% rename from src/renderer/src/components/settings/source-control/RepositorySourceControlAiActionSaveControls.tsx rename to src/renderer/src/components/settings/repository/source-control/RepositorySourceControlAiActionSaveControls.tsx index d5bdcf3d533..26f40724727 100644 --- a/src/renderer/src/components/settings/source-control/RepositorySourceControlAiActionSaveControls.tsx +++ b/src/renderer/src/components/settings/repository/source-control/RepositorySourceControlAiActionSaveControls.tsx @@ -1,4 +1,4 @@ -import { Button } from '../../ui/button' +import { Button } from '../../../ui/button' import { useTranslate } from '@/i18n/use-translate' type RepositorySourceControlAiActionSaveControlsProps = { diff --git a/src/renderer/src/components/settings/repository/repository-git-author-search-entries.ts b/src/renderer/src/components/settings/repository/source-control/repository-git-author-search-entries.ts similarity index 56% rename from src/renderer/src/components/settings/repository/repository-git-author-search-entries.ts rename to src/renderer/src/components/settings/repository/source-control/repository-git-author-search-entries.ts index 9e2621fa58f..a1783a431b6 100644 --- a/src/renderer/src/components/settings/repository/repository-git-author-search-entries.ts +++ b/src/renderer/src/components/settings/repository/source-control/repository-git-author-search-entries.ts @@ -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' - ) - ] } ] } diff --git a/src/renderer/src/components/settings/repository/source-control/repository-source-control-ai-draft.ts b/src/renderer/src/components/settings/repository/source-control/repository-source-control-ai-draft.ts index 6a78a4379ce..d8e8dfe8c17 100644 --- a/src/renderer/src/components/settings/repository/source-control/repository-source-control-ai-draft.ts +++ b/src/renderer/src/components/settings/repository/source-control/repository-source-control-ai-draft.ts @@ -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[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 | 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, diff --git a/src/renderer/src/components/settings/repository/source-control/repository-source-control-ai-global-ux.ts b/src/renderer/src/components/settings/repository/source-control/repository-source-control-ai-global-ux.ts index 399dade1c93..ba21cd67737 100644 --- a/src/renderer/src/components/settings/repository/source-control/repository-source-control-ai-global-ux.ts +++ b/src/renderer/src/components/settings/repository/source-control/repository-source-control-ai-global-ux.ts @@ -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, diff --git a/src/renderer/src/components/settings/repository/source-control/repository-source-control-ai-labels.ts b/src/renderer/src/components/settings/repository/source-control/repository-source-control-ai-labels.ts index dbde6d29730..900082ed622 100644 --- a/src/renderer/src/components/settings/repository/source-control/repository-source-control-ai-labels.ts +++ b/src/renderer/src/components/settings/repository/source-control/repository-source-control-ai-labels.ts @@ -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[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' } diff --git a/src/renderer/src/components/settings/repository/source-control/repository-source-control-ai-recipe-completion.ts b/src/renderer/src/components/settings/repository/source-control/repository-source-control-ai-recipe-completion.ts new file mode 100644 index 00000000000..db7d5e42d0f --- /dev/null +++ b/src/renderer/src/components/settings/repository/source-control/repository-source-control-ai-recipe-completion.ts @@ -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[SourceControlActionId] +> + +function completeRepoActionRecipe( + recipe: SourceControlActionRecipe, + actionId: SourceControlActionId +): NonNullable< + NonNullable[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 | 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 } : {}) } +} diff --git a/src/renderer/src/components/settings/repository/source-control/repository-source-control-ai-text-draft.ts b/src/renderer/src/components/settings/repository/source-control/repository-source-control-ai-text-draft.ts index 87d1c2e44cc..5ad80a5a6cf 100644 --- a/src/renderer/src/components/settings/repository/source-control/repository-source-control-ai-text-draft.ts +++ b/src/renderer/src/components/settings/repository/source-control/repository-source-control-ai-text-draft.ts @@ -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>, @@ -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}}` diff --git a/src/renderer/src/components/settings/repository/execution/RepositoryWorktreeDefaultsSection.test.tsx b/src/renderer/src/components/settings/repository/worktrees/RepositoryWorktreeDefaultsSection.test.tsx similarity index 100% rename from src/renderer/src/components/settings/repository/execution/RepositoryWorktreeDefaultsSection.test.tsx rename to src/renderer/src/components/settings/repository/worktrees/RepositoryWorktreeDefaultsSection.test.tsx diff --git a/src/renderer/src/components/settings/repository/execution/RepositoryWorktreeDefaultsSection.tsx b/src/renderer/src/components/settings/repository/worktrees/RepositoryWorktreeDefaultsSection.tsx similarity index 100% rename from src/renderer/src/components/settings/repository/execution/RepositoryWorktreeDefaultsSection.tsx rename to src/renderer/src/components/settings/repository/worktrees/RepositoryWorktreeDefaultsSection.tsx diff --git a/src/renderer/src/components/settings/repository/execution/SparsePresetSettingsSection.test.tsx b/src/renderer/src/components/settings/repository/worktrees/SparsePresetSettingsSection.test.tsx similarity index 100% rename from src/renderer/src/components/settings/repository/execution/SparsePresetSettingsSection.test.tsx rename to src/renderer/src/components/settings/repository/worktrees/SparsePresetSettingsSection.test.tsx diff --git a/src/renderer/src/components/settings/repository/execution/SparsePresetSettingsSection.tsx b/src/renderer/src/components/settings/repository/worktrees/SparsePresetSettingsSection.tsx similarity index 98% rename from src/renderer/src/components/settings/repository/execution/SparsePresetSettingsSection.tsx rename to src/renderer/src/components/settings/repository/worktrees/SparsePresetSettingsSection.tsx index b081c32e6ae..b15a6e36e5f 100644 --- a/src/renderer/src/components/settings/repository/execution/SparsePresetSettingsSection.tsx +++ b/src/renderer/src/components/settings/repository/worktrees/SparsePresetSettingsSection.tsx @@ -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 ? ( - { + 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} diff --git a/src/renderer/src/components/settings/repository/execution/WorktreeSymlinksSection.tsx b/src/renderer/src/components/settings/repository/worktrees/WorktreeSymlinksSection.tsx similarity index 100% rename from src/renderer/src/components/settings/repository/execution/WorktreeSymlinksSection.tsx rename to src/renderer/src/components/settings/repository/worktrees/WorktreeSymlinksSection.tsx diff --git a/src/renderer/src/components/settings/repository/execution/repository-git-worktree-search-entries.ts b/src/renderer/src/components/settings/repository/worktrees/repository-git-worktree-search-entries.ts similarity index 100% rename from src/renderer/src/components/settings/repository/execution/repository-git-worktree-search-entries.ts rename to src/renderer/src/components/settings/repository/worktrees/repository-git-worktree-search-entries.ts diff --git a/src/renderer/src/components/settings/repository/execution/sparse-preset-date.ts b/src/renderer/src/components/settings/repository/worktrees/sparse-preset-date.ts similarity index 100% rename from src/renderer/src/components/settings/repository/execution/sparse-preset-date.ts rename to src/renderer/src/components/settings/repository/worktrees/sparse-preset-date.ts diff --git a/src/renderer/src/components/settings/repository/execution/sparse-preset-directory-preview.tsx b/src/renderer/src/components/settings/repository/worktrees/sparse-preset-directory-preview.tsx similarity index 100% rename from src/renderer/src/components/settings/repository/execution/sparse-preset-directory-preview.tsx rename to src/renderer/src/components/settings/repository/worktrees/sparse-preset-directory-preview.tsx diff --git a/src/renderer/src/components/settings/repository/execution/sparse-preset-operation-error.ts b/src/renderer/src/components/settings/repository/worktrees/sparse-preset-operation-error.ts similarity index 100% rename from src/renderer/src/components/settings/repository/execution/sparse-preset-operation-error.ts rename to src/renderer/src/components/settings/repository/worktrees/sparse-preset-operation-error.ts diff --git a/src/renderer/src/components/settings/repository/execution/sparse-preset-settings-row.tsx b/src/renderer/src/components/settings/repository/worktrees/sparse-preset-settings-row.tsx similarity index 100% rename from src/renderer/src/components/settings/repository/execution/sparse-preset-settings-row.tsx rename to src/renderer/src/components/settings/repository/worktrees/sparse-preset-settings-row.tsx diff --git a/src/renderer/src/components/settings/source-control/SourceControlActionAgentPicker.tsx b/src/renderer/src/components/settings/source-control/SourceControlActionAgentPicker.tsx index 3cc5738e4e7..20b3767f7d6 100644 --- a/src/renderer/src/components/settings/source-control/SourceControlActionAgentPicker.tsx +++ b/src/renderer/src/components/settings/source-control/SourceControlActionAgentPicker.tsx @@ -43,17 +43,7 @@ type PickerProps = { onPick: (agent: TuiAgent | null, choice: Pick) => void } -export function SourceControlActionAgentPicker( - props: PickerProps | { text: ComponentProps } -) { - return 'text' in 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) diff --git a/src/renderer/src/components/settings/source-control/SourceControlActionArguments.tsx b/src/renderer/src/components/settings/source-control/SourceControlActionArguments.tsx index 2e8a28d45b9..86d23419198 100644 --- a/src/renderer/src/components/settings/source-control/SourceControlActionArguments.tsx +++ b/src/renderer/src/components/settings/source-control/SourceControlActionArguments.tsx @@ -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, diff --git a/src/renderer/src/components/settings/source-control/text-actions/SourceControlTextActionAgentPicker.tsx b/src/renderer/src/components/settings/source-control/text-actions/SourceControlTextActionAgentPicker.tsx index a676ce71a09..469f6f0d646 100644 --- a/src/renderer/src/components/settings/source-control/text-actions/SourceControlTextActionAgentPicker.tsx +++ b/src/renderer/src/components/settings/source-control/text-actions/SourceControlTextActionAgentPicker.tsx @@ -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 ( - 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( ) } - -export function JiraSetupSteps( - props: ConnectStepProps & { onConnected: () => void; onOpenIntegrations: () => void } -): React.JSX.Element { - const t = useTranslate() - const [dialogOpen, setDialogOpen] = useState(false) - - return ( - <> -
    - setDialogOpen(true)} - > - {props.connected - ? t('auto.components.settings.TasksPane.manageJira', 'Manage keys') - : t('auto.components.settings.TasksPane.addJira', 'Add Jira access')} - - } - /> - -
- - - ) -} diff --git a/src/renderer/src/components/settings/tasks/TaskSourceJiraSetup.tsx b/src/renderer/src/components/settings/tasks/TaskSourceJiraSetup.tsx new file mode 100644 index 00000000000..a8b247dd674 --- /dev/null +++ b/src/renderer/src/components/settings/tasks/TaskSourceJiraSetup.tsx @@ -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 ( + <> +
    + setDialogOpen(true)} + > + {props.connected + ? t('auto.components.settings.TasksPane.manageJira', 'Manage keys') + : t('auto.components.settings.TasksPane.addJira', 'Add Jira access')} + + } + /> + +
+ + + ) +} diff --git a/src/renderer/src/components/settings/tasks/TaskSourceSimpleSetup.test.tsx b/src/renderer/src/components/settings/tasks/TaskSourceSimpleSetup.test.tsx deleted file mode 100644 index c85146cb6af..00000000000 --- a/src/renderer/src/components/settings/tasks/TaskSourceSimpleSetup.test.tsx +++ /dev/null @@ -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( - - ) - - fireEvent.click(rendered.getByRole('button', { name: 'Manage keys' })) - - expect(onOpenIntegrations).toHaveBeenCalledOnce() - expect(mocks.dialogOpen.at(-1)).toBe(false) - }) -}) diff --git a/src/renderer/src/components/settings/tasks/TasksPane.tsx b/src/renderer/src/components/settings/tasks/TasksPane.tsx index 7b549bac428..946912f85fe 100644 --- a/src/renderer/src/components/settings/tasks/TasksPane.tsx +++ b/src/renderer/src/components/settings/tasks/TasksPane.tsx @@ -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 { diff --git a/src/renderer/src/components/settings/tasks/task-source-setup-state.ts b/src/renderer/src/components/settings/tasks/task-source-setup-state.ts index 70d126106c9..31a79cce3cc 100644 --- a/src/renderer/src/components/settings/tasks/task-source-setup-state.ts +++ b/src/renderer/src/components/settings/tasks/task-source-setup-state.ts @@ -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' +} diff --git a/src/renderer/src/components/status-bar/ClaudeSwitcherForOwner.tsx b/src/renderer/src/components/status-bar/ClaudeSwitcherForOwner.tsx index 10565b005cb..08582d13463 100644 --- a/src/renderer/src/components/status-bar/ClaudeSwitcherForOwner.tsx +++ b/src/renderer/src/components/status-bar/ClaudeSwitcherForOwner.tsx @@ -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, diff --git a/src/renderer/src/components/status-bar/status-bar-runtime-targets.ts b/src/renderer/src/components/status-bar/status-bar-runtime-targets.ts index 45493c345ba..41f07440a0f 100644 --- a/src/renderer/src/components/status-bar/status-bar-runtime-targets.ts +++ b/src/renderer/src/components/status-bar/status-bar-runtime-targets.ts @@ -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' diff --git a/src/renderer/src/lib/agent-session/launch/agent-settings-update-queue.test.ts b/src/renderer/src/lib/agent-session/launch/agent-settings-update-queue.test.ts index 71af9925394..ec15942fc1a 100644 --- a/src/renderer/src/lib/agent-session/launch/agent-settings-update-queue.test.ts +++ b/src/renderer/src/lib/agent-session/launch/agent-settings-update-queue.test.ts @@ -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 + resolve: () => void +} + +function createDeferred(): Deferred { + let resolve!: () => void + const promise = new Promise((next) => { + resolve = next + }) + return { promise, resolve } +} + +async function flushPromiseQueue(): Promise { + 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[] = [] + + useAppStore.setState({ settings }) + const updateSettings = vi.fn((update: Partial) => { + 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 + }) +}) diff --git a/src/renderer/src/lib/agent-session/launch/native-chat-provider-choice.test.tsx b/src/renderer/src/lib/agent-session/launch/native-chat-provider-choice.test.tsx index 6b007b10351..815e93a2caf 100644 --- a/src/renderer/src/lib/agent-session/launch/native-chat-provider-choice.test.tsx +++ b/src/renderer/src/lib/agent-session/launch/native-chat-provider-choice.test.tsx @@ -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( diff --git a/src/renderer/src/lib/claude-account-sign-in.ts b/src/renderer/src/lib/claude-account-sign-in.ts index 169b41fff9e..85148154eb7 100644 --- a/src/renderer/src/lib/claude-account-sign-in.ts +++ b/src/renderer/src/lib/claude-account-sign-in.ts @@ -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 { diff --git a/src/renderer/src/lib/provider-accounts/account-runtime-label.ts b/src/renderer/src/lib/provider-accounts/account-runtime-label.ts new file mode 100644 index 00000000000..8ed6cb5b416 --- /dev/null +++ b/src/renderer/src/lib/provider-accounts/account-runtime-label.ts @@ -0,0 +1,21 @@ +import { translate } from '../../i18n/i18n' +import type { Translate } from '../../i18n/use-translate' + +export type LocalAccountRuntime = { + runtime: 'host' | 'wsl' + wslDistro?: string | null + label: string +} + +export function getHostRuntimeLabel(t: Translate = translate): string { + return navigator.userAgent.includes('Windows') + ? 'Windows' + : t('auto.components.settings.AccountsPane.9baf45d071', 'This device') +} + +// 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 +} diff --git a/src/renderer/src/components/settings/accounts/accounts-pane-action-errors.ts b/src/renderer/src/lib/provider-accounts/provider-account-action-errors.ts similarity index 92% rename from src/renderer/src/components/settings/accounts/accounts-pane-action-errors.ts rename to src/renderer/src/lib/provider-accounts/provider-account-action-errors.ts index 20c10fa5d6f..0f30e9ab077 100644 --- a/src/renderer/src/components/settings/accounts/accounts-pane-action-errors.ts +++ b/src/renderer/src/lib/provider-accounts/provider-account-action-errors.ts @@ -1,5 +1,5 @@ -import { CLAUDE_SIGN_IN_FAILED_MESSAGE } from '../../../../../shared/claude-sign-in-link' -import { CODEX_LOGIN_CANCELLED_MESSAGE } from '../../../../../shared/codex-auth-errors' +import { CLAUDE_SIGN_IN_FAILED_MESSAGE } from '../../../../shared/claude-sign-in-link' +import { CODEX_LOGIN_CANCELLED_MESSAGE } from '../../../../shared/codex-auth-errors' export function getCodexAccountErrorDescription(error: unknown): string { const message = String((error as Error)?.message ?? error)