fix: streaming tool_use + скрытие сырого кода от пользователя

- readline вместо async for — убирает буферизацию stdout
- tool events показывают статус ("Читаю файл..."), не сырой Python-код
- done event как fallback для финального ответа
- tab_id для изоляции сессий между вкладками

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
anor
2026-03-24 18:15:00 +10:00
co-authored by Claude Opus 4.6
parent 0162a876ee
commit 4a9574980e
2 changed files with 14 additions and 9 deletions
+8 -3
View File
@@ -280,12 +280,17 @@ async function sendMessage() {
aiDiv.textContent = aiText;
msgs.scrollTop = msgs.scrollHeight;
} else if (eventType === 'tool') {
addMsg('tool', '🔧 ' + data.tool + (data.input.command ? ': ' + data.input.command : data.input.file_path ? ': ' + data.input.file_path : ''));
// Show minimal status, not raw code
const toolNames = {Bash: 'Выполняю...', Read: 'Читаю файл...', Write: 'Создаю файл...', Edit: 'Редактирую...', Glob: 'Ищу файлы...', Grep: 'Ищу в файлах...'};
const label = toolNames[data.tool] || 'Обрабатываю...';
removeTyping();
addTyping().textContent = label;
} else if (eventType === 'done') {
if (!aiDiv && data.result) {
removeTyping();
// Always show final result if we haven't shown text yet
if (!aiText && data.result) {
aiDiv = addMsg('ai', data.result);
}
// cost info hidden from user
}
eventType = '';
}