Files
oh-my-opencode/src/hooks/session-todo-status.ts
T
신정진 60a23a557e fix(notification): suppress ready alerts during background tasks
Gate idle ready notifications on the existing background-task continuation marker so cmux does not receive premature ready alerts while delegated work is still active.

Constraint: Reuse marker state from background task lifecycle without adding new notification config

Rejected: Patch cmux directly | notification readiness belongs upstream in OMO

Confidence: high

Scope-risk: narrow
2026-05-20 16:40:45 +09:00

31 lines
1.0 KiB
TypeScript

import type { PluginInput } from "@opencode-ai/plugin"
import { readContinuationMarker } from "../features/run-continuation-state"
import { normalizeSDKResponse } from "../shared"
interface Todo {
content: string
status: string
priority: string
id: string
}
export async function hasIncompleteTodos(ctx: PluginInput, sessionID: string): Promise<boolean> {
try {
const response = await ctx.client.session.todo({ path: { id: sessionID } })
const todos = normalizeSDKResponse(response, [] as Todo[], { preferResponseOnMissingData: true })
if (!todos || todos.length === 0) return false
return todos.some((todo) => todo.status !== "completed" && todo.status !== "cancelled")
} catch {
return false
}
}
export async function hasPendingSessionWork(ctx: PluginInput, sessionID: string): Promise<boolean> {
const marker = readContinuationMarker(ctx.directory, sessionID)
if (marker?.sources["background-task"]?.state === "active") {
return true
}
return hasIncompleteTodos(ctx, sessionID)
}