diff --git a/src/utils/messageHandler.ts b/src/utils/messageHandler.ts index 91ef177..150aec5 100644 --- a/src/utils/messageHandler.ts +++ b/src/utils/messageHandler.ts @@ -105,18 +105,29 @@ async function handleUserMessageWithBackend( const historyManager = ChatHistoryManager.getInstance(); - // 显示加载状态 + // 显示状态栏 panel.webview.postMessage({ - command: "showLoading", - text: "正在思考...", + command: "updateStatus", + text: "思考中...", + type: "thinking", }); return new Promise((resolve, reject) => { currentSession!.sendMessage(text, { onText: (fullText, isStreaming) => { - // 暂时只在完成时发送消息(非流式) - if (!isStreaming) { + if (isStreaming) { + // 流式时更新状态为"生成中" + panel.webview.postMessage({ + command: "updateStatus", + text: "生成中...", + type: "working", + }); + } else { + // 完成时发送消息并隐藏状态 console.log('[MessageHandler] 发送最终消息, 文本长度:', fullText.length); + panel.webview.postMessage({ + command: "hideStatus", + }); panel.webview.postMessage({ command: "receiveMessage", text: fullText, diff --git a/src/views/webviewContent.ts b/src/views/webviewContent.ts index 2b4fd18..0f64eef 100644 --- a/src/views/webviewContent.ts +++ b/src/views/webviewContent.ts @@ -680,6 +680,41 @@ export function getWebviewContent(iconUri?: string): string { .question-message.answered .custom-input-container { display: none; } + + /* 状态栏样式 */ + .status-bar { + display: flex; + align-items: center; + gap: 8px; + padding: 8px 16px; + background: var(--vscode-textBlockQuote-background); + border-radius: 6px; + margin: 8px 0; + font-size: 13px; + color: var(--vscode-descriptionForeground); + } + .status-indicator { + width: 8px; + height: 8px; + border-radius: 50%; + background: var(--vscode-charts-blue); + animation: statusPulse 1.5s ease-in-out infinite; + } + @keyframes statusPulse { + 0%, 100% { opacity: 1; transform: scale(1); } + 50% { opacity: 0.5; transform: scale(0.8); } + } + .status-bar.working .status-indicator { + background: var(--vscode-charts-orange); + } + .status-bar.success .status-indicator { + background: var(--vscode-charts-green); + animation: none; + } + .status-bar.error .status-indicator { + background: var(--vscode-charts-red); + animation: none; + }
@@ -722,6 +757,12 @@ export function getWebviewContent(iconUri?: string): string { + + +