Audio 50: fluxer-core audio sources, Linux capture options and the stream audio rule #340

Closed
opened 2026-11-12 18:34:14 +00:00 by charles · 2 comments
Owner

Plan: docs/superpowers/plans/2026-11-12-textchat.md, section "Task 50" (Audio devices and PipeWire, added 2026-11-12). Design: docs/superpowers/specs/2026-11-12-fluxer-native-audio-devices-design.md. Closes the gaps of #220 and #233 (and #225 item 7).

Task 50: fluxer-core audio sources, Linux capture options and the stream audio rule

Issue: (to be created)

Files:

  • Create: crates/fluxer-core/src/voice/stream/audio_sources.rs
  • Modify: crates/fluxer-core/src/voice/{port.rs,settings.rs,mod.rs}, crates/fluxer-core/src/voice/stream/{state.rs,golive.rs,mod.rs}, crates/fluxer-core/src/event.rs, README
  • Test: crates/fluxer-core/tests/stream_audio_sources.rs

Interfaces:

  • Consumes: Screen share (merged): CaptureCommand, CaptureEvent, AudioRule, AppMatch, VideoSettings::{audio_source_mode, audio_include_sources, audio_exclude_sources}, AudioSourceMatch, VoiceSettingChange.
  • Produces (ports): port::AudioNode(pub BTreeMap<String, String>); CaptureCommand::ListAudioTargets; CaptureEvent::AudioTargets(Option<Vec<AudioNode>>) (None = no PipeWire); AppMatch::Props(BTreeMap<String, String>); AudioRule.exclude: Vec<BTreeMap<String, String>> (mirrors Task 49; Default empty); UserAction::RefreshAudioSources; stream::AudioTargets::{NotAsked, Loading, Unavailable, Listed(Vec<AudioNode>)} (Default = NotAsked) in Streams::audio_targets.
  • Produces (settings): settings::LinuxAudioCapture { only_speakers: bool, only_default_speakers: bool, ignore_input_media: bool, ignore_virtual: bool, ignore_devices: bool, granular_select: bool, device_select: bool } with Default = true, true, true, false, true, false, false (app/state/VoiceSettings.ts:491-497); VideoSettings::linux_capture: LinuxAudioCapture; VoiceSettingChange::LinuxAudioCapture(LinuxAudioCaptureChange::{OnlySpeakers(bool), OnlyDefaultSpeakers(bool), IgnoreInputMedia(bool), IgnoreVirtual(bool), IgnoreDevices(bool), GranularSelect(bool), DeviceSelect(bool)}) (IgnoreDevices(true) clears device_select, DeviceSelect(true) clears ignore_devices, as StreamSettingsMenuContent.tsx:1130-1160); persisted as linux_audio_capture_<field> (audio spec §4).
  • Produces (pure, audio_sources.rs, ports of app/utils/LinuxAudioSourceRules.ts and ScreenShareAudioSummary.ts): AudioSourceFilter { granular: bool, device_select: bool, ignore_virtual: bool }; AudioSourceItem { name: String, pattern: AudioSourceMatch }; items_for_node(&AudioNode, AudioSourceFilter) -> Vec<AudioSourceItem>; menu_items(&[AudioNode], AudioSourceFilter, selected: &[AudioSourceMatch]) -> Vec<AudioSourceItem> (map, de-duplicate, then append selected patterns not listed, named by display_name); display_name(&AudioSourceMatch) -> Option<String>; routable_patterns(&[AudioSourceMatch]) -> Vec<BTreeMap<String, String>> (toNativeLinuxAudioPatterns); AudioSummary::{NoAudio, EntireSystem, Source(String), Custom, Apps(usize)} with audio_summary(&VideoSettings) -> AudioSummary and label() -> String ("No audio", "Entire system", the name, "Custom", "1 app"/"N apps"); toggle_include(&VideoSettings, &AudioSourceMatch) -> Vec<VoiceSettingChange> and toggle_exclude(..) (the mode switch rules of AudioSourcePickerLinux.tsx handleToggleApp/handleToggleExcludeApp), pick_system() / pick_none() -> Vec<VoiceSettingChange>.
  • Produces (behaviour): RefreshAudioSources → Effect::Capture(CaptureCommand::ListAudioTargets) and Loading (not again while Loading); AudioTargets(Some(v)) → Listed(v), None → Unavailable; stream_audio_rule for a screen share (or system picker) builds the rule from the settings (audio spec §3.3) — window shares unchanged; a change of mode, lists or `linux_c

🤖 Generated with Claude Code

Plan: `docs/superpowers/plans/2026-11-12-textchat.md`, section "Task 50" (Audio devices and PipeWire, added 2026-11-12). Design: `docs/superpowers/specs/2026-11-12-fluxer-native-audio-devices-design.md`. Closes the gaps of #220 and #233 (and #225 item 7). ### Task 50: `fluxer-core` audio sources, Linux capture options and the stream audio rule **Issue:** (to be created) **Files:** - Create: `crates/fluxer-core/src/voice/stream/audio_sources.rs` - Modify: `crates/fluxer-core/src/voice/{port.rs,settings.rs,mod.rs}`, `crates/fluxer-core/src/voice/stream/{state.rs,golive.rs,mod.rs}`, `crates/fluxer-core/src/event.rs`, README - Test: `crates/fluxer-core/tests/stream_audio_sources.rs` **Interfaces:** - Consumes: Screen share (merged): `CaptureCommand`, `CaptureEvent`, `AudioRule`, `AppMatch`, `VideoSettings::{audio_source_mode, audio_include_sources, audio_exclude_sources}`, `AudioSourceMatch`, `VoiceSettingChange`. - Produces (ports): `port::AudioNode(pub BTreeMap<String, String>)`; `CaptureCommand::ListAudioTargets`; `CaptureEvent::AudioTargets(Option<Vec<AudioNode>>)` (`None` = no PipeWire); `AppMatch::Props(BTreeMap<String, String>)`; `AudioRule.exclude: Vec<BTreeMap<String, String>>` (mirrors Task 49; `Default` empty); `UserAction::RefreshAudioSources`; `stream::AudioTargets::{NotAsked, Loading, Unavailable, Listed(Vec<AudioNode>)}` (`Default` = `NotAsked`) in `Streams::audio_targets`. - Produces (settings): `settings::LinuxAudioCapture { only_speakers: bool, only_default_speakers: bool, ignore_input_media: bool, ignore_virtual: bool, ignore_devices: bool, granular_select: bool, device_select: bool }` with `Default` = `true, true, true, false, true, false, false` (`app/state/VoiceSettings.ts:491-497`); `VideoSettings::linux_capture: LinuxAudioCapture`; `VoiceSettingChange::LinuxAudioCapture(LinuxAudioCaptureChange::{OnlySpeakers(bool), OnlyDefaultSpeakers(bool), IgnoreInputMedia(bool), IgnoreVirtual(bool), IgnoreDevices(bool), GranularSelect(bool), DeviceSelect(bool)})` (`IgnoreDevices(true)` clears `device_select`, `DeviceSelect(true)` clears `ignore_devices`, as `StreamSettingsMenuContent.tsx:1130-1160`); persisted as `linux_audio_capture_<field>` (audio spec §4). - Produces (pure, `audio_sources.rs`, ports of `app/utils/LinuxAudioSourceRules.ts` and `ScreenShareAudioSummary.ts`): `AudioSourceFilter { granular: bool, device_select: bool, ignore_virtual: bool }`; `AudioSourceItem { name: String, pattern: AudioSourceMatch }`; `items_for_node(&AudioNode, AudioSourceFilter) -> Vec<AudioSourceItem>`; `menu_items(&[AudioNode], AudioSourceFilter, selected: &[AudioSourceMatch]) -> Vec<AudioSourceItem>` (map, de-duplicate, then append selected patterns not listed, named by `display_name`); `display_name(&AudioSourceMatch) -> Option<String>`; `routable_patterns(&[AudioSourceMatch]) -> Vec<BTreeMap<String, String>>` (`toNativeLinuxAudioPatterns`); `AudioSummary::{NoAudio, EntireSystem, Source(String), Custom, Apps(usize)}` with `audio_summary(&VideoSettings) -> AudioSummary` and `label() -> String` ("No audio", "Entire system", the name, "Custom", "1 app"/"N apps"); `toggle_include(&VideoSettings, &AudioSourceMatch) -> Vec<VoiceSettingChange>` and `toggle_exclude(..)` (the mode switch rules of `AudioSourcePickerLinux.tsx` `handleToggleApp`/`handleToggleExcludeApp`), `pick_system() / pick_none() -> Vec<VoiceSettingChange>`. - Produces (behaviour): `RefreshAudioSources` → `Effect::Capture(CaptureCommand::ListAudioTargets)` and `Loading` (not again while `Loading`); `AudioTargets(Some(v))` → `Listed(v)`, `None` → `Unavailable`; `stream_audio_rule` for a screen share (or system picker) builds the rule from the settings (audio spec §3.3) — window shares unchanged; a change of mode, lists or `linux_c 🤖 Generated with [Claude Code](https://claude.com/claude-code)
charles added this to the Text chat milestone 2026-11-12 18:34:14 +00:00
Author
Owner

Review of Text chat 50 (local commit 5daaf34; branch not pushed, so no PR exists yet — posting here on the issue).

  • (1) All 25 plan tests exist in crates/fluxer-core/tests/stream_audio_sources.rs and assert the spec values (defaults true,true,true,false,true,false,false; keys linux_audio_capture_*; fluxer.target.objects with \n round-trips). OK.
  • (2) Interfaces block: every name/signature present as written. OK.
  • (3) fluxer-core gains no dependency; no fixtures, secrets or paths. OK. Port of mapLinuxAudioNodeToItems / toNativeLinuxAudioPatterns / buildLinuxNativeAudioRule / summary / picker toggles checked line by line against the fork: matches.
  • minor: apps/fluxer/src/capture_rt.rs touched outside the Files list (needed to compile); interim drops AppMatch::Props so specific mode falls back to the system mix in fluxer-capture until Task 52.
  • minor: branch textchat-50-core-stream-audio-sources is not pushed and has no PR.
  • (5) cargo xtask ci: NOT completed by this reviewer (run was still compiling when the review had to return); must be re-run before approval.

Verdict: no blocking code findings; not approved until the branch is pushed and ci is green.

Review of Text chat 50 (local commit 5daaf34; branch not pushed, so no PR exists yet — posting here on the issue). - (1) All 25 plan tests exist in crates/fluxer-core/tests/stream_audio_sources.rs and assert the spec values (defaults true,true,true,false,true,false,false; keys linux_audio_capture_*; fluxer.target.objects with \n round-trips). OK. - (2) Interfaces block: every name/signature present as written. OK. - (3) fluxer-core gains no dependency; no fixtures, secrets or paths. OK. Port of mapLinuxAudioNodeToItems / toNativeLinuxAudioPatterns / buildLinuxNativeAudioRule / summary / picker toggles checked line by line against the fork: matches. - minor: apps/fluxer/src/capture_rt.rs touched outside the Files list (needed to compile); interim drops AppMatch::Props so specific mode falls back to the system mix in fluxer-capture until Task 52. - minor: branch textchat-50-core-stream-audio-sources is not pushed and has no PR. - (5) cargo xtask ci: NOT completed by this reviewer (run was still compiling when the review had to return); must be re-run before approval. Verdict: no blocking code findings; not approved until the branch is pushed and ci is green.
Author
Owner

Independent review: Text chat 50 (core stream audio sources), commit 5daaf34

Posted on the issue because no PR exists yet: textchat-50-core-stream-audio-sources is still local only and not on origin. I reviewed 9fcc13d..5daaf34, which is one commit on top of origin/textchat.

Checks

  1. All 25 tests the plan names are in crates/fluxer-core/tests/stream_audio_sources.rs, plus audio_rule_default_has_no_exclude. They assert the original's values: the defaults true,true,true,false,true,false,false, the linux_audio_capture_* keys, the \n round trip of a target pattern, and the labels "No audio", "Entire system", the source's name, "Custom", "1 app" and "2 apps".
  2. The Interfaces block matches the code exactly: AudioNode, ListAudioTargets, AudioTargets(Option<..>), AppMatch::Props, AudioRule.exclude, RefreshAudioSources, stream::AudioTargets with Default = NotAsked, LinuxAudioCapture / LinuxAudioCaptureChange with their mutual exclusion, and the audio_sources functions (items_for_node, menu_items, display_name, routable_patterns, AudioSummary / audio_summary / label, toggle_include, toggle_exclude, pick_system, pick_none, and screen_share_rule).
  3. I checked the port line by line against the fork: LinuxAudioSourceRules.ts, buildLinuxNativeAudioRule, resolveScreenShareAudioSummary and the AudioSourcePickerLinux.tsx handlers. It is faithful, including the ?? and truthiness cases. The original's {node.virtual:true} exclude and its "specific has no onlySpeakers" behaviour are covered by fluxer-capture's from_audio_rule.
  4. Invariants: fluxer-core gains no dependency, does no I/O and holds no file data. No new fixtures, because this task adds no server events. No secrets or paths. Nothing in the code indexes into or unwraps node properties, so they cannot panic it.
  5. cargo xtask ci (CARGO_BUILD_JOBS=4, its own target dir) exited 0.

Findings

  • minor: The commit edits apps/fluxer/src/capture_rt.rs, which is outside the task's crate and not in its Files list. The edit is needed for the exhaustive matches. As an interim measure, ListAudioTargets answers None and AppMatch::Props is dropped in audio_rule, so a "specific" share with only property patterns falls back to the system mix, and exclude is not routed. This is no regression, because before this change stream_audio_rule ignored the lists, and no UI can select sources until Task 53. Task 52 (#342) must replace both stubs; a follow-up issue should track this before merge.
  • minor: The rule is re-sent only while golive.with_audio holds, and that flag is fixed when the share starts. A share started in mode "none" (or with desktop audio off) stays silent if the user picks "Entire system" or an app while live. The original publishes the audio track in that case (ensureLinuxScreenShareAudioPublication).
  • minor: RefreshAudioSources does nothing while the state is Loading. If an answer never arrives (for example, the capture thread is gone), the submenu stays loading until restart. This is acceptable because Task 52 must always answer.
  • minor: toggle_include returns two changes (mode, then list). Applied one at a time while live, they can send two CaptureCommand::Updates in a row, and the first carries a transient rule.

Verdict: approve. There are no blocking findings and local CI is green. The branch still needs to be pushed and its PR opened (Closes #340).

## Independent review: Text chat 50 (core stream audio sources), commit 5daaf34 Posted on the issue because no PR exists yet: `textchat-50-core-stream-audio-sources` is still local only and not on origin. I reviewed `9fcc13d..5daaf34`, which is one commit on top of origin/textchat. **Checks** 1. All 25 tests the plan names are in `crates/fluxer-core/tests/stream_audio_sources.rs`, plus `audio_rule_default_has_no_exclude`. They assert the original's values: the defaults `true,true,true,false,true,false,false`, the `linux_audio_capture_*` keys, the `\n` round trip of a target pattern, and the labels "No audio", "Entire system", the source's name, "Custom", "1 app" and "2 apps". 2. The Interfaces block matches the code exactly: `AudioNode`, `ListAudioTargets`, `AudioTargets(Option<..>)`, `AppMatch::Props`, `AudioRule.exclude`, `RefreshAudioSources`, `stream::AudioTargets` with `Default = NotAsked`, `LinuxAudioCapture` / `LinuxAudioCaptureChange` with their mutual exclusion, and the `audio_sources` functions (`items_for_node`, `menu_items`, `display_name`, `routable_patterns`, `AudioSummary` / `audio_summary` / `label`, `toggle_include`, `toggle_exclude`, `pick_system`, `pick_none`, and `screen_share_rule`). 3. I checked the port line by line against the fork: `LinuxAudioSourceRules.ts`, `buildLinuxNativeAudioRule`, `resolveScreenShareAudioSummary` and the `AudioSourcePickerLinux.tsx` handlers. It is faithful, including the `??` and truthiness cases. The original's `{node.virtual:true}` exclude and its "specific has no onlySpeakers" behaviour are covered by `fluxer-capture`'s `from_audio_rule`. 4. Invariants: fluxer-core gains no dependency, does no I/O and holds no file data. No new fixtures, because this task adds no server events. No secrets or paths. Nothing in the code indexes into or unwraps node properties, so they cannot panic it. 5. `cargo xtask ci` (CARGO_BUILD_JOBS=4, its own target dir) exited 0. **Findings** - minor: The commit edits `apps/fluxer/src/capture_rt.rs`, which is outside the task's crate and not in its Files list. The edit is needed for the exhaustive matches. As an interim measure, `ListAudioTargets` answers `None` and `AppMatch::Props` is dropped in `audio_rule`, so a "specific" share with only property patterns falls back to the system mix, and `exclude` is not routed. This is no regression, because before this change `stream_audio_rule` ignored the lists, and no UI can select sources until Task 53. Task 52 (#342) must replace both stubs; a follow-up issue should track this before merge. - minor: The rule is re-sent only while `golive.with_audio` holds, and that flag is fixed when the share starts. A share started in mode "none" (or with desktop audio off) stays silent if the user picks "Entire system" or an app while live. The original publishes the audio track in that case (`ensureLinuxScreenShareAudioPublication`). - minor: `RefreshAudioSources` does nothing while the state is `Loading`. If an answer never arrives (for example, the capture thread is gone), the submenu stays loading until restart. This is acceptable because Task 52 must always answer. - minor: `toggle_include` returns two changes (mode, then list). Applied one at a time while live, they can send two `CaptureCommand::Update`s in a row, and the first carries a transient rule. **Verdict: approve.** There are no blocking findings and local CI is green. The branch still needs to be pushed and its PR opened (Closes #340).
Sign in to join this conversation.
No milestone
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#340
No description provided.