Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.
Python agent-orchestrationaiai-agentschatopsdiscordlangchainmcpmicrosoft-teamsmulti-agentopen-sourceopenaiself-hostedslack
feat(console): create a workspace from the switcher
Petr Bauchbea22c646f80
diff --git a/console/apps/switch-console-desktop/src/renderer/app/modal-registry.ts b/console/apps/switch-console-desktop/src/renderer/app/modal-registry.tsindex b94ed44bb..e3abd6080 100644--- a/console/apps/switch-console-desktop/src/renderer/app/modal-registry.ts+++ b/console/apps/switch-console-desktop/src/renderer/app/modal-registry.ts@@ -20,6 +20,7 @@ import { DeleteServerModal } from '@renderer/features/switch-servers/DeleteServeimport { DisconnectMessagingAppModal } from '@renderer/features/switch-servers/DisconnectMessagingAppModal';import { RenameServerModal } from '@renderer/features/switch-servers/RenameServerModal';import { SaveTemplateModal } from '@renderer/features/templates/save-template-modal';+import { CreateWorkspaceModal } from '@renderer/features/workspaces/create-workspace-modal';import { ConfirmActionDialog } from '@renderer/lib/components/confirm-action-dialog';import { ExternalLinkChoiceDialog } from '@renderer/lib/components/external-link-choice-dialog';import { UnsavedChangesDialog } from '@renderer/lib/components/unsaved-changes-dialog';@@ -65,6 +66,10 @@ export const modalRegistry = {}),deleteSessionModal: createModal(DeleteSessionModal, { size: 'sm' }),addServerModal: createModal(AddServerModal, { size: 'md', dismissOnOutsideClick: false }),+ createWorkspaceModal: createModal(CreateWorkspaceModal, {+ size: 'md',+ dismissOnOutsideClick: false,+ }),addHostModal: createModal(AddHostModal, { size: 'md', dismissOnOutsideClick: false }),assignServerModal: createModal(AssignServerModal, { size: 'sm', dismissOnOutsideClick: false }),renameServerModal: createModal(RenameServerModal, {diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/workspace-switcher.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/workspace-switcher.tsxindex adf6b5bb1..574e8a1b4 100644--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/workspace-switcher.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/workspace-switcher.tsx@@ -1,4 +1,4 @@-import { ChevronsUpDown, Plus } from 'lucide-react';+import { ChevronsUpDown, Plus, Server } from 'lucide-react';import { observer } from 'mobx-react-lite';import { useEffect } from 'react';import { workspacesStore } from '@renderer/features/workspaces/workspaces-store';@@ -70,6 +70,7 @@ export const WorkspaceSwitcher = observer(function WorkspaceSwitcher() {const store = switchServersStore;const { navigate } = useNavigate();const showAddServerModal = useShowModal('addServerModal');+ const showCreateWorkspaceModal = useShowModal('createWorkspaceModal');useEffect(() => {void store.init();@@ -139,8 +140,23 @@ export const WorkspaceSwitcher = observer(function WorkspaceSwitcher() {<ServerWorkspaceGroup key={server.id} server={server} />))}<DropdownMenuSeparator />- <DropdownMenuItem onClick={() => showAddServerModal({})}>+ {/* Above Add server because it is the commoner errand by far: you add+ a server once and make workspaces on it for as long as you use+ it. It opens on the server you are already in — the modal asks+ which only where there is more than one to ask about. */}+ <DropdownMenuItem+ onClick={() =>+ showCreateWorkspaceModal({+ serverId: activeServer.id,+ onSuccess: (workspace) => navigate('server', { serverId: workspace.serverId }),+ })+ }+ ><Plus className="size-4" />+ New workspace+ </DropdownMenuItem>+ <DropdownMenuItem onClick={() => showAddServerModal({})}>+ <Server className="size-4" />Add server</DropdownMenuItem><DropdownMenuSeparator />diff --git a/console/apps/switch-console-desktop/src/renderer/features/workspaces/create-workspace-modal.tsx b/console/apps/switch-console-desktop/src/renderer/features/workspaces/create-workspace-modal.tsxnew file mode 100644index 000000000..7a2ae23aa--- /dev/null+++ b/console/apps/switch-console-desktop/src/renderer/features/workspaces/create-workspace-modal.tsx@@ -0,0 +1,245 @@+import { observer } from 'mobx-react-lite';+import { useEffect, useState } from 'react';+import { switchServersStore } from '@renderer/features/switch-servers/switch-servers-store';+import { workspacesStore } from '@renderer/features/workspaces/workspaces-store';+import { failureText } from '@renderer/lib/errors/describe-failure';+import { useModalContext, type BaseModalProps } from '@renderer/lib/modal/modal-provider';+import { Button } from '@renderer/lib/ui/button';+import { ConfirmButton } from '@renderer/lib/ui/confirm-button';+import {+ DialogContentArea,+ DialogFooter,+ DialogHeader,+ DialogTitle,+} from '@renderer/lib/ui/dialog';+import { Field, FieldGroup, FieldLabel } from '@renderer/lib/ui/field';+import { Input } from '@renderer/lib/ui/input';+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from '@renderer/lib/ui/select';+import type { Workspace } from '@shared/core/workspaces/workspaces';+import { createWorkspaceFailureText } from './describe-create-failure';++type CreateWorkspaceModalArgs = {+ /** The server to create it on — the one the window is currently scoped to. */+ serverId: string;+};++type Props = BaseModalProps<Workspace> & CreateWorkspaceModalArgs;++/**+ * Why a server cannot be asked to create a workspace, or null when it can.+ *+ * Three refusals rather than one, because the remedies are three different+ * things and only one of them is a password. Telling someone to sign in again+ * because the network is down misattributes an outage to their credentials,+ * which is the same mistake as blaming the name for an authentication failure —+ * the one this modal exists to avoid — with the arrow reversed.+ */+function whyNotReady(serverId: string): string | null {+ const server = switchServersStore.serverById(serverId);+ if (server === null) return 'That server is no longer registered on this computer.';+ if (!switchServersStore.statuses.has(serverId)) {+ return `Checking whether you’re signed in to ${server.name}…`;+ }+ if (switchServersStore.isUnreachable(serverId)) {+ return `${server.name} can’t be reached right now, so it can’t be asked to create anything.`;+ }+ if (!switchServersStore.isConnected(serverId)) {+ return `You are not signed in to ${server.name}, so it cannot be asked to create anything. Sign in on its page first.`;+ }+ return null;+}++/**+ * Make a workspace from the switcher.+ *+ * A workspace belongs to a server, so the first thing this has to be sure of is+ * which one. It opens on the server the window is already in and offers the+ * others only where there is a choice to make — on the ordinary single-server+ * install the question never appears.+ *+ * Only a server you are signed in to can be asked. Offering the rest and+ * letting Create come back with an authentication failure would blame the name+ * for something the name had nothing to do with, so the modal says which server+ * is not ready and keeps the button off.+ *+ * The design's address hint and "let my team join automatically" toggle are not+ * here: a Switch workspace has no subdomain of its own, and no server can yet+ * admit people by email domain. See the first-run create page, which leaves+ * them out for the same reasons.+ */+export const CreateWorkspaceModal = observer(function CreateWorkspaceModal({+ serverId,+ onSuccess,+ onClose,+}: Props) {+ const { transitionModal, setCloseGuard } = useModalContext();+ const [chosen, setChosen] = useState<string | null>(null);+ const [name, setName] = useState('');+ const [submitting, setSubmitting] = useState(false);+ const [error, setError] = useState<string | null>(null);+ /**+ * The workspace the gateway has already minted, when entering it is what+ * failed.+ *+ * Creating it again would ask for a name the server has just taken and come+ * back with a conflict that reads as the name being refused — so once this is+ * set the button stops offering to create and offers to open instead.+ */+ const [created, setCreated] = useState<Workspace | null>(null);++ const candidates = switchServersStore.servers.filter((server) =>+ switchServersStore.isConnected(server.id)+ );+ // The server the window is in, when it can be asked; otherwise the only one+ // that can. A default that is not a candidate would hide the picker on a+ // question the user still has to answer, and leave Create disabled with the+ // usable server offered nowhere.+ const fallback = candidates.some((server) => server.id === serverId)+ ? serverId+ : (candidates[0]?.id ?? serverId);+ const where = chosen ?? fallback;+ const target = switchServersStore.serverById(where);+ const notReady = whyNotReady(where);+ const trimmed = name.trim();++ // A status nobody has read yet leaves the modal saying "checking" forever,+ // since nothing else on screen is watching this server.+ useEffect(() => {+ if (!switchServersStore.statuses.has(where)) void switchServersStore.refreshStatus(where);+ }, [where]);++ const submit = async () => {+ if (submitting) return;+ if (created === null && (notReady !== null || trimmed === '')) return;+ setSubmitting(true);+ setCloseGuard(true);+ setError(null);+ try {+ const workspace = created ?? (await workspacesStore.create(where, trimmed));+ setCreated(workspace);+ // Made and then entered: you asked for a workspace to work in, and+ // leaving the window in the old one would look like nothing happened.+ await workspacesStore.setActive(workspace.id);+ onSuccess(workspace);+ } catch (cause) {+ // Two different failures wear the same button. Before the workspace+ // exists the likeliest one is the name, and after it exists the name is+ // settled and what failed was the move into it — saying "could not+ // create" then would be describing the wrong step.+ setError(+ created === null+ ? createWorkspaceFailureText(+ cause,+ target?.name ?? 'that server',+ `${target?.name ?? 'That server'} could not create it.`+ )+ : failureText(cause, `This window could not be moved into ${created.name}.`)+ );+ setSubmitting(false);+ } finally {+ setCloseGuard(false);+ }+ };++ return (+ <>+ <DialogHeader showCloseButton={false}>+ <DialogTitle>Create a workspace</DialogTitle>+ </DialogHeader>+ <DialogContentArea className="pt-0">+ <FieldGroup>+ <Field>+ <FieldLabel>Name</FieldLabel>+ <Input+ value={name}+ onChange={(e) => {+ setName(e.target.value);+ setError(null);+ }}+ onKeyDown={(e) => {+ if (e.key === 'Enter') void submit();+ }}+ placeholder="Weekend Robotics"+ autoFocus+ disabled={created !== null}+ />+ </Field>++ {candidates.length > 1 && (+ <Field>+ <FieldLabel>Server</FieldLabel>+ <Select+ value={where}+ onValueChange={(value) => value && setChosen(value)}+ disabled={submitting || created !== null}+ >+ <SelectTrigger>+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ {candidates.map((server) => (+ <SelectItem key={server.id} value={server.id}>+ {server.name}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </Field>+ )}++ {created !== null ? (+ <p className="text-xs text-foreground-muted">+ {created.name} was created on {target?.name ?? 'the server'}, but this window could+ not be moved into it. Try again, or close this and pick it from the switcher.+ </p>+ ) : notReady !== null ? (+ <p className="text-xs text-destructive">{notReady}</p>+ ) : target !== null && candidates.length <= 1 ? (+ <p className="text-xs text-foreground-muted">+ It will live on {target.name}, along with its rooms and agents.+ </p>+ ) : null}++ {error && <p className="text-xs text-destructive">{error}</p>}++ <p className="text-xs text-foreground-muted">+ Rather put it somewhere else?{' '}+ <button+ type="button"+ className="underline underline-offset-2 hover:text-foreground disabled:opacity-50"+ disabled={submitting || created !== null}+ onClick={() => transitionModal('addServerModal', {})}+ >+ Add a server+ </button>+ </p>+ </FieldGroup>+ </DialogContentArea>+ <DialogFooter>+ <Button variant="outline" onClick={onClose} disabled={submitting}>+ {created === null ? 'Cancel' : 'Close'}+ </Button>+ <ConfirmButton+ onClick={() => void submit()}+ /* Entering a workspace that already exists is a local move, so once it+ has been created the server's readiness stops being the question. */+ disabled={submitting || (created === null && (notReady !== null || trimmed === ''))}+ >+ {created !== null+ ? submitting+ ? 'Opening…'+ : 'Open workspace'+ : submitting+ ? 'Creating…'+ : 'Create workspace'}+ </ConfirmButton>+ </DialogFooter>+ </>+ );+});diff --git a/console/apps/switch-console-desktop/src/renderer/tests/browser/create-workspace-modal.test.tsx b/console/apps/switch-console-desktop/src/renderer/tests/browser/create-workspace-modal.test.tsxnew file mode 100644index 000000000..ba243866c--- /dev/null+++ b/console/apps/switch-console-desktop/src/renderer/tests/browser/create-workspace-modal.test.tsx@@ -0,0 +1,369 @@+/**+ * Making a workspace from the switcher.+ *+ * A workspace belongs to a server, so what this has to get right is which one:+ * the question is only asked where there is a choice, and a server that cannot+ * be asked at all is said to be so rather than allowed to fail on Create.+ */+import { act } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++const create = vi.hoisted(() => vi.fn());+const setActiveWorkspace = vi.hoisted(() => vi.fn());+const connected = vi.hoisted(() => new Set<string>());+/** Ids a status read has answered for. Not asked yet is its own state. */+const statuses = vi.hoisted(() => new Map<string, unknown>());+const unreachable = vi.hoisted(() => new Set<string>());+const refreshStatus = vi.hoisted(() => vi.fn());+const servers = vi.hoisted(() => [] as { id: string; name: string }[]);++vi.hoisted(() => {+ window.electronAPI ??= {+ invoke: () => Promise.resolve(undefined),+ eventOn: () => () => {},+ eventSend: () => {},+ } as unknown as typeof window.electronAPI;+});++vi.mock('@renderer/features/switch-servers/switch-servers-store', () => ({+ switchServersStore: {+ get servers() {+ return servers;+ },+ statuses,+ isConnected: (id: string) => connected.has(id),+ isUnreachable: (id: string) => unreachable.has(id),+ refreshStatus,+ serverById: (id: string) => servers.find((s) => s.id === id) ?? null,+ },+}));++vi.mock('@renderer/features/workspaces/workspaces-store', () => ({+ workspacesStore: { create, setActive: setActiveWorkspace },+}));++import { CreateWorkspaceModal } from '@renderer/features/workspaces/create-workspace-modal';+import { modalStore } from '@renderer/lib/modal/modal-store';+import { Dialog } from '@renderer/lib/ui/dialog';+import { RpcError } from '@shared/lib/ipc/rpc-error';++let container: HTMLDivElement | null = null;+let root: Root | null = null;++const onSuccess = vi.fn();+const onClose = vi.fn();++function workspace(id: string, serverId: string) {+ return {+ id,+ serverId,+ name: 'Weekend Robotics',+ tenantId: 't1',+ slug: 'weekend-robotics',+ role: 'owner' as const,+ createdAt: '',+ updatedAt: '',+ };+}++beforeEach(() => {+ create.mockReset();+ setActiveWorkspace.mockReset().mockResolvedValue(undefined);+ refreshStatus.mockReset();+ onSuccess.mockReset();+ onClose.mockReset();+ servers.length = 0;+ connected.clear();+ statuses.clear();+ unreachable.clear();+ modalStore.closeGuardActive = false;+});++/**+ * A server the app knows about, in one of the four states the modal tells+ * apart.+ *+ * `unknown` is the one that is not a failure: no status read has answered for+ * it yet, which is a different thing from having answered "not signed in".+ */+function addServer(+ id: string,+ name: string,+ state: 'signedIn' | 'signedOut' | 'unreachable' | 'unknown'+) {+ servers.push({ id, name });+ if (state === 'unknown') return;+ statuses.set(id, { serverId: id, connected: state === 'signedIn', user: null });+ if (state === 'signedIn') connected.add(id);+ if (state === 'unreachable') unreachable.add(id);+}++function deferred<T>() {+ let resolve!: (value: T) => void;+ let reject!: (cause: unknown) => void;+ const promise = new Promise<T>((res, rej) => {+ resolve = res;+ reject = rej;+ });+ return { promise, resolve, reject };+}++afterEach(async () => {+ if (root) await act(async () => root!.unmount());+ container?.remove();+ container = null;+ root = null;+});++async function render(serverId: string): Promise<HTMLDivElement> {+ container = document.createElement('div');+ document.body.appendChild(container);+ root = createRoot(container);+ // The modal renders the dialog's parts and not the dialog itself — the+ // registry supplies that in the app, and this supplies it here.+ await act(async () =>+ root!.render(+ <Dialog open onOpenChange={() => {}}>+ <CreateWorkspaceModal serverId={serverId} onSuccess={onSuccess} onClose={onClose} />+ </Dialog>+ )+ );+ return container;+}++async function settle(): Promise<void> {+ for (let i = 0; i < 8; i++) await act(async () => await Promise.resolve());+}++/** By substring: the confirm button carries its keyboard shortcut in its text. */+function button(el: HTMLElement, label: string): HTMLButtonElement {+ const found = [...el.querySelectorAll<HTMLButtonElement>('button')].find((b) =>+ b.textContent?.includes(label)+ );+ expect(found, `no ${label} button`).toBeDefined();+ return found!;+}++async function typeName(el: HTMLElement, value: string): Promise<void> {+ const input = el.querySelector('input')!;+ const setter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')!.set!;+ await act(async () => {+ setter.call(input, value);+ input.dispatchEvent(new Event('input', { bubbles: true }));+ });+}++/** A label that is present in the dialog, ignoring the select's own portal. */+function hasLabel(el: HTMLElement, text: string): boolean {+ return [...el.querySelectorAll('label')].some((l) => l.textContent?.trim() === text);+}++describe('the create-workspace modal', () => {+ it('creates on the server the window is in, and goes there', async () => {+ addServer('srv-1', 'Acme prod', 'signedIn');+ const made = workspace('ws-9', 'srv-1');+ create.mockResolvedValue(made);++ const el = await render('srv-1');+ await typeName(el, ' Weekend Robotics ');+ await act(async () => button(el, 'Create workspace').click());+ await settle();++ expect(create).toHaveBeenCalledWith('srv-1', 'Weekend Robotics');+ expect(setActiveWorkspace).toHaveBeenCalledWith('ws-9');+ expect(onSuccess).toHaveBeenCalledWith(made);+ });++ it('does not ask which server when there is only one to ask about', async () => {+ addServer('srv-1', 'Acme prod', 'signedIn');++ const el = await render('srv-1');++ expect(hasLabel(el, 'Server')).toBe(false);+ expect(el.textContent).toContain('Acme prod');+ });++ it('asks which server once there are two you are signed in to', async () => {+ addServer('srv-1', 'Acme prod', 'signedIn');+ addServer('srv-2', 'Acme staging', 'signedIn');++ const el = await render('srv-1');++ expect(hasLabel(el, 'Server')).toBe(true);+ });++ // The failure would otherwise arrive as an authentication error on Create,+ // which reads as the name being refused.+ it('refuses to ask a server you are not signed in to', async () => {+ addServer('srv-1', 'Acme prod', 'signedOut');++ const el = await render('srv-1');+ await typeName(el, 'Weekend Robotics');++ expect(el.textContent).toContain('not signed in to Acme prod');+ expect(button(el, 'Create workspace').disabled).toBe(true);+ });++ it('will not create a workspace with no name', async () => {+ addServer('srv-1', 'Acme prod', 'signedIn');++ const el = await render('srv-1');+ await typeName(el, ' ');++ expect(button(el, 'Create workspace').disabled).toBe(true);+ });++ it('keeps the form and says why when the server refuses the name', async () => {+ addServer('srv-1', 'Acme prod', 'signedIn');+ create.mockRejectedValue(new Error('A workspace with that name already exists.'));++ const el = await render('srv-1');+ await typeName(el, 'Weekend Robotics');+ await act(async () => button(el, 'Create workspace').click());+ await settle();++ expect(el.textContent).toContain('already exists');+ expect(onSuccess).not.toHaveBeenCalled();+ expect(button(el, 'Create workspace').disabled).toBe(false);+ });++ /**+ * The refusal the gateway actually sends, rather than a plain Error. Its+ * words are `Slug already taken: weekend-robotics` — no terminal punctuation,+ * so the shared description does not read it as a sentence and demotes it to+ * diagnostics. What reached the user was a status code and a slug they never+ * typed, for the likeliest failure of this form and the only one they can fix.+ */+ it('blames the name for a name conflict, not the status code and the slug', async () => {+ addServer('srv-1', 'Acme prod', 'signedIn');+ create.mockRejectedValue(+ new RpcError({+ __switchConsoleRpcError: true,+ code: 'GatewayError',+ message: 'Gateway returned 409: Slug already taken: weekend-robotics',+ data: { kind: 'http', status: 409, detail: 'Slug already taken: weekend-robotics' },+ } as unknown as ConstructorParameters<typeof RpcError>[0])+ );++ const el = await render('srv-1');+ await typeName(el, 'Weekend Robotics');+ await act(async () => button(el, 'Create workspace').click());+ await settle();++ expect(el.textContent).toContain('already goes by that name');+ expect(el.textContent).not.toContain('weekend-robotics');+ expect(el.textContent).not.toContain('409');+ // Still typeable: a different name is the whole of the remedy.+ expect(el.querySelector('input')!.disabled).toBe(false);+ });++ /**+ * "Not signed in" and "cannot be reached" want different things from the+ * user, and only one of them is a password. Sending someone to re-authenticate+ * for a network outage is the same misattribution this modal exists to avoid,+ * pointing the other way.+ */+ it('says a server is unreachable rather than telling you to sign in again', async () => {+ addServer('srv-1', 'Acme prod', 'unreachable');++ const el = await render('srv-1');++ expect(el.textContent).toContain('can’t be reached');+ expect(el.textContent).not.toContain('not signed in');+ });++ it('does not claim you are signed out before it has looked', async () => {+ addServer('srv-1', 'Acme prod', 'unknown');++ const el = await render('srv-1');++ expect(el.textContent).toContain('Checking whether you’re signed in');+ expect(el.textContent).not.toContain('not signed in to');+ // Nothing else on screen is watching this server, so the modal has to ask+ // or the sentence above is what it says forever.+ expect(refreshStatus).toHaveBeenCalledWith('srv-1');+ });++ /**+ * The hidden default was the window's own server, which may be the one that+ * cannot be asked — leaving Create permanently off with the usable server+ * offered nowhere.+ */+ it('opens on a server it can ask when the window’s own cannot be', async () => {+ addServer('srv-1', 'Acme prod', 'signedOut');+ addServer('srv-2', 'Acme staging', 'signedIn');+ create.mockResolvedValue(workspace('ws-9', 'srv-2'));++ const el = await render('srv-1');+ await typeName(el, 'Weekend Robotics');+ await act(async () => button(el, 'Create workspace').click());+ await settle();++ expect(el.textContent).toContain('Acme staging');+ expect(create).toHaveBeenCalledWith('srv-2', 'Weekend Robotics');+ });++ /**+ * `dismissOnOutsideClick: false` stops the backdrop but not Escape, so+ * without the guard a keypress mid-create leaves the window re-scoped and+ * `onSuccess` firing on a modal the user believed they had cancelled.+ */+ it('holds itself shut while the create is in flight', async () => {+ addServer('srv-1', 'Acme prod', 'signedIn');+ const creating = deferred<ReturnType<typeof workspace>>();+ create.mockReturnValue(creating.promise);++ const el = await render('srv-1');+ await typeName(el, 'Weekend Robotics');+ await act(async () => button(el, 'Create workspace').click());++ expect(modalStore.closeGuardActive).toBe(true);++ creating.resolve(workspace('ws-9', 'srv-1'));+ await settle();++ expect(modalStore.closeGuardActive).toBe(false);+ });++ /**+ * The workspace exists on the server from the moment Create returns.+ * Offering Create again would send the same name back and earn a conflict+ * that reads as the name being refused — on the first-run page with no way+ * back, that is the end of the road.+ */+ it('offers to open the workspace it already made rather than creating it twice', async () => {+ addServer('srv-1', 'Acme prod', 'signedIn');+ create.mockResolvedValue(workspace('ws-9', 'srv-1'));+ setActiveWorkspace.mockRejectedValueOnce(new Error('could not switch'));++ const el = await render('srv-1');+ await typeName(el, 'Weekend Robotics');+ await act(async () => button(el, 'Create workspace').click());+ await settle();++ expect(el.textContent).toContain('could not be moved into it');++ await act(async () => button(el, 'Open workspace').click());+ await settle();++ expect(create).toHaveBeenCalledTimes(1);+ expect(onSuccess).toHaveBeenCalledWith(expect.objectContaining({ id: 'ws-9' }));+ });++ // Creating it and then leaving the window in the old workspace would look+ // like nothing happened, so a switch that fails is not reported as success.+ it('does not report success when the new workspace cannot be entered', async () => {+ addServer('srv-1', 'Acme prod', 'signedIn');+ create.mockResolvedValue(workspace('ws-9', 'srv-1'));+ setActiveWorkspace.mockRejectedValue(new Error('could not switch'));++ const el = await render('srv-1');+ await typeName(el, 'Weekend Robotics');+ await act(async () => button(el, 'Create workspace').click());+ await settle();++ expect(onSuccess).not.toHaveBeenCalled();+ expect(el.textContent).toContain('could not switch');+ });+});