Text chat 50: core stream audio sources (#340) #356

Manually merged
charles merged 5 commits from textchat-50-core-stream-audio-sources into textchat 2026-11-12 22:32:22 +00:00
Owner

What this builds

fluxer-core audio sources, Linux capture options and the stream audio rule (audio spec §3.3, §4; plan Task 50).

  • Ports: AudioNode, CaptureCommand::ListAudioTargets, CaptureEvent::AudioTargets(Option<Vec<AudioNode>>), AppMatch::Props, AudioRule.exclude.
  • State: UserAction::RefreshAudioSources asks once (not again while Loading); the answer becomes Listed(v) or Unavailable in Streams::audio_targets.
  • Settings: LinuxAudioCapture (defaults from VoiceSettings.ts:491-497) in VideoSettings::linux_capture, with VoiceSettingChange::LinuxAudioCapture(..). IgnoreDevices and DeviceSelect turn each other off. Persisted as linux_audio_capture_<field>; older settings files still load.
  • Pure helpers (audio_sources.rs): ports of LinuxAudioSourceRules.ts and ScreenShareAudioSummary.ts: items_for_node, menu_items, display_name, routable_patterns, audio_summary/label, toggle_include/toggle_exclude, pick_system/pick_none.
  • Rule: a screen share or system-picker share builds its rule from the mode, the lists and the Linux switches (screen_share_rule). Window shares are unchanged. A change while live re-sends CaptureCommand::Update.

Testing

  • crates/fluxer-core/tests/stream_audio_sources.rs has the 25 tests named in the plan. I wrote them first and confirmed they failed before writing the code.
  • apps/fluxer capture_rt::tests::property_patterns_alone_fall_back_to_system_audio covers the review fix.
  • FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci passes locally after merging the current origin/textchat (eaafba9).

Deviations / files outside the Files list

  • apps/fluxer/src/capture_rt.rs changed so the app compiles. ListAudioTargets answers AudioTargets(None), so the submenu stays hidden. AppMatch::Props is not routed and the exclude list is empty. A rule made only of property patterns becomes System. Text chat 52 (#342) replaces all of this.

Closes #340

🤖 Generated with Claude Code

## What this builds `fluxer-core` audio sources, Linux capture options and the stream audio rule (audio spec §3.3, §4; plan Task 50). - **Ports:** `AudioNode`, `CaptureCommand::ListAudioTargets`, `CaptureEvent::AudioTargets(Option<Vec<AudioNode>>)`, `AppMatch::Props`, `AudioRule.exclude`. - **State:** `UserAction::RefreshAudioSources` asks once (not again while `Loading`); the answer becomes `Listed(v)` or `Unavailable` in `Streams::audio_targets`. - **Settings:** `LinuxAudioCapture` (defaults from `VoiceSettings.ts:491-497`) in `VideoSettings::linux_capture`, with `VoiceSettingChange::LinuxAudioCapture(..)`. `IgnoreDevices` and `DeviceSelect` turn each other off. Persisted as `linux_audio_capture_<field>`; older settings files still load. - **Pure helpers (`audio_sources.rs`):** ports of `LinuxAudioSourceRules.ts` and `ScreenShareAudioSummary.ts`: `items_for_node`, `menu_items`, `display_name`, `routable_patterns`, `audio_summary`/`label`, `toggle_include`/`toggle_exclude`, `pick_system`/`pick_none`. - **Rule:** a screen share or system-picker share builds its rule from the mode, the lists and the Linux switches (`screen_share_rule`). Window shares are unchanged. A change while live re-sends `CaptureCommand::Update`. ## Testing - `crates/fluxer-core/tests/stream_audio_sources.rs` has the 25 tests named in the plan. I wrote them first and confirmed they failed before writing the code. - `apps/fluxer` `capture_rt::tests::property_patterns_alone_fall_back_to_system_audio` covers the review fix. - `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` passes locally after merging the current `origin/textchat` (eaafba9). ## Deviations / files outside the Files list - `apps/fluxer/src/capture_rt.rs` changed so the app compiles. `ListAudioTargets` answers `AudioTargets(None)`, so the submenu stays hidden. `AppMatch::Props` is not routed and the exclude list is empty. A rule made only of property patterns becomes `System`. Text chat 52 (#342) replaces all of this. Closes #340 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Refs #340

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Until Text chat 52 routes property patterns, a "specific" rule made only
of them reached fluxer-capture as an empty application list, which WASAPI
refuses and PipeWire treats as capturing nothing. Map it to System.

Refs #340

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

Review round 1, changes per finding:

  • Branch not on the remote (blocking): pushed textchat-50-core-stream-audio-sources and opened this PR, which targets textchat.
  • CI not confirmed (blocking): merged the current origin/textchat (eaafba9). FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci runs to the end and every step passes on c4d2fa7.
  • screen_share_rule on Windows (minor): fixed in 1ca0b0f. capture_rt::audio_rule now maps an Applications rule to System when no entries are left after it drops Props. So WASAPI never gets an empty application list, and PipeWire no longer captures nothing. The core rule is the same on every platform, so the core tests run the same on both runners. New test: property_patterns_alone_fall_back_to_system_audio.
  • RefreshAudioSources can stay Loading (minor): deferred to follow-up #357. It matches the spec ("not again while Loading"); the fix depends on how Text chat 52 reports listing errors.
  • capture_rt.rs outside the Files list (minor): kept, because the app does not compile without it. It is now listed under Deviations in the PR body, and Text chat 52 (#342) replaces it. With the fix above, a specific rule that has only property patterns falls back to system audio as intended.
Review round 1, changes per finding: - **Branch not on the remote (blocking):** pushed `textchat-50-core-stream-audio-sources` and opened this PR, which targets `textchat`. - **CI not confirmed (blocking):** merged the current `origin/textchat` (eaafba9). `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` runs to the end and every step passes on c4d2fa7. - **`screen_share_rule` on Windows (minor):** fixed in 1ca0b0f. `capture_rt::audio_rule` now maps an `Applications` rule to `System` when no entries are left after it drops `Props`. So WASAPI never gets an empty application list, and PipeWire no longer captures nothing. The core rule is the same on every platform, so the core tests run the same on both runners. New test: `property_patterns_alone_fall_back_to_system_audio`. - **`RefreshAudioSources` can stay `Loading` (minor):** deferred to follow-up #357. It matches the spec ("not again while Loading"); the fix depends on how Text chat 52 reports listing errors. - **`capture_rt.rs` outside the Files list (minor):** kept, because the app does not compile without it. It is now listed under Deviations in the PR body, and Text chat 52 (#342) replaces it. With the fix above, a `specific` rule that has only property patterns falls back to system audio as intended.
Author
Owner

Independent review: Text chat 50 (head c4d2fa7)

Scope: git diff origin/textchat..c4d2fa7, the 11 files this task touches.

Checks

  1. Plan tests: all 25 named tests are in crates/fluxer-core/tests/stream_audio_sources.rs, and each asserts what the plan says. The defaults are true, true, true, false, true, false, false (VoiceSettings.ts:491-497). The labels are "No audio", "Entire system", the name, "Custom", "1 app" and "N apps". The fluxer.target.objects value keeps its \n through the U+001E/U+001F encoding. Old files load with the defaults, and a wrong-typed value keeps the default.
  2. Interfaces: every name in the Task 50 Interfaces block exists as written: AudioNode, ListAudioTargets, AudioTargets(Option<Vec<AudioNode>>), AppMatch::Props, AudioRule.exclude (Default is empty), RefreshAudioSources, stream::AudioTargets (Default is NotAsked), LinuxAudioCapture / LinuxAudioCaptureChange, VideoSettings::linux_capture, and the full set of audio_sources functions.
  3. Invariants: fluxer-core gains no dependency. It does no I/O and holds no file data. Nothing here touches the server, fixtures or --record.
  4. Port fidelity: I checked the code line by line against LinuxAudioSourceRules.ts, ScreenShareAudioSummary.ts and ScreenShareStartFlow.ts buildLinuxNativeAudioRule. These all match: the ?? and empty-pid handling, the sink target pattern, the volatile-key stripping, the device target lifting ignoreDevices, and ignoreVirtual (as a flag here; fluxer-capture turns it into a node.virtual exclude).
  5. FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci in a fresh review worktree: all steps passed.

Findings

  • (minor) golive.rs refresh_share: with_audio is fixed when the share starts. A screen share started in mode "None" publishes no audio track. Picking "Entire system" or an app while live then sends nothing (with_audio is false), so stream audio stays off until the share restarts. The original republishes (ensureLinuxScreenShareAudioPublication). No test covers this. Suggest a follow-up issue rather than a fix here.
  • (minor) golive.rs: CaptureCommand::Switch does not update golive.audio. After a window to screen switch, the next unrelated settings change sends an Update whose audio rule differs from the one the capture has. This realigns the capture, so it is harmless, but it does not happen at the switch itself. The audio-on-switch behaviour was there before this task.
  • (minor, already handled) RefreshAudioSources can stay Loading forever if no answer comes. Deferred to follow-up #357, which exists and is open.
  • (minor, already handled) apps/fluxer/src/capture_rt.rs is outside the Files list. The change is needed to keep the build compiling (exhaustive matches), it is listed under Deviations, and Task 52 (#342) replaces it. The fallback to System for rules made only of Props, with its test, is right for now.

No blocking findings.

Verdict: approve. CI is green locally. I did not check the remote runners.

## Independent review: Text chat 50 (head c4d2fa7) Scope: `git diff origin/textchat..c4d2fa7`, the 11 files this task touches. **Checks** 1. Plan tests: all 25 named tests are in `crates/fluxer-core/tests/stream_audio_sources.rs`, and each asserts what the plan says. The defaults are `true, true, true, false, true, false, false` (`VoiceSettings.ts:491-497`). The labels are "No audio", "Entire system", the name, "Custom", "1 app" and "N apps". The `fluxer.target.objects` value keeps its `\n` through the U+001E/U+001F encoding. Old files load with the defaults, and a wrong-typed value keeps the default. 2. Interfaces: every name in the Task 50 Interfaces block exists as written: `AudioNode`, `ListAudioTargets`, `AudioTargets(Option<Vec<AudioNode>>)`, `AppMatch::Props`, `AudioRule.exclude` (`Default` is empty), `RefreshAudioSources`, `stream::AudioTargets` (`Default` is `NotAsked`), `LinuxAudioCapture` / `LinuxAudioCaptureChange`, `VideoSettings::linux_capture`, and the full set of `audio_sources` functions. 3. Invariants: fluxer-core gains no dependency. It does no I/O and holds no file data. Nothing here touches the server, fixtures or `--record`. 4. Port fidelity: I checked the code line by line against `LinuxAudioSourceRules.ts`, `ScreenShareAudioSummary.ts` and `ScreenShareStartFlow.ts` `buildLinuxNativeAudioRule`. These all match: the `??` and empty-pid handling, the sink target pattern, the volatile-key stripping, the device target lifting `ignoreDevices`, and `ignoreVirtual` (as a flag here; `fluxer-capture` turns it into a `node.virtual` exclude). 5. `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` in a fresh review worktree: **all steps passed**. **Findings** - (minor) `golive.rs` `refresh_share`: `with_audio` is fixed when the share starts. A screen share started in mode "None" publishes no audio track. Picking "Entire system" or an app while live then sends nothing (`with_audio` is false), so stream audio stays off until the share restarts. The original republishes (`ensureLinuxScreenShareAudioPublication`). No test covers this. Suggest a follow-up issue rather than a fix here. - (minor) `golive.rs`: `CaptureCommand::Switch` does not update `golive.audio`. After a window to screen switch, the next unrelated settings change sends an `Update` whose audio rule differs from the one the capture has. This realigns the capture, so it is harmless, but it does not happen at the switch itself. The audio-on-switch behaviour was there before this task. - (minor, already handled) `RefreshAudioSources` can stay `Loading` forever if no answer comes. Deferred to follow-up #357, which exists and is open. - (minor, already handled) `apps/fluxer/src/capture_rt.rs` is outside the Files list. The change is needed to keep the build compiling (exhaustive matches), it is listed under Deviations, and Task 52 (#342) replaces it. The fallback to System for rules made only of `Props`, with its test, is right for now. No blocking findings. **Verdict: approve.** CI is green locally. I did not check the remote runners.
charles manually merged commit 173ee74762 into textchat 2026-11-12 22:32:22 +00:00
Sign in to join this conversation.
No description provided.