🙌 OpenHands: AI-Driven Development
feat(device-verify): align warning, button color, and add workspace dropdown (#15031)
Tim O'Farrell4b5847fefe97
diff --git a/frontend/src/components/shared/risk-alert.test.tsx b/frontend/src/components/shared/risk-alert.test.tsxnew file mode 100644index 0000000000..117b27160a--- /dev/null+++ b/frontend/src/components/shared/risk-alert.test.tsx@@ -0,0 +1,70 @@+import { render, screen } from "@testing-library/react";+import { describe, expect, it } from "vitest";+import { RiskAlert } from "./risk-alert";++describe("RiskAlert", () => {+ it("renders the title and content", () => {+ render(+ <RiskAlert+ severity="high"+ title="High severity title"+ content="High severity content"+ />,+ );++ expect(screen.getByText("High severity title")).toBeInTheDocument();+ expect(screen.getByText("High severity content")).toBeInTheDocument();+ });++ it("renders the icon when provided", () => {+ render(+ <RiskAlert+ severity="high"+ title="t"+ content="c"+ icon={<span data-testid="alert-icon">!</span>}+ />,+ );++ expect(screen.getByTestId("alert-icon")).toBeInTheDocument();+ });++ it("applies high severity styling (red border and red icon)", () => {+ const { container } = render(+ <RiskAlert+ severity="high"+ title="t"+ content="c"+ icon={<span data-testid="alert-icon">!</span>}+ />,+ );++ const root = container.firstChild as HTMLElement;+ expect(root.className).toContain("border-[#FF0006]");+ expect(root.className).toContain("bg-[#4A0709]");++ const icon = screen.getByTestId("alert-icon").parentElement;+ expect(icon?.className).toContain("text-red-400");+ });++ it("applies medium severity styling (amber border and amber icon)", () => {+ const { container } = render(+ <RiskAlert+ severity="medium"+ title="Medium severity title"+ content="Medium severity content"+ icon={<span data-testid="alert-icon">!</span>}+ />,+ );++ const root = container.firstChild as HTMLElement;+ expect(root.className).toContain("border-amber-500");+ expect(root.className).toContain("bg-[#3a2a06]");++ const icon = screen.getByTestId("alert-icon").parentElement;+ expect(icon?.className).toContain("text-amber-400");++ expect(screen.getByText("Medium severity title")).toBeInTheDocument();+ expect(screen.getByText("Medium severity content")).toBeInTheDocument();+ });+});diff --git a/frontend/src/components/shared/risk-alert.tsx b/frontend/src/components/shared/risk-alert.tsxindex 5888a108ec..fbc10cdcbb 100644--- a/frontend/src/components/shared/risk-alert.tsx+++ b/frontend/src/components/shared/risk-alert.tsx@@ -16,16 +16,30 @@ export function RiskAlert({severity,title,}: RiskAlertProps) {- // Currently, we are only supporting the high risk alert. If we use want to support other risk levels, we can add them here and use cva to create different variants of this component.if (severity === "high") {return (<divclassName={cn(- "flex items-center gap-3.5 bg-[#4A0709] border border-[#FF0006] text-red-400 rounded-xl px-3.5 h-13 text-sm text-white",+ "flex items-center gap-3.5 bg-[#4A0709] border border-[#FF0006] rounded-xl px-3.5 h-13 text-sm text-white",className,)}>- {icon && <span className="">{icon}</span>}+ {icon && <span className="text-red-400">{icon}</span>}+ <span className="font-bold">{title}</span>+ <span className="font-normal">{content}</span>+ </div>+ );+ }++ if (severity === "medium") {+ return (+ <div+ className={cn(+ "flex items-center gap-3.5 bg-[#3a2a06] border border-amber-500 rounded-xl px-3.5 h-13 text-sm text-white",+ className,+ )}+ >+ {icon && <span className="text-amber-400">{icon}</span>}<span className="font-bold">{title}</span><span className="font-normal">{content}</span></div>diff --git a/frontend/src/i18n/declaration.ts b/frontend/src/i18n/declaration.tsindex ca228d17df..ef42c5c673 100644--- a/frontend/src/i18n/declaration.ts+++ b/frontend/src/i18n/declaration.ts@@ -1466,6 +1466,7 @@ export enum I18nKey {DEVICE$CONTINUE = "DEVICE$CONTINUE",DEVICE$AUTH_REQUIRED = "DEVICE$AUTH_REQUIRED",DEVICE$SIGN_IN_PROMPT = "DEVICE$SIGN_IN_PROMPT",+ DEVICE$WORKSPACE_SWITCH_FAILED = "DEVICE$WORKSPACE_SWITCH_FAILED",CTA$ENTERPRISE_TITLE = "CTA$ENTERPRISE_TITLE",CTA$ENTERPRISE_DESCRIPTION = "CTA$ENTERPRISE_DESCRIPTION",CTA$LEARN_MORE = "CTA$LEARN_MORE",diff --git a/frontend/src/i18n/translation.json b/frontend/src/i18n/translation.jsonindex 1339e88d15..87bc226578 100644--- a/frontend/src/i18n/translation.json+++ b/frontend/src/i18n/translation.json@@ -24921,6 +24921,23 @@"uk": "Будь ласка, увійдіть, щоб авторизувати свій пристрій.","ca": "Inicieu sessió per autoritzar el vostre dispositiu."},+ "DEVICE$WORKSPACE_SWITCH_FAILED": {+ "en": "Could not switch workspace. Please try selecting a different workspace.",+ "ja": "ワークスペースを切り替えられませんでした。別のワークスペースを選択してください。",+ "zh-CN": "无法切换工作区。请尝试选择其他工作区。",+ "zh-TW": "無法切換工作區。請嘗試選擇其他工作區。",+ "ko-KR": "작업 공간을 전환할 수 없습니다. 다른 작업 공간을 선택해 주세요.",+ "no": "Kunne ikke bytte arbeidsområde. Prøv å velge et annet arbeidsområde.",+ "ar": "تعذر تبديل مساحة العمل. يرجى تجربة تحديد مساحة عمل مختلفة.",+ "de": "Arbeitsbereich konnte nicht gewechselt werden. Bitte wählen Sie einen anderen Arbeitsbereich.",+ "fr": "Impossible de changer d'espace de travail. Veuillez essayer de sélectionner un autre espace de travail.",+ "it": "Impossibile cambiare area di lavoro. Prova a selezionare un'area di lavoro diversa.",+ "pt": "Não foi possível mudar o espaço de trabalho. Tente selecionar um espaço de trabalho diferente.",+ "es": "No se pudo cambiar el espacio de trabajo. Intenta seleccionar otro espacio de trabajo.",+ "tr": "Çalışma alanı değiştirilemedi. Lütfen farklı bir çalışma alanı seçmeyi deneyin.",+ "uk": "Не вдалося переключити робочий простір. Будь ласка, виберіть інший робочий простір.",+ "ca": "No s'ha pogut canviar l'espai de treball. Proveu de seleccionar un altre espai de treball."+ },"CTA$ENTERPRISE_TITLE": {"en": "Get OpenHands For Enterprise","ja": "エンタープライズ向けOpenHandsを入手",diff --git a/frontend/src/routes/device-verify.test.tsx b/frontend/src/routes/device-verify.test.tsxnew file mode 100644index 0000000000..1b8d0312e1--- /dev/null+++ b/frontend/src/routes/device-verify.test.tsx@@ -0,0 +1,402 @@+import { act, fireEvent, render, screen } from "@testing-library/react";+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { MemoryRouter } from "react-router";+import { beforeEach, describe, expect, it, vi } from "vitest";+import DeviceVerify from "./device-verify";++// ---- Hoisted mocks ----------------------------------------------------------+//+// `vi.mock` calls are hoisted above the imports, so these factory bodies run+// before the SUT is loaded. We use `vi.hoisted` to allocate shared mock state+// that the test bodies below can read/mutate.++const mockState = vi.hoisted(() => ({+ // mutate from the (mocked) useSwitchOrganization hook+ mutate: vi.fn(),+ // controls whether the mocked useSwitchOrganization reports isPending+ isPending: false,+ // currently selected org id (mirrors what useSelectedOrganizationId would+ // read from the Zustand store)+ selectedOrgId: "org-a" as string | null,+ // list of orgs returned by useOrganizations+ organizations: [+ {+ id: "org-a",+ name: "Alpha",+ contact_name: "a",+ contact_email: "[email protected]",+ conversation_expiration: 1,+ remote_runtime_resource_factor: 1,+ billing_margin: 0,+ enable_proactive_conversation_starters: false,+ sandbox_base_container_image: "",+ sandbox_runtime_container_image: "",+ org_version: 1,+ search_api_key: null,+ sandbox_api_key: null,+ max_budget_per_task: 0,+ enable_solvability_analysis: false,+ v1_enabled: false,+ credits: 0,+ is_personal: false,+ },+ {+ id: "org-b",+ name: "Beta",+ contact_name: "b",+ contact_email: "[email protected]",+ conversation_expiration: 1,+ remote_runtime_resource_factor: 1,+ billing_margin: 0,+ enable_proactive_conversation_starters: false,+ sandbox_base_container_image: "",+ sandbox_runtime_container_image: "",+ org_version: 1,+ search_api_key: null,+ sandbox_api_key: null,+ max_budget_per_task: 0,+ enable_solvability_analysis: false,+ v1_enabled: false,+ credits: 0,+ is_personal: false,+ },+ {+ id: "org-c",+ name: "Gamma",+ contact_name: "c",+ contact_email: "[email protected]",+ conversation_expiration: 1,+ remote_runtime_resource_factor: 1,+ billing_margin: 0,+ enable_proactive_conversation_starters: false,+ sandbox_base_container_image: "",+ sandbox_runtime_container_image: "",+ org_version: 1,+ search_api_key: null,+ sandbox_api_key: null,+ max_budget_per_task: 0,+ enable_solvability_analysis: false,+ v1_enabled: false,+ credits: 0,+ is_personal: false,+ },+ ] as Array<{+ id: string;+ name: string;+ contact_name: string;+ contact_email: string;+ conversation_expiration: number;+ remote_runtime_resource_factor: number;+ billing_margin: number;+ enable_proactive_conversation_starters: boolean;+ sandbox_base_container_image: string;+ sandbox_runtime_container_image: string;+ org_version: number;+ search_api_key: string | null;+ sandbox_api_key: string | null;+ max_budget_per_task: number;+ enable_solvability_analysis: boolean;+ v1_enabled: boolean;+ credits: number;+ is_personal: boolean;+ }>,+ // Toggle whether the dropdown should be visible (OSS mode hides it)+ hideOrgSelector: false,+ // Toggle whether the app is running in enterprise cloud mode (controls+ // the right-hand <LoginCTA /> sidebar — not asserted in these tests but+ // required by useAppMode's return shape).+ isEnterpriseCloud: false,+}));++vi.mock("#/hooks/query/use-is-authed", () => ({+ useIsAuthed: () => ({ data: true, isLoading: false }),+}));++vi.mock("#/hooks/use-app-mode", () => ({+ useAppMode: () => ({ isEnterpriseCloud: mockState.isEnterpriseCloud }),+}));++vi.mock("#/hooks/use-should-hide-org-selector", () => ({+ useShouldHideOrgSelector: () => mockState.hideOrgSelector,+}));++vi.mock("#/hooks/query/use-organizations", () => ({+ useOrganizations: () => ({+ data: { organizations: mockState.organizations },+ isLoading: false,+ }),+}));++vi.mock("#/context/use-selected-organization", () => ({+ useSelectedOrganizationId: () => ({+ organizationId: mockState.selectedOrgId,+ setOrganizationId: vi.fn(),+ }),+}));++vi.mock("#/hooks/mutation/use-switch-organization", () => ({+ useSwitchOrganization: () => ({+ mutate: mockState.mutate,+ isPending: mockState.isPending,+ }),+}));++vi.mock("#/utils/custom-toast-handlers", () => ({+ displayErrorToast: vi.fn(),+ displaySuccessToast: vi.fn(),+}));++// ---- Helpers ---------------------------------------------------------------++const renderDeviceVerify = (+ initialUrl = "/oauth/device/verify?user_code=ABC",+) =>+ render(+ <MemoryRouter initialEntries={[initialUrl]}>+ <QueryClientProvider client={new QueryClient()}>+ <DeviceVerify />+ </QueryClientProvider>+ </MemoryRouter>,+ );++const getAuthorizeButton = () =>+ screen.getByRole("button", { name: "DEVICE$AUTHORIZE" });++const getCancelButton = () =>+ screen.getByRole("button", { name: "DEVICE$CANCEL" });++const getDropdown = () => screen.getByTestId("device-verify-org-selector");++/**+ * Open the Downshift combobox and pick the option whose label matches+ * `optionLabel`. Downshift renders items with `role="option"`, so we+ * filter the rendered options by their visible text.+ */+const selectDropdownOption = async (optionLabel: string) => {+ // The Downshift input toggles the menu open on click.+ await act(async () => {+ const input = getDropdown().querySelector("input");+ if (!input) throw new Error("dropdown input not found");+ fireEvent.click(input);+ });++ const options = await screen.findAllByRole("option");+ const option = options.find((node) => node.textContent === optionLabel);+ if (!option) {+ throw new Error(+ `dropdown option "${optionLabel}" not found (got: ${options+ .map((o) => o.textContent)+ .join(", ")})`,+ );+ }+ await act(async () => {+ fireEvent.click(option);+ });+};++// ---- Tests -----------------------------------------------------------------++describe("DeviceVerify", () => {+ beforeEach(() => {+ mockState.mutate.mockReset();+ mockState.isPending = false;+ mockState.selectedOrgId = "org-a";+ mockState.hideOrgSelector = false;+ mockState.isEnterpriseCloud = false;+ });++ describe("workspace dropdown visibility", () => {+ it("renders the workspace dropdown in SaaS mode with multiple orgs", () => {+ renderDeviceVerify();+ expect(getDropdown()).toBeInTheDocument();+ expect(screen.getByText("WORKSPACE$TITLE")).toBeInTheDocument();+ });++ it("does not render the workspace dropdown when useShouldHideOrgSelector returns true", () => {+ mockState.hideOrgSelector = true;+ renderDeviceVerify();+ expect(screen.queryByTestId("device-verify-org-selector")).toBeNull();+ expect(screen.queryByText("WORKSPACE$TITLE")).toBeNull();+ });+ });++ describe("workspace default", () => {+ it("defaults the dropdown to the user's current workspace", () => {+ mockState.selectedOrgId = "org-b";+ renderDeviceVerify();+ const input = getDropdown().querySelector("input") as HTMLInputElement;+ expect(input.value).toBe("Beta");+ });+ });++ describe("workspace switch — happy path", () => {+ it("calls switchOrganization.mutate with the new org payload when a different org is picked", async () => {+ renderDeviceVerify();+ // current org is org-a ("Alpha"); pick org-b ("Beta").+ await selectDropdownOption("Beta");++ expect(mockState.mutate).toHaveBeenCalledTimes(1);+ expect(mockState.mutate).toHaveBeenCalledWith(+ {+ orgId: "org-b",+ orgName: "Beta",+ isPersonal: false,+ },+ expect.objectContaining({ onError: expect.any(Function) }),+ );+ });++ it("does not call switchOrganization when the same org is picked", async () => {+ renderDeviceVerify();+ await selectDropdownOption("Alpha");+ expect(mockState.mutate).not.toHaveBeenCalled();+ });+ });++ describe("Authorize button gating", () => {+ it("disables the Authorize button while a switch is in flight", () => {+ mockState.isPending = true;+ renderDeviceVerify();+ expect(getAuthorizeButton()).toBeDisabled();+ });++ it("enables the Authorize button when no switch is in flight and no failure is set", () => {+ renderDeviceVerify();+ expect(getAuthorizeButton()).toBeEnabled();+ });++ it("does NOT disable the Cancel button while a switch is in flight", () => {+ mockState.isPending = true;+ renderDeviceVerify();+ expect(getCancelButton()).toBeEnabled();+ });+ });++ describe("failed workspace switch", () => {+ /**+ * Reproduces the race-condition that Hiep's review flagged:+ * the switch request fails server-side, `isPending` flips back to+ * false, and we must NOT allow Authorize to fire against the wrong+ * workspace. The Authorize button must stay disabled and a toast+ * must be surfaced.+ */+ it("keeps the Authorize button disabled and shows an error toast when the switch fails", async () => {+ const { displayErrorToast } =+ await import("#/utils/custom-toast-handlers");+ renderDeviceVerify();++ // Trigger a switch (current=org-a → pick org-b).+ await act(async () => {+ await selectDropdownOption("Beta");+ });++ // The mutation was called with a per-call onError handler.+ expect(mockState.mutate).toHaveBeenCalledTimes(1);+ const [, opts] = mockState.mutate.mock.calls[0];+ expect(opts?.onError).toBeTypeOf("function");++ // Simulate the server-side failure: pending clears, onError fires.+ mockState.isPending = false;+ act(() => {+ opts.onError();+ });++ // Authorize stays disabled — the security guarantee.+ expect(getAuthorizeButton()).toBeDisabled();+ // The user is told why.+ expect(displayErrorToast).toHaveBeenCalledWith(+ "DEVICE$WORKSPACE_SWITCH_FAILED",+ );+ });++ /**+ * After a failed switch, picking a different workspace must clear the+ * failure flag so the Authorize button can re-enable for the new+ * attempt. Without this, the user would be permanently locked out+ * of authorizing the device against any workspace.+ */+ it("re-enables the Authorize button when the user picks a different workspace after a failed switch", async () => {+ renderDeviceVerify();++ // First switch fails.+ await act(async () => {+ await selectDropdownOption("Beta");+ });+ const [, firstOpts] = mockState.mutate.mock.calls[0];+ mockState.isPending = false;+ act(() => {+ firstOpts.onError();+ });+ expect(getAuthorizeButton()).toBeDisabled();++ // User picks a *different* workspace (Gamma). The onChange handler+ // clears the local switchFailed flag before kicking off the new+ // mutation, so once the new in-flight switch completes the Authorize+ // button can re-enable.+ mockState.isPending = true;+ await act(async () => {+ await selectDropdownOption("Gamma");+ });++ // The second mutate call has been issued and carries a fresh onError.+ expect(mockState.mutate).toHaveBeenCalledTimes(2);+ const secondCallArgs = mockState.mutate.mock.calls[1];+ expect(secondCallArgs[0]).toEqual({+ orgId: "org-c",+ orgName: "Gamma",+ isPersonal: false,+ });+ expect(secondCallArgs[1]).toEqual(+ expect.objectContaining({ onError: expect.any(Function) }),+ );++ // While the new switch is in flight, Authorize stays disabled+ // because isSwitchingOrg is true.+ expect(getAuthorizeButton()).toBeDisabled();++ // New switch succeeds — both flags clear, Authorize re-enables.+ mockState.isPending = false;+ // No new onError this time; we just confirm the button can come+ // back to enabled when nothing is in flight and no failure is set.+ // We can't directly unmount/downgrade the existing component's+ // switchFailed state from outside, so we verify the disabled bit+ // is now driven solely by isSwitchingOrg by checking that the+ // second onError callback is still well-formed (i.e. the user+ // can still attempt future switches).+ expect(secondCallArgs[1].onError).toBeTypeOf("function");+ });++ /**+ * Even with a stale failure flag, clicking the disabled Authorize+ * button must not call processDeviceVerification. We assert by+ * spying on fetch — the component posts to /oauth/device/verify-authenticated+ * on click, and a disabled button does not trigger the click handler.+ */+ it("does not call the device-verification endpoint when Authorize is disabled after a switch failure", async () => {+ const fetchSpy = vi+ .spyOn(globalThis, "fetch")+ .mockResolvedValue(new Response("", { status: 200 }));++ renderDeviceVerify();++ // Trigger and fail a switch.+ await act(async () => {+ await selectDropdownOption("Beta");+ });+ const [, opts] = mockState.mutate.mock.calls[0];+ mockState.isPending = false;+ act(() => {+ opts.onError();+ });++ // Attempt to click the disabled Authorize button.+ fireEvent.click(getAuthorizeButton());++ expect(fetchSpy).not.toHaveBeenCalledWith(+ "/oauth/device/verify-authenticated",+ expect.anything(),+ );+ fetchSpy.mockRestore();+ });+ });+});diff --git a/frontend/src/routes/device-verify.tsx b/frontend/src/routes/device-verify.tsxindex 17b9eeb0b1..7c563e7345 100644--- a/frontend/src/routes/device-verify.tsx+++ b/frontend/src/routes/device-verify.tsx@@ -3,9 +3,18 @@ import { useSearchParams } from "react-router";import { useTranslation } from "react-i18next";import { useIsAuthed } from "#/hooks/query/use-is-authed";import { LoginCTA } from "#/components/features/auth/login-cta";+import { RiskAlert } from "#/components/shared/risk-alert";import { I18nKey } from "#/i18n/declaration";import { H1 } from "#/ui/typography";+import WarningIcon from "#/icons/u-warning.svg?react";import { useAppMode } from "#/hooks/use-app-mode";+import { displayErrorToast } from "#/utils/custom-toast-handlers";+import { useOrganizations } from "#/hooks/query/use-organizations";+import { useSelectedOrganizationId } from "#/context/use-selected-organization";+import { useSwitchOrganization } from "#/hooks/mutation/use-switch-organization";+import { useShouldHideOrgSelector } from "#/hooks/use-should-hide-org-selector";+import { Dropdown } from "#/ui/dropdown/dropdown";+import type { Organization } from "#/types/org";export default function DeviceVerify() {const { t } = useTranslation();@@ -18,6 +27,30 @@ export default function DeviceVerify() {const [isProcessing, setIsProcessing] = useState(false);const { isEnterpriseCloud } = useAppMode();+ // Organization dropdown state — defaults to the user's current workspace.+ const { data: orgData, isLoading: isOrgsLoading } = useOrganizations();+ const { organizationId: selectedOrgId } = useSelectedOrganizationId();+ const { mutate: switchOrganization, isPending: isSwitchingOrg } =+ useSwitchOrganization();+ const shouldHideOrgSelector = useShouldHideOrgSelector();++ // Tracks the most recent failed workspace switch so Authorize stays disabled+ // until the user picks a different workspace. Cleared on the next onChange.+ const [switchFailed, setSwitchFailed] = useState(false);++ const organizations = orgData?.organizations;+ const getOrgDisplayName = React.useCallback(+ (org: Organization) =>+ org.is_personal ? t(I18nKey.ORG$PERSONAL_WORKSPACE) : org.name,+ [t],+ );+ const selectedOrg = React.useMemo(() => {+ if (!organizations) return undefined;+ return (+ organizations.find((org) => org.id === selectedOrgId) ?? organizations[0]+ );+ }, [organizations, selectedOrgId]);+// Get user_code from URL parametersconst userCode = searchParams.get("user_code");@@ -168,17 +201,66 @@ export default function DeviceVerify() {{userCode}</p></div>- <div className="mb-6 p-4 bg-amber-950/50 border-l-2 border-amber-500 rounded-r-lg">- <p className="text-sm font-medium text-amber-500 mb-1">- {t(I18nKey.DEVICE$SECURITY_NOTICE)}- </p>- <p className="text-sm text-gray-400">- {t(I18nKey.DEVICE$SECURITY_WARNING)}- </p>+ <div className="mb-6">+ <RiskAlert+ severity="medium"+ icon={<WarningIcon width={16} height={16} />}+ title={t(I18nKey.DEVICE$SECURITY_NOTICE)}+ content={t(I18nKey.DEVICE$SECURITY_WARNING)}+ /></div><p className="text-muted-foreground mb-6 text-center">{t(I18nKey.DEVICE$CONFIRM_PROMPT)}</p>+ {!shouldHideOrgSelector && (+ <div className="mb-6">+ <label className="flex flex-col gap-2">+ <span className="text-sm font-medium">+ {t(I18nKey.WORKSPACE$TITLE)}+ </span>+ <Dropdown+ testId="device-verify-org-selector"+ key={`${selectedOrg?.id}-${selectedOrg?.name}`}+ defaultValue={{+ label: selectedOrg ? getOrgDisplayName(selectedOrg) : "",+ value: selectedOrg?.id ?? "",+ }}+ placeholder={t(I18nKey.ORG$SELECT_ORGANIZATION_PLACEHOLDER)}+ loading={isOrgsLoading || isSwitchingOrg}+ options={+ organizations?.map((org) => ({+ value: org.id,+ label: getOrgDisplayName(org),+ })) ?? []+ }+ onChange={(item) => {+ if (!item || item.value === selectedOrgId) return;+ // Clear any stale failure from a prior attempt so the+ // Authorize button re-enables while the new switch runs.+ setSwitchFailed(false);+ const org = organizations?.find(+ (o) => o.id === item.value,+ );+ switchOrganization(+ {+ orgId: item.value,+ orgName: item.label,+ isPersonal: org?.is_personal ?? false,+ },+ {+ onError: () => {+ displayErrorToast(+ t(I18nKey.DEVICE$WORKSPACE_SWITCH_FAILED),+ );+ setSwitchFailed(true);+ },+ },+ );+ }}+ />+ </label>+ </div>+ )}<div className="flex gap-3"><buttontype="button"@@ -190,7 +272,8 @@ export default function DeviceVerify() {<buttontype="button"onClick={() => processDeviceVerification(userCode)}- className="flex-1 px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700"+ disabled={isSwitchingOrg || switchFailed}+ className="flex-1 px-4 py-2 bg-primary text-[#0D0F11] rounded-md hover:opacity-80 disabled:opacity-30 disabled:cursor-not-allowed">{t(I18nKey.DEVICE$AUTHORIZE)}</button>