Text chat 57: core entrance-sound library, scopes and per-user entrance preferences (#386) #411
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "textchat-57-core-entrance-library"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What this builds
The store half of the entrance-sound items of #142 (
fluxer-core, plus the[voice.entrance]table influxer-platform's settings file).voice::EntranceLibraryinVoice::entrance_library:LibraryStatus, sounds newest first,selectionsby scope id,pending: Option<EntranceOp>,error: Option<EntranceError>;resolve/selectionfollowEntranceSoundScope::fallbacks. The join-time fetch fills the library too, and the posted entrance sound now comes fromresolve(EntranceSoundScope::for_voice(guild)).LoadEntranceSounds(once per session, again afterFailed),SetEntranceSound→PutEntranceSoundSelection(applied onEntranceSelectionSet;Noneclears),UploadEntranceSound(checks feature limit → quota 8 → 1 MiB → magic bytes → name ≤ 32 chars, empty → "Entrance sound"; then selects forselect_for),RenameEntranceSound,DeleteEntranceSound(drops its selections),PreviewEntranceSound(entrance:<hash>key,PREVIEW_CLIP_TAG, output volume only). ServerENTRANCE_SOUND_*validation codes map toEntranceError; anything else isServer(message).voice::EntranceListenerPrefsinVoice::entrance_listeners,SetEntranceListenerMute/SetEntranceListenerVolume(0–200 %),entrance_gain; a muted user's entrance is never fetched; persisted inLocalSettings::entrance/[voice.entrance](non-id keys dropped, volumes clamped, absent in old files).selectors::entrance_settings(app, scope, current_guild) -> EntranceSettingsModelwithEntranceRow,EntranceResolved,ScopeTile.Testing
crates/fluxer-core/tests/entrance_sounds.rs(19 tests, every name in the plan's Step 1); existingtests/soundboard.rs(29, entrance playback included) still pass;fluxer-platform/tests/settings.rs::entrance_prefs_round_trip_and_old_files_load.FLUXER_SCREENSHOT_TESTS=1 cargo xtask cigreen locally.Deviations / reviewer notes
crates/fluxer-core/src/app.rspassesentrance_sounds_enabled(&session)intoreduce_soundboard(the upload check needs the instance limits);apps/fluxer/src/runtime.rsexecutes the four newApiRequests with Task 55'sApiClientmethods and lists them inperform_chat's exhaustive match (needed to compile; Task 61 owns the rest of the runtime).selectors::guild_order); the original sorts them by name.pendingis set is ignored.EntranceError::Name) rather than cut asderiveLibraryNamedoes; the UI derives the name.ApiRequesthas noPartialEq, so the tests compare requests byDebugormatches!.Stacked on: textchat-55-proto-api-entrance-library, textchat-56-core-soundboard-parity
Closes #386
🤖 Generated with Claude Code
Request shapes from fluxer_api/src/api/user/entrance_sound/EntranceSoundController.ts:72-96 and packages/schema/src/domains/user/EntranceSoundSchemas.ts; scopes from fluxer_app/src/features/notification/utils/EntranceSoundScopes.ts:65-74; limits from packages/constants/src/{EntranceSoundConstants,SoundboardConstants}.ts. Refs #384 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>Independent review: Text chat 57 (core-entrance-library), commit
31fecd9Scope:
git diff f3c5075..origin/textchat-57-core-entrance-library.Tests: All 19 tests the plan names are in
crates/fluxer-core/tests/entrance_sounds.rs, andentrance_prefs_round_trip_and_old_files_loadis influxer-platform/tests/settings.rs. They assert what the plan says: 8 sounds per user, 1 MiB at the boundary and one byte over, 32 characters, "Entrance sound", theentrance:<hash>key,PREVIEW_CLIP_TAGat output volume 0.5, listener gain 1.5 x 0.5 = 0.75, the 200 % clamp, the fourENTRANCE_SOUND_*codes, guild-order overrides, and the disabled notice. No new fixtures; the tests use the fixtures Task 55 added.Interfaces: Every name and signature in the Task 57 Interfaces block exists as written:
EntranceLibrary,LibraryStatus,EntranceOp,EntranceErrorUserActions, the 4ApiRequests and the 4ApiResultsEntranceListenerPrefs::{volume, is_muted},entrance_gain, andVoice::{entrance_library, entrance_listeners}(both pub)LocalSettings::entrance: Box<EntranceListenerPrefs>selectors::entrance_settings,EntranceSettingsModel,EntranceRow,EntranceResolved,ScopeTileThe runtime maps the four requests onto Task 55's
ApiClientmethods.Invariants:
SoundBytesonly passes through the action and the effect, as the plan specifies. ItsDebugprints the length only. The core keeps only theselect_forscope in its requests, not the bytes.CoreErrorstrings, and there are no URLs or paths in logs.[voice.entrance]round-trips. Older files load, non-id keys are dropped, and volumes are clamped without panicking.Implementer's flagged points, verified:
EntranceSoundUploadedclearsUploadingand then PUTs the selection forselect_for. This matchesuploadTrimmedResult, and the test covers it.Failedis set only when no other load is in flight and the status isLoading. A failed re-fetch on join leavesLoadedalone. This is correct.Findings
UploadEntranceSoundrejects a name over 32 characters withEntranceError::Name. The originalderiveLibraryName(useEntranceSound.ts:93-98) cuts it to 32 instead, and the plan cites that function. If the UI (Task 59/60) passes a long file stem, the upload fails where the original would succeed. Either cut the name in core, or make sure the UI cuts it before sending. Not blocking: no interface or invariant is affected.trimmed_namecounts Unicode scalar values, while the server and the original count UTF-16 units. A name made of astral characters (for example 20 emoji) passes the check, and the server then rejects it. That error has noENTRANCE_SOUND_*code, so it shows asServer(message). This is an edge case and degrades gracefully.docs/parity/settings.tomlstill listssection-voice_video-entrance-soundasplanned. That is right for a core-only task; the UI task should update it.CI
FLUXER_SCREENSHOT_TESTS=1 cargo xtask cion31fecd9in a clean review worktree: all steps passed (exit 0).Verdict: APPROVED. No blocking findings, and local CI is green.
🤖 Generated with Claude Code
Independent review (second pass): Text chat 57 (core-entrance-library), HEAD
9573d82Scope: the task's own commit
31fecd9withingit diff 02385ad..origin/textchat-57-core-entrance-library(the rest of that range is Task 55/56 merges).1. Tests: all 20 tests the plan names exist (19 in
crates/fluxer-core/tests/entrance_sounds.rs,entrance_prefs_round_trip_and_old_files_loadincrates/fluxer-platform/tests/settings.rs). Each asserts what the plan says: 8-sound quota, 1 MiB size, magic-byte format, 32-char name,"Entrance sound"default, the server code →EntranceErrormapping, preview at output volume underentrance:<hash>onPREVIEW_CLIP_TAG, listener volume clamped to 200,entrance_gaincapped atMAX_SOUND_GAIN, tiles Global/Guilds/Dms/current guild and overrides in guild order.2. Interfaces:
EntranceLibrary,LibraryStatus,EntranceOp,EntranceError, theUserAction/ApiRequest/ApiResultvariants,EntranceListenerPrefs(volume,is_muted),entrance_gain(u8, u8) -> f32,LocalSettings::entrance: Box<EntranceListenerPrefs>, andselectors::entrance_settings/EntranceSettingsModel/ScopeTilematch the plan.selected_soundgoes throughEntranceSoundScope::fallbacks.3. Invariants: no Cargo.toml change, so no new dependency. fluxer-core gets no upload URLs or paths. The sound bytes in
UploadEntranceSoundare theSoundBytesthe plan's interface prescribes, as the existing soundboard upload does. Server data cannot panic the client: the settings file drops non-id keys and clamps volumes, and a scope that does not parse becomes a 400 error in the runtime, not a panic. No new fixtures, and no secrets in logs.4. Review Focus: none of the items belongs to this task.
5. Local CI:
FLUXER_SCREENSHOT_TESTS=1 cargo xtask cion9573d82: all steps passed (exit 0).Findings:
trimmed_namerefuses a name over 32 characters withEntranceError::Name, while the original'sderiveLibraryNamecuts it to 32 (base.slice(0, 32)). It also counts chars, not UTF-16 units. The first review raised the same point. The UI task can cut the name before sending; if it does not, this needs a follow-up.FetchEntranceSoundsanswer replacesselectionswith the server's copy. If a selection PUT is still pending at that moment, the library shows the old selection untilEntranceSelectionSetarrives. That answer then applies the change, so nothing is lost.About the relayed request "remove the cap": this PR has several caps (
MAX_SOUND_GAINonentrance_gain, the 200 % listener clamp, and the 8-sound, 1 MiB and 32-char limits that match the server). The request does not say which one, so this review changes none of them. Charles should name the cap.Verdict: APPROVED (0 blocking, 2 minor).