mirror of
https://github.com/logancyang/obsidian-copilot.git
synced 2026-07-22 07:50:24 +00:00
Fix background tool handling to prevent orphaned spinners in agent conversation (#2072)
This commit is contained in:
parent
60b380117d
commit
214627c64c
1 changed files with 16 additions and 1 deletions
|
|
@ -766,6 +766,19 @@ ${params}
|
|||
loopDeps.availableTools.filter((tool) => tool.isBackground).map((tool) => tool.name)
|
||||
);
|
||||
|
||||
// Remove any accidental background-tool markers to avoid orphaned spinners
|
||||
if (currentIterationToolCallMessages.length > 0 && backgroundToolNames.size > 0) {
|
||||
const backgroundPrefixes = Array.from(backgroundToolNames).map(
|
||||
(name) => `temporary-tool-call-id-${name}-`
|
||||
);
|
||||
for (let i = currentIterationToolCallMessages.length - 1; i >= 0; i -= 1) {
|
||||
const message = currentIterationToolCallMessages[i];
|
||||
if (backgroundPrefixes.some((prefix) => message.includes(prefix))) {
|
||||
currentIterationToolCallMessages.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const visibleToolNames: string[] = [];
|
||||
toolCalls.forEach((toolCall) => {
|
||||
if (!backgroundToolNames.has(toolCall.name)) {
|
||||
|
|
@ -777,7 +790,9 @@ ${params}
|
|||
if (partialToolName) {
|
||||
const lastToolNameIndex = fullMessage.lastIndexOf(partialToolName);
|
||||
if (fullMessage.length - lastToolNameIndex > STREAMING_TRUNCATE_THRESHOLD) {
|
||||
visibleToolNames.push(partialToolName);
|
||||
if (!backgroundToolNames.has(partialToolName)) {
|
||||
visibleToolNames.push(partialToolName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue