fix(companion): clear stale channel-index refs when a channel is removed

CMD_SET_CHANNEL clearing a slot (empty secret) left bot_channel_idx,
loc_share_channel_idx, and the per-channel melody bitmasks pointing at that
index. A new channel added later at the same slot would then silently
inherit the old one's bot target, Live Share target, or notification
melody. New onChannelRemoved() hook, mirroring onContactRemoved(), turns
the bot/Live Share channel target off (fail closed) and clears the melody
bits for that index.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
MarekZegare4
2026-06-27 00:39:10 +02:00
co-authored by Claude Sonnet 4.6
parent 43c3f43e10
commit 6a394e2d7a
4 changed files with 45 additions and 0 deletions
@@ -79,5 +79,10 @@ public:
// Locator/Live Share target) drop a reference that would otherwise dangle.
// Default no-op.
virtual void onContactRemoved(const uint8_t* pub_key) {}
// A channel slot was cleared (companion app set it to an empty secret).
// Drop any setting that referenced it by index — otherwise a new channel
// added later at the same slot would silently inherit the old one's bot/
// share target or notification melody. Default no-op.
virtual void onChannelRemoved(uint8_t channel_idx) {}
virtual void loop() = 0;
};