feat(session-notification): include session context in ready notifications
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -2,8 +2,6 @@ import type { PluginInput } from "@opencode-ai/plugin"
|
||||
import type { Platform } from "./session-notification-sender"
|
||||
|
||||
type SessionNotificationConfig = {
|
||||
title: string
|
||||
message: string
|
||||
playSound: boolean
|
||||
soundPath: string
|
||||
idleConfirmationDelay: number
|
||||
@@ -18,7 +16,7 @@ export function createIdleNotificationScheduler(options: {
|
||||
platform: Platform
|
||||
config: SessionNotificationConfig
|
||||
hasIncompleteTodos: (ctx: PluginInput, sessionID: string) => Promise<boolean>
|
||||
send: (ctx: PluginInput, platform: Platform, title: string, message: string) => Promise<void>
|
||||
send: (ctx: PluginInput, platform: Platform, sessionID: string) => Promise<void>
|
||||
playSound: (ctx: PluginInput, platform: Platform, soundPath: string) => Promise<void>
|
||||
}) {
|
||||
const notifiedSessions = new Set<string>()
|
||||
@@ -34,23 +32,33 @@ export function createIdleNotificationScheduler(options: {
|
||||
const maxSessions = options.config.maxTrackedSessions
|
||||
if (notifiedSessions.size > maxSessions) {
|
||||
const sessionsToRemove = Array.from(notifiedSessions).slice(0, notifiedSessions.size - maxSessions)
|
||||
sessionsToRemove.forEach((id) => notifiedSessions.delete(id))
|
||||
sessionsToRemove.forEach((id) => {
|
||||
notifiedSessions.delete(id)
|
||||
})
|
||||
}
|
||||
if (sessionActivitySinceIdle.size > maxSessions) {
|
||||
const sessionsToRemove = Array.from(sessionActivitySinceIdle).slice(0, sessionActivitySinceIdle.size - maxSessions)
|
||||
sessionsToRemove.forEach((id) => sessionActivitySinceIdle.delete(id))
|
||||
sessionsToRemove.forEach((id) => {
|
||||
sessionActivitySinceIdle.delete(id)
|
||||
})
|
||||
}
|
||||
if (notificationVersions.size > maxSessions) {
|
||||
const sessionsToRemove = Array.from(notificationVersions.keys()).slice(0, notificationVersions.size - maxSessions)
|
||||
sessionsToRemove.forEach((id) => notificationVersions.delete(id))
|
||||
sessionsToRemove.forEach((id) => {
|
||||
notificationVersions.delete(id)
|
||||
})
|
||||
}
|
||||
if (executingNotifications.size > maxSessions) {
|
||||
const sessionsToRemove = Array.from(executingNotifications).slice(0, executingNotifications.size - maxSessions)
|
||||
sessionsToRemove.forEach((id) => executingNotifications.delete(id))
|
||||
sessionsToRemove.forEach((id) => {
|
||||
executingNotifications.delete(id)
|
||||
})
|
||||
}
|
||||
if (scheduledAt.size > maxSessions) {
|
||||
const sessionsToRemove = Array.from(scheduledAt.keys()).slice(0, scheduledAt.size - maxSessions)
|
||||
sessionsToRemove.forEach((id) => scheduledAt.delete(id))
|
||||
sessionsToRemove.forEach((id) => {
|
||||
scheduledAt.delete(id)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +136,7 @@ export function createIdleNotificationScheduler(options: {
|
||||
|
||||
notifiedSessions.add(sessionID)
|
||||
|
||||
await options.send(options.ctx, options.platform, options.config.title, options.config.message)
|
||||
await options.send(options.ctx, options.platform, sessionID)
|
||||
|
||||
if (options.config.playSound && options.config.soundPath) {
|
||||
await options.playSound(options.ctx, options.platform, options.config.soundPath)
|
||||
|
||||
Reference in New Issue
Block a user