SIGN IN SIGN UP

feat(webview): add batchNearby utility for smarter tool ask batching (#1005)

* feat(webview): add batchNearby utility for smarter tool ask batching

Replace batchConsecutive with batchNearby in ChatView.tsx to allow
merging same-type tool asks even when separated by ignorable messages
(api_req_started/finished, empty text rows, reasoning).

Semantic boundaries (user_feedback, visible text, completion_result,
checkpoint_saved, error) stop the merge, preserving correct ordering.

This fixes UX where models like qwen insert API request rows between
tool calls, causing UI to show multiple 'Zoo wants to read this file'
instead of a single batched prompt.

* fix: batchNearby restores dropped ignorable items when bridge fails

When a single target is followed by ignorable messages and then a
boundary (no second target found), the original code silently dropped
those ignorable items — contradicting the documented contract that all
items are preserved in-order.

Fix: track skipped ignorable items in pendingIgnorable, flush them after
the batch result so they're never lost. When bridge succeeds (second
target found), pending items are consumed into the synthesized batch as
expected.

* fix(chat): keep nearby batching boundaries in sync

* fix(chat): share tool batching predicates

---------

Co-authored-by: T <taltas@users.noreply.github.com>
Co-authored-by: Eason Liang <easonliang28@gmail.com>
E
eason liang committed
64d6e378f9f24fe0434ba89aba085ed98dd9948e
Parent: f589ce7
Committed by GitHub <noreply@github.com> on 8/5/2026, 3:00:05 AM