feat: keep typing during scheduled tasks and tell waiting users

A group-context scheduled task occupies the room queue, so a human message
sent meanwhile waited silently (up to the whole task run) with no typing
indicator; the room looked unresponsive.

- Scheduled tasks (not CI watchers) hold the room's typing indicator for
  their whole run (DiscordChannel.setTypingHold: typing stays on while any
  hold is active, independent of message-turn setTyping(false)).
- A human message that has to wait behind a running scheduled task gets a
  one-time notice per wait: "지금 예약 작업을 진행하고 있습니다. 이 작업을
  마친 뒤 바로 답변드리겠습니다." (GroupQueue.claimScheduledTaskWaitNotice,
  reset when the waiting messages run).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Codex
2026-10-27 23:12:00 +09:00
parent fdfdd384bf
commit fdd98e9eb8
14 changed files with 323 additions and 1 deletions

View File

@@ -177,6 +177,8 @@ export class DiscordChannel implements Channel {
private botToken: string;
private typingIntervals = new Map<string, NodeJS.Timeout>();
private typingGenerations = new Map<string, number>();
private typingRequested = new Set<string>();
private typingHolds = new Map<string, Set<string>>();
private agentTypeFilter?: AgentType;
private receivesInbound: boolean;
private ownsDiscordJids: boolean;
@@ -560,7 +562,42 @@ export class DiscordChannel implements Channel {
}
async setTyping(jid: string, isTyping: boolean): Promise<void> {
if (isTyping) {
this.typingRequested.add(jid);
} else {
this.typingRequested.delete(jid);
}
await this.applyTyping(jid);
}
/**
* Keeps the typing indicator on while any hold is active (e.g. a scheduled
* task run), even if a message turn turns its own typing off meanwhile.
*/
async setTypingHold(
jid: string,
holdId: string,
active: boolean,
): Promise<void> {
const holds = this.typingHolds.get(jid) ?? new Set<string>();
if (active) {
if (holds.has(holdId)) return;
holds.add(holdId);
this.typingHolds.set(jid, holds);
} else {
if (!holds.delete(holdId)) return;
if (holds.size === 0) this.typingHolds.delete(jid);
// Still typing for someone else: leave the running indicator alone.
if (holds.size > 0 || this.typingRequested.has(jid)) return;
}
await this.applyTyping(jid);
}
private async applyTyping(jid: string): Promise<void> {
if (!this.client) return;
const isTyping =
this.typingRequested.has(jid) ||
(this.typingHolds.get(jid)?.size ?? 0) > 0;
const generation = (this.typingGenerations.get(jid) ?? 0) + 1;
this.typingGenerations.set(jid, generation);