feat(vscode-ide-companion): 优化权限请求组件并添加错误处理功能

- 移动权限请求组件到抽屉中,优化用户体验
- 为权限选项添加编号,提高可识别性
- 实现错误对象的特殊处理,提取更有意义的错误信息
- 优化工具调用错误内容的展示,提高错误信息的可读性
This commit is contained in:
yiliang114
2025-11-20 00:01:18 +08:00
parent 018990b7f6
commit e81255e589
6 changed files with 342 additions and 20 deletions

View File

@@ -8,10 +8,10 @@ import React, { useState, useEffect, useRef } from 'react';
import { useVSCode } from './hooks/useVSCode.js';
import type { Conversation } from '../storage/conversationStore.js';
import {
PermissionRequest,
type PermissionOption,
type ToolCall as PermissionToolCall,
} from './components/PermissionRequest.js';
import { PermissionDrawer } from './components/PermissionDrawer.js';
import { ToolCall, type ToolCallData } from './components/ToolCall.js';
import { EmptyState } from './components/EmptyState.js';
@@ -624,11 +624,7 @@ export const App: React.FC = () => {
};
// Check if there are any messages or active content
const hasContent =
messages.length > 0 ||
isStreaming ||
toolCalls.size > 0 ||
permissionRequest !== null;
const hasContent = messages.length > 0 || isStreaming || toolCalls.size > 0;
return (
<div className="chat-container">
@@ -810,15 +806,6 @@ export const App: React.FC = () => {
<ToolCall key={toolCall.toolCallId} toolCall={toolCall} />
))}
{/* Permission Request */}
{permissionRequest && (
<PermissionRequest
options={permissionRequest.options}
toolCall={permissionRequest.toolCall}
onResponse={handlePermissionResponse}
/>
)}
{/* Loading/Waiting Message - in message list */}
{isWaitingForResponse && loadingMessage && (
<div className="message assistant waiting-message">
@@ -1003,6 +990,17 @@ export const App: React.FC = () => {
</form>
</div>
</div>
{/* Permission Drawer - Cursor style */}
{permissionRequest && (
<PermissionDrawer
isOpen={!!permissionRequest}
options={permissionRequest.options}
toolCall={permissionRequest.toolCall}
onResponse={handlePermissionResponse}
onClose={() => setPermissionRequest(null)}
/>
)}
</div>
);
};