Агент чата: один автор - одно имя во входе (справочник person + пометка [менеджер] в диалоге канала); deviations п.68
All checks were successful
ci / test (push) Successful in 29s
ci / deploy (push) Successful in 2m20s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-30 13:47:12 +03:00
parent 2b3cd2ab82
commit 333106e518
5 changed files with 46 additions and 10 deletions

View File

@@ -184,10 +184,18 @@ export async function handleManagerMessages(
const disabled = aps.filter((r) => !r.is_enabled) as { jt_job_id: string; name: string | null }[];
const writableJobs = ctx.settings.allowedJobIds.filter((id) => !disabled.some((d) => d.jt_job_id === id));
// автор каждого сообщения: ответ адресуется тому, кто написал (в чате могут писать и другие, не только менеджер)
const senderNames = new Map<string, string>();
for (const id of new Set(messages.map((m) => m.senderUserId).filter((x): x is string => !!x))) {
// имя человека по Slack-id одно во всех блоках входа (новые сообщения, диалог канала): справочник person, затем Slack
const nameCache = new Map<string, string | null>();
const nameOfUser = async (id: string): Promise<string | null> => {
if (nameCache.has(id)) return nameCache.get(id)!;
const row = (await ctx.pool.query("select display_name from person where slack_user_id = $1 and is_active limit 1", [id])).rows[0];
const name = (row?.display_name as string | undefined) ?? (await deps.slack.userName?.(id).catch(() => null)) ?? null;
nameCache.set(id, name);
return name;
};
const senderNames = new Map<string, string>();
for (const id of new Set(messages.map((m) => m.senderUserId).filter((x): x is string => !!x))) {
const name = await nameOfUser(id);
if (name) senderNames.set(id, name);
}
const authorOf = (m: IncomingMessage): string => {
@@ -283,7 +291,7 @@ export async function handleManagerMessages(
const channelBlocks: string[] = [];
const recapOn = !!proj && !!channel; // тихий режим и recap проектных каналов - у всех менеджеров (промты согласованы, approved = proposed)
if (recapOn && proj && channel) {
const dialogText = await loadChannelDialog(deps.slack, channel, now, deps.timezone);
const dialogText = await loadChannelDialog(deps.slack, channel, now, deps.timezone, 24, { nameOf: nameOfUser, managerUserId: manager.slackUserId });
const st = await getRecapState(ctx.pool, channel);
channelBlocks.push("", `# Диалог канала за последние сутки (время по Тампе)
${dialogText}`, "", `# Накопленное для Daily Log