From 41f4308a28b782fd604af5d77c2d4a251d3adf1c Mon Sep 17 00:00:00 2001 From: David Cramer Date: Tue, 25 Aug 2026 20:29:59 -0700 Subject: [PATCH] ref(slack): move turn lifecycle setup --- packages/junior/src/chat/conversations/turn-lifecycle.ts | 6 ++++++ packages/junior/src/chat/providers/slack/resume.ts | 7 ++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/junior/src/chat/conversations/turn-lifecycle.ts b/packages/junior/src/chat/conversations/turn-lifecycle.ts index 31f3761df..1eb8e78d1 100644 --- a/packages/junior/src/chat/conversations/turn-lifecycle.ts +++ b/packages/junior/src/chat/conversations/turn-lifecycle.ts @@ -3,6 +3,7 @@ import type { ConversationTurnFailureCode, ConversationTurnFailureReason, } from "./history"; +import { getConversationEventStore } from "@/chat/db"; /** Product-owned inputs for opening one correlated conversation turn. */ export interface StartConversationTurnInput { @@ -92,3 +93,8 @@ export class ConversationTurnLifecycleService implements ConversationTurnLifecyc ]); } } + +/** Return the Turn lifecycle that records Conversation events. */ +export function getTurnLifecycle(): ConversationTurnLifecycle { + return new ConversationTurnLifecycleService(getConversationEventStore()); +} diff --git a/packages/junior/src/chat/providers/slack/resume.ts b/packages/junior/src/chat/providers/slack/resume.ts index 0e3a9b3f4..b11a6a9a0 100644 --- a/packages/junior/src/chat/providers/slack/resume.ts +++ b/packages/junior/src/chat/providers/slack/resume.ts @@ -36,11 +36,10 @@ import { requireTurnFailureEventId, } from "@/chat/services/turn-failure-response"; import { - ConversationTurnLifecycleService, + getTurnLifecycle, type ConversationTurnLifecycle, } from "@/chat/conversations/turn-lifecycle"; import type { ConversationTurnFailureCode } from "@/chat/conversations/history"; -import { getConversationEventStore } from "@/chat/db"; import { recordTurnSummary, saveTurnCheckpoint, @@ -457,9 +456,7 @@ async function resumeSlackTurnInContext( let assistantMessageDelivered = false; let shouldScheduleCompletedPluginTasks = false; let postDeliveryCommitError: unknown; - const turnLifecycle = new ConversationTurnLifecycleService( - getConversationEventStore(), - ); + const turnLifecycle = getTurnLifecycle(); let failureCode: ConversationTurnFailureCode = "agent_run_failed"; let runArgs = args; try {