refactor(settings): group repository identity modules (#31830)

This commit is contained in:
Neil
2026-10-21 21:54:24 -07:00
committed by GitHub
parent eba0124de9
commit 70ab09ca2f
17 changed files with 74 additions and 71 deletions
@@ -7,7 +7,7 @@ import type { Repo } from '../../../../shared/repo-types'
import type { GlobalSettings } from '../../../../shared/global-settings-types'
import type { GhAccountBinding } from '../../../../shared/github/account-binding'
import type { GhAccountBindingInventory } from '../../../../shared/github/auth-types'
import type * as RepositoryGitHubAccountModule from './repository-github-account'
import type * as RepositoryGitHubAccountModule from './repository/identity/repository-github-account'
import { RepositoryGitHubAccountSection } from './RepositoryGitHubAccountSection'
const { listAccountsMock, validateBindingMock, storeState } = vi.hoisted(() => {
@@ -19,7 +19,7 @@ const { listAccountsMock, validateBindingMock, storeState } = vi.hoisted(() => {
return { listAccountsMock: vi.fn(), validateBindingMock: vi.fn(), storeState }
})
vi.mock('../../store', () => {
vi.mock('@/store/index', () => {
const useAppStore = (selector: (state: typeof storeState) => unknown) => selector(storeState)
useAppStore.getState = () => storeState
return { useAppStore }
@@ -27,7 +27,7 @@ vi.mock('../../store', () => {
vi.mock('@/runtime/runtime-rpc-client', () => ({ callRuntimeRpc: vi.fn() }))
vi.mock('./repository-github-account', async (importOriginal) => ({
vi.mock('./repository/identity/repository-github-account', async (importOriginal) => ({
...(await importOriginal<typeof RepositoryGitHubAccountModule>()),
listRepositoryGhBindableAccounts: listAccountsMock,
validateRepositoryGhAccountBinding: validateBindingMock
@@ -10,8 +10,8 @@ import type {
GhMultiAccountCapability
} from '../../../../shared/github/auth-types'
import type { GhAccountBinding } from '../../../../shared/github/account-binding'
import type * as RepositoryGitHubAccountModule from './repository-github-account'
import { isGhAccountBindingEnforced } from './repository-github-account'
import type * as RepositoryGitHubAccountModule from './repository/identity/repository-github-account'
import { isGhAccountBindingEnforced } from './repository/identity/repository-github-account'
import { RepositoryGitHubAccountSection } from './RepositoryGitHubAccountSection'
const { listAccountsMock, validateBindingMock, storeState } = vi.hoisted(() => {
@@ -27,7 +27,7 @@ const { listAccountsMock, validateBindingMock, storeState } = vi.hoisted(() => {
}
})
vi.mock('../../store', () => {
vi.mock('@/store/index', () => {
const useAppStore = (selector: (state: typeof storeState) => unknown) => selector(storeState)
useAppStore.getState = () => storeState
return { useAppStore }
@@ -35,7 +35,7 @@ vi.mock('../../store', () => {
vi.mock('@/runtime/runtime-rpc-client', () => ({ callRuntimeRpc: vi.fn() }))
vi.mock('./repository-github-account', async (importOriginal) => ({
vi.mock('./repository/identity/repository-github-account', async (importOriginal) => ({
...(await importOriginal<typeof RepositoryGitHubAccountModule>()),
listRepositoryGhBindableAccounts: listAccountsMock,
validateRepositoryGhAccountBinding: validateBindingMock
@@ -6,7 +6,7 @@ import type { GhAccountBindingInventory } from '../../../../shared/github/auth-t
import { Button } from '../ui/button'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/select'
import { SearchableSetting } from './SearchableSetting'
import { useAppStore } from '../../store'
import { useAppStore } from '@/store/index'
import { runtimeTargetForOwnerEnvironment } from '@/runtime/runtime-client-target'
import { getRepoExecutionHostId, parseExecutionHostId } from '../../../../shared/execution-host'
import { translate } from '@/i18n/i18n'
@@ -15,7 +15,7 @@ import {
isGhAccountBindingEnforced,
listRepositoryGhBindableAccounts,
validateRepositoryGhAccountBinding
} from './repository-github-account'
} from './repository/identity/repository-github-account'
type RepositoryGitHubAccountSectionProps = {
repo: Repo
@@ -9,12 +9,9 @@ import type { Project } from '../../../../shared/project-types'
import type { Repo } from '../../../../shared/repo-types'
import type { TerminalTab } from '../../../../shared/terminal-tab-types'
import type { AgentStatusEntry } from '../../../../shared/agent-status-types'
import { useAppStore } from '../../store'
import {
getRepositoryPaneSearchEntries,
matchesRepositoryIdentitySearch,
RepositoryPane
} from './RepositoryPane'
import { useAppStore } from '@/store/index'
import { getRepositoryPaneSearchEntries, RepositoryPane } from './RepositoryPane'
import { matchesRepositoryIdentitySearch } from './repository/identity/repository-identity-search'
import { matchesSettingsSearch } from './settings-search'
import { TooltipProvider } from '../ui/tooltip'
@@ -17,23 +17,22 @@ import { SearchableSetting } from './SearchableSetting'
import { RepositoryRemoveProjectButton } from './RepositoryRemoveProjectButton'
import type { SettingsProjectRemovalScope } from './settings-project-list'
import { matchesSettingsSearch } from './settings-search'
import { useAppStore } from '../../store'
import { useAppStore } from '@/store/index'
import { getRepositoryIconSectionId } from './repository-settings-targets'
import { RepositoryIconPicker } from './RepositoryIconPicker'
import { RepositoryIconPicker } from './repository/identity/RepositoryIconPicker'
import { getRepositoryPaneSearchEntries } from './repository-search'
import { RepositoryHostSetupsSection } from './RepositoryHostSetupsSection'
import { RepoSettingsDraftInput } from './RepositorySettingsDraftInput'
import { RepositoryForkSyncSection } from './RepositoryForkSyncSection'
import { RepositoryForkSyncSection } from './repository/identity/RepositoryForkSyncSection'
import { RepositoryGitHubAccountSection } from './RepositoryGitHubAccountSection'
import { translate } from '@/i18n/i18n'
import { RepositoryWindowsRuntimeSection } from './RepositoryWindowsRuntimeSection'
import { matchesRepositoryIdentitySearch } from './repository-identity-search'
import { matchesRepositoryIdentitySearch } from './repository/identity/repository-identity-search'
import { RepositoryWorktreeDefaultsSection } from './RepositoryWorktreeDefaultsSection'
import { RepositoryJiraProjectSection } from './RepositoryJiraProjectSection'
import { getProjectRuntimeSessionSummary } from './repository-runtime-session-summary'
import { getRepoOwnerWorktreeVisibilityDefaults } from '../../store/worktree-visibility-defaults-by-host'
export { getRepositoryPaneSearchEntries }
export { matchesRepositoryIdentitySearch } from './repository-identity-search'
type RepositoryPaneRepoUpdate = Omit<
Partial<Repo>,
@@ -1,16 +1,16 @@
// @vitest-environment happy-dom
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
import { afterEach, describe, expect, it, vi } from 'vitest'
import type { Repo } from '../../../../shared/repo-types'
import type { Repo } from '../../../../../../shared/repo-types'
import { RepositoryForkSyncSection } from './RepositoryForkSyncSection'
const syncRuntimeGitForkDefaultBranch = vi.fn()
vi.mock('../../runtime/runtime-git-sync-client', () => ({
vi.mock('../../../../runtime/runtime-git-sync-client', () => ({
syncRuntimeGitForkDefaultBranch: (...args: unknown[]) => syncRuntimeGitForkDefaultBranch(...args)
}))
vi.mock('../../store', () => ({
vi.mock('@/store/index', () => ({
useAppStore: (selector: (state: Record<string, unknown>) => unknown) =>
selector({ settingsSearchQuery: '', settings: { activeRuntimeEnvironmentId: 'env-1' } })
}))
@@ -1,18 +1,18 @@
import { useRef, useState } from 'react'
import { RefreshCw } from 'lucide-react'
import { toast } from 'sonner'
import type { ForkSyncMode, GitForkSyncResult } from '../../../../shared/git-fork-sync'
import type { Repo } from '../../../../shared/repo-types'
import { getRepoMainWorktreeId } from '../../../../shared/worktree/id'
import { Button } from '../ui/button'
import { SearchableSetting } from './SearchableSetting'
import { SettingsSegmentedControl } from './SettingsFormControls'
import { syncRuntimeGitForkDefaultBranch } from '../../runtime/runtime-git-sync-client'
import type { ForkSyncMode, GitForkSyncResult } from '../../../../../../shared/git-fork-sync'
import type { Repo } from '../../../../../../shared/repo-types'
import { getRepoMainWorktreeId } from '../../../../../../shared/worktree/id'
import { Button } from '../../../ui/button'
import { SearchableSetting } from '../../SearchableSetting'
import { SettingsSegmentedControl } from '../../SettingsFormControls'
import { syncRuntimeGitForkDefaultBranch } from '../../../../runtime/runtime-git-sync-client'
import { ipcOrRuntimeTargetForHostId } from '@/runtime/runtime-client-target'
import { UNRESOLVED_GIT_HOST_ERROR } from '@/store/slices/editor/actions/git-operation-target'
import { getRepoExecutionHostId } from '../../../../shared/execution-host'
import { getRepoExecutionHostId } from '../../../../../../shared/execution-host'
import { translate } from '@/i18n/i18n'
import { searchKeywords } from './settings-search-keywords'
import { searchKeywords } from '../../settings-search-keywords'
type RepositoryForkSyncSectionProps = {
repo: Repo
@@ -1,7 +1,7 @@
import { DEFAULT_REPO_BADGE_COLOR, REPO_COLORS } from '../../../../shared/constants'
import { normalizeRepoBadgeColor } from '../../../../shared/repo-badge-color'
import { Label } from '../ui/label'
import { ColorPicker } from '../ui/color-picker'
import { DEFAULT_REPO_BADGE_COLOR, REPO_COLORS } from '../../../../../../shared/constants'
import { normalizeRepoBadgeColor } from '../../../../../../shared/repo-badge-color'
import { Label } from '../../../ui/label'
import { ColorPicker } from '../../../ui/color-picker'
import { cn } from '@/lib/utils'
import { translate } from '@/i18n/i18n'
@@ -3,7 +3,7 @@
import { act } from 'react'
import { createRoot, type Root } from 'react-dom/client'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import type { AppState } from '@/store'
import type { AppState } from '@/store/types'
import { RepositoryIconEmojiPicker } from './RepositoryIconEmojiPicker'
const toastMocks = vi.hoisted(() => ({
@@ -19,7 +19,7 @@ const storeMocks = vi.hoisted(() => ({
state: { settings: { theme: 'light' } } as Partial<AppState>
}))
vi.mock('@/store', () => ({
vi.mock('@/store/index', () => ({
useAppStore: (selector: (state: Partial<AppState>) => unknown) => selector(storeMocks.state)
}))
@@ -1,8 +1,8 @@
import { toast } from 'sonner'
import EmojiPicker, { EmojiStyle, Theme, type EmojiClickData } from 'emoji-picker-react'
import type { RepoIcon } from '../../../../shared/repo-icon'
import { sanitizeRepoIcon } from '../../../../shared/repo-icon'
import { useAppStore } from '../../store'
import type { RepoIcon } from '../../../../../../shared/repo-icon'
import { sanitizeRepoIcon } from '../../../../../../shared/repo-icon'
import { useAppStore } from '@/store/index'
import { useSystemPrefersDark } from '@/components/terminal-pane/use-system-prefers-dark'
import { translate } from '@/i18n/i18n'
@@ -3,7 +3,7 @@
import { act } from 'react'
import { createRoot, type Root } from 'react-dom/client'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import type { Repo } from '../../../../shared/repo-types'
import type { Repo } from '../../../../../../shared/repo-types'
import { RepositoryIconPicker } from './RepositoryIconPicker'
vi.mock('@/runtime/runtime-rpc-client', () => ({ callRuntimeRpc: vi.fn() }))
@@ -1,15 +1,18 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { toast } from 'sonner'
import { RotateCcw } from 'lucide-react'
import type { Repo } from '../../../../shared/repo-types'
import type { RepoIcon } from '../../../../shared/repo-icon'
import { DEFAULT_REPO_BADGE_COLOR } from '../../../../shared/constants'
import { normalizeRepoBadgeColor } from '../../../../shared/repo-badge-color'
import { Button } from '../ui/button'
import { Label } from '../ui/label'
import { RepoIconGlyph, getRepoLucideIconOptions } from '../repo/repo-icon'
import type { Repo } from '../../../../../../shared/repo-types'
import type { RepoIcon } from '../../../../../../shared/repo-icon'
import { DEFAULT_REPO_BADGE_COLOR } from '../../../../../../shared/constants'
import { normalizeRepoBadgeColor } from '../../../../../../shared/repo-badge-color'
import { Button } from '../../../ui/button'
import { Label } from '../../../ui/label'
import { RepoIconGlyph, getRepoLucideIconOptions } from '../../../repo/repo-icon'
import { runtimeTargetForOwnerEnvironment } from '@/runtime/runtime-client-target'
import { getRepoExecutionHostId, parseExecutionHostId } from '../../../../shared/execution-host'
import {
getRepoExecutionHostId,
parseExecutionHostId
} from '../../../../../../shared/execution-host'
import { useMountedRef } from '@/hooks/useMountedRef'
import { RepositoryIconColorSection } from './RepositoryIconColorSection'
import { RepositoryIconTabs } from './RepositoryIconTabs'
@@ -1,13 +1,13 @@
import { Suspense, useState } from 'react'
import { toast } from 'sonner'
import { Github, Image, Link2 } from 'lucide-react'
import type { RepoIcon } from '../../../../shared/repo-icon'
import { faviconUrlFromWebsite } from '../../../../shared/repo-icon'
import { Button } from '../ui/button'
import { Input } from '../ui/input'
import { Tabs, TabsContent, TabsList, TabsTrigger } from '../ui/tabs'
import { Tooltip, TooltipContent, TooltipTrigger } from '../ui/tooltip'
import { getRepoLucideIconOptions } from '../repo/repo-icon'
import type { RepoIcon } from '../../../../../../shared/repo-icon'
import { faviconUrlFromWebsite } from '../../../../../../shared/repo-icon'
import { Button } from '../../../ui/button'
import { Input } from '../../../ui/input'
import { Tabs, TabsContent, TabsList, TabsTrigger } from '../../../ui/tabs'
import { Tooltip, TooltipContent, TooltipTrigger } from '../../../ui/tooltip'
import { getRepoLucideIconOptions } from '../../../repo/repo-icon'
import { useMountedRef } from '@/hooks/useMountedRef'
import { translate } from '@/i18n/i18n'
import { lazyWithRetry } from '@/lib/lazy-with-retry'
@@ -1,12 +1,12 @@
import type { GhAccountBinding } from '../../../../shared/github/account-binding'
import type { Repo } from '../../../../shared/repo-types'
import type { GhAccountBinding } from '../../../../../../shared/github/account-binding'
import type { Repo } from '../../../../../../shared/repo-types'
import type {
GhAccountBindingInventory,
GhAccountBindingValidationResult
} from '../../../../shared/github/auth-types'
import { ghAccountBindingsEqual } from '../../../../shared/github/account-binding'
} from '../../../../../../shared/github/auth-types'
import { ghAccountBindingsEqual } from '../../../../../../shared/github/account-binding'
import { callRuntimeRpc } from '@/runtime/runtime-rpc-client'
import type { RuntimeClientTarget } from '../../../../shared/runtime-client-target'
import type { RuntimeClientTarget } from '../../../../../../shared/runtime-client-target'
const LOCAL_GH_ACCOUNT_IPC_TIMEOUT_MS = 30_000
@@ -1,6 +1,6 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import type { Repo } from '../../../../shared/repo-types'
import { githubAvatarIcon } from '../../../../shared/repo-icon'
import type { Repo } from '../../../../../../shared/repo-types'
import { githubAvatarIcon } from '../../../../../../shared/repo-icon'
import {
buildRepositoryGitHubAvatarUpdate,
resolveRepositoryGitHubAvatar
@@ -1,9 +1,13 @@
import type { GitHubRepositoryIdentity } from '../../../../shared/github/pull-request-types'
import type { Repo } from '../../../../shared/repo-types'
import { githubAvatarIcon, githubAvatarSlug, type RepoIcon } from '../../../../shared/repo-icon'
import { githubRepoIdentityKey } from '../../../../shared/github/repository-identity-key'
import type { GitHubRepositoryIdentity } from '../../../../../../shared/github/pull-request-types'
import type { Repo } from '../../../../../../shared/repo-types'
import {
githubAvatarIcon,
githubAvatarSlug,
type RepoIcon
} from '../../../../../../shared/repo-icon'
import { githubRepoIdentityKey } from '../../../../../../shared/github/repository-identity-key'
import { callRuntimeRpc } from '@/runtime/runtime-rpc-client'
import type { RuntimeClientTarget } from '../../../../shared/runtime-client-target'
import type { RuntimeClientTarget } from '../../../../../../shared/runtime-client-target'
type ResolveRepositoryGitHubAvatarOptions = {
forceLive?: boolean
@@ -1,5 +1,5 @@
import type { Repo } from '../../../../shared/repo-types'
import { normalizeSettingsSearchQuery } from './settings-search'
import type { Repo } from '../../../../../../shared/repo-types'
import { normalizeSettingsSearchQuery } from '../../settings-search'
export function matchesRepositoryIdentitySearch(query: string, repo: Repo): boolean {
const normalizedQuery = normalizeSettingsSearchQuery(query)