From 9359edc2b01c7c38ce59766bf911da79600d5f08 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Mon, 10 Aug 2026 20:25:13 -0700 Subject: [PATCH] refactor(workspaces): remove replaced host combobox (#13507) --- config/scripts/locale-ko-key-overrides.json | 6 - .../ProjectHostSetupCombobox.test.tsx | 157 ------------------ .../ProjectHostSetupCombobox.tsx | 105 ------------ src/renderer/src/i18n/locales/en.json | 4 - src/renderer/src/i18n/locales/es.json | 4 - src/renderer/src/i18n/locales/ja.json | 4 - src/renderer/src/i18n/locales/ko.json | 4 - src/renderer/src/i18n/locales/zh.json | 4 - 8 files changed, 288 deletions(-) delete mode 100644 src/renderer/src/components/new-workspace/ProjectHostSetupCombobox.test.tsx delete mode 100644 src/renderer/src/components/new-workspace/ProjectHostSetupCombobox.tsx diff --git a/config/scripts/locale-ko-key-overrides.json b/config/scripts/locale-ko-key-overrides.json index 7c0bf011de4..d3c2375bc45 100644 --- a/config/scripts/locale-ko-key-overrides.json +++ b/config/scripts/locale-ko-key-overrides.json @@ -1502,12 +1502,6 @@ "auto.components.new.workspace.ProjectCombobox.search": { "ko": "프로젝트 검색..." }, - "auto.components.new.workspace.ProjectHostSetupCombobox.empty": { - "ko": "이 프로젝트에 준비된 호스트가 없습니다." - }, - "auto.components.new.workspace.ProjectHostSetupCombobox.placeholder": { - "ko": "호스트 선택" - }, "auto.components.notification.sound.options.0acd3d384e": { "ko": "클랙" }, diff --git a/src/renderer/src/components/new-workspace/ProjectHostSetupCombobox.test.tsx b/src/renderer/src/components/new-workspace/ProjectHostSetupCombobox.test.tsx deleted file mode 100644 index 06b1267f80b..00000000000 --- a/src/renderer/src/components/new-workspace/ProjectHostSetupCombobox.test.tsx +++ /dev/null @@ -1,157 +0,0 @@ -// @vitest-environment happy-dom - -import React, { act } from 'react' -import { createRoot, type Root } from 'react-dom/client' -import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type { - NeedsSetupProjectHostOption, - ProjectHostSetupOption -} from '@/lib/project-host-setup-options' -import ProjectHostSetupCombobox from './ProjectHostSetupCombobox' - -vi.mock('@/components/ui/popover', () => ({ - Popover: ({ children }: { children: React.ReactNode }) =>
{children}
, - PopoverContent: ({ children }: { children: React.ReactNode }) =>
{children}
, - PopoverTrigger: ({ children }: { children: React.ReactNode }) => <>{children} -})) - -vi.mock('@/components/ui/command', () => ({ - Command: ({ children }: { children: React.ReactNode }) =>
{children}
, - CommandEmpty: ({ children }: { children: React.ReactNode }) =>
{children}
, - CommandList: ({ children }: { children: React.ReactNode }) =>
{children}
, - CommandItem: ({ - children, - disabled, - onSelect, - value - }: { - children: React.ReactNode - disabled?: boolean - onSelect?: (value: string) => void - value: string - }) => ( - - ) -})) - -let container: HTMLDivElement -let root: Root - -const readyOption: ProjectHostSetupOption = { - id: 'local-setup', - kind: 'ready', - projectId: 'project-1', - hostId: 'local', - repoId: 'local-repo', - label: 'Local Mac', - detail: 'Orca', - path: '/Users/alice/orca' -} - -const needsSetupOption: NeedsSetupProjectHostOption = { - id: 'needs-setup:ssh:builder', - kind: 'needs-setup', - projectId: 'project-1', - hostId: 'ssh:builder', - label: 'Builder', - detail: 'Project location not set', - isAvailable: true, - attention: false -} - -const unavailableOption: NeedsSetupProjectHostOption = { - id: 'needs-setup:runtime:old', - kind: 'needs-setup', - projectId: 'project-1', - hostId: 'runtime:old', - label: 'Old server', - detail: 'Update Orca on this host to set up projects', - isAvailable: false, - attention: false -} - -beforeEach(() => { - container = document.createElement('div') - document.body.appendChild(container) - root = createRoot(container) -}) - -afterEach(() => { - act(() => { - root.unmount() - }) - container.remove() -}) - -function renderCombobox({ - onValueChange = vi.fn() -}: { - onValueChange?: (setupId: string) => void -} = {}): void { - act(() => { - root.render( - - ) - }) -} - -describe('ProjectHostSetupCombobox', () => { - it('routes ready setup rows through onValueChange', () => { - const onValueChange = vi.fn() - - renderCombobox({ onValueChange }) - - act(() => { - container - .querySelector('[data-command-value="local-setup"]') - ?.dispatchEvent(new MouseEvent('click', { bubbles: true })) - }) - - expect(onValueChange).toHaveBeenCalledWith('local-setup') - }) - - it('hides hosts that need setup from the run target list', () => { - const onValueChange = vi.fn() - - renderCombobox({ onValueChange }) - - expect( - container.querySelector('[data-command-value="needs-setup:ssh:builder"]') - ).toBeNull() - expect(container.textContent).not.toContain('Project location not set') - expect(onValueChange).not.toHaveBeenCalled() - }) - - it('hides unavailable setup rows from the run target list', () => { - const onValueChange = vi.fn() - - act(() => { - root.render( - - ) - }) - - const unavailableButton = container.querySelector( - '[data-command-value="needs-setup:runtime:old"]' - ) - expect(unavailableButton).toBeNull() - expect(container.textContent).not.toContain('Update Orca on this host') - - expect(onValueChange).not.toHaveBeenCalled() - }) -}) diff --git a/src/renderer/src/components/new-workspace/ProjectHostSetupCombobox.tsx b/src/renderer/src/components/new-workspace/ProjectHostSetupCombobox.tsx deleted file mode 100644 index 22df2d5f192..00000000000 --- a/src/renderer/src/components/new-workspace/ProjectHostSetupCombobox.tsx +++ /dev/null @@ -1,105 +0,0 @@ -import React from 'react' -import { Check, ChevronsUpDown, Server } from 'lucide-react' -import { Button } from '@/components/ui/button' -import { Command, CommandEmpty, CommandItem, CommandList } from '@/components/ui/command' -import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover' -import { cn } from '@/lib/utils' -import type { ProjectHostSetupOption } from '@/lib/project-host-setup-options' -import { translate } from '@/i18n/i18n' - -type ProjectHostSetupComboboxProps = { - options: readonly ProjectHostSetupOption[] - value: string | null - onValueChange: (setupId: string) => void -} - -export default function ProjectHostSetupCombobox({ - options, - value, - onValueChange -}: ProjectHostSetupComboboxProps): React.JSX.Element { - const [open, setOpen] = React.useState(false) - const readyOptions = options.filter((option) => option.kind === 'ready') - const selected = readyOptions.find((option) => option.id === value) ?? readyOptions[0] ?? null - - const handleSelect = React.useCallback( - (setupId: string): void => { - const option = options.find((candidate) => candidate.id === setupId) - if (!option) { - return - } - if (!readyOptions.some((candidate) => candidate.id === setupId)) { - return - } - onValueChange(setupId) - setOpen(false) - }, - [onValueChange, options, readyOptions] - ) - - return ( - - - - - - - - - {translate( - 'auto.components.new.workspace.ProjectHostSetupCombobox.empty', - 'No hosts are ready for this project.' - )} - - {readyOptions.map((option) => ( - handleSelect(option.id)} - className="items-center gap-2 px-3 py-2" - > - - -
-
{option.label}
-
- {option.path} -
-
-
- ))} -
-
-
-
- ) -} diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index 10c9c94fd6f..f782865d3be 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -12254,10 +12254,6 @@ "jiraSelectBindFailed": "Couldn’t link this Jira issue. Pick the matching site or reconnect Jira, then try again.", "emoji": "Emoji" }, - "ProjectHostSetupCombobox": { - "empty": "No hosts are ready for this project.", - "placeholder": "Choose host" - }, "ProjectCombobox": { "empty": "No projects match your search.", "addProject": "Add a new project", diff --git a/src/renderer/src/i18n/locales/es.json b/src/renderer/src/i18n/locales/es.json index e572aebea50..4447e45e0f7 100644 --- a/src/renderer/src/i18n/locales/es.json +++ b/src/renderer/src/i18n/locales/es.json @@ -11742,10 +11742,6 @@ "jiraSelectBindFailed": "Couldn’t link this Jira issue. Pick the matching site or reconnect Jira, then try again.", "emoji": "Emoji" }, - "ProjectHostSetupCombobox": { - "empty": "No hay hosts listos para este proyecto.", - "placeholder": "Elegir host" - }, "ProjectCombobox": { "empty": "Ningún proyecto coincide con tu búsqueda.", "addProject": "Add a new project", diff --git a/src/renderer/src/i18n/locales/ja.json b/src/renderer/src/i18n/locales/ja.json index 94acf2379a5..883ec789b60 100644 --- a/src/renderer/src/i18n/locales/ja.json +++ b/src/renderer/src/i18n/locales/ja.json @@ -11742,10 +11742,6 @@ "jiraSelectBindFailed": "この Jira Issue をリンクできませんでした。該当するサイトを選択するか Jira に再接続してから、もう一度お試しください。", "emoji": "絵文字" }, - "ProjectHostSetupCombobox": { - "empty": "このプロジェクトで準備が整ったホストはありません。", - "placeholder": "ホストを選択" - }, "ProjectCombobox": { "empty": "検索条件に一致するプロジェクトはありません。", "addProject": "新規プロジェクトを追加", diff --git a/src/renderer/src/i18n/locales/ko.json b/src/renderer/src/i18n/locales/ko.json index a3ee8dd668d..4641da71258 100644 --- a/src/renderer/src/i18n/locales/ko.json +++ b/src/renderer/src/i18n/locales/ko.json @@ -11742,10 +11742,6 @@ "jiraSelectBindFailed": "Couldn’t link this Jira issue. Pick the matching site or reconnect Jira, then try again.", "emoji": "Emoji" }, - "ProjectHostSetupCombobox": { - "empty": "이 프로젝트에 준비된 호스트가 없습니다.", - "placeholder": "호스트 선택" - }, "ProjectCombobox": { "empty": "검색과 일치하는 프로젝트가 없습니다.", "addProject": "새 프로젝트 추가", diff --git a/src/renderer/src/i18n/locales/zh.json b/src/renderer/src/i18n/locales/zh.json index 30aba037f97..4f1f86c0a46 100644 --- a/src/renderer/src/i18n/locales/zh.json +++ b/src/renderer/src/i18n/locales/zh.json @@ -11762,10 +11762,6 @@ "jiraSelectBindFailed": "无法关联此 Jira 议题。请选择匹配的站点或重新连接 Jira,然后重试。", "emoji": "Emoji" }, - "ProjectHostSetupCombobox": { - "empty": "此项目没有已就绪的主机。", - "placeholder": "选择主机" - }, "ProjectCombobox": { "empty": "没有匹配搜索的项目。", "addProject": "添加新项目",