fix: 用 Static 标题栏替代 Textual Header,确保始终显示

- 自定义 #title-bar (dock top, height 1, bold)
- 移除不可靠的 Header widget
- _setup_title 更新 title_bar 内容

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
qinglong
2026-06-13 12:00:36 +08:00
parent 18f9fcfcd3
commit ae8586bc4a
+16 -15
View File
@@ -7,7 +7,7 @@ import io
import time
from textual.app import App
from textual.containers import Container, ScrollableContainer
from textual.widgets import Static, Input, Header
from textual.widgets import Static, Input
from textual.suggester import Suggester
try:
@@ -546,6 +546,7 @@ class TUIFramework(App):
self.message_display = MessageDisplay()
self.system_monitor = SystemMonitor()
self.plugin_panel = PluginStatusPanel(plugin_service)
self.title_bar = Static("🐱 SenSu", id="title-bar")
self.command_input = None
self.CSS = self._generate_css()
@@ -553,8 +554,13 @@ class TUIFramework(App):
def _generate_css(self):
"""动态生成 CSS — dock 布局:标题 + 状态栏 + 主内容 + 底部输入"""
return """
Header {
#title-bar {
dock: top;
height: 1;
padding: 0 1;
background: $panel;
color: $text;
text-style: bold;
}
#monitor-area {
@@ -591,7 +597,7 @@ class TUIFramework(App):
def compose(self):
"""组合界面 — 标题 + 状态栏 / 主显示区 / 底部输入栏"""
yield Header()
yield self.title_bar
yield Container(
self.system_monitor,
self.plugin_panel,
@@ -851,20 +857,15 @@ class TuiService:
name = framework_config.get('name', 'SenSu')
version = framework_config.get('version', 'Unknown')
debug_mode = framework_config.get('debug', False)
# 构建标题
title_parts = [f"🐱 {name} Ver.{version}"]
title = f"🐱 {name} Ver.{version}"
if debug_mode:
title_parts.append("[DEBUG]")
self.tui_app.title = " ".join(title_parts)
self.tui_app.sub_title = "Based DreamSu Framework"
logger.debug(f"设置TUI标题: {self.tui_app.title}")
logger.debug(f"设置TUI副标题: {self.tui_app.sub_title}")
title += " [DEBUG]"
self.tui_app.title_bar.update(title)
logger.debug(f"设置TUI标题: {title}")
except Exception as e:
logger.error(f"设置TUI标题时出错: {e}")
self.tui_app.title = "🐱 SenSu - Based DreamSu Framework" # 默认标题
logger.error(f"设置TUI标题时出错: {e}")
async def _run_tui(self):
"""运行TUI"""