Name Chrome streams after their browser tabs

A browser extension reports audible tabs to moonmix-tabs-host, which matches
them to PipeWire streams by time and publishes the names for the mixer; streams
of one tab share a row. Ambiguous streams keep the browser's name. Without the
extension, a browser's only running stream shows its MPRIS title.

The smoke test no longer claims real audio hardware.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
nandiandClaude Opus 5.5 committed 2026-11-29 19:26:29 -08:00
1 parent b61d504234
commit e16cc1b2ad
31 files changed
+1830 -15

No files matched your search

+37 -6
View File
@@ -58,6 +58,9 @@ pub(all) struct DeviceChoice {
#derive(Eq, Debug)
pub(all) struct Row {
id : Int32
/// Nodes this row controls: its own id first, then, for a browser tab, the
/// tab's other streams.
members : Array[Int32]
title : String
subtitle : String
/// Icon-theme names to try in order (see icons.mbt).
@@ -91,12 +94,33 @@ pub fn rows(state : State, tab : Tab) -> Array[Row] {
.map(fn(d) { { id: d.id, name: d.name, label: display_title(d), } })
None => []
}
state
.nodes_of(kind)
.map(fn(n) {
// Streams of one browser tab share a row.
let groups : Map[String, Array[Int32]] = Map([])
let nodes = state
.nodes_of(kind)
.filter(fn(n) {
match state.tab_of(n) {
Some(t) =>
match groups.get(t.key) {
Some(g) => {
g.push(n.id)
false
}
None => {
groups.set(t.key, [n.id])
true
}
}
None => true
}
})
nodes.map(fn(n) {
let is_stream = device_kind is Some(_)
let subtitle = if is_stream {
n.media_name
let tab = state.tab_of(n)
let subtitle = if tab is Some(_) {
display_title(n)
} else if is_stream {
state.media_title(n).unwrap_or(n.media_name)
} else if n.name != display_title(n) {
n.name
} else {
@@ -125,7 +149,14 @@ pub fn rows(state : State, tab : Tab) -> Array[Row] {
}
{
id: n.id,
title: display_title(n),
members: match tab {
Some(t) => groups.get(t.key).unwrap_or([n.id])
None => [n.id]
},
title: match tab {
Some(t) if t.title != "" => t.title
_ => display_title(n)
},
subtitle,
icons: if is_stream {
stream_icon_chain(n)