Skip to content

Commit 3fe1f9f

Browse files
committed
fix(demo/web): memoize metadata track name to avoid re-subscribing per catalog frame
The watch inspector read the advertised metadata track name straight off the catalog signal, so the subscription effect tore down and recreated the `meta.json` subscription on every catalog update (e.g. a live encoder-setting tweak), briefly flickering the metadata panel. Derive the track name through a memoized computed so the subscription only re-runs when the name or the active broadcast actually changes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BQ9o9paZnRLpYRgbyjUwFV
1 parent c7410f3 commit 3fe1f9f

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

demo/web/src/index.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -381,16 +381,20 @@ ui.run((effect) => {
381381
// in the catalog's `metadata` list. We read the active broadcast off
382382
// `broadcast.output.active`, subscribe to that track, and decode the JSON value,
383383
// re-subscribing whenever the broadcast (or the advertised track) changes.
384-
ui.run((effect) => {
384+
// Memoize the advertised track name so the subscription below only re-runs when it
385+
// (or the active broadcast) changes, not on every catalog frame (e.g. a live
386+
// encoder-setting tweak rewrites the catalog).
387+
const metaTrackName = ui.computed((effect) => {
385388
const watch = effect.get(activeWatch);
386-
if (!watch) {
387-
metaSignal.set(undefined);
388-
return;
389-
}
390-
391-
const broadcast = effect.get(watch.broadcast.output.active);
389+
if (!watch) return undefined;
392390
const catalog = effect.get(watch.broadcast.output.catalog) as { metadata?: string[] } | undefined;
393-
const trackName = catalog?.metadata?.[0];
391+
return catalog?.metadata?.[0];
392+
});
393+
394+
ui.run((effect) => {
395+
const watch = effect.get(activeWatch);
396+
const broadcast = watch ? effect.get(watch.broadcast.output.active) : undefined;
397+
const trackName = effect.get(metaTrackName);
394398
if (!broadcast || !trackName) {
395399
metaSignal.set(undefined);
396400
return;

0 commit comments

Comments
 (0)