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,
|
||||
onAgentEvent: (evt) => {
|
||||
if (evt.stream !== "compaction") return;
|
||||
const phase =
|
||||
typeof evt.data.phase === "string" ? evt.data.phase : "";
|
||||
const willRetry = Boolean(evt.data.willRetry);
|
||||
if (phase === "end" && !willRetry) {
|
||||
autoCompactionCompleted = true;
|
||||
// Trigger typing when tools start executing
|
||||
if (evt.stream === "tool") {
|
||||
const phase =
|
||||
typeof evt.data.phase === "string" ? evt.data.phase : "";
|
||||
if (phase === "start") {
|
||||
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:
|
||||
|
||||
@@ -30,6 +30,7 @@ export type TypingSignaler = {
|
||||
signalRunStart: () => Promise<void>;
|
||||
signalTextDelta: (text?: string) => Promise<void>;
|
||||
signalReasoningDelta: () => Promise<void>;
|
||||
signalToolStart: () => Promise<void>;
|
||||
};
|
||||
|
||||
export function createTypingSignaler(params: {
|
||||
@@ -65,6 +66,12 @@ export function createTypingSignaler(params: {
|
||||
typing.refreshTypingTtl();
|
||||
};
|
||||
|
||||
const signalToolStart = async () => {
|
||||
if (disabled) return;
|
||||
// Keep typing indicator alive during tool execution
|
||||
await typing.startTypingLoop();
|
||||
};
|
||||
|
||||
return {
|
||||
mode,
|
||||
shouldStartImmediately,
|
||||
@@ -73,5 +80,6 @@ export function createTypingSignaler(params: {
|
||||
signalRunStart,
|
||||
signalTextDelta,
|
||||
signalReasoningDelta,
|
||||
signalToolStart,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user