Skip to content

Commit 41a318d

Browse files
committed
fix(background-task): send notification to parent session instead of main session
🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
1 parent e533a35 commit 41a318d

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/features/background-agent/manager.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import type {
44
LaunchInput,
55
} from "./types"
66
import { log } from "../../shared/logger"
7-
import { getMainSessionID } from "../claude-code-session-state"
87

98
type OpencodeClient = PluginInput["client"]
109

@@ -240,25 +239,19 @@ export class BackgroundManager {
240239

241240
const message = `[BACKGROUND TASK COMPLETED] Task "${task.description}" finished in ${duration}. Use background_output with task_id="${task.id}" to get results.`
242241

243-
const mainSessionID = getMainSessionID()
244-
if (!mainSessionID) {
245-
log("[background-agent] No main session ID available, relying on pending queue")
246-
return
247-
}
248-
249-
log("[background-agent] Sending notification to main session:", mainSessionID)
242+
log("[background-agent] Sending notification to parent session:", { parentSessionID: task.parentSessionID })
250243

251244
setTimeout(async () => {
252245
try {
253246
await this.client.session.prompt({
254-
path: { id: mainSessionID },
247+
path: { id: task.parentSessionID },
255248
body: {
256249
parts: [{ type: "text", text: message }],
257250
},
258251
query: { directory: this.directory },
259252
})
260253
this.clearNotificationsForTask(task.id)
261-
log("[background-agent] Successfully sent prompt to main session")
254+
log("[background-agent] Successfully sent prompt to parent session:", { parentSessionID: task.parentSessionID })
262255
} catch (error) {
263256
log("[background-agent] prompt failed:", String(error))
264257
}

0 commit comments

Comments
 (0)