refactor: unify typing callbacks

This commit is contained in:
Peter Steinberger
2026-01-23 22:55:41 +00:00
parent d82ecaf9dc
commit 8252ae2da1
11 changed files with 114 additions and 63 deletions

View File

@@ -1,4 +1,5 @@
import {
createTypingCallbacks,
resolveChannelMediaMaxBytes,
type ClawdbotConfig,
type MSTeamsReplyStyle,
@@ -39,12 +40,14 @@ export function createMSTeamsReplyDispatcher(params: {
}) {
const core = getMSTeamsRuntime();
const sendTypingIndicator = async () => {
try {
await params.context.sendActivities([{ type: "typing" }]);
} catch {
// Typing indicator is best-effort.
}
await params.context.sendActivities([{ type: "typing" }]);
};
const typingCallbacks = createTypingCallbacks({
start: sendTypingIndicator,
onStartError: () => {
// Typing indicator is best-effort.
},
});
return core.channel.reply.createReplyDispatcherWithTyping({
responsePrefix: core.channel.reply.resolveEffectiveMessagesConfig(
@@ -102,6 +105,6 @@ export function createMSTeamsReplyDispatcher(params: {
hint,
});
},
onReplyStart: sendTypingIndicator,
onReplyStart: typingCallbacks.onReplyStart,
});
}