Skip to content

Commit b984bfd

Browse files
committed
fix(session-notification): skip notification for subagent sessions (#70)
- Import subagentSessions from claude-code-session-state in both manager.ts and session-notification.ts - Add sessionID to subagentSessions Set when creating background task session - Remove sessionID from subagentSessions when background task session is deleted - Check if session is in subagentSessions before triggering notification Fixes #70: Notification hook no longer triggers for subagent idle events 🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
1 parent ecc8ade commit b984bfd

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/features/background-agent/manager.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
findNearestMessageWithFields,
1111
MESSAGE_STORAGE,
1212
} from "../hook-message-injector"
13+
import { subagentSessions } from "../claude-code-session-state"
1314

1415
type OpencodeClient = PluginInput["client"]
1516

@@ -82,6 +83,7 @@ export class BackgroundManager {
8283
}
8384

8485
const sessionID = createResult.data.id
86+
subagentSessions.add(sessionID)
8587

8688
const task: BackgroundTask = {
8789
id: `bg_${crypto.randomUUID().slice(0, 8)}`,
@@ -236,6 +238,7 @@ export class BackgroundManager {
236238

237239
this.tasks.delete(task.id)
238240
this.clearNotificationsForTask(task.id)
241+
subagentSessions.delete(sessionID)
239242
}
240243
}
241244

src/hooks/session-notification.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { PluginInput } from "@opencode-ai/plugin"
22
import { platform } from "os"
3+
import { subagentSessions } from "../features/claude-code-session-state"
34

45
interface Todo {
56
content: string
@@ -219,6 +220,8 @@ export function createSessionNotification(
219220
const sessionID = props?.sessionID as string | undefined
220221
if (!sessionID) return
221222

223+
if (subagentSessions.has(sessionID)) return
224+
222225
if (notifiedSessions.has(sessionID)) return
223226
if (pendingTimers.has(sessionID)) return
224227

0 commit comments

Comments
 (0)