Skip to content

Delete account: a Windows computer's row opens Computers for an admin there - #2951

Open
mxmzb wants to merge 2 commits into
mainfrom
delete-account-open-computers
Open

mxmzb wants to merge 2 commits into
mainfrom
delete-account-open-computers

Conversation

@mxmzb

@mxmzb mxmzb commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

A follow-up to #2840, from Dave's review: the windows_computer row in Delete account says an admin removes or forgets the computer under Computers, and now takes an admin there.

App

  • Open Computers on the windows_computer row, for someone who is an admin or the owner of that organization, read from their list of organizations (or from their own role where OpenBot keeps one organization and lists none). Like Open its settings, it switches to that organization first, then opens /admin/computers.
  • No button for anybody else. /admin sends a non-admin home, so the row keeps its words and no empty actions area, as today.
  • OpenOrganizationSettings becomes OpenInOrganization, which takes the page and the label, and serves both rows.

No API change, so the server needs nothing.

Tests

  • app/tests/delete-account.test.tsx: an admin's Open Computers switches to the organization and opens Computers. A member there gets no button and no actions area. That test fails when the role check is dropped.
  • bun run format:check, bun run lint, app typecheck, delete-account*.test.tsx: pass.

Changelog

Windows computers.

  • Changed: Delete account's Windows computer row has Open Computers for an admin of that organization.

🤖 Generated with Claude Code

… there

- The windows_computer blocker offers Open Computers to someone who is an admin or the owner of that organization, as their list of organizations says. It switches to the organization first, as Open its settings does.
- Someone who isn't an admin there gets no button, since Computers would send them home, and the row keeps no empty actions area.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@davidmckayv davidmckayv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Visibility is right: only an admin or owner of the machine's organization sees the button, and the guards are unchanged. One real bug, though.

The button sends the admins who need it home. Take someone who is a member of the organization they're working in and an admin of the one holding the machine:

  • OpenInOrganization hands the navigation to the switch as leave (delete-account.tsx:263);
  • the switch runs leave() before setCurrentOrganization (lib/organizations/mutations.ts:58-61);
  • so /admin's guard (routes/_authed/admin/route.tsx:21-30) reads the cached current user under the old organization, gets role "member", and redirects to /.

The test misses it because its mocked people/me always answers role: "owner" (app/tests/delete-account.test.tsx:340).

Fix: switch first, then navigate once the switch has finished, so the guard reads the person under the new organization. Add a test where people/me answers per organization: a member where she works, an admin of Acme. The button must land on /admin/computers; today it lands on /.

…s, so Admin's gate reads the person in that organization

Computers was opened as the switch's `leave`, which runs before the app changes over, so Admin's
gate read the person as they are where they were working and sent somebody who is only a member
there home. The page now opens once the switch has finished. Admin's gate moves to
lib/auth/admin-gate.ts, and the test's router uses it, with `people/me` answering per organization.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mxmzb

mxmzb commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator Author

Fixed in dfdd304. Open Computers now switches first and opens Computers once the switch has finished, so Admin's gate reads the person in the computer's organization. Admin's gate moved to lib/auth/admin-gate.ts, and the test's router uses it, with people/me answering per organization. The new test (a member where she works, an admin of Acme) lands on /admin/computers, and it fails on the old code by landing on /.

@mxmzb
mxmzb requested a review from davidmckayv December 4, 2026 19:43

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.

2 participants