2026-02-08 16:23:56 +09:00
|
|
|
import type { PluginInput } from "@opencode-ai/plugin"
|
2026-05-20 16:40:45 +09:00
|
|
|
import { readContinuationMarker } from "../features/run-continuation-state"
|
2026-02-16 18:20:19 +09:00
|
|
|
import { normalizeSDKResponse } from "../shared"
|
2026-02-08 16:23:56 +09:00
|
|
|
|
|
|
|
|
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 } })
|
2026-02-16 18:20:19 +09:00
|
|
|
const todos = normalizeSDKResponse(response, [] as Todo[], { preferResponseOnMissingData: true })
|
2026-02-08 16:23:56 +09:00
|
|
|
if (!todos || todos.length === 0) return false
|
|
|
|
|
return todos.some((todo) => todo.status !== "completed" && todo.status !== "cancelled")
|
|
|
|
|
} catch {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-05-20 16:40:45 +09:00
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
}
|