Merge pull request #2111 from code-yeongyu/fix/background-notification-idle-queue
fix(background-agent): queue notifications for idle parent sessions
This commit is contained in:
@@ -19,6 +19,7 @@ function createMockHandlerArgs(overrides?: {
|
||||
},
|
||||
hooks: {
|
||||
stopContinuationGuard: null,
|
||||
backgroundNotificationHook: null,
|
||||
keywordDetector: null,
|
||||
claudeCodeHooks: null,
|
||||
autoSlashCommand: null,
|
||||
@@ -115,4 +116,30 @@ describe("createChatMessageHandler - TUI variant passthrough", () => {
|
||||
//#then - gate should still be marked as applied
|
||||
expect(args._appliedSessions).toContain("test-session")
|
||||
})
|
||||
|
||||
test("injects queued background notifications through chat.message hook", async () => {
|
||||
//#given
|
||||
const args = createMockHandlerArgs()
|
||||
args.hooks.backgroundNotificationHook = {
|
||||
"chat.message": async (
|
||||
_input: { sessionID: string },
|
||||
output: ChatMessageHandlerOutput,
|
||||
): Promise<void> => {
|
||||
output.parts.push({
|
||||
type: "text",
|
||||
text: "<system-reminder>[BACKGROUND TASK COMPLETED]</system-reminder>",
|
||||
})
|
||||
},
|
||||
}
|
||||
const handler = createChatMessageHandler(args)
|
||||
const input = createMockInput("hephaestus", { providerID: "openai", modelID: "gpt-5.3-codex" })
|
||||
const output = createMockOutput()
|
||||
|
||||
//#when
|
||||
await handler(input, output)
|
||||
|
||||
//#then
|
||||
expect(output.parts).toHaveLength(1)
|
||||
expect(output.parts[0].text).toContain("[BACKGROUND TASK COMPLETED]")
|
||||
})
|
||||
})
|
||||
|
||||
@@ -97,6 +97,7 @@ export function createChatMessageHandler(args: {
|
||||
setSessionModel(input.sessionID, input.model)
|
||||
}
|
||||
await hooks.stopContinuationGuard?.["chat.message"]?.(input)
|
||||
await hooks.backgroundNotificationHook?.["chat.message"]?.(input, output)
|
||||
await hooks.runtimeFallback?.["chat.message"]?.(input, output)
|
||||
await hooks.keywordDetector?.["chat.message"]?.(input, output)
|
||||
await hooks.claudeCodeHooks?.["chat.message"]?.(input, output)
|
||||
|
||||
Reference in New Issue
Block a user