mirror of
https://github.com/sst/opencode.git
synced 2025-08-22 14:04:07 +00:00
Merge pull request #2 from pawcoding/copilot/fix-1
[WIP] Add session title to plugin api
This commit is contained in:
commit
f8d6dffaa7
4 changed files with 7 additions and 6 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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,
|
||||
})
|
||||
},
|
||||
}
|
||||
|
|
|
@ -488,7 +488,7 @@ export type EventSessionDeleted = {
|
|||
export type EventSessionIdle = {
|
||||
type: string
|
||||
properties: {
|
||||
sessionID: string
|
||||
info: Session
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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"'`
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue