feat(enclave): remove default enclave, prompt to create when none (LC-516) #499

Merged
nrupard merged 2 commits from feat/LC-516-remove-default-enclave into main 2026-07-01 19:22:36 +02:00
Owner

What

Removes the auto-default "General" enclave and replaces it with an inline create-enclave prompt on Home, per LC-516.

  • Drop the two production callers of backfill_general_membership (server startup + bot creation) so users are no longer force-joined to a shared default enclave. The helper (and get_general_id) stay as pub test fixtures used across the suite; the immutable 0009 General seed row is left in place (deleting it would cascade-delete its rooms and messages on existing installs).
  • Add an inline "create your first enclave" prompt on Home, shown only when the user belongs to no enclave (WelcomePage.has_enclaves), posting to the existing POST /enclaves handler. The no-enclave state already degraded gracefully to a DM-only Home, so no other flow changed.
  • Add POST /enclave/{id}/members/add-bot (manage-gated) plus a bot picker on the enclave settings members panel, so managers can add a bot directly. This closes a gap the removal exposed: bots cannot accept invitations, and General membership was previously the only way a bot entered an enclave. Reuses db::enclave::add_member and the existing EnclaveMemberAdded live event; rejects non-bots and skips banned or already-member bots.
  • New Fluent keys (en + es) for the prompt and the add-bot control.

Testing

  • New server/tests/routes_enclave_prompt.rs: a no-enclave user sees the prompt, an enclave member does not, an owner can add a bot, a non-manager is rejected (403), a non-bot is rejected (400).
  • just check (fmt + clippy -D warnings on default + saas + desktop) and just test (full workspace, 164 test binaries, 0 failures) pass.

Notes

  • Retiring the seeded General row at the DB level (reassigning its rooms and members) is deliberately out of scope; it is inert after this change (invisible on fresh installs, an ordinary enclave on existing ones). Worth a separate issue if wanted.

🤖 Generated with Claude Code

## What Removes the auto-default "General" enclave and replaces it with an inline create-enclave prompt on Home, per LC-516. - Drop the two production callers of `backfill_general_membership` (server startup + bot creation) so users are no longer force-joined to a shared default enclave. The helper (and `get_general_id`) stay as `pub` test fixtures used across the suite; the immutable `0009` `General` seed row is left in place (deleting it would cascade-delete its rooms and messages on existing installs). - Add an inline "create your first enclave" prompt on Home, shown only when the user belongs to no enclave (`WelcomePage.has_enclaves`), posting to the existing `POST /enclaves` handler. The no-enclave state already degraded gracefully to a DM-only Home, so no other flow changed. - Add `POST /enclave/{id}/members/add-bot` (manage-gated) plus a bot picker on the enclave settings members panel, so managers can add a bot directly. This closes a gap the removal exposed: bots cannot accept invitations, and General membership was previously the only way a bot entered an enclave. Reuses `db::enclave::add_member` and the existing `EnclaveMemberAdded` live event; rejects non-bots and skips banned or already-member bots. - New Fluent keys (en + es) for the prompt and the add-bot control. ## Testing - New `server/tests/routes_enclave_prompt.rs`: a no-enclave user sees the prompt, an enclave member does not, an owner can add a bot, a non-manager is rejected (403), a non-bot is rejected (400). - `just check` (fmt + clippy `-D warnings` on default + saas + desktop) and `just test` (full workspace, 164 test binaries, 0 failures) pass. ## Notes - Retiring the seeded `General` row at the DB level (reassigning its rooms and members) is deliberately out of scope; it is inert after this change (invisible on fresh installs, an ordinary enclave on existing ones). Worth a separate issue if wanted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(enclave): remove default enclave, prompt to create when none
All checks were successful
check-secrets / Kingfisher (push) Successful in 4s
check-secrets / Nosey parker (push) Successful in 4s
check-secrets / TruffleHog (push) Successful in 5s
check-secrets / Nosey parker (pull_request) Successful in 11s
check-secrets / Kingfisher (pull_request) Successful in 13s
check-secrets / TruffleHog (pull_request) Successful in 13s
Check / clippy + fmt + tests (pull_request) Successful in 6m58s
630f411254
lets-chat auto-joined every user to a seeded "General" enclave via backfill_general_membership, run at each server startup and after bot creation. This made "no enclave" an unreachable state and forced a shared default on everyone. Remove the two production callers so users are no longer auto-joined to anything; the backfill/get_general_id helpers stay as pub test fixtures (used across the suite), and the immutable 0009 General seed row is left untouched (deleting it would cascade-delete its rooms and messages on existing installs).

The no-enclave state already degrades to a DM-only Home, so replace the removed default with an inline "create your first enclave" prompt shown on Home only when the user belongs to no enclave (WelcomePage.has_enclaves), posting straight to the existing POST /enclaves handler.

Removing the General auto-add left enclave managers no way to bring in a bot (bots cannot accept invitations, and General membership was the only path a bot entered an enclave). Add POST /enclave/{id}/members/add-bot: a manage-gated route that adds a site bot directly as a member, with a bot picker in the enclave settings members panel. It reuses db::enclave::add_member and the existing EnclaveMemberAdded live event, rejects non-bot users, and skips banned or already-member bots.

New i18n keys (en+es) for the Home prompt and the add-bot control. Tests cover the prompt visibility toggle and the add-bot route (owner adds, non-manager rejected, non-bot rejected).

#LC-516

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
fix(enclave): guard disabled bots, cap name, drop redundant home query
All checks were successful
check-secrets / TruffleHog (push) Successful in 4s
check-secrets / Kingfisher (push) Successful in 5s
check-secrets / TruffleHog (pull_request) Successful in 5s
check-secrets / Nosey parker (push) Successful in 6s
check-secrets / Nosey parker (pull_request) Successful in 5s
check-secrets / Kingfisher (pull_request) Successful in 6s
Check / clippy + fmt + tests (pull_request) Successful in 6m1s
Create release / Create release from merged PR (pull_request) Has been skipped
7031e2eeb9
Address code-review findings on the LC-516 change:

- get_home derived has_enclaves from a second list_enclaves_for_user query, but load_chrome/load_switcher already fetched the user's enclaves to build the switcher; derive the flag from the switcher (Home tile has id None, enclave tiles Some(_)) instead of querying the DB again.
- The add-bot picker (list_bots) and post_add_bot did not exclude site-disabled bots (is_banned=1, tokens revoked): filter them out of the picker and reject them in the handler.
- post_create enforced no server-side name-length cap (the Home form's maxlength is a client-side hint only and the discover form has none); cap at 80 chars server-side.

Add tests for the disabled-bot rejection and the overlong-name rejection.

#LC-516

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
nrupard scheduled this pull request to auto merge when all checks succeed 2026-07-01 19:18:15 +02:00
nrupard deleted branch feat/LC-516-remove-default-enclave 2026-07-01 19:22:36 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/lets-chat!499
No description provided.