fix: terminal command output not displaying - add diagnostics

User reported: '已连接, 但终端啥也不显示'
Likely cause: command ran but stdout was empty / scrolled to wrong place
/ output widget didn't refresh before worker finished.

Changes:
- Eagerly show the typed command in the output area (\$ <cmd>) so user
  sees the input was received even if the worker hangs/fails
- Show '(stdout 为空)' placeholder when worker returns no output, so it's
  clear the worker actually ran
- Force output.repaint() and ensureCursorVisible() after append
- Add 2 diagnostic buttons in terminal bottom bar:
    * [🔍 诊断]  prints current SSH connection / worker state
    * [▶ 测试命令]  pre-fills a known-good test command
- Make CommandWorker explicitly check conn.connected before exec
- Surface full traceback in stderr on exception instead of bare str(e)

All 15 existing tests still pass (core 6/6 + UI 3/3 + E2E 6/6).
This commit is contained in:
Hermes
2026-07-28 21:18:21 +08:00
parent 01c8d3581a
commit 8b5dacda58
2 changed files with 59 additions and 7 deletions
+5 -1
View File
@@ -40,9 +40,13 @@ class CommandWorker(QThread):
def run(self):
try:
if not self.conn or not self.conn.connected or not self.conn.client:
self.finished_with.emit(-1, "", "连接已断开或 client 不可用")
return
code, out, err = self.conn.exec_command(self.command, timeout=self.timeout)
except Exception as e:
code, out, err = -1, "", str(e)
import traceback
code, out, err = -1, "", f"执行异常: {e}\n{traceback.format_exc()}"
self.finished_with.emit(code, out, err)