Server admin 16: fluxer-core channel and category settings; delete and duplicate #683

Closed
opened 2026-11-15 19:01:16 +00:00 by charles · 1 comment
Owner

Task 16 of the Server administration plan (docs/superpowers/plans/2026-11-15-serveradmin.md, section "### Task 16:"). The plan on the serveradmin branch is the source of truth; this copy is for reading.

Closes: —
Depends on: 11

Files:

  • Modify: crates/fluxer-core/src/admin/channel.rs
  • Test: crates/fluxer-core/tests/admin_channel.rs

Interfaces:

  • Produces: OpenChannelSettings (a tab channel_tabs allows, else the first; nothing when none); admin::channel::settings_model(app) -> Option<ChannelSettingsModel { title, nav, danger: "Delete channel" | "Delete category", tab, bar, page: ChannelPage }>; the Overview draft by type (spec §3.6; CT/ChannelOverviewTab.tsx, CT/channel_overview_tab/*): name (label "Category name" for a category; normalised as #663 does unless the guild has TEXT_CHANNEL_FLEXIBLE_NAMES), topic ≤ 1024 (text, voice, announcement), slowmode (the 14 stops), link URL, the announcement switch (text ↔ announcement; turning it off asks FetchFollowerStats and Confirm::AnnouncementOff with the count), voice: bitrate (8 kbps to max_bitrate(guild) = 96, or 128 / 256 / 384 by feature, C/GuildConstants.ts getMaxVoiceChannelBitrate; sent in bit/s), participant limit 0–99, connection limit 1–100, region (with UPDATE_RTC_REGION; options from the existing regions request, "Automatic" = null; a user with only UPDATE_RTC_REGION gets the region alone). Save: one UpdateChannel with only the changed fields; CHANNEL_UPDATE re-syncs; refusals mapped to the original's texts.

  • ChannelAdminAction::Delete → Confirm::DeleteChannel (a category's body counts its channels; feat/channel/utils/ChannelDeleteModalUtils.ts, AM/items/CategoryMenuData.tsx) → the existing DeleteChannel; CHANNEL_DELETE removes it, closes its settings and, if it was open, selects the guild's first channel (the rule keynav already has). OpenDuplicate → the duplicate modal state prefilled with the name; Duplicate { name } (and the Shift path with the source's name) → #663's create request with the source's type, parent, url, bitrate, user limit, connection limit and overwrites (feat/channel/components/modals/ChannelDuplicateModal.tsx); limits (MAX_GUILD_CHANNELS, MAX_CATEGORY_CHANNELS) → the original's texts.

  • The settings close when the channel goes away or channel_tabs becomes empty.

  • Step 1: Write failing tests: table overview_fields_by_type (text, announcement, voice, link, category), name_normalised_unless_flexible, slowmode_stops, bitrate_max_by_feature_and_sent_in_bits, region_only_user_sees_region_alone, announcement_off_fetches_stats_and_confirms, save_sends_only_changed_fields, channel_update_resyncs_clean_form, delete_channel_confirms_then_selects_first_channel, delete_category_counts_children, duplicate_copies_fields_and_overwrites, shift_duplicate_skips_modal, limit_error_texts, settings_close_when_channel_deleted.

  • Step 2–5: FAIL → implement → PASS → commit feat(core): channel settings, delete, duplicate.

Task 16 of the Server administration plan (`docs/superpowers/plans/2026-11-15-serveradmin.md`, section "### Task 16:"). The plan on the `serveradmin` branch is the source of truth; this copy is for reading. **Closes:** — **Depends on:** 11 **Files:** - Modify: `crates/fluxer-core/src/admin/channel.rs` - Test: `crates/fluxer-core/tests/admin_channel.rs` **Interfaces:** - Produces: `OpenChannelSettings` (a tab `channel_tabs` allows, else the first; nothing when none); `admin::channel::settings_model(app) -> Option<ChannelSettingsModel { title, nav, danger: "Delete channel" | "Delete category", tab, bar, page: ChannelPage }>`; the Overview draft by type (spec §3.6; `CT/ChannelOverviewTab.tsx`, `CT/channel_overview_tab/*`): name (label "Category name" for a category; normalised as #663 does unless the guild has `TEXT_CHANNEL_FLEXIBLE_NAMES`), topic ≤ 1024 (text, voice, announcement), slowmode (the 14 stops), link URL, the announcement switch (text ↔ announcement; turning it off asks `FetchFollowerStats` and `Confirm::AnnouncementOff` with the count), voice: bitrate (8 kbps to `max_bitrate(guild)` = 96, or 128 / 256 / 384 by feature, `C/GuildConstants.ts` `getMaxVoiceChannelBitrate`; sent in bit/s), participant limit 0–99, connection limit 1–100, region (with UPDATE_RTC_REGION; options from the existing regions request, "Automatic" = null; a user with only UPDATE_RTC_REGION gets the region alone). Save: one `UpdateChannel` with only the changed fields; `CHANNEL_UPDATE` re-syncs; refusals mapped to the original's texts. - `ChannelAdminAction::Delete` → `Confirm::DeleteChannel` (a category's body counts its channels; `feat/channel/utils/ChannelDeleteModalUtils.ts`, `AM/items/CategoryMenuData.tsx`) → the existing `DeleteChannel`; `CHANNEL_DELETE` removes it, closes its settings and, if it was open, selects the guild's first channel (the rule `keynav` already has). `OpenDuplicate` → the duplicate modal state prefilled with the name; `Duplicate { name }` (and the Shift path with the source's name) → #663's create request with the source's type, parent, url, bitrate, user limit, connection limit and overwrites (`feat/channel/components/modals/ChannelDuplicateModal.tsx`); limits (`MAX_GUILD_CHANNELS`, `MAX_CATEGORY_CHANNELS`) → the original's texts. - The settings close when the channel goes away or `channel_tabs` becomes empty. - [ ] **Step 1: Write failing tests**: table `overview_fields_by_type` (text, announcement, voice, link, category), `name_normalised_unless_flexible`, `slowmode_stops`, `bitrate_max_by_feature_and_sent_in_bits`, `region_only_user_sees_region_alone`, `announcement_off_fetches_stats_and_confirms`, `save_sends_only_changed_fields`, `channel_update_resyncs_clean_form`, `delete_channel_confirms_then_selects_first_channel`, `delete_category_counts_children`, `duplicate_copies_fields_and_overwrites`, `shift_duplicate_skips_modal`, `limit_error_texts`, `settings_close_when_channel_deleted`. - [ ] **Step 2–5:** FAIL → implement → PASS → commit `feat(core): channel settings, delete, duplicate`.
Author
Owner

Independent review: Server admin 16 (branch serveradmin-16-core-channel-settings, head dd275751)

No open PR exists for this branch yet, so the review is posted on the task issue. Scope: commits 98747aa4 (proto) and b1c9c1d8 (core). The Task 18 reorder code in the same range was not reviewed here.

Local gate: FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci is green (EXIT 0). The first run failed in xtask/tests/package.rs (appimage_bundles_ffmpeg_under_usr_lib_flaxative) with could not execute process .../rustc ... No such file or directory (os error 2) while it built tower-http. This was a transient environment error unrelated to this diff: rustc was present, and an unchanged rerun passed.

Checks

  1. All 14 tests the plan names exist in tests/admin_channel.rs and assert the spec's values: the slowmode stops; bitrates of 96/128/256/384 kbps, clamped to 8 kbps and sent in bit/s; participant limits 0–99; connection limits 1–100; the delete and category texts; the limit texts. One extra test, open_needs_a_tab_and_falls_back_to_the_first, also exists.
  2. The interfaces are present: OpenChannelSettings opens on an allowed tab or else the first, and does nothing when no tab is allowed. settings_model returns ChannelSettingsModel{title, nav, danger, tab, bar, page}, plus channel_id and sidebar_title. ChannelAdminAction::{Delete, OpenDuplicate, Duplicate, SetAnnouncement} are unchanged from 9a. The settings close when the channel is deleted or no tab is left.
  3. Invariants hold: core has no I/O and no forbidden crates; the new proto fixture matches ChannelRequestSchemas.ts ChannelOverwriteRequest (type 0|1, decimal-string allow/deny); there are no secrets; server data takes non-panicking paths (try_from, saturating arithmetic, unwrap_or).
  4. Parity was spot-checked against the fork and matches:
    • The announcement-off flow (ChannelOverviewTab.onSubmit): the follower count is fetched on save, a count of 0 saves without asking, and a failed load gives the "unknown followers" body.
    • The delete and category confirm texts (ChannelDeleteModal.tsx, CategoryMenuData.tsx).
    • getMaxVoiceChannelBitrate, SLOWMODE_STOP_SECONDS, MAX_GUILD_CHANNELS/MAX_CHANNELS_PER_CATEGORY and their error texts (ErrorI18nMessages.ts).
    • The duplicate body (duplicateChannel: the overwrite type is 1, otherwise 0; voice fields are sent only for voice channels) and the duplicate helper texts.
    • The name is not normalised on the client in the original's Overview, and the native sends it as typed, as #663 does. This is correct.
  5. Review Focus: none is specific to this task.

Findings

  • [minor] Deviation in admin/channel.rs on_deleted: the client moves to the guild's first channel only when this user deleted the open channel. Spec §3.6 says "If the deleted channel is open, the client goes to the guild's first channel", and the original clears the selection on every delete (SelectedChannel.handleChannelDelete), after which the route redirects. For a delete made elsewhere, the native keeps its earlier behaviour, which presence_ui::deleted_channel_and_guild_are_deselected_and_forgotten asserts (selection None). Reviewer decision: accept it for this task, because changing it means rewriting a test outside this task's files. It should become a follow-up/parity issue.
  • [minor] Process: the task is scoped to one crate but also changes fluxer-proto (GuildChannelCreate.permission_overwrites, fixture channel_create_duplicate.json). The change is needed for duplicate parity, small, in its own commit, cites the server schema and keeps #663's body unchanged (left out when empty). It should be named in the PR body.
  • [minor] An empty save resets the form silently, while the original shows the "Channel updated" toast (Object.keys(updateData).length === 0).
  • [minor] The original shows CHANNEL_HAS_FOLLOWED_CHANNELS/CHANNEL_HAS_THREADS refusals in a "Couldn't convert this channel" error modal. Here they go to the bar's error text. This is acceptable for core, but the UI task should know.
  • [minor] ApiResult::GuildChannelCreated is matched by guild only, as #663's reducer does. If a #663 create and a duplicate are in flight in the same guild at once, either reducer can claim the other's answer. This is an edge case and does no harm.
  • [minor] The ChannelSettings struct gains a public field, regions. Tasks 14 and 17 should build it with ChannelSettings::new rather than a struct literal, or they will not compile after merging.

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

## Independent review: Server admin 16 (branch `serveradmin-16-core-channel-settings`, head dd275751) No open PR exists for this branch yet, so the review is posted on the task issue. Scope: commits 98747aa4 (proto) and b1c9c1d8 (core). The Task 18 reorder code in the same range was not reviewed here. **Local gate:** `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` is **green** (EXIT 0). The first run failed in `xtask/tests/package.rs` (`appimage_bundles_ffmpeg_under_usr_lib_flaxative`) with `could not execute process .../rustc ... No such file or directory (os error 2)` while it built `tower-http`. This was a transient environment error unrelated to this diff: rustc was present, and an unchanged rerun passed. **Checks** 1. All 14 tests the plan names exist in `tests/admin_channel.rs` and assert the spec's values: the slowmode stops; bitrates of 96/128/256/384 kbps, clamped to 8 kbps and sent in bit/s; participant limits 0–99; connection limits 1–100; the delete and category texts; the limit texts. One extra test, `open_needs_a_tab_and_falls_back_to_the_first`, also exists. 2. The interfaces are present: `OpenChannelSettings` opens on an allowed tab or else the first, and does nothing when no tab is allowed. `settings_model` returns `ChannelSettingsModel{title, nav, danger, tab, bar, page}`, plus `channel_id` and `sidebar_title`. `ChannelAdminAction::{Delete, OpenDuplicate, Duplicate, SetAnnouncement}` are unchanged from 9a. The settings close when the channel is deleted or no tab is left. 3. Invariants hold: core has no I/O and no forbidden crates; the new proto fixture matches `ChannelRequestSchemas.ts` `ChannelOverwriteRequest` (type 0|1, decimal-string allow/deny); there are no secrets; server data takes non-panicking paths (`try_from`, saturating arithmetic, `unwrap_or`). 4. Parity was spot-checked against the fork and matches: - The announcement-off flow (`ChannelOverviewTab.onSubmit`): the follower count is fetched on save, a count of 0 saves without asking, and a failed load gives the "unknown followers" body. - The delete and category confirm texts (`ChannelDeleteModal.tsx`, `CategoryMenuData.tsx`). - `getMaxVoiceChannelBitrate`, `SLOWMODE_STOP_SECONDS`, `MAX_GUILD_CHANNELS`/`MAX_CHANNELS_PER_CATEGORY` and their error texts (`ErrorI18nMessages.ts`). - The duplicate body (`duplicateChannel`: the overwrite type is 1, otherwise 0; voice fields are sent only for voice channels) and the duplicate helper texts. - The name is not normalised on the client in the original's Overview, and the native sends it as typed, as #663 does. This is correct. 5. Review Focus: none is specific to this task. **Findings** - [minor] Deviation in `admin/channel.rs` `on_deleted`: the client moves to the guild's first channel only when this user deleted the open channel. Spec §3.6 says "If the deleted channel is open, the client goes to the guild's first channel", and the original clears the selection on every delete (`SelectedChannel.handleChannelDelete`), after which the route redirects. For a delete made elsewhere, the native keeps its earlier behaviour, which `presence_ui::deleted_channel_and_guild_are_deselected_and_forgotten` asserts (selection `None`). Reviewer decision: accept it for this task, because changing it means rewriting a test outside this task's files. It should become a `follow-up`/`parity` issue. - [minor] Process: the task is scoped to one crate but also changes `fluxer-proto` (`GuildChannelCreate.permission_overwrites`, fixture `channel_create_duplicate.json`). The change is needed for duplicate parity, small, in its own commit, cites the server schema and keeps #663's body unchanged (left out when empty). It should be named in the PR body. - [minor] An empty save resets the form silently, while the original shows the "Channel updated" toast (`Object.keys(updateData).length === 0`). - [minor] The original shows `CHANNEL_HAS_FOLLOWED_CHANNELS`/`CHANNEL_HAS_THREADS` refusals in a "Couldn't convert this channel" error modal. Here they go to the bar's error text. This is acceptable for core, but the UI task should know. - [minor] `ApiResult::GuildChannelCreated` is matched by guild only, as #663's reducer does. If a #663 create and a duplicate are in flight in the same guild at once, either reducer can claim the other's answer. This is an edge case and does no harm. - [minor] The `ChannelSettings` struct gains a public field, `regions`. Tasks 14 and 17 should build it with `ChannelSettings::new` rather than a struct literal, or they will not compile after merging. **Verdict: APPROVED.** No blocking findings, and the local CI is green.
Sign in to join this conversation.
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
charles/fluxer-native#683
No description provided.