Chat: show Chat/Agent tag next to message timestamp

Sometimes the user lands in chat mode without realizing — surface the
mode the message went out on as a small uppercase pill right after the
timestamp in the role header.

- roleTimestamp(when, mode) gains an optional mode arg. Agent renders
  in accent; Chat renders in muted/neutral. Other values render
  nothing (back-compat for older history without the field).
- The three roleTimestamp call sites pass metadata?.mode through.
- chat.js writes mode into the user-message metadata at send time and
  into the assistant metadata when the active-stream render lands,
  reading toggleState.mode so research/agent overrides upstream still
  flow through correctly.

Historical messages from before this change just don't show the pill —
graceful fallback, no migration needed.
This commit is contained in:
pewdiepie-archdaemon
2026-06-11 20:44:18 +09:00
parent 1d1678214a
commit e0af7bd8a0
3 changed files with 42 additions and 6 deletions
+9 -1
View File
@@ -628,8 +628,13 @@ import { wireArrowUpRecall, getLastUserMessageFromChatHistory } from './composer
}
}
let _userMsgEl = null;
// Capture which mode the user picked at send time so the message
// header can show "Chat" or "Agent" next to the timestamp.
const _sendMode = (toggleState.mode || 'chat') === 'agent' ? 'agent' : 'chat';
if (!skipBubble) {
_userMsgEl = addMessage('user', userDisplay, null, _pendingAttachInfo ? { attachments: _pendingAttachInfo } : null);
const _userMeta = { mode: _sendMode };
if (_pendingAttachInfo) _userMeta.attachments = _pendingAttachInfo;
_userMsgEl = addMessage('user', userDisplay, null, _userMeta);
}
messageInput.value = '';
messageInput.style.height = '';
@@ -3423,6 +3428,9 @@ import { wireArrowUpRecall, getLastUserMessageFromChatHistory } from './composer
if (holder.parentNode) holder.remove();
const model = meta && meta.model;
const meta_ = metricsData ? Object.assign({ model }, metricsData) : { model };
// Carry the send-time mode through so the assistant header gets
// the same Chat/Agent tag next to its timestamp.
meta_.mode = (toggleState.mode || 'chat') === 'agent' ? 'agent' : 'chat';
chatRenderer.addMessage('assistant', roundText, model, meta_);
uiModule.scrollHistory();
return true;