diff --git a/domain/sessionTabTitle.test.ts b/domain/sessionTabTitle.test.ts index 3d807640c..35f2396be 100644 --- a/domain/sessionTabTitle.test.ts +++ b/domain/sessionTabTitle.test.ts @@ -60,6 +60,36 @@ test('resolveSessionTabTitle disables dynamic titles in off mode', () => { ); }); +test('resolveSessionTabTitle ignores live prompt host in off mode', () => { + assert.equal( + resolveSessionTabTitle( + { hostLabel: '192.0.2.10', promptHostname: 'ubuntu', dynamicTitle: 'root@ubuntu:~' }, + 'off', + ), + '192.0.2.10', + ); + assert.equal( + resolveSessionTabTitle({ hostLabel: '', promptHostname: 'ubuntu' }, 'off'), + '', + ); +}); + +test('resolveSessionTabTitle keeps customName ahead of live titles in off mode', () => { + assert.equal( + resolveSessionTabTitle( + { + customName: 'Prod deploy', + hostLabel: '192.0.2.10', + promptHostname: 'ubuntu', + dynamicTitle: 'claude: refactor auth', + codingCliProviderId: 'claude', + }, + 'off', + ), + 'Prod deploy', + ); +}); + test('resolveSessionTabTitle falls back to connection label when dynamic title is empty', () => { assert.equal( resolveSessionTabTitle({ hostLabel: 'web-01', dynamicTitle: ' ' }), diff --git a/domain/sessionTabTitle.ts b/domain/sessionTabTitle.ts index 2aa7faa28..3d0abe588 100644 --- a/domain/sessionTabTitle.ts +++ b/domain/sessionTabTitle.ts @@ -141,11 +141,14 @@ export const resolveSessionTabTitle = ( >, dynamicTabTitleMode: DynamicTabTitleMode = 'agent', ): string => { + if (dynamicTabTitleMode === 'off') { + return session.customName || session.hostLabel || ''; + } const connectionLabel = getSessionConnectionLabel(session); if (session.customName) { return session.customName; } - if (dynamicTabTitleMode !== 'off' && session.codingCliProviderId) { + if (session.codingCliProviderId) { const agentTitle = session.dynamicTitle?.trim(); if (agentTitle) return normalizeCodingCliTitle(agentTitle) || agentTitle; } @@ -153,9 +156,6 @@ export const resolveSessionTabTitle = ( if (promptHostname) { return promptHostname; } - if (dynamicTabTitleMode === 'off') { - return connectionLabel; - } if (dynamicTabTitleMode === 'agent' && !session.codingCliProviderId) { return connectionLabel; }