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
Keep organization names through failed lookups and re-ask what may be created
Petr Baucha4412945b7f1
diff --git a/console/apps/switch-console-desktop/src/main/core/switch-servers/controller.ts b/console/apps/switch-console-desktop/src/main/core/switch-servers/controller.tsindex ad57a62bf..6d93edb4b 100644--- a/console/apps/switch-console-desktop/src/main/core/switch-servers/controller.ts+++ b/console/apps/switch-console-desktop/src/main/core/switch-servers/controller.ts@@ -170,41 +170,38 @@ async function adoptWorkspaces(server: SwitchServer): Promise<void> {}/**- * Reported by reason rather than by outcome: the two are the same fact, and a- * sign-in that never left this machine — the server's host is down — has a- * reason of its own but no result to read one from.- */-/**- * The local row for a workspace a server has just added the account to.+ * The local row for a membership a server has just given the account, by+ * creating a workspace or adding it to one; `recorded` names which, for the+ * error raised when no row turns up.*- * Reconciled rather than inserted here, the same as `createWorkspace`: which- * local row a membership belongs to is decided in one place.+ * Reconciled rather than inserted here: which local row a membership belongs+ * to is decided in one place.*/-/** The local row for a workspace the account has just created on a server. */-async function recordCreated(server: SwitchServer, tenant: RemoteTenant): Promise<Workspace> {+async function recordMembership(+ server: SwitchServer,+ tenant: RemoteTenant,+ recorded: string+): Promise<Workspace> {await reconcileServerWorkspaces(server.id);const workspaces = await listWorkspacesForServer(server.id);- const created = workspaces.find((workspace) => workspace.tenantId === tenant.id);- if (!created) {- throw new Error(- `${server.name} created the workspace ${tenant.name}, but this install did not record it.`- );- }- return created;+ const found = workspaces.find((workspace) => workspace.tenantId === tenant.id);+ if (!found) throw new Error(`${server.name} ${recorded}, but this install did not record it.`);+ return found;+}++async function recordCreated(server: SwitchServer, tenant: RemoteTenant): Promise<Workspace> {+ return recordMembership(server, tenant, `created the workspace ${tenant.name}`);}async function recordJoined(server: SwitchServer, tenant: RemoteTenant): Promise<Workspace> {- await reconcileServerWorkspaces(server.id);- const workspaces = await listWorkspacesForServer(server.id);- const joined = workspaces.find((workspace) => workspace.tenantId === tenant.id);- if (!joined) {- throw new Error(- `${server.name} added you to ${tenant.name}, but this install did not record it.`- );- }- return joined;+ return recordMembership(server, tenant, `added you to ${tenant.name}`);}+/**+ * Reported by reason rather than by outcome: the two are the same fact, and a+ * sign-in that never left this machine — the server's host is down — has a+ * reason of its own but no result to read one from.+ */function reportSignIn(method: TelemetryAuthMethod,server: SwitchServer,diff --git a/console/apps/switch-console-desktop/src/main/core/switch-servers/gateway-client.test.ts b/console/apps/switch-console-desktop/src/main/core/switch-servers/gateway-client.test.tsindex ee632e8f0..1be747407 100644--- a/console/apps/switch-console-desktop/src/main/core/switch-servers/gateway-client.test.ts+++ b/console/apps/switch-console-desktop/src/main/core/switch-servers/gateway-client.test.ts@@ -2406,14 +2406,11 @@ describe('organizations', () => {await expect(fetchTenants(SERVER)).rejects.toThrow(/unknown organization role: billing/);});- it('names the organizations by id, and says when the server has none', async () => {+ it('names the organizations by id', async () => {fetchMock.mockResolvedValue(jsonResponse([{ id: 'o1', slug: 'acme', name: 'Acme Inc', role: 'org_admin' }]) as never);await expect(fetchOrganizationNames(SERVER)).resolves.toEqual(new Map([['o1', 'Acme Inc']]));-- fetchMock.mockResolvedValue(errorResponse(404, '{"detail":"Not Found"}') as never);- await expect(fetchOrganizationNames(SERVER)).resolves.toBeNull();});it('creates an organization and answers with its first workspace', async () => {diff --git a/console/apps/switch-console-desktop/src/main/core/switch-servers/gateway-client.ts b/console/apps/switch-console-desktop/src/main/core/switch-servers/gateway-client.tsindex 15afdf2fc..f85745517 100644--- a/console/apps/switch-console-desktop/src/main/core/switch-servers/gateway-client.ts+++ b/console/apps/switch-console-desktop/src/main/core/switch-servers/gateway-client.ts@@ -661,19 +661,9 @@ export async function fetchTenants(server: SwitchServer): Promise<RemoteTenant[]/*** The names of the organizations the signed-in user belongs to, by id. Like* `GET /tenants` it needs no tenant selected.- *- * Null on a server from before organizations, which has no such route.*/-export async function fetchOrganizationNames(- server: SwitchServer-): Promise<Map<string, string> | null> {- let res: Response;- try {- res = await gatewayFetch(server, '/organizations', { authenticated: true });- } catch (cause) {- if (cause instanceof GatewayError && cause.status === 404) return null;- throw cause;- }+export async function fetchOrganizationNames(server: SwitchServer): Promise<Map<string, string>> {+ const res = await gatewayFetch(server, '/organizations', { authenticated: true });const json = (await res.json()) as Array<{ id: string; name: string }>;return new Map(json.map((o) => [o.id, o.name]));}diff --git a/console/apps/switch-console-desktop/src/main/core/workspaces/reconcile-workspaces.db.test.ts b/console/apps/switch-console-desktop/src/main/core/workspaces/reconcile-workspaces.db.test.tsindex db58fdc5d..1832f790d 100644--- a/console/apps/switch-console-desktop/src/main/core/workspaces/reconcile-workspaces.db.test.ts+++ b/console/apps/switch-console-desktop/src/main/core/workspaces/reconcile-workspaces.db.test.ts@@ -169,23 +169,60 @@ describe('reconcile-workspaces', () => {]);});- it('keeps the organization without a name, and says so, where the server cannot name it', async () => {+ it('records the workspace, and says so, where the server cannot name its organization', async () => {await ensureServerWorkspace({ id: 'srv-1', name: 'Local dev' });fetchTenants.mockResolvedValue([tenant('t-1', 'Default', 'owner', { id: 'o-1', role: 'org_admin' }),]);- fetchOrganizationNames.mockResolvedValue(null);+ fetchOrganizationNames.mockRejectedValue(new Error('Switch gateway returned 503'));await reconcileServerWorkspaces('srv-1');const [found] = await listWorkspacesForServer('srv-1');- expect([found!.organizationId, found!.organizationName]).toEqual(['o-1', null]);+ expect([found!.tenantId, found!.organizationId, found!.organizationName]).toEqual([+ 't-1',+ 'o-1',+ null,+ ]);expect(warn).toHaveBeenCalledWith('workspaces: the server reports organizations but could not name them',- { server: 'srv-1' }+ { server: 'srv-1', error: 'Error: Switch gateway returned 503' });});+ it('keeps the names it has when a later reconcile cannot read them', async () => {+ await ensureServerWorkspace({ id: 'srv-1', name: 'Local dev' });+ fetchTenants.mockResolvedValue([+ tenant('t-1', 'Default', 'owner', { id: 'o-1', role: 'org_admin' }),+ ]);+ fetchOrganizationNames.mockResolvedValue(new Map([['o-1', 'Acme']]));+ await reconcileServerWorkspaces('srv-1');++ fetchOrganizationNames.mockRejectedValue(new Error('Switch gateway returned 503'));+ await reconcileServerWorkspaces('srv-1');++ const [found] = await listWorkspacesForServer('srv-1');+ expect(found!.organizationName).toBe('Acme');+ });++ it('drops a kept name once the workspace has moved to another organization', async () => {+ await ensureServerWorkspace({ id: 'srv-1', name: 'Local dev' });+ fetchTenants.mockResolvedValue([+ tenant('t-1', 'Default', 'owner', { id: 'o-1', role: 'org_admin' }),+ ]);+ fetchOrganizationNames.mockResolvedValue(new Map([['o-1', 'Acme']]));+ await reconcileServerWorkspaces('srv-1');++ fetchTenants.mockResolvedValue([+ tenant('t-1', 'Default', 'owner', { id: 'o-2', role: 'member' }),+ ]);+ fetchOrganizationNames.mockRejectedValue(new Error('Switch gateway returned 503'));+ await reconcileServerWorkspaces('srv-1');++ const [found] = await listWorkspacesForServer('srv-1');+ expect([found!.organizationId, found!.organizationName]).toEqual(['o-2', null]);+ });+it('forgets the organization role along with the workspace role when a membership goes', async () => {await createTenantWorkspace('srv-1', {id: 't-1',diff --git a/console/apps/switch-console-desktop/src/main/core/workspaces/reconcile-workspaces.ts b/console/apps/switch-console-desktop/src/main/core/workspaces/reconcile-workspaces.tsindex dd90f3718..c4d262cfb 100644--- a/console/apps/switch-console-desktop/src/main/core/workspaces/reconcile-workspaces.ts+++ b/console/apps/switch-console-desktop/src/main/core/workspaces/reconcile-workspaces.ts@@ -27,21 +27,29 @@ import {* The account's memberships on `server`, each with its organization's name.** The names are asked for only where a membership names an organization, so a- * server from before organizations is not asked about a route it lacks. One- * that reports organization ids but cannot list them leaves the names null,- * with a warning: the switcher then lists those workspaces without grouping- * them, which is what it did before organizations.+ * server from before organizations is not asked about a route it lacks. They+ * only label the switcher, so failing to read them does not stop the+ * reconcile — which records a workspace just created or joined — but leaves+ * them null, with a warning, and the rows keep the names they already had.*/async function fetchTenantRecords(server: SwitchServer): Promise<TenantRecord[]> {const tenants = await fetchTenants(server);- const organized = tenants.some((tenant) => tenant.organizationId !== null);- const names = organized ? await fetchOrganizationNames(server) : null;- if (organized && names === null) {+ const names = tenants.some((tenant) => tenant.organizationId !== null)+ ? await organizationNames(server)+ : null;+ return tenants.map((tenant) => withOrganizationName(tenant, names));+}++async function organizationNames(server: SwitchServer): Promise<Map<string, string> | null> {+ try {+ return await fetchOrganizationNames(server);+ } catch (error) {log.warn('workspaces: the server reports organizations but could not name them', {server: server.id,+ error: String(error),});+ return null;}- return tenants.map((tenant) => withOrganizationName(tenant, names));}function withOrganizationName(diff --git a/console/apps/switch-console-desktop/src/main/core/workspaces/workspaces-store.ts b/console/apps/switch-console-desktop/src/main/core/workspaces/workspaces-store.tsindex f90ae9f8b..98fc6df27 100644--- a/console/apps/switch-console-desktop/src/main/core/workspaces/workspaces-store.ts+++ b/console/apps/switch-console-desktop/src/main/core/workspaces/workspaces-store.ts@@ -34,6 +34,20 @@ function tenantColumns(tenant: TenantRecord) {};}+/**+ * The organization name to store on an update. A reconcile that could not read+ * the names keeps the one the row already has for the same organization, so+ * one failed lookup does not strip every heading in the switcher.+ */+function keptOrganizationName(tenant: TenantRecord) {+ if (tenant.organizationName !== null || tenant.organizationId === null) {+ return tenant.organizationName;+ }+ return sql<+ string | null+ >`CASE WHEN ${workspaces.organizationId} = ${tenant.organizationId} THEN ${workspaces.organizationName} END`;+}+function mapRow(row: WorkspaceRow): Workspace {return {id: row.id,@@ -188,6 +202,7 @@ export async function setWorkspaceTenant(workspaceId: string, tenant: TenantReco.update(workspaces).set({...tenantColumns(tenant),+ organizationName: keptOrganizationName(tenant),updatedAt: sql`CURRENT_TIMESTAMP`,}).where(eq(workspaces.id, workspaceId));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 463b8ca0b..115fb5c2a 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@@ -7,7 +7,7 @@ import type { CreateTarget } from '@renderer/features/workspaces/create-workspacimport {addWorkspaceThrough,type CreationAnswer,- groupByOrganization,+ switcherSections,} from '@renderer/features/workspaces/organization-groups';import {InvitedBadge,@@ -21,7 +21,10 @@ import {usePendingInvitations,} from '@renderer/features/workspaces/pending-invitations';import { WorkspaceAvatar } from '@renderer/features/workspaces/workspace-avatar';-import { workspacesStore } from '@renderer/features/workspaces/workspaces-store';+import {+ workspaceCreationKey,+ workspacesStore,+} from '@renderer/features/workspaces/workspaces-store';import { failureText } from '@renderer/lib/errors/describe-failure';import { useToast } from '@renderer/lib/hooks/use-toast';import { rpc } from '@renderer/lib/ipc';@@ -530,8 +533,15 @@ function AvailableServerWorkspaceGroup({ server, query }: { server: SwitchServer// The server's own answer, so Create organization is not offered where// creating one is refused: a deployment that keeps to one workspace,// invite-only sign-up, or a spent allowance. Offered until it has said no.+ // Keyed by the workspace the answer is for as well, so switching workspace on+ // the server asks again rather than reusing one given for another.+ const onServer = workspacesStore.onServer(server.id);+ const scoped =+ onServer.length === 1+ ? onServer[0]!.id+ : (onServer.find((w) => w.id === workspacesStore.activeId)?.id ?? null);const answer = useQuery({- queryKey: ['workspace-creation', server.id],+ queryKey: workspaceCreationKey(server.id, scoped),queryFn: () => rpc.switchServers.workspaceCreation(server.id),staleTime: 60_000,});@@ -543,7 +553,7 @@ function AvailableServerWorkspaceGroup({ server, query }: { server: SwitchServer}: {canCreate: true,- organizations: workspacesStore.onServer(server.id).some((w) => w.organizationId !== null),+ organizations: onServer.some((w) => w.organizationId !== null),answer: null,};return (@@ -635,9 +645,7 @@ const ServerWorkspaceGroupBody = observer(function ServerWorkspaceGroupBody({target,onSuccess: (workspace) => navigate('server', { serverId: workspace.serverId }),});- const groups = groupByOrganization(workspaces);- // Headed only where there is more than one to tell apart.- const headed = groups.length > 1;+ const { sections, headed } = switcherSections(workspaces);return (<DropdownMenuGroup>@@ -690,7 +698,7 @@ const ServerWorkspaceGroupBody = observer(function ServerWorkspaceGroupBody({No workspace yet — this server has not finished being set up.</div>) : (- groups.map((group) => {+ sections.map((group) => {const through = whole ? addWorkspaceThrough(group, all, creation.answer) : null;return (<Fragment key={group.organizationId ?? 'none'}>diff --git a/console/apps/switch-console-desktop/src/renderer/features/workspaces/organization-groups.test.ts b/console/apps/switch-console-desktop/src/renderer/features/workspaces/organization-groups.test.tsindex 5ef29cbc9..a3de446b5 100644--- a/console/apps/switch-console-desktop/src/renderer/features/workspaces/organization-groups.test.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/workspaces/organization-groups.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from 'vitest';import type { OrganizationRole, Workspace } from '@shared/core/workspaces/workspaces';-import { addWorkspaceThrough, groupByOrganization } from './organization-groups';+import { addWorkspaceThrough, groupByOrganization, switcherSections } from './organization-groups';function workspace(id: string,@@ -49,6 +49,40 @@ describe('groupByOrganization', () => {});});+describe('switcherSections', () => {+ it('heads each organization where there are several, all named', () => {+ const { sections, headed } = switcherSections([+ workspace('a', ACME_ADMIN),+ workspace('b', GLOBEX_MEMBER),+ ]);++ expect(headed).toBe(true);+ expect(sections.map((s) => s.name)).toEqual(['Acme', 'Globex']);+ });++ it('heads nothing where there is one organization', () => {+ const { sections, headed } = switcherSections([workspace('a', ACME_ADMIN)]);++ expect(headed).toBe(false);+ expect(sections.map((s) => s.name)).toEqual(['Acme']);+ });++ it('lists everything in one run, in order, where an organization has no name', () => {+ const unnamed = { id: 'o-2', name: null, role: 'member' } as const;+ const { sections, headed } = switcherSections([+ workspace('a', ACME_ADMIN),+ workspace('b', unnamed),+ workspace('c', ACME_ADMIN),+ ]);++ expect(headed).toBe(false);+ expect(sections).toHaveLength(1);+ expect(sections[0]!.organizationId).toBeNull();+ expect(sections[0]!.workspaces.map((w) => w.id)).toEqual(['a', 'b', 'c']);+ expect(addWorkspaceThrough(sections[0]!, sections[0]!.workspaces, null)).toBeNull();+ });+});+describe('addWorkspaceThrough', () => {it('offers it to an org admin, through one of the organization’s workspaces', () => {const all = [workspace('a', ACME_ADMIN), workspace('b', GLOBEX_MEMBER)];diff --git a/console/apps/switch-console-desktop/src/renderer/features/workspaces/organization-groups.ts b/console/apps/switch-console-desktop/src/renderer/features/workspaces/organization-groups.tsindex 5a00ffcac..ae070821f 100644--- a/console/apps/switch-console-desktop/src/renderer/features/workspaces/organization-groups.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/workspaces/organization-groups.ts@@ -34,6 +34,27 @@ export function groupByOrganization(workspaces: Workspace[]): OrganizationGroup[return [...groups.values()];}+/**+ * How the switcher lists a server's workspaces: one section per organization,+ * each headed with its name, where there is more than one and every one of+ * them has a name to show.+ *+ * Otherwise one unheaded section in the order listed, as before organizations.+ * Headings without names would read as several identical ones, so a server+ * whose organizations could not be named is listed as if it had none, and its+ * section offers no Add workspace, having no organization to say it is for.+ */+export function switcherSections(workspaces: Workspace[]): {+ sections: OrganizationGroup[];+ headed: boolean;+} {+ const groups = groupByOrganization(workspaces);+ if (groups.length <= 1) return { sections: groups, headed: false };+ const named = groups.every((group) => group.organizationId === null || group.name !== null);+ if (named) return { sections: groups, headed: true };+ return { sections: [{ organizationId: null, name: null, workspaces }], headed: false };+}+/** What a server answered about creating, for the workspace it was asked about. */export type CreationAnswer = { canAddWorkspace: boolean; workspaceId: string };diff --git a/console/apps/switch-console-desktop/src/renderer/features/workspaces/workspaces-store.test.ts b/console/apps/switch-console-desktop/src/renderer/features/workspaces/workspaces-store.test.tsindex 1117e5526..3e1d50a4f 100644--- a/console/apps/switch-console-desktop/src/renderer/features/workspaces/workspaces-store.test.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/workspaces/workspaces-store.test.ts@@ -6,6 +6,11 @@ const getActiveId = vi.hoisted(() => vi.fn());const setActive = vi.hoisted(() => vi.fn());const serversWithoutMembership = vi.hoisted(() => vi.fn(async () => [] as string[]));const subscribers = vi.hoisted(() => new Map<string, (data: unknown) => void>());+const createWorkspace = vi.hoisted(() => vi.fn());+const addOrganizationWorkspace = vi.hoisted(() => vi.fn());+const invalidateQueries = vi.hoisted(() => vi.fn(async () => {}));++vi.mock('@renderer/lib/query-client', () => ({ queryClient: { invalidateQueries } }));vi.mock('@renderer/lib/ipc', () => ({events: {@@ -14,7 +19,10 @@ vi.mock('@renderer/lib/ipc', () => ({return () => subscribers.delete(event.name);},},- rpc: { workspaces: { list, getActiveId, setActive, serversWithoutMembership } },+ rpc: {+ workspaces: { list, getActiveId, setActive, serversWithoutMembership },+ switchServers: { createWorkspace, addOrganizationWorkspace },+ },}));const { WorkspacesStore } = await import('./workspaces-store');@@ -186,3 +194,30 @@ describe('the workspace a server-routed view acts in', () => {expect(store.idOnServerInScope(null)).toBeNull();});});++describe('creating', () => {+ // The server may have spent the account's allowance, and an answer cached+ // from before would go on offering Create until a refusal said otherwise.+ it('asks the server again what may be created once an organization is made', async () => {+ const store = await loaded([], null);+ createWorkspace.mockResolvedValue(workspace('ws-9', 'srv-1'));++ await store.create('srv-1', 'Acme');++ expect(invalidateQueries).toHaveBeenCalledWith({+ queryKey: ['workspace-creation', 'srv-1'],+ });+ });++ it('asks the server again once a workspace is added to an organization', async () => {+ const store = await loaded([workspace('ws-1', 'srv-1')], 'ws-1');+ addOrganizationWorkspace.mockResolvedValue(workspace('ws-9', 'srv-1'));++ await store.addToOrganization('ws-1', 'Labs');++ expect(addOrganizationWorkspace).toHaveBeenCalledWith({ workspaceId: 'ws-1', name: 'Labs' });+ expect(invalidateQueries).toHaveBeenCalledWith({+ queryKey: ['workspace-creation', 'srv-1'],+ });+ });+});diff --git a/console/apps/switch-console-desktop/src/renderer/features/workspaces/workspaces-store.ts b/console/apps/switch-console-desktop/src/renderer/features/workspaces/workspaces-store.tsindex d5cb47c19..6d1595b8b 100644--- a/console/apps/switch-console-desktop/src/renderer/features/workspaces/workspaces-store.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/workspaces/workspaces-store.ts@@ -1,9 +1,28 @@import { makeAutoObservable, runInAction } from 'mobx';import { events, rpc } from '@renderer/lib/ipc';+import { queryClient } from '@renderer/lib/query-client';import type { JoinableWorkspace, PendingInvitation } from '@shared/core/workspaces/invitations';import { workspacesChangedChannel } from '@shared/core/workspaces/workspaceEvents';import type { Workspace } from '@shared/core/workspaces/workspaces';+/**+ * The query key for what a server lets the account create, answered for+ * `workspaceId`, the workspace a call about the server is scoped to: adding a+ * workspace is a question about that workspace's organization.+ */+export function workspaceCreationKey(serverId: string, workspaceId: string | null) {+ return ['workspace-creation', serverId, workspaceId] as const;+}++/**+ * Ask the server again once something has been created there: it may have+ * spent the account's allowance, and offering Create for another minute would+ * end in a refusal after a name had been typed.+ */+function forgetWorkspaceCreation(serverId: string): Promise<void> {+ return queryClient.invalidateQueries({ queryKey: ['workspace-creation', serverId] });+}+/*** Renderer view of the workspaces this install knows about, and which one the* window is scoped to.@@ -90,7 +109,7 @@ export class WorkspacesStore {*/async create(serverId: string, name: string): Promise<Workspace> {const workspace = await rpc.switchServers.createWorkspace({ serverId, name });- await this.refresh();+ await Promise.all([this.refresh(), forgetWorkspaceCreation(serverId)]);return workspace;}@@ -100,7 +119,7 @@ export class WorkspacesStore {*/async addToOrganization(workspaceId: string, name: string): Promise<Workspace> {const workspace = await rpc.switchServers.addOrganizationWorkspace({ workspaceId, name });- await this.refresh();+ await Promise.all([this.refresh(), forgetWorkspaceCreation(workspace.serverId)]);return workspace;}diff --git a/console/apps/switch-console-desktop/src/renderer/tests/browser/workspace-switcher.test.tsx b/console/apps/switch-console-desktop/src/renderer/tests/browser/workspace-switcher.test.tsxindex 9ffec01fb..ff2eca324 100644--- a/console/apps/switch-console-desktop/src/renderer/tests/browser/workspace-switcher.test.tsx+++ b/console/apps/switch-console-desktop/src/renderer/tests/browser/workspace-switcher.test.tsx@@ -87,6 +87,11 @@ vi.mock('@renderer/features/switch-servers/switch-servers-store', () => ({}));vi.mock('@renderer/features/workspaces/workspaces-store', () => ({+ workspaceCreationKey: (serverId: string, workspaceId: string | null) => [+ 'workspace-creation',+ serverId,+ workspaceId,+ ],workspacesStore: {get activeId() {return state.activeId;@@ -182,7 +187,7 @@ function workspace(patch: {tenantId?: string | null;role?: WorkspaceRole | null;- organization?: { id: string; name: string; role: OrganizationRole };+ organization?: { id: string; name: string | null; role: OrganizationRole };} = {}): Workspace {const tenantId = patch.tenantId === undefined ? `tenant-${id}` : patch.tenantId;@@ -493,6 +498,22 @@ describe('organizations in the switcher', () => {expect(text.indexOf('Globex')).toBeLessThan(text.indexOf('ws-b'));});+ it('lists everything unheaded where an organization could not be named', async () => {+ state.organizations.add('srv-1');+ await openSwitcher(+ [server('srv-1', 'Cloud')],+ [+ workspace('ws-a', 'srv-1', { organization: ACME, role: 'owner' }),+ workspace('ws-b', 'srv-1', { organization: { id: 'o-9', name: null, role: 'member' } }),+ ],+ 'ws-a'+ );+ await settle();++ expect(document.querySelectorAll('[data-org-heading]')).toHaveLength(0);+ expect(menuRows().some((text) => text.startsWith('Add workspace'))).toBe(false);+ });+it('offers an org admin Add workspace in their organization only', async () => {state.organizations.add('srv-1');await openSwitcher(