feat: expose M13.2 normalized process diagnostics
Expose scrollable per-stream normalized fields with explicit unavailable values and exclude raw secrets. Add native, Proton-like, restricted-read and exit fixtures. Tests: stream_diagnostics regression failed before implementation, now passes; cargo test -p tui --quiet and cargo test -p volume_lib process_metadata --quiet passed. Workspace check and clippy all-targets/all-features passed; cargo fmt and git diff --check passed.
This commit is contained in:
parent
0e224c664b
commit
e0d17d735a
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -260,6 +260,8 @@ pub struct MixerSnapshot {
|
|||
|
||||
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
|
||||
pub struct ConfigurationSnapshot {
|
||||
#[serde(default)]
|
||||
pub stream_metadata: Vec<String>,
|
||||
pub revision: u64,
|
||||
pub dirty: bool,
|
||||
pub applied_revision: u64,
|
||||
|
|
|
|||
|
|
@ -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::<String>()
|
||||
)
|
||||
})
|
||||
})
|
||||
.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");
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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<u32>,
|
||||
}
|
||||
impl ProcessSource for Fixture {
|
||||
fn start_time(&self, _: u32) -> Option<u64> {
|
||||
let n = self.reads.get();
|
||||
self.reads.set(n + 1);
|
||||
(!(self.exits && n > 0)).then_some(10)
|
||||
}
|
||||
fn link(&self, _: u32, _: &str) -> Option<String> {
|
||||
self.executable.map(str::to_owned)
|
||||
}
|
||||
fn environment(&self, _: u32) -> Option<Vec<u8>> {
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
5
task.md
5
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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ pub struct DiscoveredMidiPort {
|
|||
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub struct ConfigurationSnapshot {
|
||||
pub stream_metadata: Vec<String>,
|
||||
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<C: MixerClient> LiveTui<C> {
|
|||
backend_id: port.backend_id.clone(),
|
||||
}
|
||||
}));
|
||||
rows.extend(
|
||||
self.snapshot
|
||||
.configuration
|
||||
.stream_metadata
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(SettingsRow::StreamMetadata),
|
||||
);
|
||||
rows
|
||||
}
|
||||
|
||||
|
|
@ -4717,6 +4727,7 @@ impl<C: MixerClient> LiveTui<C> {
|
|||
" "
|
||||
};
|
||||
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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue