fix(tabs): honor dynamic tab title Off over live prompt hostname (#4432)

This commit is contained in:
陈大猫 committed 2026-11-26 16:29:55 +08:00
1 parent ac8869884f
commit 430932e855
2 files changed
+34 -4

No files matched your search

+30
View File
@@ -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: ' ' }),
+4 -4
View File
@@ -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;
}