diff --git a/muxplex/frontend/app.js b/muxplex/frontend/app.js index 4d112dd..e4cbbb9 100644 --- a/muxplex/frontend/app.js +++ b/muxplex/frontend/app.js @@ -530,6 +530,8 @@ function buildStatusTileHTML(deviceName, statusText, statusClass) { function getVisibleSessions(sessions) { var hidden = (_serverSettings && _serverSettings.hidden_sessions) || []; return (sessions || []).filter(function(s) { + // Skip status entries (unreachable, auth_failed) — rendered separately as status tiles + if (s.status) return false; if (hidden.length > 0 && hidden.includes(s.name)) { return false; } diff --git a/muxplex/frontend/tests/test_app.mjs b/muxplex/frontend/tests/test_app.mjs index 257fc9e..7a76b8f 100644 --- a/muxplex/frontend/tests/test_app.mjs +++ b/muxplex/frontend/tests/test_app.mjs @@ -1769,6 +1769,37 @@ test('renderSidebar does nothing when view is not fullscreen', () => { globalThis.document.getElementById = origGetById; }); +// --- getVisibleSessions --- + +test('getVisibleSessions filters out entries with unreachable status (no name)', () => { + const sessions = [ + { name: 'real-session', snapshot: '' }, + { status: 'unreachable', remoteId: 0, deviceName: 'alienware-r13' }, + ]; + const result = app.getVisibleSessions(sessions); + assert.strictEqual(result.length, 1, 'should return only the real session'); + assert.strictEqual(result[0].name, 'real-session'); +}); + +test('getVisibleSessions filters out entries with auth_failed status', () => { + const sessions = [ + { name: 'real-session', snapshot: '' }, + { name: 'Workstation', status: 'auth_failed' }, + ]; + const result = app.getVisibleSessions(sessions); + assert.strictEqual(result.length, 1, 'auth_failed entry should be filtered out'); + assert.strictEqual(result[0].name, 'real-session'); +}); + +test('getVisibleSessions passes through sessions with no status field', () => { + const sessions = [ + { name: 'alpha', snapshot: '' }, + { name: 'beta', snapshot: '' }, + ]; + const result = app.getVisibleSessions(sessions); + assert.strictEqual(result.length, 2, 'normal sessions should all pass through'); +}); + // ─── initSidebar ───────────────────────────────────────────────────────────── test('initSidebar defaults to open (removes sidebar--collapsed) on wide screens when no stored value', () => {