fix: store volumes/mutes in profiles + fix hide rule matching

- Snapshot node volumes and mutes when saving a profile; restore
  them on load via setNodeVolume/setNodeMute for each matching node
- Fix hide rules to do exact case-insensitive match on display name
  (alias/nick) instead of regex substring match on PW name, so
  "Speaker" no longer accidentally hides "Gaming Speaker"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
joren
2026-04-02 18:39:28 +02:00
parent 503d69bf59
commit a58df9cdaa
3 changed files with 32 additions and 9 deletions

View File

@@ -322,11 +322,20 @@ export async function saveProfile(name: string) {
});
}
const volumes: Record<string, number> = {};
const mutes: Record<string, boolean> = {};
for (const n of currentNodes) {
volumes[n.name] = n.volume;
mutes[n.name] = n.mute;
}
const profile: PatchbayProfile = {
name,
connections,
hide_rules: [...pb.hide_rules],
merge_rules: [...pb.merge_rules],
volumes,
mutes,
};
patchbay.update(pb => ({
@@ -337,11 +346,26 @@ export async function saveProfile(name: string) {
savePatchbayState();
}
async function applyProfileVolumes(profile: PatchbayProfile) {
if (!profile.volumes && !profile.mutes) return;
const currentNodes = get_store_value(nodes);
for (const n of currentNodes) {
if (profile.volumes?.[n.name] !== undefined) {
await setNodeVolume(n.id, profile.volumes[n.name]);
}
if (profile.mutes?.[n.name] !== undefined) {
await setNodeMute(n.id, profile.mutes[n.name]);
}
}
}
export function loadProfile(name: string) {
patchbay.update(pb => ({ ...pb, active_profile: name }));
const pb = get_store_value(patchbay);
// Always apply connections when explicitly loading a profile
applyPatchbay(pb);
const profile = pb.profiles[name];
if (profile) applyProfileVolumes(profile);
savePatchbayState();
}