Skip to content

Commit 79a25e2

Browse files
quic-boyucclaude
andcommitted
observatory: strip archive label prefix in compare-mode sidebar
In compare mode each archive column already shows the label in its sticky header (commit 5ae2a72), so the `<label>/` that compare_archives prepends to every record and session name renders as redundant noise inside the column and squeezes the natural-width layout from c9e7bda. Strip is display-only — `rec.name` / `session.name` in `state.data` stay prefixed so graph_ref resolution and the global record map keep working. A `displayPrefix` arg threads through `renderRecordItem`, `_renderSessionDashboardLink`, `renderIndexFlat`, and `renderIndexTree`; `_renderArchiveColumn` passes `archive.label`. Single-archive paths pass no prefix and are unchanged. Collision suffixes (`A/foo #2`) strip cleanly to `foo #2` since only the head matches. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 872fc25 commit 79a25e2

1 file changed

Lines changed: 25 additions & 11 deletions

File tree

devtools/observatory/templates/js/02_layout.js

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,19 @@
162162
// separator (2-way compare summary) which only makes sense between
163163
// adjacent records in flat order — in tree view two consecutive
164164
// records can sit in different regions, so the diff is misleading.
165-
function renderRecordItem(rec, idx, treeMode) {
165+
// Compare-mode merge prepends `<archive_label>/` to every record name and
166+
// session name (observatory.py compare_archives). Inside an archive column
167+
// the label is already shown in the column header, so we strip it from the
168+
// displayed text only — `rec.name` / `session.name` themselves stay
169+
// prefixed because graph_ref resolution and the global record map depend
170+
// on the unique name.
171+
function _stripArchivePrefix(displayed, prefix) {
172+
if (!prefix) return displayed;
173+
const head = prefix + '/';
174+
return displayed.startsWith(head) ? displayed.slice(head.length) : displayed;
175+
}
176+
177+
function renderRecordItem(rec, idx, treeMode, displayPrefix) {
166178
const isSelected = state.selectedIndices.has(idx);
167179
const checkbox = state.selectionMode
168180
? `<input type="checkbox" class="selection-checkbox" ${isSelected ? 'checked' : ''} onclick="toggleSelect(${idx}, event)" style="margin-right:0.5rem;">`
@@ -228,7 +240,7 @@
228240
<div style="display:flex;align-items:center;overflow:hidden;flex:1;">
229241
${checkbox}
230242
<div style="flex:1;min-width:0;">
231-
<div style="text-overflow:ellipsis;overflow:hidden;white-space:nowrap;">${escapeHtml(rec.name || '')}</div>
243+
<div style="text-overflow:ellipsis;overflow:hidden;white-space:nowrap;">${escapeHtml(_stripArchivePrefix(rec.name || '', displayPrefix))}</div>
232244
</div>
233245
</div>
234246
<div class="badges">${badges}</div>
@@ -248,9 +260,10 @@
248260
return false;
249261
}
250262

251-
function _renderSessionDashboardLink(session) {
263+
function _renderSessionDashboardLink(session, displayPrefix) {
252264
const active = _isActiveSession(session.id) ? 'active' : '';
253-
const label = session.name || session.id || '(unnamed session)';
265+
const rawLabel = session.name || session.id || '(unnamed session)';
266+
const label = _stripArchivePrefix(rawLabel, displayPrefix);
254267
return `
255268
<li class="index-item session-dashboard-link ${active}"
256269
onclick="selectSession('${escapeHtml(session.id)}')">
@@ -259,13 +272,13 @@
259272
`;
260273
}
261274

262-
function renderIndexFlat(records, sessionFilter) {
275+
function renderIndexFlat(records, sessionFilter, displayPrefix) {
263276
let html = '';
264277
const filtered = sessionFilter
265278
? records.map((r, i) => ({rec: r, idx: i})).filter(x => x.rec.session_id === sessionFilter)
266279
: records.map((r, i) => ({rec: r, idx: i}));
267280
filtered.forEach(({rec, idx}) => {
268-
html += renderRecordItem(rec, idx, false);
281+
html += renderRecordItem(rec, idx, false, displayPrefix);
269282
});
270283
return html;
271284
}
@@ -277,7 +290,7 @@
277290
// adjacent records is suppressed in tree view (renderRecordItem
278291
// receives treeMode=true) since adjacent records in the records[]
279292
// array may not be visually adjacent under the tree.
280-
function renderIndexTree(records, sessionFilter) {
293+
function renderIndexTree(records, sessionFilter, displayPrefix) {
281294
let html = '';
282295

283296
// Walk records preserving order. Track open region path; when the
@@ -328,7 +341,7 @@
328341
openRegion(stack[i], fullKey);
329342
}
330343

331-
html += renderRecordItem(rec, idx, true);
344+
html += renderRecordItem(rec, idx, true, displayPrefix);
332345
});
333346

334347
closeTo(0);
@@ -337,12 +350,13 @@
337350

338351
function _renderArchiveColumn(archive, sessions, records, useTree) {
339352
const sessionsInArchive = sessions.filter((s) => s.archive === archive.label);
353+
const displayPrefix = archive.label;
340354
let inner = '';
341355
sessionsInArchive.forEach((session) => {
342-
inner += _renderSessionDashboardLink(session);
356+
inner += _renderSessionDashboardLink(session, displayPrefix);
343357
inner += useTree
344-
? renderIndexTree(records, session.id)
345-
: renderIndexFlat(records, session.id);
358+
? renderIndexTree(records, session.id, displayPrefix)
359+
: renderIndexFlat(records, session.id, displayPrefix);
346360
});
347361
return `
348362
<li class="archive-column">

0 commit comments

Comments
 (0)