fix(notify): harden bundled ownership and idle suppression

This commit is contained in:
Kenny
2026-04-19 14:34:13 +08:00
parent f5a11281f8
commit 6fffacd4fc
7 changed files with 144 additions and 36 deletions
+10 -4
View File
@@ -9,13 +9,19 @@ interface Todo {
id?: string
}
export async function hasIncompleteTodos(ctx: PluginInput, sessionID: string): Promise<boolean> {
export type SessionTodoState = "pending" | "clear" | "unknown"
export async function getSessionTodoState(ctx: PluginInput, sessionID: string): Promise<SessionTodoState> {
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 getIncompleteCount(todos) > 0
if (!todos || todos.length === 0) return "clear"
return getIncompleteCount(todos) > 0 ? "pending" : "clear"
} catch {
return false
return "unknown"
}
}
export async function hasIncompleteTodos(ctx: PluginInput, sessionID: string): Promise<boolean> {
return (await getSessionTodoState(ctx, sessionID)) === "pending"
}