feat: 添加工作区状态检查功能,优化用户体验

- 用户鼠标聚焦到输入框中就弹窗提示用户打开 优化用户体验
This commit is contained in:
Roe-xin
2025-12-30 16:02:36 +08:00
parent 0f458f6299
commit 3f0cc8ae29
4 changed files with 88 additions and 21 deletions

View File

@ -271,6 +271,10 @@ export function getInputAreaScript(): string {
// 对话状态管理
let isConversationActive = false;
// 工作区检测状态
let hasCheckedWorkspace = false; // 是否已经检测过工作区
let hasWorkspace = true; // 工作区状态
// 自动调整 textarea 高度
function autoResizeTextarea() {
if (messageInput) {
@ -283,11 +287,16 @@ export function getInputAreaScript(): string {
if (messageInput) {
messageInput.addEventListener('input', autoResizeTextarea);
// 监听点击事件,检测工作区状态
messageInput.addEventListener('focus', () => {
if (!hasCheckedWorkspace) {
hasCheckedWorkspace = true;
vscode.postMessage({ command: 'checkWorkspace' });
}
});
// 初始化时调整一次高度
autoResizeTextarea();
// 聚焦到输入框
messageInput.focus();
}
// 切换发送按钮状态
@ -326,6 +335,14 @@ export function getInputAreaScript(): string {
const text = messageInput.value.trim();
if (!text) return;
// 检查工作区状态
if (!hasWorkspace) {
// 如果没有工作区,阻止发送并清空输入框
messageInput.value = '';
autoResizeTextarea();
return;
}
const mode = getCurrentMode(); // 从模式选择器组件获取当前模式
const model = getCurrentModel(); // 从模型选择器组件获取当前模型