From fb19a9e872c6f8142f89bbc23442a8b68ec99d27 Mon Sep 17 00:00:00 2001 From: honor2030 <19909783+honor2030@users.noreply.github.com> Date: Thu, 14 May 2026 14:36:52 +0900 Subject: [PATCH 1/2] fix(viewer): handle sessions missing ids --- src/viewer/index.html | 55 +++++++++---- test/viewer-session-id.test.ts | 137 +++++++++++++++++++++++++++++++++ 2 files changed, 177 insertions(+), 15 deletions(-) create mode 100644 test/viewer-session-id.test.ts diff --git a/src/viewer/index.html b/src/viewer/index.html index 551d016..f1a133d 100644 --- a/src/viewer/index.html +++ b/src/viewer/index.html @@ -1039,6 +1039,23 @@

agentmemory

if (!s) return ''; return s.length > n ? s.slice(0, n) + '...' : s; } + function sessionId(s) { + return s && s.id !== undefined && s.id !== null ? String(s.id) : ''; + } + function shortSessionId(s, n) { + var id = sessionId(s); + return id ? id.slice(0, n || 8) : ''; + } + function sessionDisplayName(s) { + var project = s && s.project ? String(s.project).split('/').pop() : ''; + if (project) return project; + return shortSessionId(s, 8) || 'Unknown session'; + } + function sessionLabel(s) { + var id = shortSessionId(s, 8); + var name = sessionDisplayName(s); + return id ? name + ' (' + id + ')' : name + ' (missing id)'; + } function debounce(fn, ms) { var t; return function() { @@ -1278,7 +1295,7 @@

agentmemory

html += ''; recent.forEach(function(s) { var statusBadge = s.status === 'active' ? 'badge-green' : s.status === 'completed' ? 'badge-blue' : 'badge-muted'; - html += ''; + html += ''; html += ''; html += ''; html += ''; @@ -2204,8 +2221,9 @@

agentmemory

var html = '
'; html += ''; html += '
ProjectStatusObsStarted
' + esc(s.project ? s.project.split('/').pop() : s.id.slice(0,8)) + '
' + esc(sessionDisplayName(s)) + '' + esc(s.status) + '' + (s.observationCount || 0) + '' + esc(shortTime(s.startedAt)) + '