From 867f29e2e9ccf922fa32bd439cae62ae17b16d4f Mon Sep 17 00:00:00 2001 From: Minidoracat Date: Sat, 28 Jun 2025 20:31:59 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=BE=A9=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/static/js/app.js | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/mcp_feedback_enhanced/web/static/js/app.js b/src/mcp_feedback_enhanced/web/static/js/app.js index 6101871..2d2dd3e 100644 --- a/src/mcp_feedback_enhanced/web/static/js/app.js +++ b/src/mcp_feedback_enhanced/web/static/js/app.js @@ -700,7 +700,11 @@ * 處理 WebSocket 訊息(防抖版本) */ FeedbackApp.prototype.handleWebSocketMessage = function(data) { - if (this._debouncedHandleWebSocketMessage) { + // 命令輸出相關的訊息不應該使用防抖,需要立即處理 + if (data.type === 'command_output' || data.type === 'command_complete' || data.type === 'command_error') { + this._originalHandleWebSocketMessage(data); + } else if (this._debouncedHandleWebSocketMessage) { + // 其他訊息類型使用防抖 this._debouncedHandleWebSocketMessage(data); } else { // 回退到原始方法(防抖未初始化時) @@ -1412,6 +1416,22 @@ FeedbackApp.prototype.appendCommandOutput = function(output) { const commandOutput = window.MCPFeedback.Utils.safeQuerySelector('#commandOutput'); if (commandOutput) { + // 檢查是否是空的(首次使用) + if (commandOutput.textContent === '' && output.startsWith('$')) { + // 如果是空的且輸出以 $ 開頭,添加歡迎訊息 + const projectPathElement = window.MCPFeedback.Utils.safeQuerySelector('#projectPathDisplay'); + const projectPath = projectPathElement ? projectPathElement.getAttribute('data-full-path') : 'unknown'; + + const welcomeText = `歡迎使用互動回饋終端 +======================================== +專案目錄: ${projectPath} +輸入命令後按 Enter 或點擊執行按鈕 +支援的命令: ls, dir, pwd, cat, type 等 + +`; + commandOutput.textContent = welcomeText; + } + commandOutput.textContent += output; commandOutput.scrollTop = commandOutput.scrollHeight; }