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)
This commit is contained in:
@@ -4,7 +4,6 @@ import type {
|
|||||||
LaunchInput,
|
LaunchInput,
|
||||||
} from "./types"
|
} from "./types"
|
||||||
import { log } from "../../shared/logger"
|
import { log } from "../../shared/logger"
|
||||||
import { getMainSessionID } from "../claude-code-session-state"
|
|
||||||
|
|
||||||
type OpencodeClient = PluginInput["client"]
|
type OpencodeClient = PluginInput["client"]
|
||||||
|
|
||||||
@@ -240,25 +239,19 @@ export class BackgroundManager {
|
|||||||
|
|
||||||
const message = `[BACKGROUND TASK COMPLETED] Task "${task.description}" finished in ${duration}. Use background_output with task_id="${task.id}" to get results.`
|
const message = `[BACKGROUND TASK COMPLETED] Task "${task.description}" finished in ${duration}. Use background_output with task_id="${task.id}" to get results.`
|
||||||
|
|
||||||
const mainSessionID = getMainSessionID()
|
log("[background-agent] Sending notification to parent session:", { parentSessionID: task.parentSessionID })
|
||||||
if (!mainSessionID) {
|
|
||||||
log("[background-agent] No main session ID available, relying on pending queue")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
log("[background-agent] Sending notification to main session:", mainSessionID)
|
|
||||||
|
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
try {
|
try {
|
||||||
await this.client.session.prompt({
|
await this.client.session.prompt({
|
||||||
path: { id: mainSessionID },
|
path: { id: task.parentSessionID },
|
||||||
body: {
|
body: {
|
||||||
parts: [{ type: "text", text: message }],
|
parts: [{ type: "text", text: message }],
|
||||||
},
|
},
|
||||||
query: { directory: this.directory },
|
query: { directory: this.directory },
|
||||||
})
|
})
|
||||||
this.clearNotificationsForTask(task.id)
|
this.clearNotificationsForTask(task.id)
|
||||||
log("[background-agent] Successfully sent prompt to main session")
|
log("[background-agent] Successfully sent prompt to parent session:", { parentSessionID: task.parentSessionID })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log("[background-agent] prompt failed:", String(error))
|
log("[background-agent] prompt failed:", String(error))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user