feat: use sessionKey for bell comparison in pill badges
Update updatePillBell and updateSessionPill to build a viewingKey that accounts for remote sessions (_viewingRemoteId prefix) and compare using s.sessionKey || s.name instead of s.name alone. This prevents false bell suppression when a local session shares a name with a remote session — the two are now distinguished by their fully-qualified key (remoteId:name vs plain name).
This commit is contained in:
@@ -1039,8 +1039,9 @@ function showToast(msg) {
|
|||||||
function updatePillBell() {
|
function updatePillBell() {
|
||||||
const el = $('session-pill-bell');
|
const el = $('session-pill-bell');
|
||||||
if (!el) return;
|
if (!el) return;
|
||||||
|
const viewingKey = _viewingRemoteId ? (_viewingRemoteId + ':' + _viewingSession) : _viewingSession;
|
||||||
const hasBell = _currentSessions.some(
|
const hasBell = _currentSessions.some(
|
||||||
(s) => s.name !== _viewingSession && s.bell && s.bell.unseen_count > 0,
|
(s) => (s.sessionKey || s.name) !== viewingKey && s.bell && s.bell.unseen_count > 0,
|
||||||
);
|
);
|
||||||
if (hasBell) el.classList.remove('hidden'); else el.classList.add('hidden');
|
if (hasBell) el.classList.remove('hidden'); else el.classList.add('hidden');
|
||||||
}
|
}
|
||||||
@@ -1872,8 +1873,9 @@ function updateSessionPill(sessions) {
|
|||||||
if (_viewMode !== 'fullscreen') return;
|
if (_viewMode !== 'fullscreen') return;
|
||||||
var pillBell = $('session-pill-bell');
|
var pillBell = $('session-pill-bell');
|
||||||
if (!pillBell) return;
|
if (!pillBell) return;
|
||||||
|
var viewingKey = _viewingRemoteId ? (_viewingRemoteId + ':' + _viewingSession) : _viewingSession;
|
||||||
var othersWithBell = sessions.filter(function(s) {
|
var othersWithBell = sessions.filter(function(s) {
|
||||||
return s.name !== _viewingSession &&
|
return (s.sessionKey || s.name) !== viewingKey &&
|
||||||
s.bell && s.bell.unseen_count > 0 &&
|
s.bell && s.bell.unseen_count > 0 &&
|
||||||
(s.bell.seen_at === null || s.bell.last_fired_at > s.bell.seen_at);
|
(s.bell.seen_at === null || s.bell.last_fired_at > s.bell.seen_at);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2494,3 +2494,52 @@ def test_device_name_change_updates_document_title() -> None:
|
|||||||
assert "document.title" in body, (
|
assert "document.title" in body, (
|
||||||
"bindStaticEventListeners device-name handler must update document.title"
|
"bindStaticEventListeners device-name handler must update document.title"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# ─── task-4-frontend-session-key-comparison ─────────────────────────────────
|
||||||
|
|
||||||
|
|
||||||
|
def test_update_pill_bell_uses_session_key_or_name() -> None:
|
||||||
|
"""updatePillBell must compare using sessionKey||name against a viewingKey
|
||||||
|
that accounts for remote sessions (_viewingRemoteId prefix)."""
|
||||||
|
match = re.search(
|
||||||
|
r"function updatePillBell\s*\(\s*\)\s*\{(.*?)\n\}",
|
||||||
|
_JS,
|
||||||
|
re.DOTALL,
|
||||||
|
)
|
||||||
|
assert match, "updatePillBell function not found"
|
||||||
|
body = match.group(1)
|
||||||
|
# Must build viewingKey using _viewingRemoteId
|
||||||
|
assert "_viewingRemoteId" in body, (
|
||||||
|
"updatePillBell must reference _viewingRemoteId to build viewingKey"
|
||||||
|
)
|
||||||
|
assert "viewingKey" in body, (
|
||||||
|
"updatePillBell must define a viewingKey variable"
|
||||||
|
)
|
||||||
|
# Must compare using sessionKey || s.name (not just s.name)
|
||||||
|
assert "sessionKey" in body, (
|
||||||
|
"updatePillBell must compare using s.sessionKey || s.name (not just s.name)"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_update_session_pill_uses_session_key_or_name() -> None:
|
||||||
|
"""updateSessionPill must compare using sessionKey||name against a viewingKey
|
||||||
|
that accounts for remote sessions (_viewingRemoteId prefix)."""
|
||||||
|
match = re.search(
|
||||||
|
r"function updateSessionPill\s*\(\w+\)\s*\{(.*?)\n\}",
|
||||||
|
_JS,
|
||||||
|
re.DOTALL,
|
||||||
|
)
|
||||||
|
assert match, "updateSessionPill function not found"
|
||||||
|
body = match.group(1)
|
||||||
|
# Must build viewingKey using _viewingRemoteId
|
||||||
|
assert "_viewingRemoteId" in body, (
|
||||||
|
"updateSessionPill must reference _viewingRemoteId to build viewingKey"
|
||||||
|
)
|
||||||
|
assert "viewingKey" in body, (
|
||||||
|
"updateSessionPill must define a viewingKey variable"
|
||||||
|
)
|
||||||
|
# Must compare using sessionKey || s.name (not just s.name)
|
||||||
|
assert "sessionKey" in body, (
|
||||||
|
"updateSessionPill must compare using s.sessionKey || s.name (not just s.name)"
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user