Hermes
|
2c6f06e392
|
feat: multi-tab terminal (Xshell-style)
User asked: '终端应该支持多标签功能,不能只支持一个'
Changes:
1. New ui/terminal_tab_widget.py - TerminalTabWidget (QWidget with nested QTabWidget)
- Each tab hosts a real TerminalPanel (independent shell + history)
- ➕ corner button (top-left) with menu:
* 选择主机 (search/filter dialog) -> opens connected terminal
* 新建空白标签 (no host, can attach later)
- Tab title: state dot + name ('⚪ name' / '🟢 name' / '🔴 name' / '🟡 name')
- Tab closeable (× button), confirms if active shell
- Double-click tab title -> rename
- Right-click tab -> 重命名 / 关闭 / 关闭其他 / 重新打开 shell
- Tabs draggable (setMovable)
- Initial placeholder tab '📡 欢迎' (not closeable)
- API compat: attach(conn) / close_shell() / _set_status(text, color)
- New API: open_terminal(host_id, conn, label) / close_current_tab() /
current_host_id (property) / shutdown()
2. ui/main_window.py
- TerminalPanel() -> TerminalTabWidget(self.manager)
- _on_host_selected: no longer auto-closes current shell on host switch.
Instead creates a new tab if host already connected.
- _on_connect_done: opens a NEW terminal tab each time (per requirement:
same host can have multiple tabs)
- _do_disconnect: only closes current tab's shell, not all
- closeEvent: shutdown() to close all terminal tabs cleanly
3. test_ui.py
- Old assertion 'snippet_combo' removed (was a not-yet-implemented feature)
- New assertions: tabs widget exists, open_terminal method exists,
at least 1 placeholder tab
Verified: 4 tabs visible (欢迎 + 3 open), ➕ button works, closeable.
Tests: core 6/6 + UI 3/3 pass.
|
2026-07-29 07:05:59 +08:00 |
|