Rejoin the voice channel after an update restart (#784) #787

Closed
charles wants to merge 0 commits from feat-784-rejoin-voice-after-update into textchat
Owner

Closes #784

What it does. When the updater restarts the app to install an update (UpdateCommand::Apply { relaunch: true }) while the user is in voice, the app writes down where they were. On the next start it joins that voice channel again by itself, with the same self-mute and self-deafen.

Why it did not happen before. Nothing recorded the voice connection across the restart. #615 brings back only the place shown on screen ([navigation] last_location). Voice started idle, and the user had to join again by hand.

How it works (the decision is in fluxer-core, new module rejoin, with no I/O):

  • Writing. After every event, the core checks whether the effects contain an Apply with relaunch: true while the connection is not idle or failed. If so, it stores a VoiceRejoin in LocalSettings.rejoin_voice: the account, the guild (None for a DM call), the channel, the mute/deafen switches and the store clock's time. It queues a SaveSettings just before the Apply, and the runtime already lets queued writes land before it runs the installer.
  • Never written: on an ordinary quit, by the install on quit (which does not relaunch), or by a start the user makes.
  • Forgotten on UpdateEvent::ApplyFailed (the app keeps running) and on logout.
  • Reading. The intent is taken once, at the first live READY. The cached READY is not enough: a join needs the live gateway, and only the live READY confirms the channel and the permissions. It is removed from the file whatever happens next. It is ignored if any of these is true:
    • another account wrote it;
    • it is older than 5 minutes;
    • the user already joined voice by hand.
  • Why 5 minutes. A relaunch plus the READY takes seconds. Five minutes leaves room for a slow disk or network, but a failed relaunch followed by a start much later does not join voice by surprise. It is the same as the original's VOICE_SESSION_RESTORE_DECAY_MS.
  • Guild channel. If the channel is gone, is no longer a voice channel of that guild, or the user lacks VIEW_CHANNEL/CONNECT, the app does not join. It logs this at INFO and shows nothing. Otherwise it restores the switches and follows up with UserAction::JoinVoice. A full channel gets the usual "Voice channel full" modal, and a refusal from the server gets the usual "Connection failed".
  • DM call. It is joined only once its CALL_CREATE/CALL_UPDATE arrives (within the same expiry), because the gateway announces calls after READY. Joining a DM that has no call would start a new one and ring the other person; the original checks CallState.hasActiveCall for the same reason. Any voice action the user takes meanwhile drops the wait.
  • Settings file. The new table is [rejoin_voice] in settings.toml (fluxer-platform). If the table cannot be read in full, it counts as no rejoin, and the rest of the file is kept.
  • In-call restart confirmation (fluxer-ui). The text is now "Flaxative restarts on {version} and puts you back in {channel}." When the user is sharing their screen it adds: "Your screen share stops and does not come back by itself: share again after the restart." This client has no camera publishing yet, so there is nothing to say about the camera.

Difference from the original (~/src/fluxer-soundboard). VoiceSessionRestore.ts saves a snapshot of the voice session all the time: a heartbeat every minute, plus on beforeunload. That snapshot covers any restart and expires after 5 minutes. After a restart the original shows a nagbar ("… restarted while you were connected to …", with "Reconnect" / "Not now") and never joins by itself. Its Electron relaunch (ShellSelfUpdate.ts: relaunchStableLaunchPath / quitAndInstall) has no special voice handling. This PR joins without a click, but only after the app's own update restart, as #784 asks.

Verified with:

  • crates/fluxer-core/tests/voice_rejoin.rs, 16 tests:
    • the intent is written before the install (Apply) in a call, and not outside voice;
    • it is not written by the install on quit;
    • it is forgotten after a failed install and after a logout;
    • a normal start never joins;
    • the next start joins with the same mute/deafen;
    • it is consumed once (a second READY does not join);
    • an expired intent is ignored, and one just within the limit still joins;
    • another account's intent is ignored;
    • a channel that is gone or not a voice channel is not joined, and nothing is shown;
    • a channel without CONNECT is not joined, and nothing is shown;
    • the cached READY does not join;
    • a user who already joined by hand is not moved;
    • a DM call is joined only after CALL_CREATE, and not when it is announced too late.
  • crates/fluxer-platform/tests/settings_rejoin.rs: the [rejoin_voice] table round-trips (guild and DM); a table that cannot be read is none.
  • crates/fluxer-ui/tests/update.rs: the confirmation text, with and without a screen share.
  • apps/fluxer/tests/rejoin_voice_runtime.rs against the dev server (voice scenario, FakeRoom, the --devserver dry-run installer):
    1. First run: join Hangout, mute, get an update ready, click the button, then "Restart". The intent lands in settings.toml.
    2. Next start with the same settings: back in Hangout by itself, still muted, and connected. The intent is gone from the file.
    3. A third, ordinary start does not join.
  • FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci ends with ==> xtask ci: all steps passed. No goldens changed.

Not tested on Windows. No test runs a real relaunch on Windows, since none can run here. That covers Velopack's apply-and-restart, and the persist write landing before Velopack takes over. The core logic and the settings write are the same on both platforms. The AppImage re-exec on Linux is not exercised end to end either: the runtime test uses the dry run, which installs nothing and does not exit, so the "next start" is a new runtime on the same settings directory.

🤖 Generated with Claude Code

Closes #784 **What it does.** When the updater restarts the app to install an update (`UpdateCommand::Apply { relaunch: true }`) while the user is in voice, the app writes down where they were. On the next start it joins that voice channel again by itself, with the same self-mute and self-deafen. **Why it did not happen before.** Nothing recorded the voice connection across the restart. #615 brings back only the place shown on screen (`[navigation] last_location`). Voice started idle, and the user had to join again by hand. **How it works** (the decision is in `fluxer-core`, new module `rejoin`, with no I/O): - **Writing.** After every event, the core checks whether the effects contain an `Apply` with `relaunch: true` while the connection is not idle or failed. If so, it stores a `VoiceRejoin` in `LocalSettings.rejoin_voice`: the account, the guild (`None` for a DM call), the channel, the mute/deafen switches and the store clock's time. It queues a `SaveSettings` just before the `Apply`, and the runtime already lets queued writes land before it runs the installer. - **Never written:** on an ordinary quit, by the install on quit (which does not relaunch), or by a start the user makes. - **Forgotten** on `UpdateEvent::ApplyFailed` (the app keeps running) and on logout. - **Reading.** The intent is taken once, at the first *live* `READY`. The cached `READY` is not enough: a join needs the live gateway, and only the live `READY` confirms the channel and the permissions. It is removed from the file whatever happens next. It is ignored if any of these is true: - another account wrote it; - it is older than **5 minutes**; - the user already joined voice by hand. - **Why 5 minutes.** A relaunch plus the `READY` takes seconds. Five minutes leaves room for a slow disk or network, but a failed relaunch followed by a start much later does not join voice by surprise. It is the same as the original's `VOICE_SESSION_RESTORE_DECAY_MS`. - **Guild channel.** If the channel is gone, is no longer a voice channel of that guild, or the user lacks `VIEW_CHANNEL`/`CONNECT`, the app does not join. It logs this at INFO and shows nothing. Otherwise it restores the switches and follows up with `UserAction::JoinVoice`. A full channel gets the usual "Voice channel full" modal, and a refusal from the server gets the usual "Connection failed". - **DM call.** It is joined only once its `CALL_CREATE`/`CALL_UPDATE` arrives (within the same expiry), because the gateway announces calls after `READY`. Joining a DM that has no call would start a new one and ring the other person; the original checks `CallState.hasActiveCall` for the same reason. Any voice action the user takes meanwhile drops the wait. - **Settings file.** The new table is `[rejoin_voice]` in `settings.toml` (`fluxer-platform`). If the table cannot be read in full, it counts as no rejoin, and the rest of the file is kept. - **In-call restart confirmation** (`fluxer-ui`). The text is now "Flaxative restarts on {version} and puts you back in {channel}." When the user is sharing their screen it adds: "Your screen share stops and does not come back by itself: share again after the restart." This client has no camera publishing yet, so there is nothing to say about the camera. **Difference from the original** (`~/src/fluxer-soundboard`). `VoiceSessionRestore.ts` saves a snapshot of the voice session all the time: a heartbeat every minute, plus on `beforeunload`. That snapshot covers any restart and expires after 5 minutes. After a restart the original shows a nagbar ("… restarted while you were connected to …", with "Reconnect" / "Not now") and never joins by itself. Its Electron relaunch (`ShellSelfUpdate.ts`: `relaunchStableLaunchPath` / `quitAndInstall`) has no special voice handling. This PR joins without a click, but only after the app's own update restart, as #784 asks. **Verified with:** - `crates/fluxer-core/tests/voice_rejoin.rs`, 16 tests: - the intent is written before the install (`Apply`) in a call, and not outside voice; - it is not written by the install on quit; - it is forgotten after a failed install and after a logout; - a normal start never joins; - the next start joins with the same mute/deafen; - it is consumed once (a second `READY` does not join); - an expired intent is ignored, and one just within the limit still joins; - another account's intent is ignored; - a channel that is gone or not a voice channel is not joined, and nothing is shown; - a channel without `CONNECT` is not joined, and nothing is shown; - the cached `READY` does not join; - a user who already joined by hand is not moved; - a DM call is joined only after `CALL_CREATE`, and not when it is announced too late. - `crates/fluxer-platform/tests/settings_rejoin.rs`: the `[rejoin_voice]` table round-trips (guild and DM); a table that cannot be read is none. - `crates/fluxer-ui/tests/update.rs`: the confirmation text, with and without a screen share. - `apps/fluxer/tests/rejoin_voice_runtime.rs` against the dev server (`voice` scenario, FakeRoom, the `--devserver` dry-run installer): 1. First run: join Hangout, mute, get an update ready, click the button, then "Restart". The intent lands in `settings.toml`. 2. Next start with the same settings: back in Hangout by itself, still muted, and connected. The intent is gone from the file. 3. A third, ordinary start does not join. - `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` ends with `==> xtask ci: all steps passed`. No goldens changed. **Not tested on Windows.** No test runs a real relaunch on Windows, since none can run here. That covers Velopack's apply-and-restart, and the persist write landing before Velopack takes over. The core logic and the settings write are the same on both platforms. The AppImage re-exec on Linux is not exercised end to end either: the runtime test uses the dry run, which installs nothing and does not exit, so the "next start" is a new runtime on the same settings directory. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
An install that relaunches the app (UpdateCommand::Apply { relaunch: true })
while the user is in voice first writes a [rejoin_voice] intent (account,
guild or DM call, channel, self-mute/deafen, time) with a SaveSettings queued
just before the Apply. The next start consumes it once at the first live
READY: same account and within 5 minutes, a guild voice channel still there
and connectable is joined with the same switches; a DM call is joined once
its CALL_CREATE/CALL_UPDATE says it still goes. A failed install and a logout
forget it; a normal quit or the install on quit never write it.

The in-call restart confirmation now says the call is rejoined, and that a
screen share is not restarted when the user shares.

Refs #784

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

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

Merged into `textchat` by hand (the merge API returns 405); the commits are in the branch.
charles closed this pull request 2026-11-17 21:40:20 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.