Merge pull request #2 from pawcoding/copilot/fix-1

[WIP] Add session title to plugin api
This commit is contained in:
pawcode 2025-08-09 11:10:17 +02:00 committed by GitHub
commit f8d6dffaa7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 7 additions and 6 deletions

View file

@ -34,7 +34,7 @@ export namespace ConfigHooks {
Bus.subscribe(Session.Event.Idle, async (payload) => { Bus.subscribe(Session.Event.Idle, async (payload) => {
const cfg = await Config.get() const cfg = await Config.get()
if (cfg.experimental?.hook?.session_completed) { 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) // Only fire hook for top-level sessions (not subagent sessions)
if (session.parentID) return if (session.parentID) return

View file

@ -113,7 +113,7 @@ export namespace Session {
Idle: Bus.event( Idle: Bus.event(
"session.idle", "session.idle",
z.object({ z.object({
sessionID: z.string(), info: Info,
}), }),
), ),
Error: Bus.event( Error: Bus.event(
@ -1381,7 +1381,7 @@ export namespace Session {
if (session.parentID) return if (session.parentID) return
Bus.publish(Event.Idle, { Bus.publish(Event.Idle, {
sessionID, info: session,
}) })
}, },
} }

View file

@ -488,7 +488,7 @@ export type EventSessionDeleted = {
export type EventSessionIdle = { export type EventSessionIdle = {
type: string type: string
properties: { properties: {
sessionID: string info: Session
} }
} }

View file

@ -73,9 +73,10 @@ Send notifications when certain events occur:
export const NotificationPlugin = async ({ client, $ }) => { export const NotificationPlugin = async ({ client, $ }) => {
return { return {
event: async ({ event }) => { event: async ({ event }) => {
// Send notification on session completion // Send notification on session completion with session title
if (event.type === "session.idle") { 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"'`
} }
}, },
} }