diff --git a/packages/opencode/src/config/hooks.ts b/packages/opencode/src/config/hooks.ts index 8772c9c6..0dd23500 100644 --- a/packages/opencode/src/config/hooks.ts +++ b/packages/opencode/src/config/hooks.ts @@ -34,7 +34,7 @@ export namespace ConfigHooks { Bus.subscribe(Session.Event.Idle, async (payload) => { const cfg = await Config.get() if (cfg.experimental?.hook?.session_completed) { - const session = await Session.get(payload.properties.sessionID) + const session = payload.properties.info // Only fire hook for top-level sessions (not subagent sessions) if (session.parentID) return diff --git a/packages/opencode/src/session/index.ts b/packages/opencode/src/session/index.ts index 494a39c4..f3f423a6 100644 --- a/packages/opencode/src/session/index.ts +++ b/packages/opencode/src/session/index.ts @@ -113,7 +113,7 @@ export namespace Session { Idle: Bus.event( "session.idle", z.object({ - sessionID: z.string(), + info: Info, }), ), Error: Bus.event( @@ -1381,7 +1381,7 @@ export namespace Session { if (session.parentID) return Bus.publish(Event.Idle, { - sessionID, + info: session, }) }, } diff --git a/packages/sdk/js/src/gen/types.gen.ts b/packages/sdk/js/src/gen/types.gen.ts index 3a97c283..49313779 100644 --- a/packages/sdk/js/src/gen/types.gen.ts +++ b/packages/sdk/js/src/gen/types.gen.ts @@ -488,7 +488,7 @@ export type EventSessionDeleted = { export type EventSessionIdle = { type: string properties: { - sessionID: string + info: Session } } diff --git a/packages/web/src/content/docs/docs/plugins.mdx b/packages/web/src/content/docs/docs/plugins.mdx index 910ee4cd..4a10077a 100644 --- a/packages/web/src/content/docs/docs/plugins.mdx +++ b/packages/web/src/content/docs/docs/plugins.mdx @@ -73,9 +73,10 @@ Send notifications when certain events occur: export const NotificationPlugin = async ({ client, $ }) => { return { event: async ({ event }) => { - // Send notification on session completion + // Send notification on session completion with session title if (event.type === "session.idle") { - await $`osascript -e 'display notification "Session completed!" with title "opencode"'` + const sessionTitle = event.properties.info.title + await $`osascript -e 'display notification "Session ${sessionTitle} completed!" with title "opencode"'` } }, }