Server admin 12: fluxer-core roles: list, create, edit, permissions, reorder, duplicate, delete (#679) #737

Closed
charles wants to merge 0 commits from serveradmin-12-core-roles into serveradmin
Owner

Stacked on: origin/serveradmin-10-core-permission-lists, origin/serveradmin-11-core-forms-community (both already contained in origin/serveradmin at 05e6c55e, so the merges were no-ops).

What this builds

fluxer-core admin::roles (plan Task 12, spec §3.4, §6.2 "Roles"):

  • roles::model(app) -> Option<RolesModel { list: Vec<RoleRow>, can_create, editor: Option<RoleEditorModel> }>: roles by position (lower id first at equal positions, sorted only through perms::is_role_higher), @everyone forced last, unsaved edits shown in the rows and the editor; with nothing selected the first role is shown (the original's desktop useLayoutEffect). The editor carries the permission groups of perm_spec::guild, filtered by perm_spec::search, each switch with perm_spec::role_switch's state and disabled reason.
  • RoleAction::Create sends {name: "New role"}, toast "Role created successfully", selects the next GUILD_ROLE_CREATE (pendingRoleCreationRef); MAX_GUILD_ROLES shows "You've reached the maximum of 250 community roles.", any other refusal "Couldn't create role".
  • Edit / TogglePermission / ClearPermissions fill edits with only the fields that differ from the server's (a locked role or a disabled switch changes nothing; names cut to 100).
  • Move is createRoleMovePreview plus RoleReorderStateMachine.getResultBlockedReason (locked roles do not move and are not crossed, nothing lands right above a locked role unless owner, nothing goes below @everyone). The pending order stays valid through role create / delete / bulk events (each role once, @everyone last) and goes when it equals the server's.
  • Bar save: blank name refused ("Give the role a name before saving."); one UpdateRole per changed role with only its changed fields and mask_for_saved permissions; when all are answered, one UpdateRolePositions built as createSubmittableRoleOrderIds + createRoleOrderPayload (no @everyone, no locked roles, positions n..1). A refusal keeps the unsaved rest and shows "Couldn't update roles" on the bar; RESOURCE_LOCKED on the order is retried once after 1 s; success toasts "Roles updated successfully".
  • Duplicate (handleDuplicateRole): create "{name} copy" (cut to 100) with the source's colour, permissions & mine and icon_source_role_id when the source has an icon, then PATCH hoist + mentionable, then the order placing it below its source; shown at once through optimistic (not an unsaved change).
  • Delete: Confirm::DeleteRole from the editor, immediate with confirmed: true (the context menu); not for @everyone or locked roles; the next role is selected; a failure shows We couldn't delete "{name}". Try again.
  • roles::context_menu(app, role_id): "Copy role ID" (UserAction::CopyId(IdKind::Role, id)), "Duplicate role" (MANAGE_ROLES), then "Delete role" (danger; not @everyone, not locked).

Strings recorded (from GT/GuildRolesTab.tsx, RoleItem.tsx, RoleSidebar.tsx, RoleEditor.tsx, AM/RoleContextMenu.tsx, CopyMenuItems.tsx, CommonMessageDescriptors.ts, server ErrorI18nMessages.ts): New role; Role created successfully; Roles updated successfully; Role deleted successfully; Couldn't create role; Couldn't update roles; Couldn't delete role; Try again in a moment.; Role name is required; Give the role a name before saving.; Delete role; Duplicate role; Copy role ID; Create role; Clear permissions; You cannot edit this role because it is at or above your highest role; Are you sure you want to delete the {name} role? Any members with this role will no longer have it.; We couldn't delete "{name}". Try again.; You've reached the maximum of {count} community roles.

Outside roles.rs (minimal)

  • event.rs: IdKind::Role (no exhaustive match on IdKind exists; the copy reducer handles every kind).
  • admin/mod.rs: Admin::role_writes (in-flight role requests, like guild_writes) and re-exports.
  • admin/guild.rs: the bar's saving / error read the Roles editor; Unsaved uses RolesEditor::dirty.
  • admin/perms.rs, admin/perm_spec.rs: is_role_locked_with, highest_role_in, role_switch_with, mask_for_save_with -- the same rules over &Guilds / the thread-guild set, because reducers get AdminCtx, not &App. The &App functions now delegate to them; behaviour unchanged (their tests pass).

Deviations from the plan / spec

  • @everyone: the spec says "only the permission list". The original's RoleEditor.tsx also shows the colour for @everyone and the server applies color to it (GuildRoleService.ts:807), so the colour stays editable; name, hoist, mentionable and delete are not. The test keeps the plan's name everyone_shows_permissions_only and documents this.
  • Save order: roles first, then the order (plan and spec). The original sends the order first, then the role PATCHes.
  • RoleAction::Search is the editor's permission search (the original's role list has no search); its doc comment is corrected.
  • RolesEditor gains optimistic, saving, error, creating; RoleRow gains is_everyone; RoleEditorModel gains role_id, can_edit, can_delete; PermissionGroupModel { title, rows: Vec<PermissionSwitchRow { permission, title, description, on, disabled }> } is defined here.
  • context_menu(app, role_id) uses the guild of the open community settings (the menu only exists in the Roles tab).

Tests

  • crates/fluxer-core/tests/admin_roles.rs: the 16 tests of the plan (list_order_and_everyone_last, create_selects_on_event, max_roles_error_text, edits_accumulate_per_role, blocked_switch_changes_nothing, clear_permissions, move_within_manageable_roles, locked_role_cannot_move_or_be_crossed, save_sends_changed_roles_then_order_without_everyone_and_locked, partial_failure_keeps_remaining_edits, resource_locked_retries_once, duplicate_three_requests_in_order, delete_confirms_in_editor_not_in_menu, everyone_shows_permissions_only, role_deleted_elsewhere_drops_its_edits_and_selection, bulk_event_while_dragging_keeps_pending_order_valid), written first and seen failing.
  • FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci green locally. No new fixtures (no new event or endpoint); no UI, so no screenshots and no display tests.

Closes #679

🤖 Generated with Claude Code

https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K

Stacked on: origin/serveradmin-10-core-permission-lists, origin/serveradmin-11-core-forms-community (both already contained in origin/serveradmin at 05e6c55e, so the merges were no-ops). ## What this builds `fluxer-core` `admin::roles` (plan Task 12, spec §3.4, §6.2 "Roles"): - `roles::model(app) -> Option<RolesModel { list: Vec<RoleRow>, can_create, editor: Option<RoleEditorModel> }>`: roles by position (lower id first at equal positions, sorted only through `perms::is_role_higher`), @everyone forced last, unsaved edits shown in the rows and the editor; with nothing selected the first role is shown (the original's desktop `useLayoutEffect`). The editor carries the permission groups of `perm_spec::guild`, filtered by `perm_spec::search`, each switch with `perm_spec::role_switch`'s state and disabled reason. - `RoleAction::Create` sends `{name: "New role"}`, toast "Role created successfully", selects the next `GUILD_ROLE_CREATE` (`pendingRoleCreationRef`); `MAX_GUILD_ROLES` shows "You've reached the maximum of 250 community roles.", any other refusal "Couldn't create role". - `Edit` / `TogglePermission` / `ClearPermissions` fill `edits` with only the fields that differ from the server's (a locked role or a disabled switch changes nothing; names cut to 100). - `Move` is `createRoleMovePreview` plus `RoleReorderStateMachine.getResultBlockedReason` (locked roles do not move and are not crossed, nothing lands right above a locked role unless owner, nothing goes below @everyone). The pending order stays valid through role create / delete / bulk events (each role once, @everyone last) and goes when it equals the server's. - Bar save: blank name refused ("Give the role a name before saving."); one `UpdateRole` per changed role with only its changed fields and `mask_for_save`d permissions; when all are answered, one `UpdateRolePositions` built as `createSubmittableRoleOrderIds` + `createRoleOrderPayload` (no @everyone, no locked roles, positions n..1). A refusal keeps the unsaved rest and shows "Couldn't update roles" on the bar; `RESOURCE_LOCKED` on the order is retried once after 1 s; success toasts "Roles updated successfully". - `Duplicate` (`handleDuplicateRole`): create "{name} copy" (cut to 100) with the source's colour, `permissions & mine` and `icon_source_role_id` when the source has an icon, then PATCH hoist + mentionable, then the order placing it below its source; shown at once through `optimistic` (not an unsaved change). - `Delete`: `Confirm::DeleteRole` from the editor, immediate with `confirmed: true` (the context menu); not for @everyone or locked roles; the next role is selected; a failure shows `We couldn't delete "{name}". Try again.` - `roles::context_menu(app, role_id)`: "Copy role ID" (`UserAction::CopyId(IdKind::Role, id)`), "Duplicate role" (MANAGE_ROLES), then "Delete role" (danger; not @everyone, not locked). Strings recorded (from `GT/GuildRolesTab.tsx`, `RoleItem.tsx`, `RoleSidebar.tsx`, `RoleEditor.tsx`, `AM/RoleContextMenu.tsx`, `CopyMenuItems.tsx`, `CommonMessageDescriptors.ts`, server `ErrorI18nMessages.ts`): New role; Role created successfully; Roles updated successfully; Role deleted successfully; Couldn't create role; Couldn't update roles; Couldn't delete role; Try again in a moment.; Role name is required; Give the role a name before saving.; Delete role; Duplicate role; Copy role ID; Create role; Clear permissions; You cannot edit this role because it is at or above your highest role; Are you sure you want to delete the {name} role? Any members with this role will no longer have it.; We couldn't delete "{name}". Try again.; You've reached the maximum of {count} community roles. ## Outside roles.rs (minimal) - `event.rs`: `IdKind::Role` (no exhaustive match on `IdKind` exists; the copy reducer handles every kind). - `admin/mod.rs`: `Admin::role_writes` (in-flight role requests, like `guild_writes`) and re-exports. - `admin/guild.rs`: the bar's `saving` / `error` read the Roles editor; `Unsaved` uses `RolesEditor::dirty`. - `admin/perms.rs`, `admin/perm_spec.rs`: `is_role_locked_with`, `highest_role_in`, `role_switch_with`, `mask_for_save_with` -- the same rules over `&Guilds` / the thread-guild set, because reducers get `AdminCtx`, not `&App`. The `&App` functions now delegate to them; behaviour unchanged (their tests pass). ## Deviations from the plan / spec - @everyone: the spec says "only the permission list". The original's `RoleEditor.tsx` also shows the colour for @everyone and the server applies `color` to it (`GuildRoleService.ts:807`), so the colour stays editable; name, hoist, mentionable and delete are not. The test keeps the plan's name `everyone_shows_permissions_only` and documents this. - Save order: roles first, then the order (plan and spec). The original sends the order first, then the role PATCHes. - `RoleAction::Search` is the editor's permission search (the original's role list has no search); its doc comment is corrected. - `RolesEditor` gains `optimistic`, `saving`, `error`, `creating`; `RoleRow` gains `is_everyone`; `RoleEditorModel` gains `role_id`, `can_edit`, `can_delete`; `PermissionGroupModel { title, rows: Vec<PermissionSwitchRow { permission, title, description, on, disabled }> }` is defined here. - `context_menu(app, role_id)` uses the guild of the open community settings (the menu only exists in the Roles tab). ## Tests - `crates/fluxer-core/tests/admin_roles.rs`: the 16 tests of the plan (list_order_and_everyone_last, create_selects_on_event, max_roles_error_text, edits_accumulate_per_role, blocked_switch_changes_nothing, clear_permissions, move_within_manageable_roles, locked_role_cannot_move_or_be_crossed, save_sends_changed_roles_then_order_without_everyone_and_locked, partial_failure_keeps_remaining_edits, resource_locked_retries_once, duplicate_three_requests_in_order, delete_confirms_in_editor_not_in_menu, everyone_shows_permissions_only, role_deleted_elsewhere_drops_its_edits_and_selection, bulk_event_while_dragging_keeps_pending_order_valid), written first and seen failing. - `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` green locally. No new fixtures (no new event or endpoint); no UI, so no screenshots and no display tests. Closes #679 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K
The Roles tab of community settings (spec §3.4, §6.2): the list by
position with @everyone last, create (selected on GUILD_ROLE_CREATE),
edits per role, permission switches through perm_spec::role_switch,
clear permissions, drag reorder with the original's move preview and
state machine checks, the bar's save (one PATCH per changed role, then
the order without @everyone and locked roles, RESOURCE_LOCKED retried
once after 1 s), duplicate (create, PATCH hoist/mentionable, order),
delete (confirm from the editor, immediate from the context menu) and
the role context menu. Adds IdKind::Role for "Copy role ID" and
reducer-side variants of is_role_locked, role_switch and mask_for_save.

Refs #679

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K
Author
Owner

Review: Server admin 12 (core roles), commit 847cd2fd

I reviewed only the diff 05e6c55e..847cd2fd, with no prior context.

Findings

[blocking] The plan's test locked_reorder_is_not_sent_again is missing. In its place, the branch adds a resend the spec rules out.
crates/fluxer-core/src/admin/roles.rs (on_failure, on_timer, RESOURCE_LOCKED_RETRY) sends a role order again after 1 s when it is refused with RESOURCE_LOCKED. tests/admin_roles.rs::resource_locked_retries_once tests that resend.

  • Plan Task 12 says: "a locked reorder (423 GENERAL_ERROR, Retry-After: 2, spec §3.4; not RESOURCE_LOCKED) is not sent again: it fails like any other refusal, as in the original".
  • I checked the fork. GuildRoleService.ts:450-453 throws ResourceLockedError, and packages/errors/src/domains/core/ResourceLockedError.ts gives that error code GENERAL_ERROR with Retry-After: 2.
  • RESOURCE_LOCKED comes only from RetryingLock.ts, which this endpoint does not use. It is a 429, and the 429 path in RestTransport.reactToOutcome is a transport concern, not a reducer one.
  • The resend therefore never fires for the real lock, and adds a second retry layer for a code this endpoint never returns. No test checks the real case.

Fix:

  • Drop the retry path (RoleWrites::retry, on_timer, retried, RESOURCE_LOCKED_RETRY) and its README sentence.
  • Add locked_reorder_is_not_sent_again: refuse the order with 423 and GENERAL_ERROR. Assert that nothing is sent again and no timer is set, that the bar shows "Couldn't update roles", and that the pending order is kept.

[minor] @everyone's colour stays editable, but spec §3.4 says "only the permission list". The code is right and the spec is wrong.

  • In the fork's RoleEditor.tsx:162, the ColorPickerField sits outside the !isEveryone guards (lines 130, 149, 178, 187).
  • In GuildRoleService.ts:807, the server applies color to @everyone and ignores only name, hoist, hoist_position and mentionable.
  • The core matches the original, so I accept it. Note for Task 25: it should draw the colour field for @everyone too, despite its "no display fields" line. Worth a follow-up issue to correct the spec and plan text.

[minor] The save sends the role PATCHes first and the order second, as the plan says.
The original's handleSave sends the order first (GuildRolesTab.tsx:284-297). The difference is recorded in the module doc. No action needed.

[minor] A blank name is refused on the bar ("Give the role a name before saving.").
The original shows a modal titled "Role name is required". NAME_REQUIRED is defined but unused. Task 25 or 27 can use it if the modal is drawn.

Checks

  1. Tests: 15 of the 16 tests the plan names exist and assert the plan's values: "New role", MAX_GUILD_ROLES (250), "{name} copy" cut to 100, permissions & mine, the three duplicate requests in order, the order without @everyone and locked roles numbered from the top down to 1, confirm in the editor and none in the menu, and the bulk event keeping the pending order valid. locked_reorder_is_not_sent_again is the missing one (see above).
  2. Interfaces: match the plan and the 9a stub.
    • roles::model(&App) -> Option<RolesModel> (already Option in the 9a stub).
    • RolesModel, RoleRow and RoleEditorModel have every field the plan names, plus the extra fields listed in the PR.
    • RoleAction and RoleMove are unchanged.
    • context_menu(app, role) -> MenuModel has the rows "Copy role ID", "Duplicate role", "Delete role".
    • The new IdKind::Role is additive.
    • The *_with helpers in perms and perm_spec keep the &App functions' behaviour; their existing tests are green.
  3. Invariants:
    • No iced, reqwest or I/O in fluxer-core.
    • No new fixtures.
    • No secrets.
    • Server data cannot panic: slice bounds come from position() and positions use try_from.
    • No role-position comparison outside perms (sorting goes through perms::is_role_higher).
  4. Parity spot-checks against the fork, all matching:
    • handleDuplicateRole: colour, permissions & currentUserPermissions, iconSourceRoleId only with an icon or emoji, the position after the source, and the order-failure toast.
    • handleContextMenuDeleteRole: no confirm, next role roles[i+1] ?? roles[0], the failure text We couldn't delete "{name}". Try again.
    • createRoleMovePreview and RoleReorderStateMachine: no move for a locked or @everyone role, nothing after @everyone, no crossing a locked role when moving up, and the target-before-locked-role rule for non-owners.
    • handleSave: the blank-name check and thread bits masked when threads are inactive.
  5. Review Focus 2: a role reorder leaves out @everyone and locked roles, and each PATCH carries only its changed fields. Tested in save_sends_changed_roles_then_order_without_everyone_and_locked and bulk_event_while_dragging_keeps_pending_order_valid.
  6. Local gate: FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci on 847cd2fd: green ("xtask ci: all steps passed").

Verdict: changes requested. One blocking finding: the missing locked_reorder_is_not_sent_again test and the RESOURCE_LOCKED resend the spec rules out.

## Review: Server admin 12 (core roles), commit 847cd2fd I reviewed only the diff `05e6c55e..847cd2fd`, with no prior context. ### Findings **[blocking] The plan's test `locked_reorder_is_not_sent_again` is missing. In its place, the branch adds a resend the spec rules out.** `crates/fluxer-core/src/admin/roles.rs` (`on_failure`, `on_timer`, `RESOURCE_LOCKED_RETRY`) sends a role order again after 1 s when it is refused with `RESOURCE_LOCKED`. `tests/admin_roles.rs::resource_locked_retries_once` tests that resend. - Plan Task 12 says: "a locked reorder (423 `GENERAL_ERROR`, `Retry-After: 2`, spec §3.4; not `RESOURCE_LOCKED`) is not sent again: it fails like any other refusal, as in the original". - I checked the fork. `GuildRoleService.ts:450-453` throws `ResourceLockedError`, and `packages/errors/src/domains/core/ResourceLockedError.ts` gives that error code `GENERAL_ERROR` with `Retry-After: 2`. - `RESOURCE_LOCKED` comes only from `RetryingLock.ts`, which this endpoint does not use. It is a 429, and the 429 path in `RestTransport.reactToOutcome` is a transport concern, not a reducer one. - The resend therefore never fires for the real lock, and adds a second retry layer for a code this endpoint never returns. No test checks the real case. Fix: - Drop the retry path (`RoleWrites::retry`, `on_timer`, `retried`, `RESOURCE_LOCKED_RETRY`) and its README sentence. - Add `locked_reorder_is_not_sent_again`: refuse the order with 423 and `GENERAL_ERROR`. Assert that nothing is sent again and no timer is set, that the bar shows "Couldn't update roles", and that the pending order is kept. **[minor] @everyone's colour stays editable, but spec §3.4 says "only the permission list". The code is right and the spec is wrong.** - In the fork's `RoleEditor.tsx:162`, the `ColorPickerField` sits outside the `!isEveryone` guards (lines 130, 149, 178, 187). - In `GuildRoleService.ts:807`, the server applies `color` to @everyone and ignores only name, hoist, hoist_position and mentionable. - The core matches the original, so I accept it. Note for Task 25: it should draw the colour field for @everyone too, despite its "no display fields" line. Worth a follow-up issue to correct the spec and plan text. **[minor] The save sends the role PATCHes first and the order second, as the plan says.** The original's `handleSave` sends the order first (`GuildRolesTab.tsx:284-297`). The difference is recorded in the module doc. No action needed. **[minor] A blank name is refused on the bar ("Give the role a name before saving.").** The original shows a modal titled "Role name is required". `NAME_REQUIRED` is defined but unused. Task 25 or 27 can use it if the modal is drawn. ### Checks 1. **Tests:** 15 of the 16 tests the plan names exist and assert the plan's values: "New role", `MAX_GUILD_ROLES` (250), "{name} copy" cut to 100, `permissions & mine`, the three duplicate requests in order, the order without @everyone and locked roles numbered from the top down to 1, confirm in the editor and none in the menu, and the bulk event keeping the pending order valid. `locked_reorder_is_not_sent_again` is the missing one (see above). 2. **Interfaces:** match the plan and the 9a stub. - `roles::model(&App) -> Option<RolesModel>` (already `Option` in the 9a stub). - `RolesModel`, `RoleRow` and `RoleEditorModel` have every field the plan names, plus the extra fields listed in the PR. - `RoleAction` and `RoleMove` are unchanged. - `context_menu(app, role) -> MenuModel` has the rows "Copy role ID", "Duplicate role", "Delete role". - The new `IdKind::Role` is additive. - The `*_with` helpers in perms and perm_spec keep the `&App` functions' behaviour; their existing tests are green. 3. **Invariants:** - No iced, reqwest or I/O in fluxer-core. - No new fixtures. - No secrets. - Server data cannot panic: slice bounds come from `position()` and positions use `try_from`. - No role-position comparison outside `perms` (sorting goes through `perms::is_role_higher`). 4. **Parity spot-checks against the fork, all matching:** - `handleDuplicateRole`: colour, `permissions & currentUserPermissions`, `iconSourceRoleId` only with an icon or emoji, the position after the source, and the order-failure toast. - `handleContextMenuDeleteRole`: no confirm, next role `roles[i+1] ?? roles[0]`, the failure text `We couldn't delete "{name}". Try again.` - `createRoleMovePreview` and `RoleReorderStateMachine`: no move for a locked or @everyone role, nothing after @everyone, no crossing a locked role when moving up, and the target-before-locked-role rule for non-owners. - `handleSave`: the blank-name check and thread bits masked when threads are inactive. 5. **Review Focus 2:** a role reorder leaves out @everyone and locked roles, and each PATCH carries only its changed fields. Tested in `save_sends_changed_roles_then_order_without_everyone_and_locked` and `bulk_event_while_dragging_keeps_pending_order_valid`. 6. **Local gate:** `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` on 847cd2fd: green ("xtask ci: all steps passed"). **Verdict: changes requested.** One blocking finding: the missing `locked_reorder_is_not_sent_again` test and the `RESOURCE_LOCKED` resend the spec rules out.
Drop the RESOURCE_LOCKED resend (RoleWrites::retry, on_timer, retried,
RESOURCE_LOCKED_RETRY): the fork's role-order lock answers 423
GENERAL_ERROR with Retry-After: 2 and the original does not resend it.
Add the plan's locked_reorder_is_not_sent_again in place of
resource_locked_retries_once. Document the two remaining differences
(order sent after the PATCHes; blank name refused on the bar).

Refs #679

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K
Author
Owner

Review round 1, fixed in e67995ad (local FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci green):

  • Blocking: locked reorder resend. Removed the RESOURCE_LOCKED retry path (RoleWrites::retry, on_timer, retried, RESOURCE_LOCKED_RETRY, and the now-unused positions copy kept for resending) and its README line. Replaced resource_locked_retries_once with the plan's locked_reorder_is_not_sent_again: a 423 GENERAL_ERROR refusal (and a RESOURCE_LOCKED one) sends nothing again, schedules no timer, shows "Couldn't update roles" and keeps the pending order. The test failed on the old code before the fix.
  • Minor: @everyone colour editable. Accepted as the fork behaves; no code change. Opened follow-up #746 to correct spec §3.4 and Task 25's "no display fields".
  • Minor: PATCHes before the order; blank name on the bar. No code change. Both are documented in the module doc of admin/roles.rs (which now names NAME_REQUIRED as the original's modal title) and in the crate README.
Review round 1, fixed in e67995ad (local `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` green): - **Blocking: locked reorder resend.** Removed the `RESOURCE_LOCKED` retry path (`RoleWrites::retry`, `on_timer`, `retried`, `RESOURCE_LOCKED_RETRY`, and the now-unused `positions` copy kept for resending) and its README line. Replaced `resource_locked_retries_once` with the plan's `locked_reorder_is_not_sent_again`: a 423 `GENERAL_ERROR` refusal (and a `RESOURCE_LOCKED` one) sends nothing again, schedules no timer, shows "Couldn't update roles" and keeps the pending order. The test failed on the old code before the fix. - **Minor: @everyone colour editable.** Accepted as the fork behaves; no code change. Opened follow-up #746 to correct spec §3.4 and Task 25's "no display fields". - **Minor: PATCHes before the order; blank name on the bar.** No code change. Both are documented in the module doc of `admin/roles.rs` (which now names `NAME_REQUIRED` as the original's modal title) and in the crate README.
Author
Owner

Review round 2: Server admin 12 (core roles), commit e67995ad

I reviewed the whole diff 05e6c55e..e67995ad from scratch. I did not rely on the earlier round or on the implementer's notes.

Checks

  1. Plan tests. All 16 tests that Step 1 names exist, and each asserts what the plan says. locked_reorder_is_not_sent_again covers both 423 GENERAL_ERROR and RESOURCE_LOCKED. In both cases there is no timer, no second order request, the bar shows "Couldn't update roles" and the pending order is kept. save_sends_changed_roles_then_order_without_everyone_and_locked checks the order body [LOW2, BELOW, ZERO] numbered 3..1, with @everyone and the locked roles ABOVE and ACTOR left out. It also checks that @everyone's PATCH carries permissions only and that the thread bit is masked out.
  2. Interfaces. model, RolesModel, RoleRow, RoleEditorModel, PermissionGroupModel, RoleAction::{Create, Select, Edit, TogglePermission, ClearPermissions, Move(RoleMove), Duplicate, Delete, Search}, RoleMoveTarget, RolesEditor and context_menu(app, role) -> MenuModel are present and re-exported from admin. model returns Option<RolesModel>, which is 9a's existing stub signature, so the existing code wins over the plan text. The extra fields (is_everyone, can_edit, can_delete, role_id) only add to the interface.
  3. Invariants. fluxer-core does no I/O and adds no dependencies. No fixtures are added; the test roles have the GuildRoleResponse shape. Every lookup is guarded, and the only unwrap_or is a position conversion that saturates. No secrets appear. No role positions are compared outside admin::perms: sorted_ids goes through perms::is_role_higher, and the _with variants of is_role_locked, role_switch and mask_for_save are pure refactors of the old functions.
  4. Parity spot-checks against the fork.
    • Duplicate matches GuildRolesTab.tsx:402-454: "{name} copy" .slice(0,100), colour, permissions & mine, iconSourceRoleId, then the hoist/mentionable PATCH, then the order with the copy counted as not locked. A failed order still shows the "Role created successfully" toast.
    • createSubmittableRoleOrderIds / createRoleOrderPayload match: positions are len - index, and @everyone and duplicates are dropped.
    • MAX_GUILD_ROLES = 250 (LimitConstants.ts:42). The text matches messages.json "You've reached the maximum of # community roles."
    • The strings "Couldn't update roles", "Give the role a name before saving." and "You cannot edit this role because it is at or above your highest role" (RoleItem.tsx:36) are exact.
    • GuildRoleService.ts:450-453 throws ResourceLockedError, and this branch does not send that order again.
  5. Review Focus 2 and 4. The reorder leaves out @everyone and the locked roles. A GUILD_ROLE_UPDATE_BULK while a drag is pending keeps the pending order valid: every role appears once, @everyone is last, and the user's move is kept. A role that becomes locked is left out of what is sent. The round-1 retry path is gone from roles.rs and the README.
  6. Local CI. FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci exited 0 with the screenshot suite included.

Findings

  • [minor] on_created matches an ApiResult::RoleCreated to the oldest pending Create/DuplicateCreate of the guild, not to its effect. If someone clicks "Create role" and "Duplicate role" quickly and the answers come back in the other order, the plain new role would get the copy's hoist/mentionable PATCH and order. This is unlikely, and the original has the same per-click race through pendingRoleCreationRef. It does not block.
  • [minor] The save sends all role PATCHes at once and keeps the edits that fail. The original sends them one at a time and stops at the first failure. The plan asks for this ("a failure keeps the remaining edits"), so this is a note only.

Verdict: approve. No blocking findings, and local CI is green.

## Review round 2: Server admin 12 (core roles), commit e67995ad I reviewed the whole diff `05e6c55e..e67995ad` from scratch. I did not rely on the earlier round or on the implementer's notes. ### Checks 1. **Plan tests.** All 16 tests that Step 1 names exist, and each asserts what the plan says. `locked_reorder_is_not_sent_again` covers both 423 `GENERAL_ERROR` and `RESOURCE_LOCKED`. In both cases there is no timer, no second order request, the bar shows "Couldn't update roles" and the pending order is kept. `save_sends_changed_roles_then_order_without_everyone_and_locked` checks the order body `[LOW2, BELOW, ZERO]` numbered 3..1, with @everyone and the locked roles ABOVE and ACTOR left out. It also checks that @everyone's PATCH carries permissions only and that the thread bit is masked out. 2. **Interfaces.** `model`, `RolesModel`, `RoleRow`, `RoleEditorModel`, `PermissionGroupModel`, `RoleAction::{Create, Select, Edit, TogglePermission, ClearPermissions, Move(RoleMove), Duplicate, Delete, Search}`, `RoleMoveTarget`, `RolesEditor` and `context_menu(app, role) -> MenuModel` are present and re-exported from `admin`. `model` returns `Option<RolesModel>`, which is 9a's existing stub signature, so the existing code wins over the plan text. The extra fields (`is_everyone`, `can_edit`, `can_delete`, `role_id`) only add to the interface. 3. **Invariants.** fluxer-core does no I/O and adds no dependencies. No fixtures are added; the test roles have the `GuildRoleResponse` shape. Every lookup is guarded, and the only `unwrap_or` is a position conversion that saturates. No secrets appear. No role positions are compared outside `admin::perms`: `sorted_ids` goes through `perms::is_role_higher`, and the `_with` variants of `is_role_locked`, `role_switch` and `mask_for_save` are pure refactors of the old functions. 4. **Parity spot-checks against the fork.** - Duplicate matches `GuildRolesTab.tsx:402-454`: "{name} copy" `.slice(0,100)`, colour, `permissions & mine`, `iconSourceRoleId`, then the hoist/mentionable PATCH, then the order with the copy counted as not locked. A failed order still shows the "Role created successfully" toast. - `createSubmittableRoleOrderIds` / `createRoleOrderPayload` match: positions are `len - index`, and @everyone and duplicates are dropped. - `MAX_GUILD_ROLES` = 250 (`LimitConstants.ts:42`). The text matches `messages.json` "You've reached the maximum of # community roles." - The strings "Couldn't update roles", "Give the role a name before saving." and "You cannot edit this role because it is at or above your highest role" (`RoleItem.tsx:36`) are exact. - `GuildRoleService.ts:450-453` throws `ResourceLockedError`, and this branch does not send that order again. 5. **Review Focus 2 and 4.** The reorder leaves out @everyone and the locked roles. A `GUILD_ROLE_UPDATE_BULK` while a drag is pending keeps the pending order valid: every role appears once, @everyone is last, and the user's move is kept. A role that becomes locked is left out of what is sent. The round-1 retry path is gone from `roles.rs` and the README. 6. **Local CI.** `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` exited 0 with the screenshot suite included. ### Findings - **[minor]** `on_created` matches an `ApiResult::RoleCreated` to the oldest pending `Create`/`DuplicateCreate` of the guild, not to its effect. If someone clicks "Create role" and "Duplicate role" quickly and the answers come back in the other order, the plain new role would get the copy's hoist/mentionable PATCH and order. This is unlikely, and the original has the same per-click race through `pendingRoleCreationRef`. It does not block. - **[minor]** The save sends all role PATCHes at once and keeps the edits that fail. The original sends them one at a time and stops at the first failure. The plan asks for this ("a failure keeps the remaining edits"), so this is a note only. **Verdict: approve.** No blocking findings, and local CI is green.
Author
Owner

Merged into serveradmin by hand (the merge API returns 405); the commits are in the branch.

Merged into `serveradmin` by hand (the merge API returns 405); the commits are in the branch.
charles closed this pull request 2026-11-16 06:08:07 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.