fix: anchor typing loop to run
This commit is contained in:
@@ -187,10 +187,13 @@ export async function getReplyFromConfig(
|
|||||||
await triggerTyping();
|
await triggerTyping();
|
||||||
};
|
};
|
||||||
let typingTimer: NodeJS.Timeout | undefined;
|
let typingTimer: NodeJS.Timeout | undefined;
|
||||||
const typingIntervalMs =
|
const configuredTypingSeconds =
|
||||||
(agentCfg?.typingIntervalSeconds ??
|
agentCfg?.typingIntervalSeconds ?? sessionCfg?.typingIntervalSeconds;
|
||||||
sessionCfg?.typingIntervalSeconds ??
|
const typingIntervalSeconds =
|
||||||
8) * 1000;
|
typeof configuredTypingSeconds === "number"
|
||||||
|
? configuredTypingSeconds
|
||||||
|
: 6;
|
||||||
|
const typingIntervalMs = typingIntervalSeconds * 1000;
|
||||||
const cleanupTyping = () => {
|
const cleanupTyping = () => {
|
||||||
if (typingTimer) {
|
if (typingTimer) {
|
||||||
clearInterval(typingTimer);
|
clearInterval(typingTimer);
|
||||||
@@ -656,9 +659,6 @@ export async function getReplyFromConfig(
|
|||||||
const isGroupChat = sessionCtx.ChatType === "group";
|
const isGroupChat = sessionCtx.ChatType === "group";
|
||||||
const wasMentioned = ctx.WasMentioned === true;
|
const wasMentioned = ctx.WasMentioned === true;
|
||||||
const shouldEagerType = !isGroupChat || wasMentioned;
|
const shouldEagerType = !isGroupChat || wasMentioned;
|
||||||
if (shouldEagerType) {
|
|
||||||
await startTypingLoop();
|
|
||||||
}
|
|
||||||
const shouldInjectGroupIntro =
|
const shouldInjectGroupIntro =
|
||||||
isGroupChat &&
|
isGroupChat &&
|
||||||
(isFirstTurnInSession || sessionEntry?.groupActivationNeedsSystemIntro);
|
(isFirstTurnInSession || sessionEntry?.groupActivationNeedsSystemIntro);
|
||||||
@@ -876,6 +876,9 @@ export async function getReplyFromConfig(
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (shouldEagerType) {
|
||||||
|
await startTypingLoop();
|
||||||
|
}
|
||||||
const runId = crypto.randomUUID();
|
const runId = crypto.randomUUID();
|
||||||
const runResult = await runEmbeddedPiAgent({
|
const runResult = await runEmbeddedPiAgent({
|
||||||
sessionId: sessionIdFinal,
|
sessionId: sessionIdFinal,
|
||||||
@@ -936,7 +939,7 @@ export async function getReplyFromConfig(
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
if (shouldSignalTyping) {
|
if (shouldSignalTyping) {
|
||||||
await onReplyStart();
|
await startTypingLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sessionStore && sessionKey) {
|
if (sessionStore && sessionKey) {
|
||||||
|
|||||||
Reference in New Issue
Block a user