' + esc(s.project ? s.project.split('/').pop() : 'Unknown') + '';
+ var id = sessionId(s);
+ var selected = id && state.sessions.selectedId === id;
+ html += '
';
+ html += '
' + esc(sessionDisplayName(s)) + '';
html += '' + esc(s.status) + '
';
var preview = s.firstPrompt || s.summary || '';
if (preview) {
html += '
' + esc(truncate(preview, 140)) + '
';
}
- html += '
';
@@ -2672,7 +2691,8 @@
agentmemory
html += '
Metadata
';
html += '
';
- html += '
id: ' + esc(s.id) + '
';
+ var detailId = sessionId(s);
+ html += '
id: ' + esc(detailId || 'missing id') + '
';
html += '
cwd: ' + esc(s.cwd || '-') + '
';
html += '
started: ' + esc(formatTime(s.startedAt)) + '
';
if (s.endedAt) html += '
ended: ' + esc(formatTime(s.endedAt)) + '
';
@@ -2681,10 +2701,14 @@
agentmemory
html += '
';
html += '
';
- if (s.status === 'active') {
- html += '';
+ if (detailId && s.status === 'active') {
+ html += '';
+ }
+ if (detailId) {
+ html += '';
+ } else {
+ html += '';
}
- html += '';
html += '
';
panel.innerHTML = html;
}
@@ -3587,8 +3611,9 @@
agentmemory
var el = document.getElementById('view-replay');
var sessions = state.replay.sessions || [];
var options = '
' + sessions.map(function(s) {
- var label = (s.project || 'unknown') + ' · ' + (s.id || '').slice(0, 8) + ' · ' + (s.observationCount || 0) + ' obs';
- return '
';
+ var id = sessionId(s);
+ var label = sessionDisplayName(s) + ' · ' + (shortSessionId(s, 8) || 'missing id') + ' · ' + (s.observationCount || 0) + ' obs';
+ return '
';
}).join('');
var tl = state.replay.timeline;
diff --git a/test/viewer-session-id.test.ts b/test/viewer-session-id.test.ts
new file mode 100644
index 0000000..12a1f24
--- /dev/null
+++ b/test/viewer-session-id.test.ts
@@ -0,0 +1,137 @@
+import * as vm from "node:vm";
+import { describe, expect, it } from "vitest";
+import { renderViewerDocument } from "../src/viewer/document.js";
+
+function htmlEscape(value: string): string {
+ return value
+ .replace(/&/g, "&")
+ .replace(//g, ">")
+ .replace(/"/g, """);
+}
+
+function loadViewerSandbox() {
+ const rendered = renderViewerDocument();
+ expect(rendered.found).toBe(true);
+ if (!rendered.found) throw new Error("viewer document not found");
+
+ const scriptMatch = rendered.html.match(/