Voice 11: fluxer-core::voice DM calls and status selector (#72) #116

Manually merged
charles merged 0 commits from voice-11-core-calls-status into voice 2026-11-11 21:03:49 +00:00
Owner

What this builds

  • fluxer-core::voice::calls: app.voice.calls (Calls { by_channel: HashMap<Snowflake, Call { ringing, voice_states, message_id, region }>, incoming, not_ringable }), a port of the fork's CallState/CallStateMachine, CallInitiator, CallCommands and the ringing rule of IncomingCallManager.
    • CALL_CREATE/CALL_UPDATE/CALL_DELETE keep the calls; a live READY and logging out forget them (the gateway announces existing calls again on session start).
    • incoming = the longest-ringing call that rings me, that I did not start and whose room I am not in. While there is one and the connection is Idle/Failed, AudioCommand::PlayChime(Chime::IncomingCall) is emitted at once and again every RING_PERIOD (4572 ms, the length of the original's looped ring) on a timer, until answered, declined, CALL_DELETE or the server stops ringing me.
    • UserAction::{StartCall, AcceptCall, DeclineCall, EndCall}(channel_id); ApiRequest::{CallEligibility, Ring, StopRinging, EndCall} with ApiResult::{CallEligibility, RingOk, StopRingingOk, EndCallOk}. Start = eligibility check, then op 4 with guild_id: null, then Ring to the channel's other recipients once the room is joined. Accept = op 4 with guild_id: null. Decline = StopRinging for everyone (the fork's rejectCall). End = StopRinging for those I rang who have not answered, then leave.
  • selectors::voice_status(&App) -> Option<VoiceStatusPayload>: a port of DesktopVoiceStatusBridge.ts (connection state mapping, one participant per user with activity OR-ed across devices and mute/deafen from the local connection, self first then display name then id). None only before login.
  • The VoiceStatus* types moved from fluxer-status-api (tokio, tokio-tungstenite) to fluxer_proto::status, unchanged, and are re-exported from fluxer-status-api (the plan's "otherwise" branch). Own commit.
  • Fixtures fixtures/status/voice_status_{connected,disconnected}.json: whole voice_status frames with the fork's member names, order and types (DesktopBridgeTypes.ts, local-status-api.md).

How it was tested

  • crates/fluxer-core/tests/calls.rs (20 tests): the four named ones (call_create_with_me_ringing_sets_incoming, accept_joins_with_null_guild, decline_stops_ringing, call_delete_clears) plus the start/ring/end flows, the ring timer (repeat, stale timers, no ring while in voice, queue of two calls), failed requests, READY, logout and unknown channels.
  • crates/fluxer-core/tests/voice_status.rs (7 tests): status_payload_disconnected_shape, status_payload_merges_devices_and_sorts, status_payload_json_matches_fork_fixture (value equality with the fixture, member order of the three objects, and the fixture reading back as the typed payload), plus the connection-state mapping, sorting and a DM call.
  • Written first and seen failing (unresolved names), then passing. FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci is green locally.

Deviations from the plan

  • Files outside the task's list, each minimal: voice/mod.rs, app.rs, lib.rs, selectors/mod.rs (wiring); voice/connection.rs (join is now pub(super) and LeaveVoice goes through a new pub(super) fn leave, so the calls reducer can use both; no behaviour change); apps/fluxer/src/runtime.rs (the four new ApiRequests mapped to the existing fluxer-api methods, because perform matches exhaustively); fluxer-proto and fluxer-status-api for the type move. fluxer-core/Cargo.toml did not need to change.
  • ApiRequest::EndCall exists but the store never emits it: the fork's server answers POST /call/end with 204 without doing anything and the fork's client never sends it. Hanging up is the fork's leaveCall.
  • Extras the UI needs that the Interfaces block does not name: Calls::not_ringable (the original's "call not ringable" dialog) and the eligibility's silent flag (join without ringing).
  • The ring is looped by the store with a timer, since the port has no way to stop a chime: the round that is playing when the call is answered runs to its end. speaking in the status payload is false until Voice 8 is on voice; avatarUrl is the user's own avatar or null. All three are in follow-up #115.
  • CALL_UPDATE replaces ringing and voice_states (the proto type cannot tell a missing list from an empty one) and keeps message_id/region when the update leaves them out.

Stacked on: voice-7-core-voice-connection

Closes #72

🤖 Generated with Claude Code

## What this builds - `fluxer-core::voice::calls`: `app.voice.calls` (`Calls { by_channel: HashMap<Snowflake, Call { ringing, voice_states, message_id, region }>, incoming, not_ringable }`), a port of the fork's `CallState`/`CallStateMachine`, `CallInitiator`, `CallCommands` and the ringing rule of `IncomingCallManager`. - `CALL_CREATE`/`CALL_UPDATE`/`CALL_DELETE` keep the calls; a live `READY` and logging out forget them (the gateway announces existing calls again on session start). - `incoming` = the longest-ringing call that rings me, that I did not start and whose room I am not in. While there is one and the connection is `Idle`/`Failed`, `AudioCommand::PlayChime(Chime::IncomingCall)` is emitted at once and again every `RING_PERIOD` (4572 ms, the length of the original's looped ring) on a timer, until answered, declined, `CALL_DELETE` or the server stops ringing me. - `UserAction::{StartCall, AcceptCall, DeclineCall, EndCall}(channel_id)`; `ApiRequest::{CallEligibility, Ring, StopRinging, EndCall}` with `ApiResult::{CallEligibility, RingOk, StopRingingOk, EndCallOk}`. Start = eligibility check, then op 4 with `guild_id: null`, then `Ring` to the channel's other recipients once the room is joined. Accept = op 4 with `guild_id: null`. Decline = `StopRinging` for everyone (the fork's `rejectCall`). End = `StopRinging` for those I rang who have not answered, then leave. - `selectors::voice_status(&App) -> Option<VoiceStatusPayload>`: a port of `DesktopVoiceStatusBridge.ts` (connection state mapping, one participant per user with activity OR-ed across devices and mute/deafen from the local connection, self first then display name then id). `None` only before login. - The `VoiceStatus*` types moved from `fluxer-status-api` (tokio, tokio-tungstenite) to `fluxer_proto::status`, unchanged, and are re-exported from `fluxer-status-api` (the plan's "otherwise" branch). Own commit. - Fixtures `fixtures/status/voice_status_{connected,disconnected}.json`: whole `voice_status` frames with the fork's member names, order and types (`DesktopBridgeTypes.ts`, `local-status-api.md`). ## How it was tested - `crates/fluxer-core/tests/calls.rs` (20 tests): the four named ones (`call_create_with_me_ringing_sets_incoming`, `accept_joins_with_null_guild`, `decline_stops_ringing`, `call_delete_clears`) plus the start/ring/end flows, the ring timer (repeat, stale timers, no ring while in voice, queue of two calls), failed requests, `READY`, logout and unknown channels. - `crates/fluxer-core/tests/voice_status.rs` (7 tests): `status_payload_disconnected_shape`, `status_payload_merges_devices_and_sorts`, `status_payload_json_matches_fork_fixture` (value equality with the fixture, member order of the three objects, and the fixture reading back as the typed payload), plus the connection-state mapping, sorting and a DM call. - Written first and seen failing (unresolved names), then passing. `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` is green locally. ## Deviations from the plan - Files outside the task's list, each minimal: `voice/mod.rs`, `app.rs`, `lib.rs`, `selectors/mod.rs` (wiring); `voice/connection.rs` (`join` is now `pub(super)` and `LeaveVoice` goes through a new `pub(super) fn leave`, so the calls reducer can use both; no behaviour change); `apps/fluxer/src/runtime.rs` (the four new `ApiRequest`s mapped to the existing `fluxer-api` methods, because `perform` matches exhaustively); `fluxer-proto` and `fluxer-status-api` for the type move. `fluxer-core/Cargo.toml` did not need to change. - `ApiRequest::EndCall` exists but the store never emits it: the fork's server answers `POST /call/end` with 204 without doing anything and the fork's client never sends it. Hanging up is the fork's `leaveCall`. - Extras the UI needs that the Interfaces block does not name: `Calls::not_ringable` (the original's "call not ringable" dialog) and the eligibility's `silent` flag (join without ringing). - The ring is looped by the store with a timer, since the port has no way to stop a chime: the round that is playing when the call is answered runs to its end. `speaking` in the status payload is `false` until Voice 8 is on `voice`; `avatarUrl` is the user's own avatar or `null`. All three are in follow-up #115. - `CALL_UPDATE` replaces `ringing` and `voice_states` (the proto type cannot tell a missing list from an empty one) and keeps `message_id`/`region` when the update leaves them out. Stacked on: voice-7-core-voice-connection Closes #72 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Refs #68

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
feat(core): voice connection state machine and ports
Some checks failed
ci / Linux (x86_64) (push) Has been cancelled
ci / Windows (x64) (push) Has been cancelled
ci / Linux (x86_64) (pull_request) Has been cancelled
ci / Windows (x64) (pull_request) Has been cancelled
3b33ca2c55
The ports of Voice spec §5.3 (voice::port), Effect::{Voice, Audio},
CoreEvent::{Voice, Audio, GatewayError}, the connection machine
(VoiceConnection, VoiceFailure) with join, leave, move, kick, resume and
token refresh, the user's mute and deafen switches (LocalVoiceState) saved
in a new [voice] section of the local settings, and effective_mute /
effective_deaf.

fluxer-platform reads and writes the new settings section; apps/fluxer
drops the two new effects until the voice runtime (Voice 14) exists.

Refs #68

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Merge remote-tracking branch 'origin/voice' into voice/7-core-voice-connection
All checks were successful
ci / Linux (x86_64) (push) Successful in 7m37s
ci / Windows (x64) (push) Successful in 8m56s
ci / Linux (x86_64) (pull_request) Successful in 7m50s
ci / Windows (x64) (pull_request) Successful in 8m51s
67f0d8f32f
fluxer-core builds the voice status and must not depend on fluxer-status-api,
which does I/O. The types move unchanged and stay re-exported from there.

Refs #72

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
feat(core): DM calls and voice status selector
All checks were successful
ci / Linux (x86_64) (push) Successful in 7m47s
ci / Windows (x64) (push) Successful in 8m56s
94cdafd1e1
Refs #72

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Author
Owner

Independent review: Voice 11 (core-calls-status) at 94cdafd

Reviewed 6962d17..94cdafd cold, against the plan's Task 11, facts §9 and the fork (CallCommands.ts, CallInitiator.ts, IncomingCallManager.tsx, DesktopVoiceStatusBridge.ts, VoiceParticipantDisplayState.ts).

1. Tests named by the plan - all seven exist and assert what the plan says: call_create_with_me_ringing_sets_incoming, accept_joins_with_null_guild (op 4 with guild_id: null, connection_id: null), decline_stops_ringing, call_delete_clears, status_payload_disconnected_shape, status_payload_merges_devices_and_sorts, status_payload_json_matches_fork_fixture (value equality, member order, round trip). 20 + 7 tests pass.

2. Interfaces - Calls { by_channel, incoming }, Call { ringing, voice_states, message_id, region }, UserAction::{StartCall, AcceptCall, DeclineCall, EndCall}(Snowflake), ApiRequest::{CallEligibility, Ring, StopRinging, EndCall}, selectors::voice_status(&App) -> Option<VoiceStatusPayload> are present as written. VoiceStatus* moved unchanged to fluxer_proto::status and are still re-exported from fluxer-status-api (the plan's "otherwise" branch; correct, that crate depends on tokio/tungstenite).

3. Invariants - fluxer-core/Cargo.toml unchanged, no I/O; no indexing/unwrap on server data in calls.rs or voice_status.rs (unknown channels, users and calls are covered by tests); no secrets in code or fixtures. connection.rs change is visibility plus an extracted leave, no behaviour change.

4. Review Focus - no item belongs to this task.

5. CI - FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci in a fresh worktree and target dir: all steps passed. Remote runners not checked.

Findings

  • minor voice/calls.rs settle_calls: when the ring stops, the scheduled timer is only forgotten, and the port has no stop-chime. A call that stops and rings again within 4.5 s (or a second call arriving right after a decline) starts a new round over the tail of the old one. Same root as the known "round runs to its end" deviation; keep it in #115.
  • minor selectors/voice_status.rs: the fork also shows the local user as muted when they lack the speak permission in the channel (isParticipantVoicePermissionMuted: suppress || (isCurrentUser && speak denied)); the port only has suppress. Not listed among the documented differences in the doc comment.
  • minor selectors/voice_status.rs sort: lowercase code-point compare instead of localeCompare; differs for accented and non-Latin names only. Documented; fine for companion apps.
  • minor voice/calls.rs: Calls::not_ringable has no dismiss action and ring_request is never cleared on RingOk (harmless: effect ids are unique). Voice 22 will need the dismiss.
  • minor ApiRequest::EndCall / ApiResult::EndCallOk are never emitted. Agreed with the reasoning (fork client never sends it); kept because the Interfaces block names it.

Checked and found faithful to the fork: DeclineCall = rejectCall (StopRinging with no recipients, leave only if in that call, call stays joinable); EndCall = leaveCall (initiatedRingingRecipients, including "everyone" when this client rang nobody); ring only after Connected in the call's room; NEW_CONVERSATIONS_LIMITED leaves the call; incoming = ringing for me, not initiated by me, not the call I am in; no ring while in or joining voice; per-user merge order is deterministic (connections ordered by id).

Verdict: APPROVE - 0 blocking, 5 minor. Local ci green.

## Independent review: Voice 11 (core-calls-status) at 94cdafd Reviewed `6962d17..94cdafd` cold, against the plan's Task 11, facts §9 and the fork (`CallCommands.ts`, `CallInitiator.ts`, `IncomingCallManager.tsx`, `DesktopVoiceStatusBridge.ts`, `VoiceParticipantDisplayState.ts`). **1. Tests named by the plan** - all seven exist and assert what the plan says: `call_create_with_me_ringing_sets_incoming`, `accept_joins_with_null_guild` (op 4 with `guild_id: null`, `connection_id: null`), `decline_stops_ringing`, `call_delete_clears`, `status_payload_disconnected_shape`, `status_payload_merges_devices_and_sorts`, `status_payload_json_matches_fork_fixture` (value equality, member order, round trip). 20 + 7 tests pass. **2. Interfaces** - `Calls { by_channel, incoming }`, `Call { ringing, voice_states, message_id, region }`, `UserAction::{StartCall, AcceptCall, DeclineCall, EndCall}(Snowflake)`, `ApiRequest::{CallEligibility, Ring, StopRinging, EndCall}`, `selectors::voice_status(&App) -> Option<VoiceStatusPayload>` are present as written. `VoiceStatus*` moved unchanged to `fluxer_proto::status` and are still re-exported from `fluxer-status-api` (the plan's "otherwise" branch; correct, that crate depends on tokio/tungstenite). **3. Invariants** - `fluxer-core/Cargo.toml` unchanged, no I/O; no indexing/unwrap on server data in `calls.rs` or `voice_status.rs` (unknown channels, users and calls are covered by tests); no secrets in code or fixtures. `connection.rs` change is visibility plus an extracted `leave`, no behaviour change. **4. Review Focus** - no item belongs to this task. **5. CI** - `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` in a fresh worktree and target dir: all steps passed. Remote runners not checked. ### Findings - **minor** `voice/calls.rs` `settle_calls`: when the ring stops, the scheduled timer is only forgotten, and the port has no stop-chime. A call that stops and rings again within 4.5 s (or a second call arriving right after a decline) starts a new round over the tail of the old one. Same root as the known "round runs to its end" deviation; keep it in #115. - **minor** `selectors/voice_status.rs`: the fork also shows the local user as muted when they lack the speak permission in the channel (`isParticipantVoicePermissionMuted`: `suppress || (isCurrentUser && speak denied)`); the port only has `suppress`. Not listed among the documented differences in the doc comment. - **minor** `selectors/voice_status.rs` sort: lowercase code-point compare instead of `localeCompare`; differs for accented and non-Latin names only. Documented; fine for companion apps. - **minor** `voice/calls.rs`: `Calls::not_ringable` has no dismiss action and `ring_request` is never cleared on `RingOk` (harmless: effect ids are unique). Voice 22 will need the dismiss. - **minor** `ApiRequest::EndCall` / `ApiResult::EndCallOk` are never emitted. Agreed with the reasoning (fork client never sends it); kept because the Interfaces block names it. Checked and found faithful to the fork: `DeclineCall` = `rejectCall` (StopRinging with no recipients, leave only if in that call, call stays joinable); `EndCall` = `leaveCall` (`initiatedRingingRecipients`, including "everyone" when this client rang nobody); ring only after `Connected` in the call's room; `NEW_CONVERSATIONS_LIMITED` leaves the call; incoming = ringing for me, not initiated by me, not the call I am in; no ring while in or joining voice; per-user merge order is deterministic (connections ordered by id). **Verdict: APPROVE** - 0 blocking, 5 minor. Local ci green.
charles manually merged commit fb05a010cb into voice 2026-11-11 21:03:49 +00:00
Sign in to join this conversation.
No description provided.