fix(vscode-ide-companion): improve message logging and permission handling

- Increase message logging truncation limit from 500 to 1500 characters
- Fix permission option mapping logic for reject_once/cancel options
- Add TODO comments for diff accept/cancel responses during permission requests

Resolves issues with permission handling and improves debugging capabilities.
This commit is contained in:
yiliang114
2025-12-05 02:15:48 +08:00
parent 4145f45c7c
commit 2d844d11df
40 changed files with 933 additions and 529 deletions

View File

@@ -73,6 +73,7 @@ interface UseWebViewMessagesProps {
breakAssistantSegment: () => void;
appendThinkingChunk: (chunk: string) => void;
clearThinking: () => void;
setWaitingForResponse: (message: string) => void;
clearWaitingForResponse: () => void;
};
@@ -421,6 +422,7 @@ export const useWebViewMessages = ({
toolCallData.type = toolCallData.sessionUpdate;
}
handlers.handleToolCallUpdate(toolCallData);
// Split assistant stream at tool boundaries similar to Claude/GPT rhythm
const status = (toolCallData.status || '').toString();
const isStart = toolCallData.type === 'tool_call';
@@ -430,6 +432,31 @@ export const useWebViewMessages = ({
if (isStart || isFinalUpdate) {
handlers.messageHandling.breakAssistantSegment();
}
// While long-running tools (e.g., execute/bash/command) are in progress,
// surface a lightweight loading indicator and expose the Stop button.
try {
const kind = (toolCallData.kind || '').toString().toLowerCase();
const isExec =
kind === 'execute' || kind === 'bash' || kind === 'command';
if (isExec && (status === 'pending' || status === 'in_progress')) {
const rawInput = toolCallData.rawInput;
let cmd = '';
if (typeof rawInput === 'string') {
cmd = rawInput;
} else if (rawInput && typeof rawInput === 'object') {
const maybe = rawInput as { command?: string };
cmd = maybe.command || '';
}
const hint = cmd ? `Running: ${cmd}` : 'Running command...';
handlers.messageHandling.setWaitingForResponse(hint);
}
if (status === 'completed' || status === 'failed') {
handlers.messageHandling.clearWaitingForResponse();
}
} catch (_err) {
// Best-effort UI hint; ignore errors
}
break;
}