fix: suppress N/A source_tag in session list sidebar (#429)

- sessions.js _formatSourceTag(): return null for unrecognised tags
  instead of raw string — prevents legacy 'N/A' values from surfacing
- sessions.js metaBits push: guarded with _stLabel null check so only
  known platform labels appear in the session metadata line
- sessions.js [SYSTEM:] title fallback: drop raw s.source_tag middle
  term, fall back directly to 'Gateway' for unknown sources

7 new tests in test_issue429.py.
1 updated test in test_sprint40_ui_polish.py (new guarded push pattern).

Closes #429
This commit is contained in:
Hermes Agent
2026-04-14 22:14:31 +00:00
parent 642f4536f0
commit 7b9f08c774
5 changed files with 171 additions and 7 deletions

View File

@@ -536,7 +536,7 @@
<div class="settings-section-title">System</div>
<div class="settings-section-meta">Instance version and access controls.</div>
</div>
<span class="settings-version-badge">v0.50.44</span>
<span class="settings-version-badge">v0.50.45</span>
</div>
<div class="settings-field" style="border-top:1px solid var(--border);padding-top:12px;margin-top:8px">
<label for="settingsPassword" data-i18n="settings_label_password">Access Password</label>

View File

@@ -587,8 +587,11 @@ function renderSessionListFromCache(){
// ── Render session items (extracted for group body use) ──
// Note: declared after the groups loop but available via function hoisting.
function _formatSourceTag(tag){
// #429: return null for unknown/unrecognised tags so callers can suppress display.
// Previously returned the raw tag string, causing 'N/A' or other junk values
// from older hermes-agent state.db records to surface in the session list.
const names={telegram:'via Telegram',discord:'via Discord',slack:'via Slack',cli:'CLI',feishu:'via Feishu',weixin:'via WeChat'};
return names[tag]||tag;
return names[tag]||null;
}
function _renderOneSession(s){
const el=document.createElement('div');
@@ -602,7 +605,7 @@ function renderSessionListFromCache(){
// Guard: system prompt content must never surface as a visible session title
const _SOURCE_DISPLAY={telegram:'Telegram',discord:'Discord',slack:'Slack',cli:'CLI',feishu:'Feishu',weixin:'WeChat'};
if(cleanTitle.startsWith('[SYSTEM:')){
cleanTitle=(_SOURCE_DISPLAY[s.source_tag]||s.source_tag||'Gateway')+' session';
cleanTitle=(_SOURCE_DISPLAY[s.source_tag]||'Gateway')+' session';
}
const sessionText=document.createElement('div');
sessionText.className='session-text';
@@ -615,7 +618,7 @@ function renderSessionListFromCache(){
const tsMs=_sessionTimestampMs(s);
titleRow.appendChild(title);
const metaBits=[];
if(s.is_cli_session && s.source_tag) metaBits.push(_formatSourceTag(s.source_tag));
if(s.is_cli_session && s.source_tag){const _stLabel=_formatSourceTag(s.source_tag);if(_stLabel)metaBits.push(_stLabel);}
if(s.message_count) metaBits.push(t('n_messages', s.message_count));
if(s.model) metaBits.push(String(s.model).split('/').pop());
sessionText.appendChild(titleRow);