Merge #4047 into stage-mj
This commit is contained in:
@@ -72,6 +72,10 @@ function syncAppTitlebar() {
|
||||
if (_renamingAppTitlebar) return;
|
||||
|
||||
titleEl.textContent = mainText;
|
||||
if (panel !== 'chat') {
|
||||
const bot = typeof assistantDisplayName === 'function' ? assistantDisplayName() : '';
|
||||
document.title = bot ? mainText + ' \u2014 ' + bot : mainText;
|
||||
}
|
||||
if (subEl) {
|
||||
if (subText) {
|
||||
subEl.textContent = subText;
|
||||
@@ -272,7 +276,8 @@ async function switchPanel(name, opts = {}) {
|
||||
if (overlay) overlay.classList.add('visible');
|
||||
}
|
||||
_resyncChatSidebarAfterPanelSwitch();
|
||||
syncAppTitlebar();
|
||||
if (nextPanel === 'chat' && typeof syncTopbar === 'function') syncTopbar();
|
||||
else syncAppTitlebar();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
31
tests/test_issue4039_panel_document_title.py
Normal file
31
tests/test_issue4039_panel_document_title.py
Normal file
@@ -0,0 +1,31 @@
|
||||
"""Regression coverage for panel-driven document.title ownership (#4039)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
def _src(name: str) -> str:
|
||||
with open(f"static/{name}", encoding="utf-8") as f:
|
||||
return f.read()
|
||||
|
||||
|
||||
def test_sync_app_titlebar_stamps_non_chat_document_title():
|
||||
src = _src("panels.js")
|
||||
|
||||
assert "if (panel !== 'chat') {" in src
|
||||
assert "const bot = typeof assistantDisplayName === 'function' ? assistantDisplayName() : '';" in src
|
||||
assert "document.title = bot ? mainText + ' \\u2014 ' + bot : mainText;" in src
|
||||
|
||||
|
||||
def test_switch_panel_restores_chat_title_via_sync_topbar():
|
||||
src = _src("panels.js")
|
||||
|
||||
assert "if (nextPanel === 'chat' && typeof syncTopbar === 'function') syncTopbar();" in src
|
||||
assert "else syncAppTitlebar();" in src
|
||||
|
||||
|
||||
def test_chat_title_format_stays_owned_by_sync_topbar():
|
||||
panels_src = _src("panels.js")
|
||||
ui_src = _src("ui.js")
|
||||
|
||||
assert "document.title=sessionTitle+' \\u2014 '+assistantDisplayName();" in ui_src
|
||||
assert "document.title=sessionTitle+' \\u2014 '+assistantDisplayName();" not in panels_src
|
||||
Reference in New Issue
Block a user