Skip to content

feat(teams): add team access and management UI - #1404

Closed
vsrikar08 wants to merge 167 commits into
mainfrom
feat/1403-teams-ui-main
Closed

vsrikar08 wants to merge 167 commits into
mainfrom
feat/1403-teams-ui-main

Conversation

@vsrikar08

@vsrikar08 vsrikar08 commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

What changed

Team membership and access need one usable management flow. Adds team-scoped patch and connection access with the approved card directory, searchable roster and people picker, and clear lifecycle dialogs using the current Patchy UI system.

This is the independent main-based assembly of the team-access stack through #1379, including roles, runtime/shared-source enforcement, owner recovery, CLI/MCP contracts and migrations. The original recovery branch is unchanged.

Closes #1403. Related: #1192, #1285, #1291, #1379.

Look at

  • The selected 03: card grid → team page design: desktop cards with member previews; compact mobile destinations; focused membership and lifecycle flows. Independent GPT-6.1 Sol UI review: 9/10.
  • Protected membership changes, explicit recorded joins, metadata-only owner recovery, dependent-patch acknowledgement and stale-owner guards remain authoritative on the server.
Fresh desktop/mobile comparison against the original Teams stack

Before and after, as Allison Mahmood (super_admin)

Before is 0e01b1c (--base) and after is f0a8447 (feat/1403-teams-ui-main), both on the brightline scenario, from pnpm dev compare.

Every page answered 200 with no browser errors.

/settings/company/teams

1280px, after

After: /settings/company/teams at 1280px

1280px, before

Before: /settings/company/teams at 1280px

Width Before After
390px Before: /settings/company/teams at 390px After: /settings/company/teams at 390px
/settings/company/teams?team=team_env_brightline_design

1280px, after

After: /settings/company/teams?team=team_env_brightline_design at 1280px

1280px, before

Before: /settings/company/teams?team=team_env_brightline_design at 1280px

Width Before After
390px Before: /settings/company/teams?team=team_env_brightline_design at 390px After: /settings/company/teams?team=team_env_brightline_design at 390px

The comparison uses fresh Brightline scenario data, not the developer preview. The normal Teams directory and roster remain as shown. Follow-up fixes correct refusal focus, role-specific controls, guest rows on People, hidden team grant preservation during publication, and resumed query membership fences.

How it was verified

  • Latest main update 9b2d0a71 retains both the Teams people icon and main’s keyboard icon. GitHub reports the PR mergeable; full workspace typecheck passes (25/25), and 70 affected core/portal/serving/server tests pass.

  • Main through b9dc456b incorporated; branch is directly based on main with no missing commits. Resolved the migration collision by retaining main’s shortcut migration 38 and assigning the team stack 39–43.

  • Full workspace pnpm typecheck: 25/25 tasks passed after the 8079d218 main update; lint and formatting pass.

  • CI reproduction and regression suites: 221 tests passed across 16 files. After the final mobile guest-label fix, both affected suites passed again (44 tests). Publication and subscription regression tests failed before their fixes and passed afterward.

  • Main integration: 21 migration/session tests passed, including the new shortcut setting, role upgrade, team lifecycle, audience upgrade and session fixtures.

  • People browser workflows: 2 passed, including invitation, deactivation/reactivation, agent access and no-script confirmation history.

  • Independent GPT-6.1 Sol review of the CI fixes found one mobile Guest-label omission; fixed and covered. No correctness findings in shared audience preservation or query fencing.

  • Before/after screenshots at 1280px and 390px: both directory and roster returned 200 without browser errors. Earlier live checks covered 320–1440px, long names, keyboard focus/Enter, dialog Escape, search selection retention and native POST save.

  • Follow-up ab738cf1 fixes the remaining Home role fixture, sidebar/switcher expectations, and a cross-test membership assumption exposed by the preceding race test. 26 affected unit tests and 22 sidebar/switcher browser tests pass; the team suite also passes on Node 26 (3 tests). Test typecheck and lint pass.

  • Latest GitHub CI verdict is pending. The prior live Attio failure was a transport error before a response, in the informational probe check. Full pnpm verify and final independent acceptance are not claimed complete; this PR is not yet claimed ready to merge.

Release impact

  • Breaking — requires action from anyone already running this
  • Not breaking — no action required

Migrations 39–43 add super_admin, team membership/audience grants and lifecycle records. Existing admins and pending admin invites migrate to super admin. Upgrade the server and its bundled CLI together; role/audience consumers must understand the new values. Existing patches retain their current company/public audience; existing connections remain company-wide until explicitly restricted.

  • What does a revert leave behind? New role values, team/audience tables and grants, lifecycle/audit rows, and any patches/connections subsequently restricted to teams.
  • Does the release before it still work with that? No. Its role and sharing decoders do not understand super_admin or teams. This PR is one-way; fix forward or perform an explicit data conversion before rolling back the application. The included rehearsal runs upgrade-only for explicitly labelled one-way PRs.

Implementation: GPT-6 in Codex. Independent UI review: GPT-6.1 Sol.

# Conflicts:
#	packages/auth/src/CompanyPage.test.ts
#	packages/companies/src/migrations.ts
@vsrikar08 vsrikar08 added the one-way Rolling production back past this PR would break the release before it label Nov 11, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T21:17:45.387017Z dd74275 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added area:server Touches the server area area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:core Touches the core area area:docs Touches the docs area area:primitives Patch tables and files area:integrations Company connections and integration implementations area:ui Portal and first-party browser pages, shared rendering and styles size:xl Over 1,000 changed lines; review in multiple passes labels Nov 11, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4ba38b1cf0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

`ALTER TABLE users ADD CONSTRAINT users_role_check CHECK (role IN ('member', 'admin', 'super_admin'))`,
`ALTER TABLE invites DROP CONSTRAINT invites_role_check`,
`ALTER TABLE invites ADD CONSTRAINT invites_role_check CHECK (role IN ('member', 'admin', 'super_admin'))`,
`UPDATE users SET role = 'super_admin' WHERE role = 'admin'`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update the remaining admin predicates for the new role

After this migration upgrades existing administrators to super_admin, several unchanged reader-facing checks stop recognizing them: MachinesPage.ts:165–217 excludes them from the people who can enable agent access and hides their Turn it on/Change links, while HomePages.ts:174 suppresses all connection-attention alerts. Conversely, ordinary admins still receive those links and alerts even though connection administration and the agent-access switch now require a super admin. Update these consumers to check the role authorized for each operation so existing administrators retain their management and recovery flows.

Useful? React with 👍 / 👎.

Comment thread packages/companies/src/TeamsPage.ts Outdated
Comment on lines +75 to +76
const problem = (refused?: Refusal) =>
refused ? notice({ tone: "danger", title: refused.message }) : "";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Focus team-operation refusals with the shared refusal helper

When adding people without selecting anyone or deleting a team that is still referenced, the rejected submission is rendered as a bare notice rather than a focusable refusal. The add-person page consequently has no error focus target, while the delete dialog focuses Cancel instead of the explanation. Use refusalNotice or wrap the notice in refusal, ensuring the refusal receives focus rather than Cancel, to satisfy the served-page refusal-focus contract.

AGENTS.md reference: AGENTS.md:L79-L79

Useful? React with 👍 / 👎.

Comment thread packages/patches/src/Patches.ts Outdated
Comment on lines +2465 to +2466
const audience =
input.audience ??

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve hidden team grants when publishing an explicit audience

When an admin has added a team outside the member owner's memberships, republishing with an explicit team audience containing only the owner's visible teams silently removes that hidden grant. record uses input.audience directly, and Audiences.validate only checks newly added teams and owner inclusion, so nothing preserves the omitted team before saveAudience replaces the grants. This contradicts the member-edit preservation contract in docs/product.md and the behavior already implemented and tested for setSharing in Audiences.test.ts. Apply the same hidden-team preservation when normalizing a publication's audience so an ordinary update cannot unexpectedly revoke another team's access.

Useful? React with 👍 / 👎.

if (declaration?.kind === "sharedTable") {
capability.onDependency(`table:${declaration.patchId}:${declaration.table}`);
capability.onDependency(`patch:${declaration.patchId}`);
capability.onDependency(`members:${binding.companyId}`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Admit membership dependencies for shared-source queries

For a live query that reads a shared table or store without declaring the member directory, the new callback tracing records members:<companyId> in its snapshot vector, but QuerySubscriptions.admit only allows that key when a members declaration exists (lines 80–87). Subsequent reconciliation therefore drops the membership key from the fence; Subscriptions.equalVector requires identical key counts, so an unchanged query can never take the revision-only fast path and executes its handler again every 30-second periodic reconciliation, including its database reads. Allow the membership dependency for shared-table/shared-store declarations as well, keeping the admitted fence consistent with the dependencies now traced.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8079d21804

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1937 to 1938
if (patch.disabledAt === null && admitted(patch.audience) && options.canOpen(patch))
openable.set(patch.id, { row, patch });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Carry hidden dependant counts into lifecycle confirmations

When a live source patch's dependants are all outside the viewer's team access, this filtering removes every dependant from Patches.read and consequently from its portal card. In packages/portal/src/render.ts, the Retire and Delete confirmations emit ack=1 only when dependantGroups is nonempty, while the service still refuses these operations because visibleDependants counts hidden readers. Every submission therefore returns HasDependants, and submitting the rendered confirmation again cannot succeed. Metadata-only recovery cards likewise carry hiddenDependants, but the confirmation ignores it. Preserve the visibility filtering, but pass an anonymous hidden count into lifecycle confirmations and allow it to trigger the acknowledgement.

Useful? React with 👍 / 👎.

mark: patchMark(card.patch.name, card.tier),
meta: [escapeHtml(card.owner.name), escapeHtml(card.patch.state)],
actions: controls,
main: `<div class="stack">${notice({ tone: "warning", title: management.canManage ? "You can manage this patch, but can’t open its content" : "You own this patch, but can’t open it", body: management.canManage ? undefined : "<p>Ask an admin to restore your team access or reassign it.</p>", action: viewer.role !== "member" ? linkButton("Manage teams", "/settings/company/teams") : undefined })}${options.notice ? notice({ tone: "danger", title: options.notice }) : ""}${card.versions.length ? section({ title: "Versions", body: renderVersions({ card, viewer, now }) }) : ""}${yield* ownershipHistory(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Focus refusals on the metadata-only recovery page

When an owner loses team access while a patch-management form is open, the POST handler catches OwnerAccessLost and renders this recovery page with options.notice. Rendering that refusal with bare notice provides neither the focusable wrapper nor autofocus, so keyboard and screen-reader users do not land on the explanation of why their submission failed. Use refusalNotice, as the normal patch-card renderer already does, to preserve the served-page refusal-focus contract required by AGENTS.md.

AGENTS.md reference: AGENTS.md:L79-L79

Useful? React with 👍 / 👎.

Comment on lines +389 to +392
name:
patch.title === null
? "Restricted patch"
: patchTitle({ ...patch, title: patch.title }, viewer.company.name),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Scope guest-removal lookups to the current viewer

When an administrator opens a guest's removal confirmation, the action handler still calls guests.list(viewer.company.id) without the viewer argument, then passes that unfiltered guest directly to this renderer. GuestGrants.companyGuests deliberately returns original patch titles when the viewer is omitted, so this null check never hides restricted titles in the confirmation—even for a super admin who has only metadata oversight. The normal Guests directory correctly passes the viewer and redacts those titles, but opening Remove reveals them again. Pass the current actor to the confirmation's guest lookup as well so the dialog observes the same patch-visibility boundary.

Useful? React with 👍 / 👎.


/** Who may open a patch: signed-in company members, or anyone with the link. */
export const SharingScope = Schema.Literals(["company", "public"]);
export const SharingScope = Schema.Literals(["company", "public", "teams"]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle the new team scope in displayed access descriptions

For a live team-restricted patch, the unchanged audience helper in packages/portal/src/render.ts:211–216 treats every scope other than company as public. Both Overview's Access fact and Settings' Who can open it therefore say “Anyone on the internet. No sign-in.” for a patch that actually requires team membership, including tier 2 tools that cannot be public. Home and All patches make the opposite mistake, labeling these patches Company-wide. Add an explicit teams case to these access descriptions so users can accurately verify the audience they committed.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ab738cf13c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

name: "audience",
value: "company",
label: "Company",
checked: selected.kind === "company"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the submitted connection audience after a refusal

When a connection currently allows Company access, selecting Selected teams without checking a team correctly returns a validation refusal, but this renderer resets the radio selection to the persisted Company audience. If the user then checks a team to correct the error and saves again, the POST still submits audience=company, so the intended restriction is not applied. act already passes submitted into confirmationPage; use those submitted values for the radios and checkboxes on refused submissions, falling back to the saved audience only on the initial GET.

Useful? React with 👍 / 👎.

(yield* (yield* Teams.Teams)
.list({ companyId, actorId })
.pipe(
Effect.catchTags({ RoleForbidden: () => Effect.fail(new AudienceExcludesOwner()) })

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve the cause when translating audience authorization errors

If Teams.list returns RoleForbidden, this translation discards the original failure, including its actor/company context and stack, and replaces it with an indistinguishable owner-exclusion validation error. The same translation appears in preserveHiddenTeams. Add an optional cause to AudienceExcludesOwner and retain the caught error at both boundaries; this preserves the diagnostic chain required by the repository's Effect failure convention without changing the public refusal message.

AGENTS.md reference: AGENTS.md:L101-L101

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9b2d0a7158

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (
!(yield* connections.canUse(companyId, declaration.id, ownerUserId).pipe(
Effect.catchTags({
ConnectionNotFound: () => Effect.fail(new ConnectionStore.ConnectionNotConnected())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve the cause when translating missing-connection errors

When publication references a connection that no longer exists, this new translation discards ConnectionNotFound, including its company/lookup context and diagnostic chain, and replaces it with an empty ConnectionNotConnected. Add an optional cause to ConnectionNotConnected and retain the caught error here so the public refusal can remain unchanged without losing the underlying failure. This follows the repository’s explicit failure-preservation convention.

AGENTS.md reference: AGENTS.md:L101-L101

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dd74275452

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

status,
...indexPage({
title,
content: notice({ tone: "danger", title: message, action: linkButton("Back to Teams", path) })

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Focus terminal team-operation refusals

When an administrator loses permission while a team form is open, the POST's RoleForbidden handler renders this failure page. Unlike the corrected add-person and delete-dialog refusals, this path still renders a bare notice with no focus target or autofocus, so keyboard and screen-reader users do not land on the explanation of why their submission failed. Wrap the notice in refusal or use refusalNotice to satisfy the served-page refusal-focus contract.

AGENTS.md reference: AGENTS.md:L79-L79

Useful? React with 👍 / 👎.

Comment on lines +1702 to +1703
RoleForbidden: () =>
Effect.fail(new ConnectionStore.ConnectionAdministrationDenied())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve authorization failures when changing connection audiences

When Users.lockAdministrator rejects an audience change, this translation discards the original RoleForbidden, including its actor/company context and diagnostic chain. The translation following Teams.list does the same. Add an optional cause to ConnectionAdministrationDenied and retain the caught error at both boundaries; the direct validation failure for a non-super-admin can remain cause-free. This preserves the underlying failure as required by the repository's Effect convention without changing the public refusal.

AGENTS.md reference: AGENTS.md:L101-L101

Useful? React with 👍 / 👎.

const owner = people.find((p) => p.id === ownerId);
if (!actor?.active || !owner) return yield* new AudienceExcludesOwner();
if (audience.members.kind !== "teams") return;
if (!audience.members.teamIds.length) return yield* new InvalidAudienceTeams();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Enforce the audience size limit before persisting team grants

In a company with more than 100 teams, an administrator can select 101 distinct teams in the Share dialog, including one the owner belongs to. SharePages decodes only the scope fields and passes all submitted team IDs to setSharing; this validation accepts them, and saveAudience commits them. However, PatchAudience in packages/api/src/schemas.ts limits teamIds to 100, so subsequent patch-row decoding fails with a schema defect. Because company listings decode these rows before visibility filtering, the invalid audience can also break Home and All patches for the company. Validate the normalized audience against the same size constraint before saving, returning a refusal instead of persisting an unreadable patch.

Useful? React with 👍 / 👎.

@allisonmahmood

Copy link
Copy Markdown
Owner

Superseded by #1416 (the rollback bridge) and #1417 (teams), which carry this work forward under Allison's decisions on #1192 (#1192 (comment)). Closing without merging; Srikar is co-author there. Posted by Fermy (Allison's agent).

allisonmahmood added a commit that referenced this pull request Nov 12, 2026
…1416)

## What changed

Teams will let a patch be opened only by chosen teams, and a connection
be built with only by chosen teams. That data can't be read by today's
release. If the feature shipped on its own, rolling back would 500 every
page listing a team patch, and team-only connections would quietly
become company-wide.

This PR ships first, on its own. It adds the teams tables and makes
every reader **fail closed** on team data:
- A patch open to teams is opened by nobody and listed nowhere. Every
attempt to change it answers 404.
- A connection restricted to teams can't be built or called with. Admins
see it tagged "Restricted to teams".
- A publish or share that names an audience, which only the coming CLI
sends, is refused with `upgrade_required` and never ignored.

It writes no team data, so nothing changes for anyone until the feature
lands on top of it.

Part of #1192. The feature is the next PR in the stack.

## Look at

- **The migrations** (`0039_company_teams`, `0040_patch_audiences`,
`0041_connection_audiences`) are byte-identical to the feature's, so the
feature PR adds none.
- **Rollback onto this release, run by hand.** On a throwaway instance,
the feature created a Finance team, made a patch Finance-only with two
outside guests, and restricted a Postgres connection to Finance. This
release was then served on the same data, then the feature again:

  | | Feature | This release | Feature again |
  | --- | --- | --- | --- |
  | Team patch, Finance members | 200 | 404 | 200 |
  | Team patch, member not on Finance | 404 | 404 | 404 |
  | Team patch, outside guests | 200 | 404 | 200 |
| Restricted connection in discovery / detail | listed / 200 | absent /
404 | listed / 200 |
  | Team data in the database | stored | unchanged | unchanged |
  | Server 500s | 0 | 0 | 0 |

## How it was verified

- **Tests.** Each seeds team data directly and fails without its fix:
- lists, cards, addresses, guest grants, shared sources, Home and the
Calls tab hide team patches;
  - every writer refuses to change one;
  - connection publish and calls refuse a team-only connection;
  - audience-bearing requests are refused.
- **`pnpm verify`** passed.
- **The four-step rollback rehearsal** passed against production's live
commit (live → this → live → this). The feature's rehearsal passed with
this release as live.

## Release impact

- [ ] **Breaking** — requires action from anyone already running this
- [x] **Not breaking** — no action required

Additive tables and a widened scope check. Installed CLIs never send an
audience, and no team data can exist yet.

- **What does a revert leave behind?** Empty teams and audience tables,
and the widened check.
- **Does the release before it still work with that?** Yes. The release
before it ignores the new tables, and no team rows exist until the
feature ships. If this release misbehaves, roll back to the live release
it was rehearsed against.

Taken over from Srikar's teams work (#1404, co-authored). Built by
Claude Opus 5.5 in Claude Code, reviewed by GPT 6.1 Sol.

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
allisonmahmood added a commit that referenced this pull request Nov 12, 2026
…ctions (#1417)

## What changed

A company can now make teams, open a patch to chosen teams instead of
the whole company, and limit who builds with a connection. Roles stay
member and admin.

- **Teams.**
- Admins create, rename and delete teams and manage anyone's
memberships.
  - Members see every team and roster.
- A team can be deleted only when nothing uses it, and the refusal says
what does.
- The Teams page is a roster editor: tick people in or out, then review
who gains, loses or keeps what before saving.
- **Patch audiences.**
- Company (the default), one or more teams, or Public, plus named guests
as today. The owner must stay inside the audience.
- A team patch's first version and its audience commit together, so it
is never briefly company-wide.
- Removal takes effect on the next request and on open live queries, on
every surface: portal, serving URLs, API, CLI, MCP, tier 2 handlers and
shared tables.
- **Admins.**
- Admins manage every patch's owner, audience and sharing, but open its
content only through its audience.
- The owner sees every audience change someone else made, and every
admin added to one of the patch's teams.
  - Needs attention shows patches whose owner lost access.
- **Connections.**
- A connection's teams decide who builds with it: the patch's owner must
be on one, and a deactivated owner's patches keep working as before.
  - Anyone the patch is shared with can use it through the patch's code.
- Shared tables keep the per-viewer check, and publish warns when a
patch reaches people its sources don't.
- **CLI.**
- `--share company|public|teams --team <name>` on `publish` and `share`,
plus `patchy audiences`.
  - Installed CLIs keep working.
- A scope-only request on a team patch is refused with an upgrade
message instead of being ignored.

Closes #1285, #1286, #1287, #1288, #1289, #1290, #1291, #1365, #1367,
#1368, #1403, #1408, #1410. Supersedes #1284 and #1361: there is no
super admin, and team rules follow #1192's decisions. #1416, the
rollback bridge, shipped first, in release 42.

## Look at

**The Teams page.** Mock B was picked from three directions. The team
list sits beside the open team. Its access card shows what the team can
open and build with. The roster is the editor, and a sticky bar counts
the changes.

![Roster mid-edit: two people being added, one
removed](https://github.com/user-attachments/assets/af45cf29-2349-4e46-8fdb-1c2e4f50914e)

**Review before saving.** It says what added people will reach and what
removed people lose or keep, and warns about live patches that will stop
working.

![Review: Kudos will stop working, because its owner builds with
attio/crm through
Design](https://github.com/user-attachments/assets/b0faf7be-9e0a-4abf-a77d-cf07123102ef)

<details><summary>Delete refused while in use, the member view, the
phone screens, and the old page</summary>

![Delete refused, naming the patch and connection with links to change
their
audiences](https://github.com/user-attachments/assets/b2a846f7-a642-409a-8e11-e5b6f2e4d418)

![A member's read-only view, naming the
admins](https://github.com/user-attachments/assets/411bfbe9-35d3-450e-927f-aaad3edfb1c5)

| Phone, list | Phone, team (admin) | Phone, team (member) |
| --- | --- | --- |
| ![Phone: the list of
teams](https://github.com/user-attachments/assets/576d4ba3-eb12-4aae-9b56-3218b356984e)
| ![Phone: a
team](https://github.com/user-attachments/assets/c2ad758e-1a0a-4650-9484-686386ce2b6c)
| ![Phone: a member's team
view](https://github.com/user-attachments/assets/0081fb28-a07f-4e57-bf88-1ee08b9fb590)
|

Before (the previous Teams page):

![The previous Teams
page](https://github.com/user-attachments/assets/8c2877de-3120-4efc-ae06-33fc3d95e284)

</details>

**Also worth a look:**
- **One audience value in code.** The wire keeps the released two-valued
`scope` and adds `audience`. A test decodes the list, publish,
publish-replay and share responses with the released CLI's schema.
- **Concurrency in forced interleavings:**
  - a team deleted while a share adds it;
  - a connection narrowed while a publish uses it;
  - an admin added to a team while a guest is removed;
  - a stale roster review;
  - the last-admin guard.

## How it was verified

- **Tests.** Every behaviour fix has a focused test that fails without
it. In an earlier end-to-end run, 21 of 22 deliberate breaks of the
access checks were caught; the 22nd now has a test.
- **`pnpm verify`** passed on the final code. The new audience check
made two serving cache tests racy in the Bun lane; they now wait past
it, and a forced slow check fails the old tests and passes the new ones.
- **Rollback.** The full four-step rollback rehearsal, with release 42
(the bridge) as the live release, passed on this head: bridge, then
this, then the bridge, then this. CI's own rehearsal job passes at once
here, because the migrations live in the bridge (#1416), where CI
rehearsed all four steps. In a hand-run rollback onto the bridge with
real team data, team patches went hidden and team-only connections
unusable, with no 500s, and rolling forward restored both.
- **Acceptance (GPT 6.1 Sol, on throwaway instances): PASS with notes**
on this head. The first run failed on three Teams page defects, all
since fixed and re-checked with its own reproductions:
  - admin names were rendered as HTML;
  - an outdated roster review could still save;
  - a roster save could deadlock against a profile refresh.

It also checked every role, every surface an outsider must be refused
on, live revocation, admin oversight, stuck owners, connections, shared
tables, and the released CLI against this server.
- **Reviews.** Four GPT 6.1 Sol review passes; all findings are fixed.

## Release impact

- [ ] **Breaking** — requires action from anyone already running this
- [x] **Not breaking** — no action required

Roles, `/api/me`, and existing patches and connections are unchanged:
patches stay Company, connections stay company-wide. Installed CLIs see
`company` or `public` for every patch, and get an upgrade message only
when changing a team patch's sharing with a scope alone.

- **What does a revert leave behind?** Teams, memberships, team
audiences, connection audiences and history rows.
- **Does the release before it still work with that?** Yes, if it is the
bridge (#1416). Team patches go hidden and team-only connections
unusable, nothing widens or 500s, and rolling forward restores both.
Deploy this only after the bridge is live, and never roll back past the
bridge once team data exists.

Taken over from Srikar's teams work (#1404, co-authored). Built by
Claude Opus 5.5 in Claude Code, reviewed by GPT 6.1 Sol.

---------

Co-authored-by: Srikar Voleti <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:core Touches the core area area:docs Touches the docs area area:integrations Company connections and integration implementations area:primitives Patch tables and files area:server Touches the server area area:ui Portal and first-party browser pages, shared rendering and styles one-way Rolling production back past this PR would break the release before it size:xl Over 1,000 changed lines; review in multiple passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(ui): redesign team management

2 participants