Skip to content

Commit 056a59d

Browse files
committed
feat: making some tool messages not use the streaming to avoid weird behavior
1 parent 9a29c79 commit 056a59d

3 files changed

Lines changed: 34 additions & 10 deletions

File tree

packages/common/src/tools.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ export const MEMORY_TOOL_DELETE = 'delete_memory';
6363
export const MEMORY_TOOL_LIST = 'list_memories';
6464
export const MEMORY_TOOL_UPDATE = 'update_memory';
6565

66+
export const STREAMING_DISABLED_TOOLS: ReadonlySet<string> = new Set([
67+
`${POWER_TOOL_GROUP_NAME}${TOOL_GROUP_NAME_SEPARATOR}${POWER_TOOL_FILE_READ}`,
68+
`${POWER_TOOL_GROUP_NAME}${TOOL_GROUP_NAME_SEPARATOR}${POWER_TOOL_GREP}`,
69+
`${POWER_TOOL_GROUP_NAME}${TOOL_GROUP_NAME_SEPARATOR}${POWER_TOOL_GLOB}`,
70+
`${POWER_TOOL_GROUP_NAME}${TOOL_GROUP_NAME_SEPARATOR}${POWER_TOOL_SEMANTIC_SEARCH}`,
71+
`${MEMORY_TOOL_GROUP_NAME}${TOOL_GROUP_NAME_SEPARATOR}${MEMORY_TOOL_RETRIEVE}`,
72+
`${MEMORY_TOOL_GROUP_NAME}${TOOL_GROUP_NAME_SEPARATOR}${MEMORY_TOOL_DELETE}`,
73+
`${MEMORY_TOOL_GROUP_NAME}${TOOL_GROUP_NAME_SEPARATOR}${MEMORY_TOOL_LIST}`,
74+
]);
75+
6676
export const MEMORY_TOOL_DESCRIPTIONS = {
6777
[MEMORY_TOOL_STORE]: 'Stores important information, patterns, or preferences into memory for future tasks',
6878
[MEMORY_TOOL_RETRIEVE]: `Searches and retrieves relevant memories using semantic vector search.

src/renderer/src/components/message/MessageBlock.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import {
2121
POWER_TOOL_SEMANTIC_SEARCH,
2222
SKILLS_TOOL_ACTIVATE_SKILL,
2323
SKILLS_TOOL_GROUP_NAME,
24+
STREAMING_DISABLED_TOOLS,
25+
TOOL_GROUP_NAME_SEPARATOR,
2426
SUBAGENTS_TOOL_GROUP_NAME,
2527
SUBAGENTS_TOOL_RUN_TASK,
2628
TASKS_TOOL_GROUP_NAME,
@@ -170,6 +172,19 @@ const MessageBlockComponent = ({
170172
if (isToolMessage(message)) {
171173
const toolMessage = message as ToolMessage;
172174

175+
if (toolMessage.isStreaming === true && STREAMING_DISABLED_TOOLS.has(`${toolMessage.serverName}${TOOL_GROUP_NAME_SEPARATOR}${toolMessage.toolName}`)) {
176+
return (
177+
<ToolMessageBlock
178+
message={toolMessage}
179+
onRemove={remove}
180+
compact={compact}
181+
hideMessageBar={hideMessageBar}
182+
onFork={onFork}
183+
onRemoveUpTo={onRemoveUpTo}
184+
/>
185+
);
186+
}
187+
173188
switch (toolMessage.serverName) {
174189
case POWER_TOOL_GROUP_NAME:
175190
switch (toolMessage.toolName) {

src/renderer/src/components/message/ToolMessageBlock.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ export const ToolMessageBlock = ({ message, onRemove, compact = false, onFork, o
4545
const getToolLabel = (message: ToolMessage): ReactNode => {
4646
const defaultLabel = () => t('toolMessage.toolLabel', { server: formatName(message.serverName), tool: formatName(message.toolName) });
4747

48+
if (isStreaming) {
49+
return defaultLabel();
50+
}
51+
4852
switch (message.serverName) {
4953
case AIDER_TOOL_GROUP_NAME:
5054
switch (message.toolName) {
@@ -177,20 +181,15 @@ export const ToolMessageBlock = ({ message, onRemove, compact = false, onFork, o
177181

178182
const content = (
179183
<div className="text-2xs whitespace-pre-wrap text-text-tertiary bg-bg-secondary relative p-3">
180-
{Object.keys(message.args).length > 0 && (
184+
{!isStreaming && Object.keys(message.args).length > 0 && (
181185
<div className="mb-3">
182-
<div className="font-semibold mb-1 text-text-secondary">
183-
{t('toolMessage.arguments')}
184-
{isStreaming && <span className="ml-2 text-text-muted-light italic font-normal text-2xs">{t('toolMessage.preparing')}</span>}
185-
</div>
186-
<pre
187-
className={`whitespace-pre-wrap max-h-[400px] overflow-y-auto scrollbar-thin scrollbar-track-bg-primary-light scrollbar-thumb-bg-secondary-light hover:scrollbar-thumb-bg-fourth bg-bg-primary-light p-2 rounded text-text-secondary text-2xs${isStreaming ? ' animate-pulse' : ''}`}
188-
>
186+
<div className="font-semibold mb-1 text-text-secondary">{t('toolMessage.arguments')}</div>
187+
<pre className="whitespace-pre-wrap max-h-[400px] overflow-y-auto scrollbar-thin scrollbar-track-bg-primary-light scrollbar-thumb-bg-secondary-light hover:scrollbar-thumb-bg-fourth bg-bg-primary-light p-2 rounded text-text-secondary text-2xs">
189188
{JSON.stringify(message.args, null, 2)}
190189
</pre>
191190
</div>
192191
)}
193-
{isStreaming && Object.keys(message.args).length === 0 ? (
192+
{isStreaming ? (
194193
<div className="text-xs italic text-text-muted-light">{t('toolMessage.preparing')}</div>
195194
) : isExecuting ? (
196195
<div className="text-xs italic text-text-muted-light">{t('toolMessage.executing')}</div>
@@ -215,7 +214,7 @@ export const ToolMessageBlock = ({ message, onRemove, compact = false, onFork, o
215214
</div>
216215
</div>
217216
{/* Tool Specific Content */}
218-
{renderToolSpecificContent()}
217+
{!isStreaming && renderToolSpecificContent()}
219218
</div>
220219
);
221220

0 commit comments

Comments
 (0)