Idle: speaking in a call counts, and Wayland ext-idle-notify-v1 (#1008) #1009

Closed
charles wants to merge 0 commits from fix-1008-idle-in-voice into textchat
Owner

Closes #1008

1. Speaking in a call is activity (fluxer-core)

Cause: the presence's idle clock (presence.rs, IDLE_AFTER, afk_timeout) was fed only by CoreEvent::Idle, the time since the last input. On KDE Plasma Wayland that is input in Flaxative's own windows, so talking in a call while working or playing elsewhere went idle after 10 minutes.

Fix: Voice::transmitting_voice() says whether the user's own voice is actually sent: connected, not effectively muted (self or server mute, deafened, push-to-talk not held, push-to-mute held), and speech behind an open gate or push-to-talk held. App passes it to PresenceState::reduce_own after the voice domains have taken in the event; on every event where it holds, the store records its clock as "last spoke at". idle and afk count from the later of the last input and the last speech (min(idle_for, now - spoke_at)). No audio polling and no I/O in the core: the level reports already arrive about 20 times a second. Op 3 still goes out only when the computed presence changes, so the first words after idle send exactly one update and later bursts send none.

Deviation recorded in docs/parity/dailyuse.md: the original (features/ui/state/Idle.ts) counts input only.

Tests (crates/fluxer-core/tests/idle_in_voice.rs; 4 of 7 fail without the fix): silent in voice for 10 min goes idle; speaking every 4 min for an hour never goes idle and sends no op 3; speaking while self-muted, deafened or behind a closed gate goes idle; push-to-talk held counts; idle, then speaking, gives one op 3 back to online; afk (300 s) follows the same clock; outside a call nothing changes.

2. Real system idle time on Wayland (fluxer-platform)

When the D-Bus probes have no answer and WAYLAND_DISPLAY is set, idle::system_idle now asks the compositor through ext-idle-notify-v1 (crates/fluxer-platform/src/idle/notify.rs). The order is still OS answer (Windows, Mutter, ScreenSaver), then Wayland idle-notify, then the client's own windows.

  • No new dependency: it uses the wayland-client and wayland-protocols (staging) that fluxer-platform already uses for activation.
  • It runs on its own connection and its own thread, started the first time the probe is asked. It binds the first wl_seat and ext_idle_notifier_v1 and uses version 2's get_input_idle_notification when offered (input only, idle inhibitors ignored), else version 1. It reads only idled and resumed. The probe reads the state under a lock and never waits on the compositor.
  • The protocol has no duration, so the notification timeout is 5 s and "idle since" is the time of idled minus 5 s. The idle time is exact above 5 s and reads zero below it, so both the 10-minute idle and the account's afk_timeout (at least 60 s) come out right.
  • Reconnects: a lost connection gets no answer (the windows fallback is used) and is retried after 2 s, doubling up to 60 s. A compositor without the protocol or a seat stops the watcher for good.
  • flaxative --debug-info prints an idle source: line (for example idle source: Wayland ext-idle-notify-v1). The log says idle time source whenever the source changes.

Tests: the watcher's state machine runs over an in-memory session double (idle::notify::tests, 6 tests: idle-since arithmetic for 10 min and 60 s, v1 fallback, protocol missing, reconnect with backoff and reset, backoff cap). Nothing in cargo xtask ci connects to a compositor. The existing ungated let _ = idle::system_idle() in tests/idle.rs now runs on Windows only, because on Linux it would reach the session's compositor. The real check is behind FLUXER_DESKTOP_TESTS=1.

How to verify on KDE Plasma Wayland

  1. flaxative --debug-info shows idle source: Wayland ext-idle-notify-v1.
  2. FLUXER_DESKTOP_TESTS=1 cargo test -p fluxer-platform --test idle idle_notify -- --nocapture: keep still for 12 s, then move the mouse or type in any app.
  3. In the app: type in another application for 10+ minutes without touching Flaxative and stay online. Leave the machine alone for 10 minutes and go idle. Join a call and talk with your hands off the keyboard and mouse for 10+ minutes and stay online. Sit muted and silent for 10 minutes and go idle.

Verification

FLUXER_SCREENSHOT_TESTS=1 FLUXER_LIVEKIT_TESTS=1 cargo xtask ci: ==> xtask ci: all steps passed. The LiveKit tests ran, voice_livekit: 2 passed.

🤖 Generated with Claude Code

Closes #1008 ## 1. Speaking in a call is activity (fluxer-core) **Cause:** the presence's idle clock (`presence.rs`, `IDLE_AFTER`, `afk_timeout`) was fed only by `CoreEvent::Idle`, the time since the last input. On KDE Plasma Wayland that is input in Flaxative's own windows, so talking in a call while working or playing elsewhere went idle after 10 minutes. **Fix:** `Voice::transmitting_voice()` says whether the user's own voice is actually sent: connected, not effectively muted (self or server mute, deafened, push-to-talk not held, push-to-mute held), and speech behind an open gate or push-to-talk held. `App` passes it to `PresenceState::reduce_own` after the voice domains have taken in the event; on every event where it holds, the store records its clock as "last spoke at". `idle` and `afk` count from the later of the last input and the last speech (`min(idle_for, now - spoke_at)`). No audio polling and no I/O in the core: the level reports already arrive about 20 times a second. Op 3 still goes out only when the computed presence changes, so the first words after idle send exactly one update and later bursts send none. **Deviation recorded** in `docs/parity/dailyuse.md`: the original (`features/ui/state/Idle.ts`) counts input only. **Tests** (`crates/fluxer-core/tests/idle_in_voice.rs`; 4 of 7 fail without the fix): silent in voice for 10 min goes idle; speaking every 4 min for an hour never goes idle and sends no op 3; speaking while self-muted, deafened or behind a closed gate goes idle; push-to-talk held counts; idle, then speaking, gives one op 3 back to online; `afk` (300 s) follows the same clock; outside a call nothing changes. ## 2. Real system idle time on Wayland (fluxer-platform) When the D-Bus probes have no answer and `WAYLAND_DISPLAY` is set, `idle::system_idle` now asks the compositor through `ext-idle-notify-v1` (`crates/fluxer-platform/src/idle/notify.rs`). The order is still OS answer (Windows, Mutter, ScreenSaver), then Wayland idle-notify, then the client's own windows. - No new dependency: it uses the `wayland-client` and `wayland-protocols` (`staging`) that `fluxer-platform` already uses for activation. - It runs on its own connection and its own thread, started the first time the probe is asked. It binds the first `wl_seat` and `ext_idle_notifier_v1` and uses version 2's `get_input_idle_notification` when offered (input only, idle inhibitors ignored), else version 1. It reads only `idled` and `resumed`. The probe reads the state under a lock and never waits on the compositor. - The protocol has no duration, so the notification timeout is 5 s and "idle since" is the time of `idled` minus 5 s. The idle time is exact above 5 s and reads zero below it, so both the 10-minute idle and the account's `afk_timeout` (at least 60 s) come out right. - Reconnects: a lost connection gets no answer (the windows fallback is used) and is retried after 2 s, doubling up to 60 s. A compositor without the protocol or a seat stops the watcher for good. - `flaxative --debug-info` prints an `idle source:` line (for example `idle source: Wayland ext-idle-notify-v1`). The log says `idle time source` whenever the source changes. **Tests:** the watcher's state machine runs over an in-memory session double (`idle::notify::tests`, 6 tests: idle-since arithmetic for 10 min and 60 s, v1 fallback, protocol missing, reconnect with backoff and reset, backoff cap). Nothing in `cargo xtask ci` connects to a compositor. The existing ungated `let _ = idle::system_idle()` in `tests/idle.rs` now runs on Windows only, because on Linux it would reach the session's compositor. The real check is behind `FLUXER_DESKTOP_TESTS=1`. ### How to verify on KDE Plasma Wayland 1. `flaxative --debug-info` shows `idle source: Wayland ext-idle-notify-v1`. 2. `FLUXER_DESKTOP_TESTS=1 cargo test -p fluxer-platform --test idle idle_notify -- --nocapture`: keep still for 12 s, then move the mouse or type in any app. 3. In the app: type in another application for 10+ minutes without touching Flaxative and stay online. Leave the machine alone for 10 minutes and go idle. Join a call and talk with your hands off the keyboard and mouse for 10+ minutes and stay online. Sit muted and silent for 10 minutes and go idle. ## Verification `FLUXER_SCREENSHOT_TESTS=1 FLUXER_LIVEKIT_TESTS=1 cargo xtask ci`: `==> xtask ci: all steps passed`. The LiveKit tests ran, `voice_livekit`: 2 passed. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
While connected to voice, every event during which the user's own voice is
sent (speech behind an open gate or push-to-talk held, not muted or
deafened: Voice::transmitting_voice) marks the store's time as the last
speech. Idle and afk count from the later of the last input and the last
speech, so the presence returns to online on the first words and op 3 goes
out only when the computed presence changes. Recorded as a deviation from
the original's Idle.ts in the parity docs.

Refs #1008

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Where the session bus has no idle answer (KDE Plasma on Wayland), the idle
probe now asks the compositor through ext-idle-notify-v1, so input in any
application counts. A watcher on its own connection and thread binds the
first wl_seat and ext_idle_notifier_v1, creates a notification with a 5 s
timeout (version 2's input-only request when offered), and keeps idle-since
from idled (its time less the timeout) and resumed; the probe only reads it
under a lock. A lost connection is retried with a doubling pause up to 60 s;
a compositor without the protocol stops it for good, and the runtime keeps
falling back to the client's own windows.

Uses the wayland-client and wayland-protocols (staging) the crate already
depends on for activation: no new dependency. The state machine is tested
over an in-memory session; the real compositor check is behind
FLUXER_DESKTOP_TESTS=1. --debug-info names the idle source, and the log
says when it changes.

Refs #1008

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

Merged by hand into textchat (c6e29b5b) with the camera acceptance test; the combined tree passed the full gate locally, LiveKit interop included.

Merged by hand into textchat (c6e29b5b) with the camera acceptance test; the combined tree passed the full gate locally, LiveKit interop included.
charles closed this pull request 2026-11-20 09:06:00 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.