web: collapse repeated sender names
A "them" message now shows its sender name only when the sender differs from the previous message, or a time separator precedes it — so a run of messages from one person is labelled once, matching how the timestamps and tighter-gap grouping already collapse. Folded into refreshGrouping, which already runs on the affected messages after separators are placed.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 file changed,
+12
−0
web/static/chat.js+12 −0
diff --git a/web/static/chat.js b/web/static/chat.js| index b8afc2a..bffe000 100644 |
| --- a/web/static/chat.js |
| +++ b/web/static/chat.js |
| @@ -842,9 +842,21 @@ async function start(session) { |
| // A continuation (same run as the message directly above) gets a tighter top |
| // gap (.cont). A time separator between two messages breaks the run, so using |
| // previousElementSibling (not prevMsgOf) is correct here. |
| + // |
| + // Also collapse repeated sender names: a "them" message shows its name only |
| + // when the sender differs from the previous message, or a time separator |
| + // precedes it — so a run from one person is labelled once. |
| function refreshGrouping(el) { |
| if (!el || !el.classList || !el.classList.contains("msg")) return; |
| el.classList.toggle("cont", sameGroup(el.previousElementSibling, el)); |
| + const name = el.querySelector(":scope > .name"); |
| + if (name) { |
| + const prevSib = el.previousElementSibling; |
| + const afterSeparator = !!prevSib && prevSib.classList.contains("time-sep"); |
| + const prev = prevMsgOf(el); |
| + const sameSender = !!prev && prev.dataset.sender === el.dataset.sender; |
| + name.style.display = !afterSeparator && sameSender ? "none" : ""; |
| + } |
| } |
| // Ensure the right separator (or none) sits before `el`, based on the gap to the |