diff --git a/docs/configuration.md b/docs/configuration.md index 4c46ddb..f367a7f 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -143,6 +143,9 @@ servers, container/PID namespace differences, and large environments can prevent enrichment. Environment reads are limited to 64 KiB; only the two allowlisted IDs are retained, never complete environment contents or command lines. Proton may report a Wine executable while its working directory identifies the game. +The Config tab lists normalized fields for each observed stream, including +`unavailable` values. Navigate down through Settings to inspect them; raw +environment contents and command lines are never included. Applications may set `selector_mode = "all"` to require every selector to match (AND). The default `"any"` preserves OR matching for existing profiles. diff --git a/fader_master/src/ipc.rs b/fader_master/src/ipc.rs index 5d303ee..82d89d1 100644 --- a/fader_master/src/ipc.rs +++ b/fader_master/src/ipc.rs @@ -260,6 +260,8 @@ pub struct MixerSnapshot { #[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)] pub struct ConfigurationSnapshot { + #[serde(default)] + pub stream_metadata: Vec, pub revision: u64, pub dirty: bool, pub applied_revision: u64, diff --git a/fader_master/src/live.rs b/fader_master/src/live.rs index b5df102..e77ac70 100644 --- a/fader_master/src/live.rs +++ b/fader_master/src/live.rs @@ -118,6 +118,7 @@ pub(crate) fn configuration_snapshot( error: None, profile_id: profile.id().to_string(), profile_path: None, + stream_metadata: Vec::new(), available_profiles: vec![profile.id().to_string()], mixer_orientation: match profile.mixer_orientation() { fader_config::MixerOrientation::Vertical => crate::ipc::MixerOrientation::Vertical, @@ -525,6 +526,48 @@ impl LiveMixerState { .unwrap_or_else(|| "offline".to_owned()); objects.push(output); } + let mut configuration = self.configuration.clone(); + configuration.stream_metadata = self + .metadata + .iter() + .flat_map(|(handle, view)| { + [ + ( + "application.name", + fader_core::MetadataField::ApplicationName, + ), + ("application.id", fader_core::MetadataField::ApplicationId), + ( + "application.process.binary", + fader_core::MetadataField::ProcessBinary, + ), + ("media.name", fader_core::MetadataField::MediaName), + ( + "application.process.executable", + fader_core::MetadataField::ProcessExecutable, + ), + ( + "application.process.working_directory", + fader_core::MetadataField::ProcessWorkingDirectory, + ), + ("steam.app_id", fader_core::MetadataField::SteamAppId), + ("steam.game_id", fader_core::MetadataField::SteamGameId), + ] + .map(|(name, field)| { + format!( + "Stream {} · {name}={}", + handle.backend_id(), + view.metadata + .value(field) + .unwrap_or("unavailable") + .chars() + .filter(|c| !c.is_control()) + .take(512) + .collect::() + ) + }) + }) + .collect(); MixerSnapshot { revision: self.view_revision(), backend: self.backend.clone(), @@ -532,7 +575,7 @@ impl LiveMixerState { objects, devices: self.devices.clone(), discovered_midi_ports: self.discovered_midi_ports.clone(), - configuration: self.configuration.clone(), + configuration, } } @@ -1096,6 +1139,31 @@ impl LiveMixerState { mod reconfigure_tests { use super::*; + #[test] + fn stream_diagnostics_expose_only_normalized_fields_including_unknowns() { + let profile = Profile::parse(include_str!("../../examples/profiles/desktop.toml")).unwrap(); + let mut state = LiveMixerState::new(Gain::UNITY, "pulse", &profile).unwrap(); + state + .worker_event(WorkerEvent::StreamMetadata { + stream: StreamHandle::new(fader_core::BackendEpoch::new(1), 7, 1), + metadata: StreamMetadata::new() + .with_application_name("Game") + .with_raw_property("SECRET", "never-publish") + .with_process_metadata( + Some("/games/game".into()), + None, + Some("123".into()), + None, + ), + volume_writable: true, + }) + .unwrap(); + let text = format!("{:?}", state.snapshot().configuration); + assert!(text.contains("steam.app_id=123")); + assert!(text.contains("steam.game_id=unavailable")); + assert!(!text.contains("never-publish")); + } + #[test] fn midi_controls_survive_repeated_reconfiguration() { let source = include_str!("../../examples/profiles/desktop.toml"); diff --git a/fader_master/src/tui_client.rs b/fader_master/src/tui_client.rs index f0af9d9..0ef9ac8 100644 --- a/fader_master/src/tui_client.rs +++ b/fader_master/src/tui_client.rs @@ -110,6 +110,7 @@ impl IpcMixerClient { error: snapshot.configuration.error, profile_id: snapshot.configuration.profile_id, profile_path: snapshot.configuration.profile_path, + stream_metadata: snapshot.configuration.stream_metadata, available_profiles: snapshot.configuration.available_profiles, mixer_orientation: match snapshot.configuration.mixer_orientation { crate::ipc::MixerOrientation::Vertical => tui::MixerOrientation::Vertical, diff --git a/sound/src/process_metadata.rs b/sound/src/process_metadata.rs index 61a7338..a2cf30e 100644 --- a/sound/src/process_metadata.rs +++ b/sound/src/process_metadata.rs @@ -260,4 +260,60 @@ mod tests { ); } } + + #[test] + fn native_proton_sandbox_and_exit_fixtures_preserve_partial_unknowns() { + struct Fixture { + executable: Option<&'static str>, + environment: Option<&'static [u8]>, + exits: bool, + reads: Cell, + } + impl ProcessSource for Fixture { + fn start_time(&self, _: u32) -> Option { + let n = self.reads.get(); + self.reads.set(n + 1); + (!(self.exits && n > 0)).then_some(10) + } + fn link(&self, _: u32, _: &str) -> Option { + self.executable.map(str::to_owned) + } + fn environment(&self, _: u32) -> Option> { + self.environment.map(<[u8]>::to_vec) + } + } + for executable in [ + Some("/games/native/game"), + Some("/proton/files/bin/wine64"), + None, + ] { + let fields = inspect( + &Fixture { + executable, + environment: Some(b"SteamAppId=123\0SteamGameId=123\0"), + exits: false, + reads: Cell::new(0), + }, + 1, + ); + assert_eq!(fields.executable.as_deref(), executable); + assert_eq!(fields.steam_app_id.as_deref(), Some("123")); + } + for exits in [false, true] { + let fields = inspect( + &Fixture { + executable: Some("/bin/game"), + environment: None, + exits, + reads: Cell::new(0), + }, + 1, + ); + assert_eq!( + fields.executable.as_deref(), + (!exits).then_some("/bin/game") + ); + assert!(fields.steam_app_id.is_none()); + } + } } diff --git a/task.md b/task.md index c946606..ced5d54 100644 --- a/task.md +++ b/task.md @@ -603,8 +603,9 @@ YouTube capture use case; no browser-name condition is needed. (executable, working_directory, steam.app_id, steam.game_id), local-machine guard and start-time consistency check. Fixture coverage includes missing process data, PID reuse, Steam/path-only cases, malformed IDs and bounded - reads. Dedicated per-stream metadata diagnostics and fuller sandbox/native - integration qualification remain pending; do not mark this milestone complete. + reads. Config now includes per-stream normalized metadata diagnostics, including + explicit unavailable values; native/Proton-like, restricted-environment and + exit-during-read fixtures are covered. Real-process checks remain opt-in. - [ ] **M13.3 Targeted MPRIS controls:** add Play, Pause and PlayPause via matched player identity/desktop ID/bus name, without keyboard simulation. Dependencies: M13.1, M13.2, M5.2, M9.5. Acceptance: a QBZ-specific binding diff --git a/tui/examples/doc_screenshots.rs b/tui/examples/doc_screenshots.rs index f8d5ec9..d68eac6 100644 --- a/tui/examples/doc_screenshots.rs +++ b/tui/examples/doc_screenshots.rs @@ -145,6 +145,7 @@ fn snapshot(mixer_orientation: MixerOrientation) -> MixerSnapshot { error: None, profile_id: "desktop".to_owned(), profile_path: Some("/home/alex/.config/fader_master/profiles/desktop.toml".to_owned()), + stream_metadata: Vec::new(), available_profiles: vec!["desktop".to_owned()], mixer_orientation, status_display: tui::StatusDisplayMode::Symbol, diff --git a/tui/src/lib.rs b/tui/src/lib.rs index 53f42bf..6607977 100644 --- a/tui/src/lib.rs +++ b/tui/src/lib.rs @@ -92,6 +92,7 @@ pub struct DiscoveredMidiPort { #[derive(Clone, Debug, Default, PartialEq)] pub struct ConfigurationSnapshot { + pub stream_metadata: Vec, pub revision: u64, pub dirty: bool, pub applied_revision: u64, @@ -1304,6 +1305,7 @@ struct EditorInput { } enum SettingsRow { + StreamMetadata(String), Theme, MixerOrientation, StatusDisplay, @@ -2368,6 +2370,14 @@ impl LiveTui { backend_id: port.backend_id.clone(), } })); + rows.extend( + self.snapshot + .configuration + .stream_metadata + .iter() + .cloned() + .map(SettingsRow::StreamMetadata), + ); rows } @@ -4717,6 +4727,7 @@ impl LiveTui { " " }; let value = match row { + SettingsRow::StreamMetadata(value) => value.clone(), SettingsRow::Theme => format!("Theme {} [←→]", self.theme.label()), SettingsRow::MixerOrientation => { format!("Mixer layout {} [←→]", config.mixer_orientation.label()) @@ -7289,6 +7300,7 @@ mod tests { error: None, profile_id: "desktop".into(), profile_path: Some("/home/test/.config/fader_master/profiles/desktop.toml".into()), + stream_metadata: Vec::new(), available_profiles: vec!["desktop".into(), "streaming".into()], mixer_orientation: MixerOrientation::Vertical, status_display: StatusDisplayMode::Detailed,