fix: remoteId=0 falsy bug in renderSheetList — use null check

The first remote instance (index 0) couldn't be opened from the mobile
bottom sheet because s.remoteId ? treated 0 as falsy. Changed to
s.remoteId != null to match buildTileHTML and buildSidebarHTML.
This commit is contained in:
Brian Krabach
2026-04-13 14:18:25 -07:00
parent f7519a8058
commit b247f01ebc
2 changed files with 15 additions and 1 deletions
+1 -1
View File
@@ -1851,7 +1851,7 @@ function renderSheetList() {
(s.bell.seen_at === null || s.bell.last_fired_at > s.bell.seen_at);
var isActive = s.name === _viewingSession;
var escapedName = escapeHtml(s.name || '');
var remoteIdAttr = s.remoteId ? ' data-remote-id="' + escapeHtml(s.remoteId) + '"' : '';
var remoteIdAttr = s.remoteId != null ? ' data-remote-id="' + escapeHtml(s.remoteId) + '"' : '';
return '<li class="sheet-item' + (isActive ? ' sheet-item--active' : '') + '"' +
' data-session="' + escapedName + '"' + remoteIdAttr + ' role="option">' +
'<span class="sheet-item__name">' + escapedName + '</span>' +
+14
View File
@@ -1604,6 +1604,20 @@ test('renderSheetList escapes HTML special chars in sheet-item__name span', () =
globalThis.document.getElementById = origGetById;
});
// --- Fix 3: renderSheetList uses null check for remoteId (not falsy) ---
test('renderSheetList uses null check for remoteId (not falsy)', () => {
const source = fs.readFileSync(new URL('../app.js', import.meta.url), 'utf8');
const fnStart = source.indexOf('function renderSheetList');
const fnEnd = source.indexOf('\n}\n', fnStart + 100);
const fnBody = source.substring(fnStart, fnEnd);
// Must use != null check, not truthy check
assert.ok(fnBody.includes('remoteId != null') || fnBody.includes('remoteId !== null'),
'renderSheetList must use null check for remoteId (0 is valid)');
assert.ok(!fnBody.match(/s\.remoteId\s*\?[^=]/),
'renderSheetList must NOT use truthy check for remoteId (0 is falsy)');
});
// --- Fix 2: openBottomSheet/closeBottomSheet use static backdrop binding ---
test('openBottomSheet does not dynamically add click listener to sheet-backdrop', () => {