Skip to content

Apps work in one organization at a time: delete an organization, keys and events by organization, the phone's switcher, the Recorder's organization - #1900

Open
davidmckayv wants to merge 4 commits into
mainfrom
feat/one-org-apps
Open

davidmckayv wants to merge 4 commits into
mainfrom
feat/one-org-apps

Conversation

@davidmckayv

Copy link
Copy Markdown
Contributor

The apps' part of working in one organization at a time. Built on the API additions in #1897; its three commits show here until it merges, after which this branch is rebased onto main.

Web

  • Delete organization. On Settings → Organization, an owner gets a Delete section (the same pattern as deleting a team). The dialog asks for the organization's name before the button works, then calls deleteOrganization. The server's refusals show in the dialog in its own words: a person's own organization, default, and a delete it couldn't finish. After a delete the person moves to another of their organizations and goes home, the same way leaving one works (the shared path is now moveOffGone). Admins and members aren't offered it.
  • API keys. Each key's row shows the organization it acts in beside its name. A key with organizationId: null was made before keys were bound to an organization, so it acts in default and is shown under that organization's name. Create says "It works in only." The request sends only the name, because the address already names the organization.
  • Conversation events. An event whose organizationId names another organization is dropped before it reaches the sidebar. It changes nothing and triggers no refetch. An event that names no organization is applied as before.

Phone

  • On Home, a person in more than one organization gets a switcher. The pick is saved on the phone (secure store, one entry per OpenBot) and used while it's still in their list. If it isn't (they left, it was deleted, or someone else signed in), the server's active organization is used. Picking an organization re-reads the list first, so you can't pick one you aren't in.
  • Once someone is signed in, every request sends OpenBot-Organization. It names the organization the address points to, or the current one for addresses that name none. The list of their organizations doesn't send it, because that list is how the current one is found.
  • Before sign-in, the deployment read still goes to default. After sign-in it goes to the person's organization, because default may not be one of theirs.
  • Signing out removes the phone's push registration from each of the person's organizations.

Recorder

  • The stored connection keeps the organizationId from its grant. The keep-alive, identity, Learning, activity, live recording and Disconnect requests all go to that organization. A grant without one falls back to default. Codes are still exchanged at default, because the code names the organization it was made for.
  • The OpenBot browser's launcher connection may carry organizationId too (optional).

Tests

  • app/tests/organization-delete.test.tsx: deleting with the name typed; the personal and default refusals; an unfinished delete followed by a retry; not offered to admins or members. The fake server's answers are checked against the generated zod schemas.
  • app/tests/api-keys-screen.test.tsx: the organization on each row, including a key from before binding; Create says where the key works and sends { name } only.
  • app/tests/conversation-events-organization.test.tsx: uses the real hook and list query. Another organization's event does nothing; this organization's event, or one that names no organization, is applied.
  • mobile/tests/generated-client.test.ts: the header on every signed-in request; the deployment read in the person's organization; a switch sends later requests to the picked organization and keeps the pick for the next sign-in; an organization the person isn't in is refused. tests/mobile-organization.test.ts: a kept pick is set aside once it's no longer one of theirs.
  • extension/tests/recorder-organization.test.ts: a connection made in another organization keeps it, and the keep-alive and Disconnect go there; a grant with no organization stays in default.

Each new test failed against the base branch's source and passes with this change.

Screens were checked in headless Chromium and WebKit, light and dark, at 1280 and 390 wide, before and after. Before and after differ only where this change adds something.

…an be held to one organization

Adds deleteOrganization (DELETE .../profile), refusing a person's own organization and default; organizationOnly on a new API key and organizationId on a key; organizationId on conversation events and on a Recorder connection; the realtime socket relayed at /api/v2/organizations/{organizationId}/realtime/websocket; and says a push device is registered per organization. Deprecates the role property of updatePerson in favour of updateOrganizationMember, sunset 2028-05-19, and reserves Intelligence's /api/v2/platform root.
Drops organizationOnly from a new key: every key is bound to the organization it was made in, and a key with no binding acts in default. ApiKey.organizationId says which, and createApiKey, the apiKey scheme and the changelog say so.
…ng the network in tests

The support-window tests assumed the spec deprecates nothing, and their run of the check looked every release's spec up by tag, fetching each from GitHub once the spec marks something deprecated: it timed out in CI. SUPPORT_WINDOW_RELEASE_SPECS reads release specs from a directory instead, which the test points at its fixtures, and the tests now find the real deprecation of updatePerson's role.
… and events by organization, the phone's switcher, the Recorder's organization

Web: an owner deletes an organization from its settings after typing its name; the server's refusal (a person's own organization, default, an unfinished delete) is shown in its own words, and the person moves to another of their organizations. Each API key's row names the organization it acts in (a key from before binding acts in default), and Create says where the key will work. Conversation events about another organization are ignored; events that name none are taken as before.

Phone: a switcher on Home for a person in several organizations. The pick is kept on the phone and used while it is still one of theirs. Every signed-in request names its organization in OpenBot-Organization, the deployment is read in the person's organization once signed in rather than default, and signing out removes the device from each organization.

Recorder: the connection keeps the organization its grant names and every request after the connect goes there, falling back to default when the grant names none.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant