feat(typing): trigger indicator on tool start events
Add signalToolStart to TypingSignaler and call it from onAgentEvent when tools begin executing. This keeps the typing indicator visible during long-running tool operations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
committed by
Peter Steinberger
parent
19595a8f99
commit
29c5ed54b2
@@ -300,12 +300,22 @@ export async function runReplyAgent(params: {
|
|||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
onAgentEvent: (evt) => {
|
onAgentEvent: (evt) => {
|
||||||
if (evt.stream !== "compaction") return;
|
// Trigger typing when tools start executing
|
||||||
const phase =
|
if (evt.stream === "tool") {
|
||||||
typeof evt.data.phase === "string" ? evt.data.phase : "";
|
const phase =
|
||||||
const willRetry = Boolean(evt.data.willRetry);
|
typeof evt.data.phase === "string" ? evt.data.phase : "";
|
||||||
if (phase === "end" && !willRetry) {
|
if (phase === "start") {
|
||||||
autoCompactionCompleted = true;
|
void typingSignals.signalToolStart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Track auto-compaction completion
|
||||||
|
if (evt.stream === "compaction") {
|
||||||
|
const phase =
|
||||||
|
typeof evt.data.phase === "string" ? evt.data.phase : "";
|
||||||
|
const willRetry = Boolean(evt.data.willRetry);
|
||||||
|
if (phase === "end" && !willRetry) {
|
||||||
|
autoCompactionCompleted = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onBlockReply:
|
onBlockReply:
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export type TypingSignaler = {
|
|||||||
signalRunStart: () => Promise<void>;
|
signalRunStart: () => Promise<void>;
|
||||||
signalTextDelta: (text?: string) => Promise<void>;
|
signalTextDelta: (text?: string) => Promise<void>;
|
||||||
signalReasoningDelta: () => Promise<void>;
|
signalReasoningDelta: () => Promise<void>;
|
||||||
|
signalToolStart: () => Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function createTypingSignaler(params: {
|
export function createTypingSignaler(params: {
|
||||||
@@ -65,6 +66,12 @@ export function createTypingSignaler(params: {
|
|||||||
typing.refreshTypingTtl();
|
typing.refreshTypingTtl();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const signalToolStart = async () => {
|
||||||
|
if (disabled) return;
|
||||||
|
// Keep typing indicator alive during tool execution
|
||||||
|
await typing.startTypingLoop();
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
mode,
|
mode,
|
||||||
shouldStartImmediately,
|
shouldStartImmediately,
|
||||||
@@ -73,5 +80,6 @@ export function createTypingSignaler(params: {
|
|||||||
signalRunStart,
|
signalRunStart,
|
||||||
signalTextDelta,
|
signalTextDelta,
|
||||||
signalReasoningDelta,
|
signalReasoningDelta,
|
||||||
|
signalToolStart,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user